| 74 |
74 |
private AppCompatSpinner mLevelSpinner;
|
| 75 |
75 |
private ArrayAdapter<String> mSpinnerAdapter;
|
| 76 |
76 |
private int mLevelValue;
|
| 77 |
|
private float mButtonSize, mTitleSize;
|
|
77 |
private float mButtonSize, mTitleSize, mMenuItemSize, mMenuTextSize;
|
| 78 |
78 |
|
| 79 |
79 |
private ArrayList<Move> mMoves;
|
| 80 |
80 |
private boolean mCanPrevMove;
|
| ... | ... | |
| 106 |
106 |
final float scale = metrics.density;
|
| 107 |
107 |
|
| 108 |
108 |
float width = act.getScreenWidthInPixels();
|
| 109 |
|
mButtonSize = width*RubikActivity.BUTTON_TEXT_SIZE;
|
| 110 |
|
mTitleSize = width*RubikActivity.TITLE_TEXT_SIZE;
|
|
109 |
mMenuTextSize = width*RubikActivity.MENU_MEDIUM_TEXT_SIZE;
|
|
110 |
mButtonSize = width*RubikActivity.BUTTON_TEXT_SIZE;
|
|
111 |
mTitleSize = width*RubikActivity.TITLE_TEXT_SIZE;
|
|
112 |
mMenuItemSize = width*RubikActivity.MENU_ITEM_SIZE;
|
| 111 |
113 |
|
| 112 |
114 |
mCanPrevMove = true;
|
| 113 |
115 |
|
| ... | ... | |
| 143 |
145 |
setupMenuButton(act,scale);
|
| 144 |
146 |
layoutRight.addView(mMenuButton);
|
| 145 |
147 |
|
| 146 |
|
setupMenuWindow(act, scale);
|
|
148 |
setupMenuWindow(act, scale, width);
|
| 147 |
149 |
}
|
| 148 |
150 |
|
| 149 |
151 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| ... | ... | |
| 263 |
265 |
mMenuButton.setPadding(padding,0,padding,0);
|
| 264 |
266 |
mMenuButton.setImageResource(R.drawable.menu);
|
| 265 |
267 |
|
|
268 |
final int barHeight = act.getScreenHeightInPixels()/10;
|
|
269 |
|
| 266 |
270 |
mMenuButton.setOnClickListener( new View.OnClickListener()
|
| 267 |
271 |
{
|
| 268 |
272 |
@Override
|
| ... | ... | |
| 270 |
274 |
{
|
| 271 |
275 |
if( act.getPreRender().canPlay() )
|
| 272 |
276 |
{
|
| 273 |
|
int total = RubikObjectList.getTotal();
|
| 274 |
|
boolean vertical = act.isVertical();
|
| 275 |
|
mMenuLayout.setOrientation(vertical ? LinearLayout.VERTICAL:LinearLayout.HORIZONTAL);
|
| 276 |
|
|
| 277 |
|
mMenuPopup.showAsDropDown(view, 0, -3*mMenuLayoutHeight, Gravity.LEFT);
|
|
277 |
mMenuPopup.showAsDropDown(view, 0, -mMenuLayoutHeight-barHeight, Gravity.LEFT);
|
| 278 |
278 |
mMenuPopup.update();
|
| 279 |
279 |
}
|
| 280 |
280 |
}
|
| ... | ... | |
| 387 |
387 |
|
| 388 |
388 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 389 |
389 |
|
| 390 |
|
private void setupMenuWindow(final RubikActivity act, final float scale)
|
|
390 |
private void setupMenuWindow(final RubikActivity act, final float scale, final float width)
|
| 391 |
391 |
{
|
| 392 |
392 |
LayoutInflater layoutInflater = (LayoutInflater)act.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
| 393 |
393 |
final View layout = layoutInflater.inflate(R.layout.popup_objects, null);
|
| ... | ... | |
| 396 |
396 |
mMenuPopup = new PopupWindow(act);
|
| 397 |
397 |
mMenuPopup.setContentView(layout);
|
| 398 |
398 |
mMenuPopup.setFocusable(true);
|
| 399 |
|
int margin = (int)(5*scale + 0.5f);
|
|
399 |
int margin = (int)(3*scale + 0.5f);
|
|
400 |
int padding= (int)(7*scale + 0.5f);
|
| 400 |
401 |
|
| 401 |
|
LinearLayout.LayoutParams p = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.WRAP_CONTENT);
|
| 402 |
|
p.setMargins(margin, margin, margin, margin);
|
|
402 |
LinearLayout.LayoutParams p = new LinearLayout.LayoutParams( (int)width/2 - 2*padding, (int)mMenuItemSize);
|
|
403 |
p.setMargins(margin, margin/2, margin, margin/2);
|
| 403 |
404 |
|
| 404 |
405 |
for(int i=0; i<NUM_BUTTONS; i++)
|
| 405 |
406 |
{
|
| ... | ... | |
| 407 |
408 |
Button button = new Button(act);
|
| 408 |
409 |
button.setLayoutParams(p);
|
| 409 |
410 |
button.setText(BUTTON_LABELS[i]);
|
|
411 |
button.setTextSize(TypedValue.COMPLEX_UNIT_PX, mMenuTextSize);
|
| 410 |
412 |
|
| 411 |
413 |
button.setOnClickListener( new View.OnClickListener()
|
| 412 |
414 |
{
|
| ... | ... | |
| 421 |
423 |
mMenuLayout.addView(button);
|
| 422 |
424 |
}
|
| 423 |
425 |
|
| 424 |
|
mMenuLayoutHeight= (int)(margin + NUM_BUTTONS*(mButtonSize+margin));
|
|
426 |
mMenuLayoutHeight= (int)(NUM_BUTTONS*(mMenuItemSize+margin));
|
| 425 |
427 |
}
|
| 426 |
428 |
|
| 427 |
429 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| ... | ... | |
| 452 |
454 |
android.util.Log.e("solution", "error: trying to back move of angle 0");
|
| 453 |
455 |
}
|
| 454 |
456 |
}
|
| 455 |
|
else
|
| 456 |
|
{
|
| 457 |
|
android.util.Log.e("solv", "error: no moves to back!");
|
| 458 |
|
}
|
| 459 |
457 |
}
|
| 460 |
458 |
}
|
| 461 |
459 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
Improvements to the Menu.