Project

General

Profile

« Previous | Next » 

Revision b45b986a

Added by Leszek Koltunski 8 months ago

Major progress with version 2.0.0.

View differences:

src/main/java/org/distorted/config/ConfigRenderer.java
9 9

  
10 10
package org.distorted.config;
11 11

  
12
import android.app.ActivityManager;
13
import android.content.Context;
14
import android.content.pm.ConfigurationInfo;
15 12
import android.content.res.Resources;
16 13
import android.opengl.GLSurfaceView;
17 14

  
src/main/java/org/distorted/config/ConfigScreenPane.java
15 15
import android.util.TypedValue;
16 16
import android.widget.ImageView;
17 17
import android.widget.LinearLayout;
18
import android.widget.RadioButton;
19
import android.widget.RadioGroup;
20 18
import android.widget.TextView;
21 19

  
22 20
import org.distorted.main.R;
......
24 22
import org.distorted.objects.RubikObject;
25 23
import org.distorted.objects.RubikObjectList;
26 24

  
27
import static org.distorted.objectlib.main.TwistyObject.MESH_NICE;
28
import static org.distorted.objectlib.main.TwistyObject.MESH_FAST;
29

  
30 25
///////////////////////////////////////////////////////////////////////////////////////////////////
31 26

  
32 27
public class ConfigScreenPane
......
52 47
  private static final int NUM_IDS         = IDS.length;
53 48
  private static final float PADDING_RATIO = 0.016f;
54 49
  private static final float TEXT_RATIO    = 0.025f;
55
  private static final float RADIO_RATIO   = 0.900f;
56

  
57
  private int mObjectOrdinal;
58
  private boolean mProgramatic;
59

  
60
///////////////////////////////////////////////////////////////////////////////////////////////////
61

  
62
  private void switchMeshState(ConfigActivity act, int meshState)
63
    {
64
    RubikObjectList.setMeshState(mObjectOrdinal,meshState);
65
    RubikObject object = RubikObjectList.getObject(mObjectOrdinal);
66
    act.changeMeshState(object,mObjectOrdinal);
67
    }
68 50

  
69 51
///////////////////////////////////////////////////////////////////////////////////////////////////
70 52

  
......
76 58
      {
77 59
      InputStream stream = object.getObjectStream(act);
78 60

  
79
      mObjectOrdinal = objectOrdinal;
80 61
      JsonReader reader = new JsonReader();
81 62
      String name,author;
82 63
      int year, difficulty;
......
97 78
        difficulty = 0;
98 79
        }
99 80

  
100
      String both = year>0 ? author+" "+year : author;
101

  
102 81
      LinearLayout layout = act.findViewById(R.id.configLayout);
103 82
      TextView view = layout.findViewById(R.id.configDetailsName2);
104 83
      view.setText(name);
105 84
      view = layout.findViewById(R.id.configDetailsAuthor2);
106
      view.setText(both);
85
      view.setText(author);
86
      view = layout.findViewById(R.id.configDetailsYear2);
87
      view.setText( year>0 ? String.valueOf(year) : "?" );
107 88

  
108 89
      if( difficulty<0        ) difficulty=0;
109 90
      if( difficulty>=NUM_IDS ) difficulty=NUM_IDS-1;
......
114 95
        image.setImageResource(IMAGES[i]);
115 96
        image.setColorFilter( difficulty==i ? 0xffff0000 : 0xffffffff, PorterDuff.Mode.MULTIPLY );
116 97
        }
117

  
118
      int meshState = object.getMeshState();
119
      int id = meshState==MESH_NICE ? R.id.meshNice : R.id.meshSimple;
120
      RadioButton button = act.findViewById(id);
121

  
122
      mProgramatic = true;
123
      button.setChecked(true);
124
      mProgramatic = false;
125 98
      }
126 99
    }
127 100

  
......
135 108

  
136 109
    LinearLayout configLayout    = act.findViewById(R.id.configLayout);
137 110
    LinearLayout nameLayout      = configLayout.findViewById(R.id.configLayoutName);
138
    LinearLayout authorLayout    = configLayout.findViewById(R.id.configLayoutAuthor);
139 111
    LinearLayout difficultyLayout= configLayout.findViewById(R.id.configLayoutDifficulty);
140
    LinearLayout meshLayout      = configLayout.findViewById(R.id.configLayoutMesh);
112
    LinearLayout authorLayout    = configLayout.findViewById(R.id.configLayoutAuthor);
113
    LinearLayout yearLayout      = configLayout.findViewById(R.id.configLayoutYear);
141 114

  
142 115
    nameLayout.setPadding(padding,padding,padding,padding/2);
143
    authorLayout.setPadding(padding,padding/2,padding,padding/2);
144 116
    difficultyLayout.setPadding(padding,padding/2,padding,padding/2);
145
    meshLayout.setPadding(padding,padding/2,padding,padding);
117
    authorLayout.setPadding(padding,padding/2,padding,padding/2);
118
    yearLayout.setPadding(padding,padding/2,padding,padding);
146 119

  
147 120
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 0, 1.00f);
148 121
    params.bottomMargin = 0;
......
151 124
    params.rightMargin  = padding;
152 125

  
153 126
    nameLayout.setLayoutParams(params);
154
    authorLayout.setLayoutParams(params);
155 127
    difficultyLayout.setLayoutParams(params);
156
    meshLayout.setLayoutParams(params);
128
    authorLayout.setLayoutParams(params);
129
    yearLayout.setLayoutParams(params);
157 130

  
158 131
    TextView text;
159 132
    text = nameLayout.findViewById(R.id.configDetailsName1);
......
166 139
    text.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
167 140
    text = difficultyLayout.findViewById(R.id.configDifficultyTitle);
168 141
    text.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
169
    text = meshLayout.findViewById(R.id.configMeshTitle);
142
    text = yearLayout.findViewById(R.id.configDetailsYear1);
143
    text.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
144
    text = yearLayout.findViewById(R.id.configDetailsYear2);
170 145
    text.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
171

  
172
    RadioButton butt1 = meshLayout.findViewById(R.id.meshNice);
173
    butt1.setTextSize(TypedValue.COMPLEX_UNIT_PX, RADIO_RATIO*textSize);
174
    RadioButton butt2 = meshLayout.findViewById(R.id.meshSimple);
175
    butt2.setTextSize(TypedValue.COMPLEX_UNIT_PX, RADIO_RATIO*textSize);
176 146

  
177 147
    LinearLayout layoutDiff = difficultyLayout.findViewById(R.id.configDifficultyLayout);
178 148
    layoutDiff.setPadding(padding,padding,padding,padding);
179 149

  
180
    RadioGroup radioGroup = meshLayout.findViewById(R.id.meshRadioGroup);
181

  
182
    radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener()
183
      {
184
      @Override
185
      public void onCheckedChanged(RadioGroup group, int checkedId)
186
        {
187
        if( !mProgramatic )
188
          {
189
          int meshState = checkedId == R.id.meshNice ? MESH_NICE : MESH_FAST;
190
          switchMeshState( act, meshState );
191
          }
192
        }
193
      });
194

  
195 150
    updatePane(act,objectOrdinal);
196 151
    }
197 152
}
src/main/java/org/distorted/config/ConfigSurfaceView.java
50 50
        }
51 51
      }
52 52

  
53
///////////////////////////////////////////////////////////////////////////////////////////////////
54

  
55
    boolean isVertical()
56
      {
57
      return mScreenHeight>mScreenWidth;
58
      }
59

  
60 53
///////////////////////////////////////////////////////////////////////////////////////////////////
61 54

  
62 55
    ObjectControl getObjectControl()
src/main/java/org/distorted/main/MainObjectPopup.java
41 41

  
42 42
///////////////////////////////////////////////////////////////////////////////////////////////////
43 43

  
44
  MainObjectPopup(Activity act, int ordinal, int width, int height)
44
  MainObjectPopup(MainActivity act, int ordinal, int width, int height)
45 45
    {
46 46
    LayoutInflater layoutInflater = (LayoutInflater)act.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
47 47
    final View layout = layoutInflater.inflate(R.layout.object_popup, null);
......
126 126
      @Override
127 127
      public void onClick(View v)
128 128
        {
129

  
129
        mPopup.dismiss();
130
        act.switchToConfig(ordinal);
130 131
        }
131 132
      });
132 133

  
src/main/java/org/distorted/main/MainScrollGrid.java
9 9

  
10 10
package org.distorted.main;
11 11

  
12
import android.app.Activity;
13 12
import android.util.DisplayMetrics;
14 13
import android.view.View;
15 14
import android.widget.GridLayout;
......
29 28

  
30 29
///////////////////////////////////////////////////////////////////////////////////////////////////
31 30

  
32
  void createGrid(final Activity act, int windowWidth)
31
  void createGrid(final MainActivity act, int windowWidth)
33 32
    {
34 33
    int numObjects = RubikObjectList.getNumObjects();
35 34
    int rowCount   = (numObjects + NUM_COLUMNS-1) / NUM_COLUMNS;
......
70 69

  
71 70
///////////////////////////////////////////////////////////////////////////////////////////////////
72 71

  
73
  void updateGrid(final Activity act, int scrW)
72
  void updateGrid(final MainActivity act, int scrW)
74 73
    {
75 74
    act.runOnUiThread(new Runnable()
76 75
      {
src/main/res/layout-ldrtl/config.xml
54 54

  
55 55
        </LinearLayout>
56 56

  
57
        <LinearLayout
58
            android:id="@+id/configLayoutAuthor"
59
            android:layout_width="fill_parent"
60
            android:layout_height="0dp"
61
            android:layout_weight="1"
62
            android:paddingLeft="5dp"
63
            android:paddingRight="5dp"
64
            android:background="@color/grey"
65
            android:orientation="horizontal">
66

  
67
            <TextView
68
                android:id="@+id/configDetailsAuthor1"
69
                android:layout_width="0dp"
70
                android:layout_height="match_parent"
71
                android:layout_weight="1.0"
72
                android:gravity="center_vertical|right"
73
                android:paddingStart="5dp"
74
                android:textSize="26sp"
75
                android:singleLine="true"
76
                android:maxLines="1"
77
                android:text="@string/config_author"/>
78

  
79
            <TextView
80
                android:id="@+id/configDetailsAuthor2"
81
                android:layout_width="0dp"
82
                android:layout_height="match_parent"
83
                android:layout_weight="2.1"
84
                android:gravity="center_vertical|right"
85
                android:paddingStart="5dp"
86
                android:textSize="26sp"
87
                android:singleLine="true"
88
                android:maxLines="1"/>
89

  
90
        </LinearLayout>
91

  
92 57
        <LinearLayout
93 58
            android:id="@+id/configLayoutDifficulty"
94 59
            android:layout_width="fill_parent"
......
155 120

  
156 121
        </LinearLayout>
157 122

  
158
         <LinearLayout
159
            android:id="@+id/configLayoutMesh"
123
        <LinearLayout
124
            android:id="@+id/configLayoutAuthor"
160 125
            android:layout_width="fill_parent"
161 126
            android:layout_height="0dp"
162 127
            android:layout_weight="1"
......
166 131
            android:orientation="horizontal">
167 132

  
168 133
            <TextView
169
                android:id="@+id/configMeshTitle"
134
                android:id="@+id/configDetailsAuthor1"
170 135
                android:layout_width="0dp"
171 136
                android:layout_height="match_parent"
172 137
                android:layout_weight="1.0"
......
175 140
                android:textSize="26sp"
176 141
                android:singleLine="true"
177 142
                android:maxLines="1"
178
                android:text="@string/config_mesh"/>
143
                android:text="@string/config_author"/>
179 144

  
180
            <RadioGroup
181
                android:id="@+id/meshRadioGroup"
145
            <TextView
146
                android:id="@+id/configDetailsAuthor2"
182 147
                android:layout_width="0dp"
183 148
                android:layout_height="match_parent"
184 149
                android:layout_weight="2.1"
185
                android:orientation="horizontal"
186
                android:checkedButton="@+id/meshNice"
187
                android:background="@color/grey">
150
                android:gravity="center_vertical|right"
151
                android:paddingStart="5dp"
152
                android:textSize="26sp"
153
                android:singleLine="true"
154
                android:maxLines="1"/>
188 155

  
189
                <RadioButton
190
                    android:id="@+id/meshSimple"
191
                    android:layout_width="0dp"
192
                    android:layout_height="match_parent"
193
                    android:layout_weight="1"
194
                    android:gravity="center_vertical|right"
195
                    android:buttonTint="@color/white"
196
                    android:text="@string/config_mesh_fast"/>
156
        </LinearLayout>
197 157

  
198
                <RadioButton
199
                    android:id="@+id/meshNice"
200
                    android:layout_width="0dp"
201
                    android:layout_height="match_parent"
202
                    android:layout_weight="1"
203
                    android:gravity="center_vertical|right"
204
                    android:buttonTint="@color/white"
205
                    android:text="@string/config_mesh_nice"/>
158
        <LinearLayout
159
            android:id="@+id/configLayoutYear"
160
            android:layout_width="fill_parent"
161
            android:layout_height="0dp"
162
            android:layout_weight="1"
163
            android:paddingLeft="5dp"
164
            android:paddingRight="5dp"
165
            android:background="@color/grey"
166
            android:orientation="horizontal">
206 167

  
207
            </RadioGroup>
168
            <TextView
169
                android:id="@+id/configDetailsYear1"
170
                android:layout_width="0dp"
171
                android:layout_height="match_parent"
172
                android:layout_weight="1.0"
173
                android:gravity="center_vertical|right"
174
                android:paddingStart="5dp"
175
                android:textSize="26sp"
176
                android:singleLine="true"
177
                android:maxLines="1"
178
                android:text="@string/config_author"/>
179

  
180
            <TextView
181
                android:id="@+id/configDetailsYear2"
182
                android:layout_width="0dp"
183
                android:layout_height="match_parent"
184
                android:layout_weight="2.1"
185
                android:gravity="center_vertical|right"
186
                android:paddingStart="5dp"
187
                android:textSize="26sp"
188
                android:singleLine="true"
189
                android:maxLines="1"/>
208 190

  
209 191
        </LinearLayout>
210 192

  
src/main/res/layout/config.xml
54 54

  
55 55
        </LinearLayout>
56 56

  
57
        <LinearLayout
58
            android:id="@+id/configLayoutAuthor"
59
            android:layout_width="fill_parent"
60
            android:layout_height="0dp"
61
            android:layout_weight="1"
62
            android:paddingLeft="5dp"
63
            android:paddingRight="5dp"
64
            android:background="@color/grey"
65
            android:orientation="horizontal">
66

  
67
            <TextView
68
                android:id="@+id/configDetailsAuthor1"
69
                android:layout_width="0dp"
70
                android:layout_height="match_parent"
71
                android:layout_weight="1.0"
72
                android:gravity="center_vertical|start"
73
                android:paddingStart="5dp"
74
                android:textSize="26sp"
75
                android:singleLine="true"
76
                android:maxLines="1"
77
                android:text="@string/config_author"/>
78

  
79
            <TextView
80
                android:id="@+id/configDetailsAuthor2"
81
                android:layout_width="0dp"
82
                android:layout_height="match_parent"
83
                android:layout_weight="2.1"
84
                android:gravity="center_vertical|start"
85
                android:paddingStart="5dp"
86
                android:textSize="26sp"
87
                android:singleLine="true"
88
                android:maxLines="1"/>
89

  
90
        </LinearLayout>
91

  
92 57
        <LinearLayout
93 58
            android:id="@+id/configLayoutDifficulty"
94 59
            android:layout_width="fill_parent"
......
155 120

  
156 121
        </LinearLayout>
157 122

  
158
         <LinearLayout
159
            android:id="@+id/configLayoutMesh"
123
        <LinearLayout
124
            android:id="@+id/configLayoutAuthor"
160 125
            android:layout_width="fill_parent"
161 126
            android:layout_height="0dp"
162 127
            android:layout_weight="1"
......
166 131
            android:orientation="horizontal">
167 132

  
168 133
            <TextView
169
                android:id="@+id/configMeshTitle"
134
                android:id="@+id/configDetailsAuthor1"
170 135
                android:layout_width="0dp"
171 136
                android:layout_height="match_parent"
172 137
                android:layout_weight="1.0"
......
175 140
                android:textSize="26sp"
176 141
                android:singleLine="true"
177 142
                android:maxLines="1"
178
                android:text="@string/config_mesh"/>
143
                android:text="@string/config_author"/>
179 144

  
180
            <RadioGroup
181
                android:id="@+id/meshRadioGroup"
145
            <TextView
146
                android:id="@+id/configDetailsAuthor2"
182 147
                android:layout_width="0dp"
183 148
                android:layout_height="match_parent"
184 149
                android:layout_weight="2.1"
185
                android:orientation="horizontal"
186
                android:checkedButton="@+id/meshNice"
187
                android:background="@color/grey">
150
                android:gravity="center_vertical|start"
151
                android:paddingStart="5dp"
152
                android:textSize="26sp"
153
                android:singleLine="true"
154
                android:maxLines="1"/>
188 155

  
189
                <RadioButton
190
                    android:id="@+id/meshSimple"
191
                    android:layout_width="0dp"
192
                    android:layout_height="match_parent"
193
                    android:layout_weight="1"
194
                    android:buttonTint="@color/white"
195
                    android:text="@string/config_mesh_fast"/>
156
        </LinearLayout>
196 157

  
197
                <RadioButton
198
                    android:id="@+id/meshNice"
199
                    android:layout_width="0dp"
200
                    android:layout_height="match_parent"
201
                    android:layout_weight="1"
202
                    android:buttonTint="@color/white"
203
                    android:text="@string/config_mesh_nice"/>
158
        <LinearLayout
159
            android:id="@+id/configLayoutYear"
160
            android:layout_width="fill_parent"
161
            android:layout_height="0dp"
162
            android:layout_weight="1"
163
            android:paddingLeft="5dp"
164
            android:paddingRight="5dp"
165
            android:background="@color/grey"
166
            android:orientation="horizontal">
204 167

  
205
            </RadioGroup>
168
            <TextView
169
                android:id="@+id/configDetailsYear1"
170
                android:layout_width="0dp"
171
                android:layout_height="match_parent"
172
                android:layout_weight="1.0"
173
                android:gravity="center_vertical|start"
174
                android:paddingStart="5dp"
175
                android:textSize="26sp"
176
                android:singleLine="true"
177
                android:maxLines="1"
178
                android:text="@string/config_year"/>
179

  
180
            <TextView
181
                android:id="@+id/configDetailsYear2"
182
                android:layout_width="0dp"
183
                android:layout_height="match_parent"
184
                android:layout_weight="2.1"
185
                android:gravity="center_vertical|start"
186
                android:paddingStart="5dp"
187
                android:textSize="26sp"
188
                android:singleLine="true"
189
                android:maxLines="1"/>
206 190

  
207 191
        </LinearLayout>
208 192

  
src/main/res/values-de/strings.xml
77 77
    <string name="config_details">Einzelheiten</string>
78 78
    <string name="config_name">Name</string>
79 79
    <string name="config_author">Autor</string>
80
    <string name="config_year">Jahr</string>
80 81
    <string name="config_difficulty">Schwierigkeit</string>
81 82
    <string name="config_mesh">3D Netz</string>
82 83
    <string name="config_mesh_fast">Schelles</string>
src/main/res/values-es/strings.xml
77 77
    <string name="config_details">Detalles</string>
78 78
    <string name="config_name">Nombre</string>
79 79
    <string name="config_author">Autor</string>
80
    <string name="config_year">Año</string>
80 81
    <string name="config_difficulty">Dificultad</string>
81 82
    <string name="config_mesh">Malla 3D</string>
82 83
    <string name="config_mesh_fast">Rápida</string>
src/main/res/values-fr/strings.xml
77 77
    <string name="config_details">Détails</string>
78 78
    <string name="config_name">Nom</string>
79 79
    <string name="config_author">Auteur</string>
80
    <string name="config_year">Année</string>
80 81
    <string name="config_difficulty">Difficulté</string>
81 82
    <string name="config_mesh">Maillage 3D</string>
82 83
    <string name="config_mesh_fast">Rapide</string>
src/main/res/values-ja/strings.xml
77 77
    <string name="config_details">詳細</string>
78 78
    <string name="config_name">名前</string>
79 79
    <string name="config_author">著者</string>
80
    <string name="config_year">年</string>
80 81
    <string name="config_difficulty">困難</string>
81 82
    <string name="config_mesh">メッシュ3D</string>
82 83
    <string name="config_mesh_fast">速い</string>
src/main/res/values-ko/strings.xml
77 77
    <string name="config_details">세부</string>
78 78
    <string name="config_name">이름</string>
79 79
    <string name="config_author">작가</string>
80
    <string name="config_year">년도</string>
80 81
    <string name="config_difficulty">어려움</string>
81 82
    <string name="config_mesh">메쉬3D</string>
82 83
    <string name="config_mesh_fast">빠른</string>
src/main/res/values-pl/strings.xml
77 77
    <string name="config_details">O kostce</string>
78 78
    <string name="config_name">Nazwa</string>
79 79
    <string name="config_author">Autor</string>
80
    <string name="config_year">Rok</string>
80 81
    <string name="config_difficulty">Trudność</string>
81 82
    <string name="config_mesh">Siatka 3D</string>
82 83
    <string name="config_mesh_fast">Szybka</string>
src/main/res/values-ru/strings.xml
77 77
    <string name="config_details">Детали</string>
78 78
    <string name="config_name">Имя</string>
79 79
    <string name="config_author">Автор</string>
80
    <string name="config_year">Год</string>
80 81
    <string name="config_difficulty">Сложность</string>
81 82
    <string name="config_mesh">3D Cетка</string>
82 83
    <string name="config_mesh_fast">Быстрая</string>
src/main/res/values-zh-rCN/strings.xml
77 77
    <string name="config_details">细节</string>
78 78
    <string name="config_name">姓名</string>
79 79
    <string name="config_author">作者</string>
80
    <string name="config_year">年</string>
80 81
    <string name="config_difficulty">困难</string>
81 82
    <string name="config_mesh">3D网格</string>
82 83
    <string name="config_mesh_fast">快</string>
src/main/res/values-zh-rTW/strings.xml
77 77
    <string name="config_details">細節</string>
78 78
    <string name="config_name">姓名</string>
79 79
    <string name="config_author">作者</string>
80
    <string name="config_year">年</string>
80 81
    <string name="config_difficulty">困難</string>
81 82
    <string name="config_mesh">3D網格</string>
82 83
    <string name="config_mesh_fast">快</string>
src/main/res/values/strings.xml
101 101
    <string name="config_details">Details</string>
102 102
    <string name="config_name">Name</string>
103 103
    <string name="config_author">Author</string>
104
    <string name="config_year">Year</string>
104 105
    <string name="config_difficulty">Difficulty</string>
105 106
    <string name="config_mesh">3D Mesh</string>
106 107
    <string name="config_mesh_fast">Fast</string>

Also available in: Unified diff