Project

General

Profile

« Previous | Next » 

Revision dd874ae8

Added by Leszek Koltunski over 2 years ago

Convert the theme to be a MaterialTheme and the TransparentImageButton to be a MaterialButton - the first forced by the second, and the second because a MaterialButton gives us control over the location of the icon in top of it. We need that because of the new 'solve/scramble' split-button in the lower right of the Play screen.

View differences:

src/main/java/org/distorted/screens/RubikScreenPlay.java
69 69
  private static final float LAST_BUTTON = 1.5f;
70 70
  private static final int[] mLocation = new int[2];
71 71

  
72
  private ImageButton mObjButton, mMenuButton, mSolveButton;
72
  private TransparentImageButton mObjButton, mMenuButton, mSolveButton, mScrambleButton;
73 73
  private Button mPlayButton;
74 74
  private PopupWindow mObjectPopup, mMenuPopup, mPlayPopup;
75 75
  private ObjectType mObject = DEF_OBJECT;
......
79 79
  private int mColCount, mRowCount, mMaxRowCount;
80 80
  private LinearLayout mPlayLayout;
81 81
  private int mUpperBarHeight;
82
  private boolean mShouldReactToEndOfScrambling;
82 83

  
83 84
  static
84 85
    {
......
128 129
    setupPlayButton(act,width);
129 130
    layoutTop.addView(mPlayButton);
130 131

  
131
    setupSolveButton(act,width);
132
    createBottomPane(act,width,mSolveButton);
132
    setupSolveButton(act);
133
    setupScrambleButton(act);
134
    createBottomPane(act,mSolveButton,mScrambleButton);
133 135
    }
134 136

  
135 137
//////////////////////////////////////////////////////////////////////////////////////////////////
......
139 141
    final int margin  = (int)(width*RubikActivity.MARGIN);
140 142
    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);
141 143

  
142
    mObjButton = new TransparentImageButton(act, icon, width,LinearLayout.LayoutParams.MATCH_PARENT);
144
    mObjButton = new TransparentImageButton(act, icon, LinearLayout.LayoutParams.MATCH_PARENT, TransparentImageButton.GRAVITY_MIDDLE);
143 145

  
144 146
    mObjButton.setOnClickListener( new View.OnClickListener()
145 147
      {
......
206 208
    final int margin = (int)(width*RubikActivity.MARGIN);
207 209
    final int icon = RubikActivity.getDrawable(R.drawable.ui_small_menu,R.drawable.ui_medium_menu, R.drawable.ui_big_menu, R.drawable.ui_huge_menu);
208 210

  
209
    mMenuButton = new TransparentImageButton(act, icon, width,LinearLayout.LayoutParams.MATCH_PARENT);
211
    mMenuButton = new TransparentImageButton(act, icon, LinearLayout.LayoutParams.MATCH_PARENT, TransparentImageButton.GRAVITY_MIDDLE);
210 212

  
211 213
    mMenuButton.setOnClickListener( new View.OnClickListener()
212 214
      {
......
398 400

  
399 401
///////////////////////////////////////////////////////////////////////////////////////////////////
400 402

  
401
  void setupSolveButton(final RubikActivity act, final float width)
403
  void setupSolveButton(final RubikActivity act)
402 404
    {
403
    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);
404
    mSolveButton = new TransparentImageButton(act, icon, width,LinearLayout.LayoutParams.MATCH_PARENT);
405
    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);
406
    mSolveButton = new TransparentImageButton(act, icon, LinearLayout.LayoutParams.MATCH_PARENT, TransparentImageButton.GRAVITY_END);
405 407

  
406 408
    mSolveButton.setOnClickListener( new View.OnClickListener()
407 409
      {
......
414 416
      });
415 417
    }
416 418

  
419
///////////////////////////////////////////////////////////////////////////////////////////////////
420

  
421
  private void setupScrambleButton(final RubikActivity act)
422
    {
423
    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);
424
    mScrambleButton = new TransparentImageButton(act, icon, LinearLayout.LayoutParams.MATCH_PARENT, TransparentImageButton.GRAVITY_START);
425

  
426
    mScrambleButton.setOnClickListener( new View.OnClickListener()
427
      {
428
      @Override
429
      public void onClick(View v)
430
        {
431
        RubikScreenPlay play = (RubikScreenPlay) ScreenList.PLAY.getScreenClass();
432
        int numScrambles = play.getObject().getNumScramble();
433
        mShouldReactToEndOfScrambling = false;
434
        act.getControl().scrambleObject(numScrambles);
435
        }
436
      });
437
    }
438

  
417 439
///////////////////////////////////////////////////////////////////////////////////////////////////
418 440

  
419 441
  public void savePreferences(SharedPreferences.Editor editor)
......
590 612
            {
591 613
            if( mPlayPopup!=null ) mPlayPopup.dismiss();
592 614
            mLevelValue = level;
615
            mShouldReactToEndOfScrambling = true;
593 616
            control.scrambleObject(scrambles);
594 617
            }
595 618
          }
......
633 656
    return mLevelValue;
634 657
    }
635 658

  
659
///////////////////////////////////////////////////////////////////////////////////////////////////
660

  
661
  public boolean shouldReactToEndOfScrambling()
662
    {
663
    return mShouldReactToEndOfScrambling;
664
    }
665

  
636 666
///////////////////////////////////////////////////////////////////////////////////////////////////
637 667

  
638 668
  public ObjectType getObject()

Also available in: Unified diff