Project

General

Profile

Download (22.1 KB) Statistics
| Branch: | Tag: | Revision:

magiccube / src / main / java / org / distorted / screens / RubikScreenPlay.java @ 3f7a4363

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2020 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// Magic Cube is free software: you can redistribute it and/or modify                            //
7
// it under the terms of the GNU General Public License as published by                          //
8
// the Free Software Foundation, either version 2 of the License, or                             //
9
// (at your option) any later version.                                                           //
10
//                                                                                               //
11
// Magic Cube is distributed in the hope that it will be useful,                                 //
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
14
// GNU General Public License for more details.                                                  //
15
//                                                                                               //
16
// You should have received a copy of the GNU General Public License                             //
17
// along with Magic Cube.  If not, see <http://www.gnu.org/licenses/>.                           //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19

    
20
package org.distorted.screens;
21

    
22
import android.content.Context;
23
import android.content.SharedPreferences;
24
import android.graphics.drawable.BitmapDrawable;
25
import android.os.Build;
26
import android.os.Bundle;
27
import android.util.TypedValue;
28
import android.view.Gravity;
29
import android.view.LayoutInflater;
30
import android.view.View;
31
import android.widget.Button;
32
import android.widget.GridLayout;
33
import android.widget.ImageButton;
34
import android.widget.LinearLayout;
35
import android.widget.PopupWindow;
36
import android.widget.ScrollView;
37

    
38
import org.distorted.objectlib.main.ObjectList;
39

    
40
import org.distorted.main.R;
41
import org.distorted.main.RubikActivity;
42
import org.distorted.main.RubikPreRender;
43
import org.distorted.dialogs.RubikDialogAbout;
44
import org.distorted.dialogs.RubikDialogPattern;
45
import org.distorted.dialogs.RubikDialogScores;
46
import org.distorted.dialogs.RubikDialogTutorial;
47
import org.distorted.helpers.TransparentButton;
48
import org.distorted.helpers.TransparentImageButton;
49
import org.distorted.network.RubikScores;
50

    
51
///////////////////////////////////////////////////////////////////////////////////////////////////
52

    
53
public class RubikScreenPlay extends RubikScreenBase
54
  {
55
  public static final int LEVELS_SHOWN = 10;
56
  public static final int DEF_OBJECT= ObjectList.CUBE.ordinal();
57
  public static final int DEF_SIZE  =  3;
58

    
59
  private static final int[] BUTTON_LABELS = { R.string.scores,
60
                                               R.string.patterns,
61
                                            //   R.string.control,
62
                                               R.string.solver,
63
                                               R.string.tutorials,
64
                                               R.string.about };
65

    
66
  private static final int NUM_BUTTONS = BUTTON_LABELS.length;
67
  private static final float LAST_BUTTON = 1.5f;
68
  private static final int[] mLocation = new int[2];
69

    
70
  private ImageButton mObjButton, mMenuButton, mSolveButton;
71
  private Button mPlayButton;
72
  private PopupWindow mObjectPopup, mMenuPopup, mPlayPopup;
73
  private int mObject = DEF_OBJECT;
74
  private int mSize   = DEF_SIZE;
75
  private int mObjectSize, mMenuLayoutWidth, mMenuLayoutHeight, mPlayLayoutWidth;
76
  private int mLevelValue;
77
  private float mButtonSize, mMenuItemSize, mMenuTextSize;
78
  private int mColCount, mRowCount, mMaxRowCount;
79
  private LinearLayout mPlayLayout;
80
  private int mUpperBarHeight;
81

    
82
  private boolean mIsFullScreen;
83

    
84
///////////////////////////////////////////////////////////////////////////////////////////////////
85

    
86
  void leaveScreen(RubikActivity act)
87
    {
88

    
89
    }
90

    
91
///////////////////////////////////////////////////////////////////////////////////////////////////
92

    
93
  void enterScreen(final RubikActivity act)
94
    {
95
    float width = act.getScreenWidthInPixels();
96
    float height= act.getScreenHeightInPixels();
97
    mUpperBarHeight = act.getHeightUpperBar();
98

    
99
    mMenuTextSize = width*RubikActivity.MENU_MED_TEXT_SIZE;
100
    mButtonSize   = width*RubikActivity.BUTTON_TEXT_SIZE;
101
    mMenuItemSize = width*RubikActivity.MENU_ITEM_SIZE;
102

    
103
    mRowCount = ObjectList.getRowCount();
104
    mColCount = ObjectList.getColumnCount();
105

    
106
    // TOP ////////////////////////////
107
    LinearLayout layoutTop = act.findViewById(R.id.upperBar);
108
    layoutTop.removeAllViews();
109

    
110
    setupObjectWindow(act,width,height);
111
    setupObjectButton(act,width);
112
    layoutTop.addView(mObjButton);
113

    
114
    setupMenuWindow(act,width);
115
    setupMenuButton(act,width);
116
    layoutTop.addView(mMenuButton);
117

    
118
    setupPlayWindow(act,width);
119
    setupPlayButton(act,width,height);
120
    layoutTop.addView(mPlayButton);
121

    
122
    setupSolveButton(act,width);
123
    createBottomPane(act,width,mSolveButton);
124
    }
125

    
126
///////////////////////////////////////////////////////////////////////////////////////////////////
127

    
128
  private void setupObjectButton(final RubikActivity act, final float width)
129
    {
130
    final int margin  = (int)(width*RubikActivity.MARGIN);
131
    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);
132

    
133
    mObjButton = new TransparentImageButton(act, icon, width,LinearLayout.LayoutParams.MATCH_PARENT);
134

    
135
    mObjButton.setOnClickListener( new View.OnClickListener()
136
      {
137
      @Override
138
      public void onClick(View view)
139
        {
140
        if( mObjectPopup!=null && act.getPreRender().isUINotBlocked())
141
          {
142
          int rowCount = Math.min(mMaxRowCount,mRowCount);
143
          View popupView = mObjectPopup.getContentView();
144
          popupView.setSystemUiVisibility(RubikActivity.FLAGS);
145
          displayPopup(act,view,mObjectPopup,mObjectSize*mColCount,mObjectSize*rowCount,margin,margin);
146
          }
147
        }
148
      });
149
    }
150

    
151
///////////////////////////////////////////////////////////////////////////////////////////////////
152

    
153
  private void setupPlayButton(final RubikActivity act, final float width, final float height)
154
    {
155
    final int margin   = (int)(width*RubikActivity.MARGIN);
156
    final int maxHeight= (int)(0.9f*(height-mUpperBarHeight) );
157

    
158
    mPlayButton = new TransparentButton(act, R.string.play, mButtonSize, width);
159

    
160
    mPlayButton.setOnClickListener( new View.OnClickListener()
161
      {
162
      @Override
163
      public void onClick(View view)
164
        {
165
        if( mPlayPopup!=null && act.getPreRender().isUINotBlocked())
166
          {
167
          View popupView = mPlayPopup.getContentView();
168
          popupView.setSystemUiVisibility(RubikActivity.FLAGS);
169
          final int sizeIndex = ObjectList.getSizeIndex(mObject,mSize);
170
          final int dbLevel = ObjectList.getDBLevel(mObject, sizeIndex);
171
          final int levelsShown = Math.min(dbLevel,LEVELS_SHOWN);
172
          final int popupHeight = (int)(levelsShown*(mMenuItemSize+margin)+3*margin+mMenuItemSize*(LAST_BUTTON-1.0f));
173
          final int realHeight = Math.min(popupHeight,maxHeight);
174
          displayPopup(act,view,mPlayPopup,mPlayLayoutWidth,realHeight,margin,margin);
175
          }
176
        }
177
      });
178
    }
179

    
180
///////////////////////////////////////////////////////////////////////////////////////////////////
181

    
182
  private void setupMenuButton(final RubikActivity act, final float width)
183
    {
184
    final int margin  = (int)(width*RubikActivity.MARGIN);
185
    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);
186

    
187
    mMenuButton = new TransparentImageButton(act, icon, width,LinearLayout.LayoutParams.MATCH_PARENT);
188

    
189
    mMenuButton.setOnClickListener( new View.OnClickListener()
190
      {
191
      @Override
192
      public void onClick(View view)
193
        {
194
        if( mMenuPopup!=null && act.getPreRender().isUINotBlocked())
195
          {
196
          View popupView = mMenuPopup.getContentView();
197
          popupView.setSystemUiVisibility(RubikActivity.FLAGS);
198
          displayPopup(act,view,mMenuPopup,mMenuLayoutWidth,mMenuLayoutHeight,(int)(-width/12),margin);
199
          }
200
        }
201
      });
202
    }
203

    
204
///////////////////////////////////////////////////////////////////////////////////////////////////
205

    
206
  private void setupObjectWindow(final RubikActivity act, final float width, final float height)
207
    {
208
    int icon = RubikActivity.getDrawable(R.drawable.ui_small_cube2,R.drawable.ui_medium_cube2, R.drawable.ui_big_cube2, R.drawable.ui_huge_cube2);
209

    
210
    BitmapDrawable bd = (BitmapDrawable) act.getResources().getDrawable(icon);
211
    int cubeWidth = bd.getIntrinsicWidth();
212
    int margin = (int)(width*RubikActivity.LARGE_MARGIN);
213
    mObjectSize = (int)(cubeWidth + 2*margin + 0.5f);
214
    mMaxRowCount = (int)(0.9f*(height-mUpperBarHeight)/mObjectSize);
215
    GridLayout objectGrid = new GridLayout(act);
216
    mObjectPopup = new PopupWindow(act);
217
    mObjectPopup.setFocusable(true);
218

    
219
    if( mMaxRowCount<mRowCount )
220
      {
221
      ScrollView scrollView = new ScrollView(act);
222
      scrollView.addView(objectGrid);
223
      mObjectPopup.setContentView(scrollView);
224
      }
225
    else
226
      {
227
      mObjectPopup.setContentView(objectGrid);
228
      }
229

    
230
    int[] indices = ObjectList.getIndices();
231

    
232
    GridLayout.Spec[] rowSpecs = new GridLayout.Spec[mRowCount];
233
    GridLayout.Spec[] colSpecs = new GridLayout.Spec[mColCount];
234

    
235
    objectGrid.setColumnCount(mColCount);
236
    objectGrid.setRowCount(mRowCount);
237

    
238
    int[] nextInRow = new int[mRowCount];
239

    
240
    for(int row=0; row<mRowCount; row++)
241
      {
242
      rowSpecs[row] = GridLayout.spec(row);
243
      nextInRow[row]= 0;
244
      }
245
    for(int col=0; col<mColCount; col++)
246
      {
247
      colSpecs[col] = GridLayout.spec(col);
248
      }
249

    
250
    for(int object=0; object< ObjectList.NUM_OBJECTS; object++)
251
      {
252
      final ObjectList list = ObjectList.getObject(object);
253
      final int[] sizes = list.getSizes();
254
      int iconSize = RubikActivity.getDrawableSize();
255
      int[] icons = list.getIconIDs(iconSize);
256
      int len = sizes.length;
257
      final int obj = object;
258
      int row = indices[object];
259

    
260
      for(int i=0; i<len; i++)
261
        {
262
        final int index = i;
263

    
264
        ImageButton button = new ImageButton(act);
265
        button.setBackgroundResource(icons[i]);
266
        button.setOnClickListener( new View.OnClickListener()
267
          {
268
          @Override
269
          public void onClick(View v)
270
            {
271
            if( act.getPreRender().isUINotBlocked() && ScreenList.getCurrentScreen()== ScreenList.PLAY )
272
              {
273
              mObject = obj;
274
              mSize   = sizes[index];
275
              act.changeObject(list,sizes[index], true);
276
              adjustLevels(act);
277
              mController.clearMoves(act);
278
              }
279

    
280
            mObjectPopup.dismiss();
281
            }
282
          });
283

    
284
        GridLayout.LayoutParams params = new GridLayout.LayoutParams(rowSpecs[row],colSpecs[nextInRow[row]]);
285
        params.bottomMargin = margin;
286
        params.topMargin    = margin;
287
        params.leftMargin   = margin;
288
        params.rightMargin  = margin;
289

    
290
        nextInRow[row]++;
291

    
292
        objectGrid.addView(button, params);
293
        }
294
      }
295
    }
296

    
297
///////////////////////////////////////////////////////////////////////////////////////////////////
298

    
299
  private void setupMenuWindow(final RubikActivity act, final float width)
300
    {
301
    LayoutInflater layoutInflater = (LayoutInflater)act.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
302
    final View layout = layoutInflater.inflate(R.layout.popup_menu, null);
303
    LinearLayout menuLayout = layout.findViewById(R.id.menuGrid);
304

    
305
    mMenuPopup = new PopupWindow(act);
306
    mMenuPopup.setContentView(layout);
307
    mMenuPopup.setFocusable(true);
308
    int margin  = (int)(width*RubikActivity.MARGIN);
309
    int padding = (int)(width*RubikActivity.PADDING);
310

    
311
    mMenuLayoutWidth = (int)(width/2);
312
    mMenuLayoutHeight= (int)(2*margin + NUM_BUTTONS*(mMenuItemSize+margin));
313

    
314
    LinearLayout.LayoutParams p = new LinearLayout.LayoutParams( mMenuLayoutWidth - 2*padding, (int)mMenuItemSize);
315

    
316
    for(int i=0; i<NUM_BUTTONS; i++)
317
      {
318
      final int but = i;
319
      Button button = new Button(act);
320
      button.setLayoutParams(p);
321
      button.setText(BUTTON_LABELS[i]);
322
      button.setTextSize(TypedValue.COMPLEX_UNIT_PX, mMenuTextSize);
323

    
324
      button.setOnClickListener( new View.OnClickListener()
325
        {
326
        @Override
327
        public void onClick(View v)
328
          {
329
          mMenuPopup.dismiss();
330
          MenuAction(act,but);
331
          }
332
        });
333

    
334
      menuLayout.addView(button);
335
      }
336
    }
337

    
338
///////////////////////////////////////////////////////////////////////////////////////////////////
339

    
340
  private void setupPlayWindow(final RubikActivity act, final float width)
341
    {
342
    LayoutInflater layoutInflater = (LayoutInflater)act.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
343
    final View layout = layoutInflater.inflate(R.layout.popup_play, null);
344
    mPlayLayout = layout.findViewById(R.id.playGrid);
345

    
346
    mPlayLayoutWidth = (int)(width*0.4f);
347

    
348
    mPlayPopup = new PopupWindow(act);
349
    mPlayPopup.setContentView(layout);
350
    mPlayPopup.setFocusable(true);
351

    
352
    adjustLevels(act);
353
    }
354

    
355
///////////////////////////////////////////////////////////////////////////////////////////////////
356

    
357
  private void MenuAction(RubikActivity act, int button)
358
    {
359
    switch(button)
360
      {
361
      case 0: RubikScreenPlay play = (RubikScreenPlay) ScreenList.PLAY.getScreenClass();
362
              int object = play.getObject();
363
              int size   = play.getSize();
364
              int sizeIndex = ObjectList.getSizeIndex(object,size);
365
              Bundle sBundle = new Bundle();
366
              sBundle.putInt("tab", ObjectList.pack(object,sizeIndex) );
367
              sBundle.putBoolean("submitting", false);
368
              RubikDialogScores scores = new RubikDialogScores();
369
              scores.setArguments(sBundle);
370
              scores.show(act.getSupportFragmentManager(), null);
371
              break;
372
      case 1: RubikDialogPattern pDiag = new RubikDialogPattern();
373
              Bundle pBundle = new Bundle();
374
              int pOrd = getPatternOrdinal();
375
              pBundle.putInt("tab", pOrd );
376
              pDiag.setArguments(pBundle);
377
              pDiag.show( act.getSupportFragmentManager(), RubikDialogPattern.getDialogTag() );
378
              break;
379
/*
380
      case 2: RubikControl control = RubikControl.getInstance();
381
              //control.animateAll(act);
382
              control.animateRotate(act);
383
              break;
384
 */
385
      case 2: ScreenList.switchScreen(act, ScreenList.SVER);
386
              break;
387
      case 3: RubikDialogTutorial tDiag = new RubikDialogTutorial();
388
              Bundle tBundle = new Bundle();
389
              int tOrd = getTutorialOrdinal();
390
              tBundle.putInt("tab", tOrd );
391
              tDiag.setArguments(tBundle);
392
              tDiag.show( act.getSupportFragmentManager(), RubikDialogTutorial.getDialogTag() );
393
              break;
394
      case 4: RubikDialogAbout aDiag = new RubikDialogAbout();
395
              aDiag.show(act.getSupportFragmentManager(), null);
396
              break;
397
      }
398
    }
399

    
400
///////////////////////////////////////////////////////////////////////////////////////////////////
401

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

    
407
    mSolveButton.setOnClickListener( new View.OnClickListener()
408
      {
409
      @Override
410
      public void onClick(View v)
411
        {
412
        act.getPreRender().solveObject();
413
        mController.clearMoves(act);
414
        }
415
      });
416
    }
417

    
418
///////////////////////////////////////////////////////////////////////////////////////////////////
419

    
420
  public void savePreferences(SharedPreferences.Editor editor)
421
    {
422
    editor.putInt("statePlay_object", mObject);
423
    editor.putInt("statePlay_size"  , mSize);
424

    
425
    if( mObjectPopup!=null )
426
      {
427
      mObjectPopup.dismiss();
428
      mObjectPopup = null;
429
      }
430

    
431
    if( mMenuPopup!=null )
432
      {
433
      mMenuPopup.dismiss();
434
      mMenuPopup = null;
435
      }
436

    
437
    if( mPlayPopup!=null )
438
      {
439
      mPlayPopup.dismiss();
440
      mPlayPopup = null;
441
      }
442
    }
443

    
444
///////////////////////////////////////////////////////////////////////////////////////////////////
445

    
446
  public void restorePreferences(SharedPreferences preferences)
447
    {
448
    mObject= preferences.getInt("statePlay_object", DEF_OBJECT);
449
    mSize  = preferences.getInt("statePlay_size"  , DEF_SIZE  );
450

    
451
    int sizeIndex = ObjectList.getSizeIndex(mObject,mSize);
452
    int dbLevel = ObjectList.getDBLevel(mObject, sizeIndex);
453

    
454
    // This means the app has been upgraded to a new version which swapped the
455
    // Object for a new one with larger sizeIndex and now getMaxLevel() returns
456
    // 0. Reset the object to default, otherwise we'll get a crash later on.
457

    
458
    if( dbLevel==0 )
459
      {
460
      mObject = DEF_OBJECT;
461
      mSize   = DEF_SIZE;
462
      }
463
    }
464

    
465
///////////////////////////////////////////////////////////////////////////////////////////////////
466

    
467
  public boolean setObjectAndSize(RubikActivity act, ObjectList obj, int size)
468
    {
469
    if( mObject!=obj.ordinal() || mSize != size )
470
      {
471
      boolean success = false;
472

    
473
      for( int s: obj.getSizes() )
474
        if( s==size )
475
          {
476
          success = true;
477
          break;
478
          }
479

    
480
      if( success )
481
        {
482
        mObject = obj.ordinal();
483
        mSize   = size;
484

    
485
        if( mPlayLayout!=null ) adjustLevels(act);
486
        }
487

    
488
      return success;
489
      }
490

    
491
    return true;
492
    }
493

    
494
///////////////////////////////////////////////////////////////////////////////////////////////////
495
// work around lame bugs in Android's version <= 10 pop-up and split-screen modes
496

    
497
  private void displayPopup(RubikActivity act, View view, PopupWindow window, int w, int h, int xoff, int yoff)
498
    {
499
    View topLayout = act.findViewById(R.id.relativeLayout);
500

    
501
    if( topLayout!=null )
502
      {
503
      topLayout.getLocationOnScreen(mLocation);
504
      mIsFullScreen = (mLocation[1]==0);
505
      }
506
    else
507
      {
508
      mIsFullScreen = true;
509
      }
510

    
511
    // if on Android 11 or we are fullscreen
512
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R || mIsFullScreen )
513
      {
514
      window.showAsDropDown(view, xoff, yoff, Gravity.CENTER);
515
      window.update(view, w, h);
516
      }
517
    else  // Android 10 or below in pop-up mode or split-screen mode
518
      {
519
      view.getLocationOnScreen(mLocation);
520
      int width  = view.getWidth();
521
      int height = view.getHeight();
522
      int x = mLocation[0]+(width-w)/2;
523
      int y = mLocation[1]+height+yoff;
524

    
525
      window.showAsDropDown(view);
526
      window.update(x,y,w,h);
527
      }
528
    }
529

    
530
///////////////////////////////////////////////////////////////////////////////////////////////////
531

    
532
  private void adjustLevels(final RubikActivity act)
533
    {
534
    int sizeIndex = ObjectList.getSizeIndex(mObject,mSize);
535
    int dbLevel = ObjectList.getDBLevel(mObject, sizeIndex);
536
    int numScrambles = ObjectList.getNumScramble(mObject, sizeIndex);
537
    int numLevel = Math.min(dbLevel, LEVELS_SHOWN);
538
    String[] levels = new String[numLevel];
539

    
540
    for(int i=0; i<numLevel-1; i++)
541
      {
542
      levels[i] = act.getString(R.string.lv_placeholder,i+1);
543
      }
544

    
545
    if( numLevel>0 )
546
      {
547
      levels[numLevel-1] = act.getString(R.string.level_full);
548
      }
549

    
550
    if( mLevelValue>dbLevel || mLevelValue<1 ||
551
       (mLevelValue<dbLevel || mLevelValue>LEVELS_SHOWN ) )
552
      {
553
      mLevelValue=1;
554
      }
555

    
556
    float width  = act.getScreenWidthInPixels();
557
    int margin   = (int)(width*RubikActivity.MARGIN);
558
    int padding  = (int)(width*RubikActivity.PADDING);
559
    int butWidth = mPlayLayoutWidth - 2*padding;
560
    int butHeight= (int)mMenuItemSize;
561
    int lastButH = (int)(mMenuItemSize*LAST_BUTTON) ;
562

    
563
    LinearLayout.LayoutParams pM = new LinearLayout.LayoutParams( butWidth, butHeight );
564
    pM.setMargins(margin, 0, margin, margin);
565
    LinearLayout.LayoutParams pT = new LinearLayout.LayoutParams( butWidth, butHeight );
566
    pT.setMargins(margin, margin, margin, margin);
567
    LinearLayout.LayoutParams pB = new LinearLayout.LayoutParams( butWidth, lastButH  );
568
    pB.setMargins(margin, margin, margin, 2*margin);
569

    
570
    mPlayLayout.removeAllViews();
571

    
572
    RubikScores scores = RubikScores.getInstance();
573

    
574
    for(int i=0; i<numLevel; i++)
575
      {
576
      final int level     = i<numLevel-1 ? i+1 : dbLevel;
577
      final int scrambles = i<numLevel-1 ? i+1 : numScrambles;
578
      Button button = new Button(act);
579
      button.setLayoutParams(i==0 ? pT : (i==numLevel-1 ? pB : pM));
580
      button.setText(levels[i]);
581
      button.setTextSize(TypedValue.COMPLEX_UNIT_PX, mMenuTextSize);
582

    
583
      int icon = scores.isSolved(mObject, sizeIndex, level-1) ? R.drawable.ui_solved : R.drawable.ui_notsolved;
584
      button.setCompoundDrawablesWithIntrinsicBounds(icon,0,0,0);
585

    
586
      button.setOnClickListener( new View.OnClickListener()
587
        {
588
        @Override
589
        public void onClick(View v)
590
          {
591
          RubikPreRender pre = act.getPreRender();
592

    
593
          if(pre.isUINotBlocked())
594
            {
595
            if( mPlayPopup!=null ) mPlayPopup.dismiss();
596
            mLevelValue = level;
597
            pre.scrambleObject(scrambles);
598
            }
599
          }
600
        });
601

    
602
      mPlayLayout.addView(button);
603
      }
604
    }
605

    
606
///////////////////////////////////////////////////////////////////////////////////////////////////
607

    
608
  public int getLevel()
609
    {
610
    return mLevelValue;
611
    }
612

    
613
///////////////////////////////////////////////////////////////////////////////////////////////////
614

    
615
  public int getObject()
616
    {
617
    return mObject;
618
    }
619

    
620
///////////////////////////////////////////////////////////////////////////////////////////////////
621

    
622
  public int getSize()
623
    {
624
    return mSize;
625
    }
626
  }
(5-5/10)