Revision d6c79ac9
Added by Leszek Koltunski over 2 years ago
src/main/java/org/distorted/screens/RubikScreenPlay.java | ||
---|---|---|
66 | 66 |
public static final int NUM_COLUMNS = 5; |
67 | 67 |
public static final int LEVELS_SHOWN = 10; |
68 | 68 |
|
69 |
private static final int[] BUTTON_LABELS = { R.string.scores, |
|
70 |
R.string.patterns, |
|
71 |
R.string.solver, |
|
72 |
R.string.tutorials, |
|
73 |
R.string.bandaged, |
|
74 |
R.string.about }; |
|
75 |
|
|
76 |
private static final int NUM_BUTTONS = BUTTON_LABELS.length; |
|
69 |
private static final int[] BUTTON_LABELS_FULL = { R.string.scores, |
|
70 |
R.string.patterns, |
|
71 |
R.string.solver, |
|
72 |
R.string.tutorials, |
|
73 |
R.string.bandaged, |
|
74 |
R.string.about }; |
|
75 |
|
|
76 |
private static final int[] BUTTON_LABELS_LEAN = { R.string.scores, |
|
77 |
R.string.patterns, |
|
78 |
R.string.solver, |
|
79 |
R.string.tutorials, |
|
80 |
R.string.about }; |
|
81 |
|
|
77 | 82 |
private static final float LAST_BUTTON = 1.5f; |
78 | 83 |
private static final int[] mLocation = new int[2]; |
79 | 84 |
|
... | ... | |
91 | 96 |
private int mBottomHeight; |
92 | 97 |
private float mScreenWidth; |
93 | 98 |
private WeakReference<RubikActivity> mWeakAct; |
99 |
private boolean mDisplayBandaged; |
|
100 |
private int mNumButtons; |
|
94 | 101 |
|
95 | 102 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
96 | 103 |
|
... | ... | |
103 | 110 |
|
104 | 111 |
void enterScreen(final RubikActivity act) |
105 | 112 |
{ |
113 |
mDisplayBandaged = Build.VERSION.SDK_INT >= Build.VERSION_CODES.N; |
|
114 |
mNumButtons = mDisplayBandaged ? BUTTON_LABELS_FULL.length : BUTTON_LABELS_LEAN.length; |
|
115 |
|
|
106 | 116 |
mWeakAct = new WeakReference<>(act); |
107 | 117 |
int numObjects = RubikObjectList.getNumObjects(); |
108 | 118 |
mScreenWidth = act.getScreenWidthInPixels(); |
... | ... | |
393 | 403 |
int padding = (int)(width*RubikActivity.PADDING); |
394 | 404 |
|
395 | 405 |
mMenuLayoutWidth = (int)(width/2); |
396 |
mMenuLayoutHeight= (int)(2*margin + NUM_BUTTONS*(mMenuItemSize+margin));
|
|
406 |
mMenuLayoutHeight= (int)(2*margin + mNumButtons*(mMenuItemSize+margin));
|
|
397 | 407 |
|
398 | 408 |
LinearLayout.LayoutParams p = new LinearLayout.LayoutParams( mMenuLayoutWidth - 2*padding, (int)mMenuItemSize); |
399 | 409 |
|
400 |
for(int i=0; i<NUM_BUTTONS; i++) |
|
410 |
int[] labels = mDisplayBandaged ? BUTTON_LABELS_FULL : BUTTON_LABELS_LEAN; |
|
411 |
|
|
412 |
for(int i=0; i<mNumButtons; i++) |
|
401 | 413 |
{ |
402 | 414 |
final int but = i; |
403 | 415 |
Button button = new Button(act); |
404 | 416 |
button.setLayoutParams(p); |
405 |
button.setText(BUTTON_LABELS[i]);
|
|
417 |
button.setText(labels[i]);
|
|
406 | 418 |
button.setTextSize(TypedValue.COMPLEX_UNIT_PX, mMenuTextSize); |
407 | 419 |
|
408 | 420 |
button.setOnClickListener( new View.OnClickListener() |
... | ... | |
458 | 470 |
case 3: RubikDialogTutorial tDiag = new RubikDialogTutorial(); |
459 | 471 |
tDiag.show( act.getSupportFragmentManager(), RubikDialogTutorial.getDialogTag() ); |
460 | 472 |
break; |
461 |
case 4: act.switchToBandagedCreator(); |
|
462 |
break; |
|
473 |
case 4: if( mDisplayBandaged ) |
|
474 |
{ |
|
475 |
act.switchToBandagedCreator(); |
|
476 |
break; |
|
477 |
} |
|
463 | 478 |
case 5: RubikDialogAbout aDiag = new RubikDialogAbout(); |
464 | 479 |
aDiag.show(act.getSupportFragmentManager(), null); |
465 | 480 |
break; |
Also available in: Unified diff
Only show Bandaged option on Android >= 7.0.