Revision 46405bb4
Added by Leszek Koltunski over 3 years ago
src/main/java/org/distorted/states/RubikStatePlay.java | ||
---|---|---|
56 | 56 |
private static int[] BUTTON_LABELS = { R.string.scores, R.string.patterns, R.string.solver, R.string.about }; |
57 | 57 |
private static final int NUM_BUTTONS = BUTTON_LABELS.length; |
58 | 58 |
|
59 |
private ImageButton mObjButton, mMenuButton, mPrevButton, mSolveButton; |
|
59 |
private ImageButton mObjButton, mMenuButton, mPrevButton, mSolveButton, mLockButton;
|
|
60 | 60 |
private Button mPlayButton; |
61 | 61 |
private PopupWindow mObjectPopup, mMenuPopup, mPlayPopup; |
62 | 62 |
private int mObject = DEF_OBJECT; |
... | ... | |
137 | 137 |
|
138 | 138 |
setupPrevButton(act,width); |
139 | 139 |
layoutLeft.addView(mPrevButton); |
140 |
setupLockButton(act,width); |
|
141 |
layoutMid.addView(mLockButton); |
|
140 | 142 |
setupSolveButton(act,width); |
141 | 143 |
layoutRight.addView(mSolveButton); |
142 | 144 |
|
... | ... | |
298 | 300 |
}); |
299 | 301 |
} |
300 | 302 |
|
303 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
304 |
|
|
305 |
private void setupLockButton(final RubikActivity act, final float width) |
|
306 |
{ |
|
307 |
int padding = (int)(width*RubikActivity.PADDING); |
|
308 |
int margin = (int)(width*RubikActivity.MARGIN); |
|
309 |
|
|
310 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT); |
|
311 |
params.topMargin = margin; |
|
312 |
params.bottomMargin = margin; |
|
313 |
params.leftMargin = margin; |
|
314 |
params.rightMargin = margin; |
|
315 |
|
|
316 |
mLockButton = new ImageButton(act); |
|
317 |
mLockButton.setLayoutParams(params); |
|
318 |
mLockButton.setPadding(padding,0,padding,0); |
|
319 |
mLockButton.setImageResource(getLockIcon(act)); |
|
320 |
|
|
321 |
mLockButton.setOnClickListener( new View.OnClickListener() |
|
322 |
{ |
|
323 |
@Override |
|
324 |
public void onClick(View v) |
|
325 |
{ |
|
326 |
toggleLock(act); |
|
327 |
} |
|
328 |
}); |
|
329 |
} |
|
330 |
|
|
301 | 331 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
302 | 332 |
|
303 | 333 |
private void setupPrevButton(final RubikActivity act, final float width) |
... | ... | |
535 | 565 |
} |
536 | 566 |
} |
537 | 567 |
|
568 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
569 |
|
|
570 |
private void toggleLock(RubikActivity act) |
|
571 |
{ |
|
572 |
act.toggleLock(); |
|
573 |
mLockButton.setImageResource(getLockIcon(act)); |
|
574 |
} |
|
575 |
|
|
576 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
577 |
|
|
578 |
private int getLockIcon(RubikActivity act) |
|
579 |
{ |
|
580 |
if( act.retLocked() ) |
|
581 |
{ |
|
582 |
return RubikActivity.getDrawable(R.drawable.ui_small_locked,R.drawable.ui_medium_locked, R.drawable.ui_big_locked, R.drawable.ui_huge_locked); |
|
583 |
} |
|
584 |
else |
|
585 |
{ |
|
586 |
return RubikActivity.getDrawable(R.drawable.ui_small_unlocked,R.drawable.ui_medium_unlocked, R.drawable.ui_big_unlocked, R.drawable.ui_huge_unlocked); |
|
587 |
} |
|
588 |
} |
|
589 |
|
|
538 | 590 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
539 | 591 |
|
540 | 592 |
public void savePreferences(SharedPreferences.Editor editor) |
Also available in: Unified diff
Add lock button.