Project

General

Profile

« Previous | Next » 

Revision 2e99ba6a

Added by Leszek Koltunski almost 3 years ago

Progress with ConfigPane.

View differences:

src/main/java/org/distorted/config/ConfigScreenPane.java
19 19

  
20 20
package org.distorted.config;
21 21

  
22
import android.util.TypedValue;
22 23
import android.widget.LinearLayout;
24
import android.widget.RadioButton;
25
import android.widget.RadioGroup;
23 26
import android.widget.TextView;
24 27

  
25 28
import org.distorted.jsons.ObjectJson;
......
35 38

  
36 39
public class ConfigScreenPane
37 40
{
38
  private static final float TEXT_RATIO = 0.015f;
41
  private static final float PADDING_RATIO = 0.015f;
42
  private static final float TEXT_RATIO    = 0.025f;
43
  private static final float RADIO_RATIO   = 0.900f;
44

  
39 45
  private JsonReader mReader;
40 46

  
41 47
///////////////////////////////////////////////////////////////////////////////////////////////////
......
64 70

  
65 71
  ConfigScreenPane(final ConfigActivity act, int objectOrdinal)
66 72
    {
73
    int height = act.getScreenHeightInPixels();
74
    float textSize = height*TEXT_RATIO;
75
    int padding = (int)(height*PADDING_RATIO);
76

  
67 77
    LinearLayout detailsLayout    = (LinearLayout)inflate( act, R.layout.config_details   , null);
68 78
    LinearLayout difficultyLayout = (LinearLayout)inflate( act, R.layout.config_difficulty, null);
69 79
    LinearLayout meshLayout       = (LinearLayout)inflate( act, R.layout.config_mesh      , null);
70 80

  
71
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 0, 1.0f);
72
    detailsLayout.setLayoutParams(params);
73
    difficultyLayout.setLayoutParams(params);
74
    meshLayout.setLayoutParams(params);
81
    detailsLayout.setPadding(padding,padding,padding,padding/2);
82
    difficultyLayout.setPadding(padding,padding/2,padding,padding/2);
83
    meshLayout.setPadding(padding,padding/2,padding,padding);
84

  
85
    LinearLayout.LayoutParams params1 = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 0, 1.0f);
86
    LinearLayout.LayoutParams params2 = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 0, 1.0f);
87
    LinearLayout.LayoutParams params3 = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 0, 1.3f);
88

  
89
    detailsLayout.setLayoutParams(params1);
90
    difficultyLayout.setLayoutParams(params2);
91
    meshLayout.setLayoutParams(params3);
75 92

  
76
    int height = act.getScreenHeightInPixels();
77
    float textSize = height*TEXT_RATIO;
78 93
    TextView text;
79 94
    text = detailsLayout.findViewById(R.id.configDetailsTitle);
80
    text.setTextSize(textSize);
95
    text.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
81 96
    text = detailsLayout.findViewById(R.id.configDetailsName1);
82
    text.setTextSize(textSize);
97
    text.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
83 98
    text = detailsLayout.findViewById(R.id.configDetailsName2);
84
    text.setTextSize(textSize);
99
    text.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
85 100
    text = detailsLayout.findViewById(R.id.configDetailsAuthor1);
86
    text.setTextSize(textSize);
101
    text.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
87 102
    text = detailsLayout.findViewById(R.id.configDetailsAuthor2);
88
    text.setTextSize(textSize);
103
    text.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
89 104

  
90 105
    text = difficultyLayout.findViewById(R.id.configDifficultyTitle);
91
    text.setTextSize(textSize);
106
    text.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
92 107
    text = meshLayout.findViewById(R.id.configMeshTitle);
93
    text.setTextSize(textSize);
108
    text.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
109

  
110
    RadioButton butt1 = meshLayout.findViewById(R.id.meshNice);
111
    butt1.setTextSize(TypedValue.COMPLEX_UNIT_PX, RADIO_RATIO*textSize);
112
    RadioButton butt2 = meshLayout.findViewById(R.id.meshSimple);
113
    butt2.setTextSize(TypedValue.COMPLEX_UNIT_PX, RADIO_RATIO*textSize);
114

  
115
    LinearLayout layoutDiff = difficultyLayout.findViewById(R.id.configDifficultyLayout);
116
    layoutDiff.setPadding(padding,padding,padding,padding);
117

  
118
    RadioGroup radioGroup = meshLayout.findViewById(R.id.meshRadioGroup);
119

  
120
    radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener()
121
      {
122
      @Override
123
      public void onCheckedChanged(RadioGroup group, int checkedId)
124
        {
125
        if(checkedId == R.id.meshNice)
126
          {
127
          android.util.Log.e("D", "mesh Nice");
128
          }
129
        else
130
          {
131
          android.util.Log.e("D", "mesh Simple");
132
          }
133
        }
134
      });
94 135

  
95 136
    LinearLayout layout = act.findViewById(R.id.configLayout);
96 137
    layout.removeAllViews();
src/main/res/layout/config_details.xml
2 2
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 3
    android:layout_width="fill_parent"
4 4
    android:layout_height="0dp"
5
    android:layout_weight="1"
5
    android:paddingRight="10dp"
6
    android:paddingLeft="10dp"
6 7
    android:gravity="center|fill_horizontal"
7 8
    android:background="@color/grey"
8 9
    android:orientation="vertical">
......
14 15
        android:layout_weight="1"
15 16
        android:gravity="center"
16 17
        android:textSize="26sp"
17
        android:layout_marginTop="10dp"
18
        android:layout_marginLeft="10dp"
19
        android:layout_marginRight="10dp"
20 18
        android:paddingLeft="2dp"
21 19
        android:paddingRight="2dp"
22 20
        android:maxLines="1"
......
27 25
        android:layout_width="fill_parent"
28 26
        android:layout_height="0dp"
29 27
        android:layout_weight="1"
30
        android:layout_marginLeft="10dp"
31
        android:layout_marginRight="10dp"
32 28
        android:paddingLeft="5dp"
33 29
        android:paddingRight="5dp"
34 30
        android:background="@color/light_grey"
......
63 59
        android:layout_width="fill_parent"
64 60
        android:layout_height="0dp"
65 61
        android:layout_weight="1"
66
        android:layout_marginLeft="10dp"
67
        android:layout_marginRight="10dp"
68 62
        android:paddingLeft="5dp"
69 63
        android:paddingRight="5dp"
70 64
        android:background="@color/light_grey"
src/main/res/layout/config_difficulty.xml
2 2
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 3
    android:layout_width="fill_parent"
4 4
    android:layout_height="0dp"
5
    android:layout_weight="1"
6 5
    android:gravity="center|fill_horizontal"
7 6
    android:background="@color/grey"
7
    android:paddingLeft="10dp"
8
    android:paddingRight="10dp"
8 9
    android:orientation="vertical">
9 10

  
10 11
    <TextView
11 12
        android:id="@+id/configDifficultyTitle"
12 13
        android:layout_width="match_parent"
13 14
        android:layout_height="0dp"
14
        android:layout_weight="1"
15
        android:layout_weight="0.8"
15 16
        android:gravity="center"
16 17
        android:textSize="26sp"
17
        android:layout_marginTop="10dp"
18
        android:layout_marginLeft="10dp"
19
        android:layout_marginRight="10dp"
20 18
        android:paddingLeft="2dp"
21 19
        android:paddingRight="2dp"
22 20
        android:maxLines="1"
23 21
        android:text="@string/config_difficulty"
24 22
        android:background="@color/light_grey"/>
25 23

  
24
    <LinearLayout
25
        android:id="@+id/configDifficultyLayout"
26
        android:layout_width="fill_parent"
27
        android:layout_height="0dp"
28
        android:layout_weight="2.0"
29
        android:paddingLeft="5dp"
30
        android:paddingRight="5dp"
31
        android:paddingTop="10dp"
32
        android:paddingBottom="10dp"
33
        android:background="@color/light_grey"
34
        android:orientation="horizontal">
35

  
36
        <ImageView
37
             android:id="@+id/configDifficulty0"
38
             android:layout_width="0dp"
39
             android:layout_height="match_parent"
40
             android:layout_weight="1"
41
             android:gravity="center"
42
             android:src="@drawable/ui_huge_info" />
43

  
44
        <ImageView
45
             android:id="@+id/configDifficulty1"
46
             android:layout_width="0dp"
47
             android:layout_height="match_parent"
48
             android:layout_weight="1"
49
             android:gravity="center"
50
             android:src="@drawable/ui_huge_tutorial" />
51

  
52
        <ImageView
53
             android:id="@+id/configDifficulty2"
54
             android:layout_width="0dp"
55
             android:layout_height="match_parent"
56
             android:layout_weight="1"
57
             android:gravity="center"
58
             android:src="@drawable/ui_huge_cube_back" />
59

  
60
        <ImageView
61
             android:id="@+id/configDifficulty3"
62
             android:layout_width="0dp"
63
             android:layout_height="match_parent"
64
             android:layout_weight="1"
65
             android:gravity="center"
66
             android:src="@drawable/ui_huge_cube_grey" />
67

  
68
        <ImageView
69
             android:id="@+id/configDifficulty4"
70
             android:layout_width="0dp"
71
             android:layout_height="match_parent"
72
             android:layout_weight="1"
73
             android:gravity="center"
74
             android:src="@drawable/ui_huge_cube_scramble" />
75

  
76
    </LinearLayout>
77

  
26 78
</LinearLayout>
src/main/res/layout/config_mesh.xml
2 2
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 3
    android:layout_width="fill_parent"
4 4
    android:layout_height="0dp"
5
    android:layout_weight="1"
5
    android:paddingLeft="10dp"
6
    android:paddingRight="10dp"
7
    android:paddingBottom="10dp"
6 8
    android:gravity="center|fill_horizontal"
7 9
    android:background="@color/grey"
8 10
    android:orientation="vertical">
......
11 13
        android:id="@+id/configMeshTitle"
12 14
        android:layout_width="match_parent"
13 15
        android:layout_height="0dp"
14
        android:layout_weight="1"
16
        android:layout_weight="0.8"
15 17
        android:gravity="center"
16 18
        android:textSize="26sp"
17
        android:layout_marginTop="10dp"
18
        android:layout_marginLeft="10dp"
19
        android:layout_marginRight="10dp"
20 19
        android:paddingLeft="2dp"
21 20
        android:paddingRight="2dp"
22 21
        android:maxLines="1"
23 22
        android:text="@string/config_mesh"
24 23
        android:background="@color/light_grey"/>
25 24

  
26
    <LinearLayout
27
        android:layout_width="fill_parent"
28
        android:layout_height="0dp"
29
        android:layout_weight="1"
30
        android:layout_marginLeft="10dp"
31
        android:layout_marginRight="10dp"
32
        android:paddingLeft="5dp"
33
        android:paddingRight="5dp"
34
        android:background="@color/light_grey"
35
        android:orientation="horizontal">
36

  
37
        <TextView
38
             android:layout_width="0dp"
39
             android:layout_height="match_parent"
40
             android:layout_weight="1.0"
41
             android:gravity="center_vertical|start"
42
             android:paddingStart="5dp"
43
             android:textSize="26sp"
44
             android:singleLine="true"
45
             android:maxLines="1"
46
             android:text="@string/config_name"/>
47

  
48
        <TextView
49
             android:id="@+id/configDetailsName"
50
             android:layout_width="0dp"
51
             android:layout_height="match_parent"
52
             android:layout_weight="1.0"
53
             android:gravity="center_vertical|start"
54
             android:paddingStart="5dp"
55
             android:textSize="26sp"
56
             android:singleLine="true"
57
             android:maxLines="1"/>
58

  
59
    </LinearLayout>
60

  
61
    <LinearLayout
62
        android:layout_width="fill_parent"
25
    <RadioGroup
26
        android:id="@+id/meshRadioGroup"
27
        android:layout_width="match_parent"
63 28
        android:layout_height="0dp"
64
        android:layout_weight="1"
65
        android:layout_marginLeft="10dp"
66
        android:layout_marginRight="10dp"
67
        android:layout_marginBottom="10dp"
68
        android:paddingLeft="5dp"
69
        android:paddingRight="5dp"
70
        android:background="@color/light_grey"
71
        android:orientation="horizontal">
72

  
73
        <TextView
74
             android:layout_width="0dp"
75
             android:layout_height="match_parent"
76
             android:layout_weight="1.0"
77
             android:gravity="center_vertical|start"
78
             android:paddingStart="5dp"
79
             android:textSize="26sp"
80
             android:singleLine="true"
81
             android:maxLines="1"
82
             android:text="@string/config_author"/>
83

  
84
        <TextView
85
             android:id="@+id/configDetailsAuthor"
86
             android:layout_width="0dp"
87
             android:layout_height="match_parent"
88
             android:layout_weight="1.0"
89
             android:gravity="center_vertical|start"
90
             android:paddingStart="5dp"
91
             android:textSize="26sp"
92
             android:singleLine="true"
93
             android:maxLines="1"/>
29
        android:layout_weight="2"
30
        android:checkedButton="@+id/meshNice"
31
        android:background="@color/light_grey">
32

  
33
        <RadioButton
34
            android:id="@+id/meshSimple"
35
            android:layout_width="match_parent"
36
            android:layout_height="wrap_content"
37
            android:layout_marginBottom="0dp"
38
            android:text="@string/config_mesh_simple"/>
39

  
40
        <RadioButton
41
            android:id="@+id/meshNice"
42
            android:layout_width="match_parent"
43
            android:layout_height="wrap_content"
44
            android:layout_marginBottom="0dp"
45
            android:text="@string/config_mesh_nice"/>
46

  
47
    </RadioGroup>
94 48

  
95
    </LinearLayout>
96 49
</LinearLayout>

Also available in: Unified diff