Revision f6a9c538
Added by Leszek Koltunski over 4 years ago
src/main/java/org/distorted/main/RubikActivity.java | ||
---|---|---|
45 | 45 |
{ |
46 | 46 |
public static final float PADDING = 0.01f; |
47 | 47 |
public static final float MARGIN = 0.004f; |
48 |
public static final float LARGE_MARGIN = 0.025f; |
|
48 | 49 |
public static final float BUTTON_TEXT_SIZE = 0.05f; |
49 | 50 |
public static final float TITLE_TEXT_SIZE = 0.06f; |
50 | 51 |
public static final float BITMAP_TEXT_SIZE = 0.09f; |
... | ... | |
56 | 57 |
|
57 | 58 |
private boolean mJustStarted; |
58 | 59 |
private FirebaseAnalytics mFirebaseAnalytics; |
59 |
private int mScreenWidth, mScreenHeight; |
|
60 |
private static int mScreenWidth, mScreenHeight;
|
|
60 | 61 |
|
61 | 62 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
62 | 63 |
|
... | ... | |
298 | 299 |
pre.setupObject(object,size,moves); |
299 | 300 |
} |
300 | 301 |
|
302 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
303 |
|
|
304 |
public static int getDrawableSize() |
|
305 |
{ |
|
306 |
if( mScreenHeight<1000 ) |
|
307 |
{ |
|
308 |
//android.util.Log.e("view", "returning small, mScrH="+mScreenHeight); |
|
309 |
return 0; |
|
310 |
} |
|
311 |
if( mScreenHeight<1600 ) |
|
312 |
{ |
|
313 |
//android.util.Log.e("view", "returning medium, mScrH="+mScreenHeight); |
|
314 |
return 1; |
|
315 |
} |
|
316 |
|
|
317 |
//android.util.Log.e("view", "returning big, mScrH="+mScreenHeight); |
|
318 |
return 2; |
|
319 |
} |
|
320 |
|
|
321 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
322 |
|
|
323 |
public static int getDrawable(int small, int medium, int big) |
|
324 |
{ |
|
325 |
int size = getDrawableSize(); |
|
326 |
|
|
327 |
switch(size) |
|
328 |
{ |
|
329 |
case 0 : return small; |
|
330 |
case 1 : return medium; |
|
331 |
default: return big; |
|
332 |
} |
|
333 |
} |
|
334 |
|
|
301 | 335 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
302 | 336 |
|
303 | 337 |
public boolean isVertical() |
src/main/java/org/distorted/objects/RubikObjectList.java | ||
---|---|---|
26 | 26 |
import org.distorted.library.mesh.MeshRectangles; |
27 | 27 |
import org.distorted.library.type.Static4D; |
28 | 28 |
import org.distorted.main.R; |
29 |
import org.distorted.main.RubikActivity; |
|
29 | 30 |
|
30 | 31 |
import java.lang.reflect.Field; |
31 | 32 |
|
... | ... | |
35 | 36 |
{ |
36 | 37 |
CUBE ( |
37 | 38 |
new int[][] { |
38 |
{2 , 12, R.drawable.ui_small_cube2, R.raw.cube2} ,
|
|
39 |
{3 , 16, R.drawable.ui_small_cube3, R.raw.cube3} ,
|
|
40 |
{4 , 20, R.drawable.ui_small_cube4, R.raw.cube4} ,
|
|
41 |
{5 , 24, R.drawable.ui_small_cube5, R.raw.cube5}
|
|
39 |
{2 , 12, R.raw.cube2, R.drawable.ui_small_cube2, R.drawable.ui_medium_cube2, R.drawable.ui_big_cube2} ,
|
|
40 |
{3 , 16, R.raw.cube3, R.drawable.ui_small_cube3, R.drawable.ui_medium_cube3, R.drawable.ui_big_cube3} ,
|
|
41 |
{4 , 20, R.raw.cube4, R.drawable.ui_small_cube4, R.drawable.ui_medium_cube4, R.drawable.ui_big_cube4} ,
|
|
42 |
{5 , 24, R.raw.cube5, R.drawable.ui_small_cube5, R.drawable.ui_medium_cube5, R.drawable.ui_big_cube5}
|
|
42 | 43 |
}, |
43 | 44 |
RubikCube.class, |
44 | 45 |
new RubikCubeMovement() |
... | ... | |
46 | 47 |
|
47 | 48 |
PYRA ( |
48 | 49 |
new int[][] { |
49 |
{3 , 10, R.drawable.ui_small_pyra3, R.raw.pyra3} ,
|
|
50 |
{4 , 15, R.drawable.ui_small_pyra4, R.raw.pyra4} ,
|
|
51 |
{5 , 20, R.drawable.ui_small_pyra5, R.raw.pyra5}
|
|
50 |
{3 , 10, R.raw.pyra3, R.drawable.ui_small_pyra3, R.drawable.ui_medium_pyra3, R.drawable.ui_big_pyra3} ,
|
|
51 |
{4 , 15, R.raw.pyra4, R.drawable.ui_small_pyra4, R.drawable.ui_medium_pyra4, R.drawable.ui_big_pyra4} ,
|
|
52 |
{5 , 20, R.raw.pyra5, R.drawable.ui_small_pyra5, R.drawable.ui_medium_pyra5, R.drawable.ui_big_pyra5}
|
|
52 | 53 |
}, |
53 | 54 |
RubikPyraminx.class, |
54 | 55 |
new RubikPyraminxMovement() |
... | ... | |
60 | 61 |
public static final int MAX_LEVEL; |
61 | 62 |
public static final int MAX_OBJECT_SIZE; |
62 | 63 |
|
63 |
private final int[] mObjectSizes, mMaxLevels, mIconIDs, mResourceIDs; |
|
64 |
private final int[] mObjectSizes, mMaxLevels, mSmallIconIDs, mMediumIconIDs, mBigIconIDs, mResourceIDs;
|
|
64 | 65 |
private final Class<? extends RubikObject> mObjectClass; |
65 | 66 |
private final RubikObjectMovement mObjectMovementClass; |
66 | 67 |
private static final RubikObjectList[] objects; |
... | ... | |
275 | 276 |
{ |
276 | 277 |
int length = info.length; |
277 | 278 |
|
278 |
mObjectSizes= new int[length]; |
|
279 |
mMaxLevels = new int[length]; |
|
280 |
mIconIDs = new int[length]; |
|
281 |
mResourceIDs= new int[length]; |
|
279 |
mObjectSizes = new int[length]; |
|
280 |
mMaxLevels = new int[length]; |
|
281 |
mResourceIDs = new int[length]; |
|
282 |
mSmallIconIDs = new int[length]; |
|
283 |
mMediumIconIDs= new int[length]; |
|
284 |
mBigIconIDs = new int[length]; |
|
282 | 285 |
|
283 | 286 |
for(int i=0; i<length; i++) |
284 | 287 |
{ |
285 |
mObjectSizes[i] = info[i][0]; |
|
286 |
mMaxLevels[i] = info[i][1]; |
|
287 |
mIconIDs[i] = info[i][2]; |
|
288 |
mResourceIDs[i] = info[i][3]; |
|
288 |
mObjectSizes[i] = info[i][0]; |
|
289 |
mMaxLevels[i] = info[i][1]; |
|
290 |
mResourceIDs[i] = info[i][2]; |
|
291 |
mSmallIconIDs[i] = info[i][3]; |
|
292 |
mMediumIconIDs[i]= info[i][4]; |
|
293 |
mBigIconIDs[i] = info[i][5]; |
|
289 | 294 |
} |
290 | 295 |
|
291 | 296 |
mObjectClass = object; |
... | ... | |
310 | 315 |
|
311 | 316 |
public int[] getIconIDs() |
312 | 317 |
{ |
313 |
return mIconIDs; |
|
318 |
int size = RubikActivity.getDrawableSize(); |
|
319 |
|
|
320 |
switch(size) |
|
321 |
{ |
|
322 |
case 0 : return mSmallIconIDs; |
|
323 |
case 1 : return mMediumIconIDs; |
|
324 |
default: return mBigIconIDs; |
|
325 |
} |
|
314 | 326 |
} |
315 | 327 |
|
316 | 328 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/states/RubikStatePattern.java | ||
---|---|---|
203 | 203 |
{ |
204 | 204 |
int padding = (int)(width*RubikActivity.PADDING); |
205 | 205 |
int margin = (int)(width*RubikActivity.MARGIN); |
206 |
int icon = RubikActivity.getDrawable(R.drawable.ui_small_left,R.drawable.ui_medium_left, R.drawable.ui_big_left); |
|
206 | 207 |
|
207 | 208 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(0,LinearLayout.LayoutParams.MATCH_PARENT,1.0f); |
208 | 209 |
params.topMargin = margin; |
... | ... | |
213 | 214 |
mPrevButton = new ImageButton(act); |
214 | 215 |
mPrevButton.setLayoutParams(params); |
215 | 216 |
mPrevButton.setPadding(padding,0,padding,0); |
216 |
mPrevButton.setImageResource(R.drawable.ui_small_left);
|
|
217 |
mPrevButton.setImageResource(icon);
|
|
217 | 218 |
|
218 | 219 |
mPrevButton.setOnClickListener( new View.OnClickListener() |
219 | 220 |
{ |
... | ... | |
235 | 236 |
{ |
236 | 237 |
int padding = (int)(width*RubikActivity.PADDING); |
237 | 238 |
int margin = (int)(width*RubikActivity.MARGIN); |
239 |
int icon = RubikActivity.getDrawable(R.drawable.ui_small_right,R.drawable.ui_medium_right, R.drawable.ui_big_right); |
|
238 | 240 |
|
239 | 241 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(0,LinearLayout.LayoutParams.MATCH_PARENT, 1.0f); |
240 | 242 |
params.topMargin = margin; |
... | ... | |
245 | 247 |
mNextButton = new ImageButton(act); |
246 | 248 |
mNextButton.setLayoutParams(params); |
247 | 249 |
mNextButton.setPadding(padding,0,padding,0); |
248 |
mNextButton.setImageResource(R.drawable.ui_small_right);
|
|
250 |
mNextButton.setImageResource(icon);
|
|
249 | 251 |
|
250 | 252 |
mNextButton.setOnClickListener( new View.OnClickListener() |
251 | 253 |
{ |
src/main/java/org/distorted/states/RubikStatePlay.java | ||
---|---|---|
102 | 102 |
|
103 | 103 |
void enterState(final RubikActivity act) |
104 | 104 |
{ |
105 |
DisplayMetrics metrics = act.getResources().getDisplayMetrics(); |
|
106 |
|
|
107 | 105 |
float width = act.getScreenWidthInPixels(); |
108 | 106 |
mMenuTextSize = width*RubikActivity.MENU_MEDIUM_TEXT_SIZE; |
109 | 107 |
mButtonSize = width*RubikActivity.BUTTON_TEXT_SIZE; |
... | ... | |
153 | 151 |
{ |
154 | 152 |
int padding = (int)(width*RubikActivity.PADDING); |
155 | 153 |
int margin = (int)(width*RubikActivity.MARGIN); |
154 |
int icon = RubikActivity.getDrawable(R.drawable.ui_small_cube_menu,R.drawable.ui_medium_cube_menu, R.drawable.ui_big_cube_menu); |
|
156 | 155 |
|
157 | 156 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT, 1.2f); |
158 | 157 |
params.topMargin = margin; |
... | ... | |
163 | 162 |
mObjButton = new ImageButton(act); |
164 | 163 |
mObjButton.setLayoutParams(params); |
165 | 164 |
mObjButton.setPadding(padding,0,padding,0); |
166 |
mObjButton.setImageResource(R.drawable.ui_small_cube_menu);
|
|
165 |
mObjButton.setImageResource(icon);
|
|
167 | 166 |
|
168 | 167 |
mObjButton.setOnClickListener( new View.OnClickListener() |
169 | 168 |
{ |
... | ... | |
197 | 196 |
{ |
198 | 197 |
int padding = (int)(width*RubikActivity.PADDING); |
199 | 198 |
int margin = (int)(width*RubikActivity.MARGIN); |
199 |
int spin = RubikActivity.getDrawable(R.drawable.ui_small_spinner,R.drawable.ui_big_spinner, R.drawable.ui_big_spinner); |
|
200 |
|
|
200 | 201 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT, 1.0f); |
201 | 202 |
params.topMargin = margin; |
202 | 203 |
params.bottomMargin = margin; |
... | ... | |
206 | 207 |
mLevelSpinner = new AppCompatSpinner(act); |
207 | 208 |
mLevelSpinner.setLayoutParams(params); |
208 | 209 |
mLevelSpinner.setPadding(padding,0,padding,0); |
209 |
mLevelSpinner.setBackgroundResource(R.drawable.ui_small_spinner);
|
|
210 |
mLevelSpinner.setBackgroundResource(spin);
|
|
210 | 211 |
mLevelSpinner.setTextAlignment(View.TEXT_ALIGNMENT_CENTER); |
211 | 212 |
|
212 | 213 |
mLevelSpinner.setOnItemSelectedListener(this); |
... | ... | |
272 | 273 |
{ |
273 | 274 |
int padding = (int)(width*RubikActivity.PADDING); |
274 | 275 |
int margin = (int)(width*RubikActivity.MARGIN); |
276 |
int icon = RubikActivity.getDrawable(R.drawable.ui_small_menu,R.drawable.ui_medium_menu, R.drawable.ui_big_menu); |
|
277 |
|
|
275 | 278 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT); |
276 | 279 |
params.topMargin = margin; |
277 | 280 |
params.bottomMargin = margin; |
... | ... | |
281 | 284 |
mMenuButton = new ImageButton(act); |
282 | 285 |
mMenuButton.setLayoutParams(params); |
283 | 286 |
mMenuButton.setPadding(padding,0,padding,0); |
284 |
mMenuButton.setImageResource(R.drawable.ui_small_menu);
|
|
287 |
mMenuButton.setImageResource(icon);
|
|
285 | 288 |
|
286 | 289 |
final int barHeight = act.getScreenHeightInPixels()/10; |
287 | 290 |
|
... | ... | |
306 | 309 |
int padding = (int)(width*RubikActivity.PADDING); |
307 | 310 |
int margin = (int)(width*RubikActivity.MARGIN); |
308 | 311 |
int widthBut = (int)(width/6); |
312 |
int icon = RubikActivity.getDrawable(R.drawable.ui_small_cube_solve,R.drawable.ui_medium_cube_solve, R.drawable.ui_big_cube_solve); |
|
313 |
|
|
309 | 314 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(widthBut, LinearLayout.LayoutParams.MATCH_PARENT); |
310 | 315 |
params.topMargin = margin; |
311 | 316 |
params.bottomMargin = margin; |
... | ... | |
315 | 320 |
mSolveButton = new ImageButton(act); |
316 | 321 |
mSolveButton.setLayoutParams(params); |
317 | 322 |
mSolveButton.setPadding(padding,0,padding,0); |
318 |
mSolveButton.setImageResource(R.drawable.ui_small_cube_solve);
|
|
323 |
mSolveButton.setImageResource(icon);
|
|
319 | 324 |
|
320 | 325 |
mSolveButton.setOnClickListener( new View.OnClickListener() |
321 | 326 |
{ |
... | ... | |
335 | 340 |
int padding = (int)(width*RubikActivity.PADDING); |
336 | 341 |
int margin = (int)(width*RubikActivity.MARGIN); |
337 | 342 |
int widthBut = (int)(width/6); |
343 |
int icon = RubikActivity.getDrawable(R.drawable.ui_small_cube_back,R.drawable.ui_medium_cube_back, R.drawable.ui_big_cube_back); |
|
344 |
|
|
338 | 345 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(widthBut, LinearLayout.LayoutParams.MATCH_PARENT); |
339 | 346 |
params.topMargin = margin; |
340 | 347 |
params.bottomMargin = margin; |
... | ... | |
344 | 351 |
mPrevButton = new ImageButton(act); |
345 | 352 |
mPrevButton.setLayoutParams(params); |
346 | 353 |
mPrevButton.setPadding(padding,0,padding,0); |
347 |
mPrevButton.setImageResource(R.drawable.ui_small_cube_back);
|
|
354 |
mPrevButton.setImageResource(icon);
|
|
348 | 355 |
|
349 | 356 |
mPrevButton.setOnClickListener( new View.OnClickListener() |
350 | 357 |
{ |
... | ... | |
368 | 375 |
mObjectPopup = new PopupWindow(act); |
369 | 376 |
mObjectPopup.setContentView(layout); |
370 | 377 |
mObjectPopup.setFocusable(true); |
371 |
int margin = (int)(width*RubikActivity.PADDING); |
|
378 |
int margin = (int)(width*RubikActivity.LARGE_MARGIN); |
|
379 |
int icon = RubikActivity.getDrawable(R.drawable.ui_small_cube2,R.drawable.ui_medium_cube2, R.drawable.ui_big_cube2); |
|
372 | 380 |
|
373 |
BitmapDrawable bd = (BitmapDrawable) act.getResources().getDrawable(R.drawable.ui_small_cube2);
|
|
381 |
BitmapDrawable bd = (BitmapDrawable) act.getResources().getDrawable(icon);
|
|
374 | 382 |
int cubeWidth = bd.getIntrinsicWidth(); |
375 | 383 |
mObjectLayoutWidth = (int)(cubeWidth + 2*margin + 0.5f); |
376 | 384 |
|
385 |
LinearLayout.LayoutParams p = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,LinearLayout.LayoutParams.WRAP_CONTENT); |
|
386 |
p.setMargins(margin, margin, margin, margin); |
|
387 |
|
|
377 | 388 |
for(int object=0; object<RubikObjectList.NUM_OBJECTS; object++) |
378 | 389 |
{ |
379 | 390 |
final RubikObjectList list = RubikObjectList.getObject(object); |
... | ... | |
386 | 397 |
{ |
387 | 398 |
final int size = i; |
388 | 399 |
|
389 |
LinearLayout.LayoutParams p = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,LinearLayout.LayoutParams.WRAP_CONTENT); |
|
390 |
p.setMargins(margin, margin, margin, margin); |
|
391 |
|
|
392 | 400 |
ImageButton button = new ImageButton(act); |
393 | 401 |
button.setLayoutParams(p); |
394 | 402 |
|
src/main/java/org/distorted/states/RubikStateReady.java | ||
---|---|---|
104 | 104 |
{ |
105 | 105 |
int padding = (int)(width*RubikActivity.PADDING); |
106 | 106 |
int widthBut= (int)(width/6); |
107 |
int icon = RubikActivity.getDrawable(R.drawable.ui_small_cube_back,R.drawable.ui_medium_cube_back, R.drawable.ui_big_cube_back); |
|
107 | 108 |
|
108 | 109 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(widthBut,LinearLayout.LayoutParams.MATCH_PARENT); |
109 | 110 |
mPrevButton = new ImageButton(act); |
110 | 111 |
mPrevButton.setLayoutParams(params); |
111 | 112 |
mPrevButton.setPadding(padding,0,padding,0); |
112 |
mPrevButton.setImageResource(R.drawable.ui_small_cube_back);
|
|
113 |
mPrevButton.setImageResource(icon);
|
|
113 | 114 |
|
114 | 115 |
mPrevButton.setOnClickListener( new View.OnClickListener() |
115 | 116 |
{ |
src/main/java/org/distorted/states/RubikStateSolution.java | ||
---|---|---|
100 | 100 |
{ |
101 | 101 |
int padding = (int)(width*RubikActivity.PADDING); |
102 | 102 |
int margin = (int)(width*RubikActivity.MARGIN); |
103 |
int icon = RubikActivity.getDrawable(R.drawable.ui_small_left,R.drawable.ui_medium_left, R.drawable.ui_big_left); |
|
104 |
|
|
103 | 105 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(0,LinearLayout.LayoutParams.MATCH_PARENT,1.0f); |
104 | 106 |
params.topMargin = margin; |
105 | 107 |
params.bottomMargin = margin; |
... | ... | |
109 | 111 |
mPrevButton = new ImageButton(act); |
110 | 112 |
mPrevButton.setLayoutParams(params); |
111 | 113 |
mPrevButton.setPadding(padding,0,padding,0); |
112 |
mPrevButton.setImageResource(R.drawable.ui_small_left);
|
|
114 |
mPrevButton.setImageResource(icon);
|
|
113 | 115 |
|
114 | 116 |
mPrevButton.setOnClickListener( new View.OnClickListener() |
115 | 117 |
{ |
... | ... | |
129 | 131 |
{ |
130 | 132 |
int padding = (int)(width*RubikActivity.PADDING); |
131 | 133 |
int margin = (int)(width*RubikActivity.MARGIN); |
134 |
int icon = RubikActivity.getDrawable(R.drawable.ui_small_right,R.drawable.ui_medium_right, R.drawable.ui_big_right); |
|
135 |
|
|
132 | 136 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(0,LinearLayout.LayoutParams.MATCH_PARENT, 1.0f); |
133 | 137 |
params.topMargin = margin; |
134 | 138 |
params.bottomMargin = margin; |
... | ... | |
138 | 142 |
mNextButton = new ImageButton(act); |
139 | 143 |
mNextButton.setLayoutParams(params); |
140 | 144 |
mNextButton.setPadding(padding,0,padding,0); |
141 |
mNextButton.setImageResource(R.drawable.ui_small_right);
|
|
145 |
mNextButton.setImageResource(icon);
|
|
142 | 146 |
|
143 | 147 |
mNextButton.setOnClickListener( new View.OnClickListener() |
144 | 148 |
{ |
src/main/java/org/distorted/states/RubikStateSolving.java | ||
---|---|---|
150 | 150 |
int padding = (int)(width*RubikActivity.PADDING); |
151 | 151 |
int margin = (int)(width*RubikActivity.MARGIN); |
152 | 152 |
int widthBut= (int)(width/6); |
153 |
int icon = RubikActivity.getDrawable(R.drawable.ui_small_cube_back,R.drawable.ui_medium_cube_back, R.drawable.ui_big_cube_back); |
|
153 | 154 |
|
154 | 155 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(widthBut,LinearLayout.LayoutParams.MATCH_PARENT); |
155 | 156 |
params.topMargin = margin; |
... | ... | |
160 | 161 |
mPrevButton = new ImageButton(act); |
161 | 162 |
mPrevButton.setLayoutParams(params); |
162 | 163 |
mPrevButton.setPadding(padding,0,padding,0); |
163 |
mPrevButton.setImageResource(R.drawable.ui_small_cube_back);
|
|
164 |
mPrevButton.setImageResource(icon);
|
|
164 | 165 |
|
165 | 166 |
mPrevButton.setOnClickListener( new View.OnClickListener() |
166 | 167 |
{ |
Also available in: Unified diff
Introduce three sizes of UI images: small, medium, large.