Revision c1df05fa
Added by Leszek Koltunski over 3 years ago
| src/main/java/org/distorted/screens/RubikScreenPlay.java | ||
|---|---|---|
| 24 | 24 |
import android.app.Activity; |
| 25 | 25 |
import android.content.Context; |
| 26 | 26 |
import android.content.SharedPreferences; |
| 27 |
import android.content.res.Resources; |
|
| 28 |
import android.graphics.drawable.BitmapDrawable; |
|
| 29 | 27 |
import android.os.Build; |
| 30 | 28 |
import android.os.Bundle; |
| 31 | 29 |
import android.util.TypedValue; |
| ... | ... | |
| 89 | 87 |
private int mColCount, mRowCount, mMaxRowCount; |
| 90 | 88 |
private int mUpperBarHeight; |
| 91 | 89 |
private boolean mShouldReactToEndOfScrambling; |
| 92 |
private int mBottomHeight; |
|
| 93 | 90 |
private float mScreenWidth; |
| 94 | 91 |
private WeakReference<RubikActivity> mWeakAct; |
| 95 | 92 |
private String mObjectsPlayed; |
| ... | ... | |
| 121 | 118 |
LinearLayout layoutTop = act.findViewById(R.id.upperBar); |
| 122 | 119 |
layoutTop.removeAllViews(); |
| 123 | 120 |
|
| 124 |
setupObjectButton(act,mScreenWidth); |
|
| 125 |
layoutTop.addView(mObjButton); |
|
| 126 |
|
|
| 121 |
setupSolveButton(act); |
|
| 122 |
layoutTop.addView(mSolveButton); |
|
| 127 | 123 |
setupMenuButton(act,mScreenWidth); |
| 128 | 124 |
layoutTop.addView(mMenuButton); |
| 129 |
|
|
| 130 |
setupPlayButton(act,mScreenWidth); |
|
| 131 |
layoutTop.addView(mPlayButton); |
|
| 132 |
|
|
| 133 |
setupSolveButton(act); |
|
| 134 | 125 |
setupScrambleButton(act); |
| 135 |
createBottomPane(act,mSolveButton,mScrambleButton); |
|
| 126 |
layoutTop.addView(mScrambleButton); |
|
| 127 |
|
|
| 128 |
// BOTTOM ///////////////////////// |
|
| 129 |
setupObjectButton(act,mScreenWidth); |
|
| 130 |
createBottomPane(act,mObjButton,null); |
|
| 136 | 131 |
} |
| 137 | 132 |
|
| 138 | 133 |
////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 140 | 135 |
private void setupObjectButton(final RubikActivity act, final float width) |
| 141 | 136 |
{
|
| 142 | 137 |
final int margin = (int)(width*RubikActivity.SMALL_MARGIN); |
| 143 |
final int lMargin = (int)(width*RubikActivity.LARGE_MARGIN); |
|
| 144 | 138 |
final int icon = RubikActivity.getDrawable(R.drawable.ui_small_cube_menu,R.drawable.ui_medium_cube_menu, R.drawable.ui_big_cube_menu, R.drawable.ui_huge_cube_menu); |
| 145 | 139 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,1.0f); |
| 146 | 140 |
mObjButton = new TransparentImageButton(act, icon, TransparentImageButton.GRAVITY_MIDDLE, params); |
| ... | ... | |
| 162 | 156 |
int rowCount = Math.min(mMaxRowCount,mRowCount); |
| 163 | 157 |
View popupView = mObjectPopup.getContentView(); |
| 164 | 158 |
popupView.setSystemUiVisibility(RubikActivity.FLAGS); |
| 165 |
displayPopup(act,view,mObjectPopup,mObjectSize*mColCount,mObjectSize*rowCount+mBottomHeight+2*lMargin+5*margin,margin,margin);
|
|
| 159 |
displayPopup(act,view,mObjectPopup,mObjectSize*mColCount,mObjectSize*rowCount+5*margin,margin,margin); |
|
| 166 | 160 |
} |
| 167 | 161 |
} |
| 168 | 162 |
}); |
| ... | ... | |
| 340 | 334 |
buttonDow.setImageResource(iconD); |
| 341 | 335 |
buttonInf.setImageResource(iconI); |
| 342 | 336 |
|
| 343 |
Resources res = act.getResources(); |
|
| 344 |
BitmapDrawable bd = (BitmapDrawable)res.getDrawable(iconI); |
|
| 345 |
mBottomHeight = bd.getIntrinsicHeight(); |
|
| 346 |
|
|
| 347 | 337 |
TypedValue outValue = new TypedValue(); |
| 348 | 338 |
act.getTheme().resolveAttribute(android.R.attr.selectableItemBackgroundBorderless, outValue, true); |
| 349 | 339 |
buttonTut.setBackgroundResource(outValue.resourceId); |
| ... | ... | |
| 390 | 380 |
network.signUpForUpdates(this); |
| 391 | 381 |
} |
| 392 | 382 |
|
| 383 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 384 |
|
|
| 385 |
void setupSolveButton(final RubikActivity act) |
|
| 386 |
{
|
|
| 387 |
int icon = RubikActivity.getDrawable(R.drawable.ui_small_cube_solve,R.drawable.ui_medium_cube_solve, R.drawable.ui_big_cube_solve, R.drawable.ui_huge_cube_solve); |
|
| 388 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,1.0f); |
|
| 389 |
mSolveButton = new TransparentImageButton(act, icon, TransparentImageButton.GRAVITY_MIDDLE,params); |
|
| 390 |
|
|
| 391 |
mSolveButton.setOnClickListener( new View.OnClickListener() |
|
| 392 |
{
|
|
| 393 |
@Override |
|
| 394 |
public void onClick(View v) |
|
| 395 |
{
|
|
| 396 |
act.getControl().solveObject(); |
|
| 397 |
mMovesController.clearMoves(act); |
|
| 398 |
} |
|
| 399 |
}); |
|
| 400 |
} |
|
| 401 |
|
|
| 402 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 403 |
|
|
| 404 |
private void setupScrambleButton(final RubikActivity act) |
|
| 405 |
{
|
|
| 406 |
int icon = RubikActivity.getDrawable(R.drawable.ui_small_cube_scramble,R.drawable.ui_medium_cube_scramble, R.drawable.ui_big_cube_scramble, R.drawable.ui_huge_cube_scramble); |
|
| 407 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,1.0f); |
|
| 408 |
mScrambleButton = new TransparentImageButton(act, icon, TransparentImageButton.GRAVITY_MIDDLE, params); |
|
| 409 |
|
|
| 410 |
mScrambleButton.setOnClickListener( new View.OnClickListener() |
|
| 411 |
{
|
|
| 412 |
@Override |
|
| 413 |
public void onClick(View v) |
|
| 414 |
{
|
|
| 415 |
int currObject = RubikObjectList.getCurrObject(); |
|
| 416 |
RubikObject object = RubikObjectList.getObject(currObject); |
|
| 417 |
int numScrambles = object==null ? 0 : object.getNumScramble(); |
|
| 418 |
mShouldReactToEndOfScrambling = false; |
|
| 419 |
act.getControl().fastScrambleObject(numScrambles); |
|
| 420 |
} |
|
| 421 |
}); |
|
| 422 |
} |
|
| 423 |
|
|
| 393 | 424 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 394 | 425 |
|
| 395 | 426 |
private void setupMenuWindow(final RubikActivity act, final float width) |
| ... | ... | |
| 476 | 507 |
} |
| 477 | 508 |
} |
| 478 | 509 |
|
| 479 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 480 |
|
|
| 481 |
void setupSolveButton(final RubikActivity act) |
|
| 482 |
{
|
|
| 483 |
int icon = RubikActivity.getDrawable(R.drawable.ui_small_cube_solve_new,R.drawable.ui_medium_cube_solve_new, R.drawable.ui_big_cube_solve_new, R.drawable.ui_huge_cube_solve_new); |
|
| 484 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,1.0f); |
|
| 485 |
mSolveButton = new TransparentImageButton(act, icon, TransparentImageButton.GRAVITY_END,params); |
|
| 486 |
|
|
| 487 |
mSolveButton.setOnClickListener( new View.OnClickListener() |
|
| 488 |
{
|
|
| 489 |
@Override |
|
| 490 |
public void onClick(View v) |
|
| 491 |
{
|
|
| 492 |
act.getControl().solveObject(); |
|
| 493 |
mMovesController.clearMoves(act); |
|
| 494 |
} |
|
| 495 |
}); |
|
| 496 |
} |
|
| 497 |
|
|
| 498 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 499 |
|
|
| 500 |
private void setupScrambleButton(final RubikActivity act) |
|
| 501 |
{
|
|
| 502 |
int icon = RubikActivity.getDrawable(R.drawable.ui_small_cube_scramble_new,R.drawable.ui_medium_cube_scramble_new, R.drawable.ui_big_cube_scramble_new, R.drawable.ui_huge_cube_scramble_new); |
|
| 503 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,1.0f); |
|
| 504 |
mScrambleButton = new TransparentImageButton(act, icon, TransparentImageButton.GRAVITY_START, params); |
|
| 505 |
|
|
| 506 |
mScrambleButton.setOnClickListener( new View.OnClickListener() |
|
| 507 |
{
|
|
| 508 |
@Override |
|
| 509 |
public void onClick(View v) |
|
| 510 |
{
|
|
| 511 |
int currObject = RubikObjectList.getCurrObject(); |
|
| 512 |
RubikObject object = RubikObjectList.getObject(currObject); |
|
| 513 |
int numScrambles = object==null ? 0 : object.getNumScramble(); |
|
| 514 |
mShouldReactToEndOfScrambling = false; |
|
| 515 |
act.getControl().scrambleObject(numScrambles); |
|
| 516 |
} |
|
| 517 |
}); |
|
| 518 |
} |
|
| 519 |
|
|
| 520 | 510 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 521 | 511 |
// This is necessary! Otherwise the ObjectPopup will not be re-created next time and we will still |
| 522 | 512 |
// hold a reference to the old instance of the RubikActivity class (because setupObjectWindow is not |
Also available in: Unified diff
- move the 'object' popup to the botton right
- move the 'solve' button to the upper left
- movee the 'scramble' button to the upper right (its new FastScrambleEffect still not implemented fully)