Project

General

Profile

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

magiccube / src / main / java / org / distorted / main / RubikActivity.java @ 588ace55

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2019 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.main;
21

    
22
import android.content.Intent;
23
import android.content.SharedPreferences;
24
import android.content.res.Resources;
25
import android.os.Build;
26
import android.os.Bundle;
27
import android.os.LocaleList;
28
import android.preference.PreferenceManager;
29

    
30
import android.util.DisplayMetrics;
31
import android.view.DisplayCutout;
32
import android.view.View;
33
import android.view.ViewGroup;
34
import android.view.WindowManager;
35
import android.widget.LinearLayout;
36

    
37
import com.google.firebase.analytics.FirebaseAnalytics;
38

    
39
import org.distorted.dialogs.RubikDialogError;
40
import org.distorted.dialogs.RubikDialogPrivacy;
41
import org.distorted.effects.BaseEffect;
42
import org.distorted.helpers.BlockController;
43
import org.distorted.helpers.TwistyActivity;
44
import org.distorted.helpers.TwistyPreRender;
45
import org.distorted.library.main.DistortedEffects;
46
import org.distorted.library.main.DistortedLibrary;
47

    
48
import org.distorted.library.main.DistortedScreen;
49
import org.distorted.library.main.DistortedTexture;
50
import org.distorted.library.mesh.MeshSquare;
51
import org.distorted.library.type.Static4D;
52
import org.distorted.objectlib.TwistyObject;
53
import org.distorted.network.RubikScores;
54
import org.distorted.network.RubikNetwork;
55
import org.distorted.objectlib.ObjectList;
56
import org.distorted.objects.TwistyBandaged2Bar;
57
import org.distorted.objects.TwistyBandaged3Plate;
58
import org.distorted.objects.TwistyBandagedEvil;
59
import org.distorted.objects.TwistyBandagedFused;
60
import org.distorted.objects.TwistyCube;
61
import org.distorted.objects.TwistyDiamond;
62
import org.distorted.objects.TwistyDino4;
63
import org.distorted.objects.TwistyDino6;
64
import org.distorted.objects.TwistyHelicopter;
65
import org.distorted.objects.TwistyIvy;
66
import org.distorted.objects.TwistyJing;
67
import org.distorted.objects.TwistyKilominx;
68
import org.distorted.objects.TwistyMegaminx;
69
import org.distorted.objects.TwistyMirror;
70
import org.distorted.objects.TwistyPyraminx;
71
import org.distorted.objects.TwistyRedi;
72
import org.distorted.objects.TwistyRex;
73
import org.distorted.objects.TwistySkewb;
74
import org.distorted.objects.TwistySquare1;
75
import org.distorted.objects.TwistySquare2;
76
import org.distorted.objects.TwistyUltimate;
77
import org.distorted.screens.ScreenList;
78
import org.distorted.screens.RubikScreenPlay;
79
import org.distorted.tutorials.TutorialActivity;
80

    
81
import java.util.Locale;
82

    
83
///////////////////////////////////////////////////////////////////////////////////////////////////
84

    
85
public class RubikActivity extends TwistyActivity
86
{
87
    public static final float PADDING             = 0.01f;
88
    public static final float MARGIN              = 0.004f;
89
    public static final float LARGE_MARGIN        = 0.025f;
90
    public static final float BUTTON_TEXT_SIZE    = 0.05f;
91
    public static final float TITLE_TEXT_SIZE     = 0.06f;
92
    public static final float SOLVER_BMP_H_SIZE   = 0.11f;
93
    public static final float SOLVER_BMP_V_SIZE   = 0.06f;
94
    public static final float MENU_ITEM_SIZE      = 0.11f;
95
    public static final float PATTERN_GROUP_TEXT  = 0.03f;
96
    public static final float PATTERN_CHILD_TEXT  = 0.02f;
97
    public static final float SCORES_LEVEL_TEXT   = 0.035f;
98
    public static final float SCORES_ITEM_TEXT    = 0.030f;
99
    public static final float TUTORIAL_ITEM_TEXT  = 0.100f;
100
    public static final float DIALOG_BUTTON_SIZE  = 0.06f;
101
    public static final float MENU_BIG_TEXT_SIZE  = 0.05f;
102
    public static final float MENU_MED_TEXT_SIZE  = 0.04f;
103
    public static final float MENU_SMALL_TEXT_SIZE= 0.035f;
104

    
105
    public static final int FLAGS =  View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
106
                                   | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
107
                                   | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
108
                                   | View.SYSTEM_UI_FLAG_FULLSCREEN
109
                                   | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
110

    
111
    public static final int FLAGS2=  View.SYSTEM_UI_FLAG_LAYOUT_STABLE
112
                                   | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
113

    
114
    private static final float RATIO_BAR  = 0.10f;
115
    private static final float RATIO_INSET= 0.08f;
116

    
117
    private boolean mJustStarted;
118
    private FirebaseAnalytics mFirebaseAnalytics;
119
    private static int mScreenWidth, mScreenHeight;
120
    private boolean mPolicyAccepted, mIsChinese;
121
    private int mCurrentApiVersion;
122
    private int mHeightUpperBar, mHeightLowerBar;
123

    
124
///////////////////////////////////////////////////////////////////////////////////////////////////
125

    
126
    @Override
127
    protected void onCreate(Bundle savedState)
128
      {
129
      super.onCreate(savedState);
130
      DistortedLibrary.onCreate(0);
131

    
132
      setTheme(R.style.CustomActivityThemeNoActionBar);
133
      setContentView(R.layout.main);
134

    
135
      mJustStarted = true;
136
      mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);
137

    
138
      DisplayMetrics displaymetrics = new DisplayMetrics();
139
      getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
140
      mScreenWidth =displaymetrics.widthPixels;
141
      mScreenHeight=displaymetrics.heightPixels;
142

    
143
      mIsChinese = localeIsChinese();
144
      unlock();
145

    
146
      hideNavigationBar();
147
      cutoutHack();
148
      computeBarHeights();
149
      // askForPermissions();
150
      }
151

    
152
///////////////////////////////////////////////////////////////////////////////////////////////////
153
// this does not include possible insets
154

    
155
    private void computeBarHeights()
156
      {
157
      float height = getScreenHeightInPixels();
158
      int barHeight = (int)(height*RATIO_BAR);
159
      mHeightLowerBar = barHeight;
160
      mHeightUpperBar = barHeight;
161

    
162
      LinearLayout layoutTop = findViewById(R.id.upperBar);
163
      LinearLayout layoutBot = findViewById(R.id.lowerBar);
164

    
165
      ViewGroup.LayoutParams paramsTop = layoutTop.getLayoutParams();
166
      paramsTop.height = mHeightUpperBar;
167
      layoutTop.setLayoutParams(paramsTop);
168
      ViewGroup.LayoutParams paramsBot = layoutBot.getLayoutParams();
169
      paramsBot.height = mHeightLowerBar;
170
      layoutBot.setLayoutParams(paramsBot);
171
      }
172

    
173
///////////////////////////////////////////////////////////////////////////////////////////////////
174

    
175
    private void hideNavigationBar()
176
      {
177
      mCurrentApiVersion = Build.VERSION.SDK_INT;
178

    
179
      if(mCurrentApiVersion >= Build.VERSION_CODES.KITKAT)
180
        {
181
        final View decorView = getWindow().getDecorView();
182

    
183
        decorView.setSystemUiVisibility(FLAGS);
184

    
185
        decorView.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener()
186
          {
187
          @Override
188
          public void onSystemUiVisibilityChange(int visibility)
189
            {
190
            if((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0)
191
              {
192
              decorView.setSystemUiVisibility(FLAGS);
193
              }
194
            }
195
          });
196
        }
197
      }
198

    
199
///////////////////////////////////////////////////////////////////////////////////////////////////
200

    
201
    @Override
202
    public void onAttachedToWindow()
203
      {
204
      super.onAttachedToWindow();
205

    
206
      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P)
207
        {
208
        DisplayCutout cutout = getWindow().getDecorView().getRootWindowInsets().getDisplayCutout();
209
        int insetHeight = cutout!=null ? cutout.getSafeInsetTop() : 0;
210

    
211
        LinearLayout layoutHid = findViewById(R.id.hiddenBar);
212
        ViewGroup.LayoutParams paramsHid = layoutHid.getLayoutParams();
213
        paramsHid.height = (int)(insetHeight*RATIO_INSET);
214
        layoutHid.setLayoutParams(paramsHid);
215
        mHeightUpperBar += paramsHid.height;
216
        }
217
      }
218

    
219
///////////////////////////////////////////////////////////////////////////////////////////////////
220
// do not avoid cutouts
221

    
222
    private void cutoutHack()
223
      {
224
      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P)
225
        {
226
        getWindow().getAttributes().layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
227
        }
228
      }
229

    
230
///////////////////////////////////////////////////////////////////////////////////////////////////
231

    
232
    @Override
233
    public void onWindowFocusChanged(boolean hasFocus)
234
      {
235
      super.onWindowFocusChanged(hasFocus);
236

    
237
      if(mCurrentApiVersion >= Build.VERSION_CODES.KITKAT && hasFocus)
238
        {
239
        getWindow().getDecorView().setSystemUiVisibility(FLAGS);
240
        }
241
      }
242

    
243
///////////////////////////////////////////////////////////////////////////////////////////////////
244

    
245
    private void askForPermissions()
246
      {
247
      final int REQUEST_EXTERNAL_STORAGE = 1;
248

    
249
      String[] PERMISSIONS_STORAGE =
250
        {
251
        android.Manifest.permission.READ_EXTERNAL_STORAGE,
252
        android.Manifest.permission.WRITE_EXTERNAL_STORAGE
253
        };
254

    
255
      int permission = androidx.core.app.ActivityCompat.checkSelfPermission(this, android.Manifest.permission.WRITE_EXTERNAL_STORAGE);
256

    
257
      if (permission != android.content.pm.PackageManager.PERMISSION_GRANTED)
258
        {
259
        androidx.core.app.ActivityCompat.requestPermissions( this, PERMISSIONS_STORAGE, REQUEST_EXTERNAL_STORAGE );
260
        }
261
      }
262

    
263
///////////////////////////////////////////////////////////////////////////////////////////////////
264
    
265
    @Override
266
    protected void onPause() 
267
      {
268
      super.onPause();
269
      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
270
      view.onPause();
271
      DistortedLibrary.onPause(0);
272
      BlockController.onPause();
273
      RubikNetwork.onPause();
274
      savePreferences();
275
      }
276

    
277
///////////////////////////////////////////////////////////////////////////////////////////////////
278
    
279
    @Override
280
    protected void onResume() 
281
      {
282
      super.onResume();
283
      DistortedLibrary.onResume(0);
284
      BlockController.onResume();
285
      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
286
      view.onResume();
287
      view.initialize();
288
      restorePreferences();
289
      ScreenList.setScreen(this);
290
      unblockEverything();
291

    
292
      if( mJustStarted )
293
        {
294
        mJustStarted = false;
295
        RubikScores scores = RubikScores.getInstance();
296
        scores.incrementNumRuns();
297
        scores.setCountry(this);
298
        }
299

    
300
      boolean success = false;
301
      RubikScreenPlay play = (RubikScreenPlay) ScreenList.PLAY.getScreenClass();
302
      int object = play.getObject();
303
      int size   = play.getSize();
304

    
305
      if( object>=0 && object< ObjectList.NUM_OBJECTS )
306
        {
307
        ObjectList obj = ObjectList.getObject(object);
308
        int[] sizes = obj.getSizes();
309
        int sizeIndex = ObjectList.getSizeIndex(object,size);
310

    
311
        if( sizeIndex>=0 && sizeIndex<sizes.length )
312
          {
313
          success = true;
314
          view.getPreRender().changeObject(obj,size);
315
          }
316
        }
317

    
318
      if( !success )
319
        {
320
        ObjectList obj = ObjectList.getObject(RubikScreenPlay.DEF_OBJECT);
321
        int s = RubikScreenPlay.DEF_SIZE;
322

    
323
        play.setObjectAndSize(this,obj,s);
324
        view.getPreRender().changeObject(obj,s);
325
        }
326

    
327
      if( mIsChinese && !mPolicyAccepted ) PrivacyPolicy();
328
      }
329
    
330
///////////////////////////////////////////////////////////////////////////////////////////////////
331
    
332
    @Override
333
    protected void onDestroy() 
334
      {
335
      DistortedLibrary.onDestroy(0);
336
      super.onDestroy();
337
      }
338

    
339
///////////////////////////////////////////////////////////////////////////////////////////////////
340

    
341
    private void savePreferences()
342
      {
343
      SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
344
      SharedPreferences.Editor editor = preferences.edit();
345

    
346
      editor.putBoolean("policyAccepted", mPolicyAccepted);
347

    
348
      for (int i=0; i<BaseEffect.Type.LENGTH; i++)
349
        {
350
        BaseEffect.Type.getType(i).savePreferences(editor);
351
        }
352

    
353
      for (int i = 0; i< ScreenList.LENGTH; i++)
354
        {
355
        ScreenList.getScreen(i).getScreenClass().savePreferences(editor);
356
        }
357

    
358
      ScreenList.savePreferences(editor);
359
      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
360
      view.getPreRender().savePreferences(editor);
361

    
362
      editor.apply();
363
      }
364

    
365
///////////////////////////////////////////////////////////////////////////////////////////////////
366

    
367
    private void restorePreferences()
368
      {
369
      SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
370

    
371
      mPolicyAccepted = preferences.getBoolean("policyAccepted", false);
372

    
373
      for (int i=0; i< BaseEffect.Type.LENGTH; i++)
374
        {
375
        BaseEffect.Type.getType(i).restorePreferences(preferences);
376
        }
377

    
378
      for (int i = 0; i< ScreenList.LENGTH; i++)
379
        {
380
        ScreenList.getScreen(i).getScreenClass().restorePreferences(preferences);
381
        }
382

    
383
      ScreenList.restorePreferences(preferences);
384

    
385
      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
386
      view.getPreRender().restorePreferences(preferences);
387

    
388
      RubikScores scores = RubikScores.getInstance();
389

    
390
      if( scores.isVerified() )
391
        {
392
        FirebaseAnalytics analytics = getAnalytics();
393
        analytics.setUserId(scores.getName());
394
        }
395
      }
396

    
397
///////////////////////////////////////////////////////////////////////////////////////////////////
398

    
399
    private void PrivacyPolicy()
400
      {
401
      RubikDialogPrivacy priDiag = new RubikDialogPrivacy();
402
      priDiag.show(getSupportFragmentManager(), null);
403
      }
404

    
405
///////////////////////////////////////////////////////////////////////////////////////////////////
406

    
407
    void OpenGLError()
408
      {
409
      RubikDialogError errDiag = new RubikDialogError();
410
      errDiag.show(getSupportFragmentManager(), null);
411
      }
412

    
413
///////////////////////////////////////////////////////////////////////////////////////////////////
414
// PUBLIC API
415
///////////////////////////////////////////////////////////////////////////////////////////////////
416

    
417
    public FirebaseAnalytics getAnalytics()
418
      {
419
      return mFirebaseAnalytics;
420
      }
421

    
422
///////////////////////////////////////////////////////////////////////////////////////////////////
423

    
424
    public int getHeightUpperBar()
425
      {
426
      return mHeightUpperBar;
427
      }
428

    
429
///////////////////////////////////////////////////////////////////////////////////////////////////
430

    
431
    public int getHeightLowerBar()
432
      {
433
      return mHeightLowerBar;
434
      }
435

    
436
///////////////////////////////////////////////////////////////////////////////////////////////////
437

    
438
    public TwistyObject getObject()
439
      {
440
      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
441
      RubikPreRender pre = view.getPreRender();
442
      return pre.getObject();
443
      }
444

    
445
///////////////////////////////////////////////////////////////////////////////////////////////////
446

    
447
    public DistortedScreen getScreen()
448
      {
449
      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
450
      RubikRenderer renderer = view.getRenderer();
451
      return renderer.getScreen();
452
      }
453

    
454
///////////////////////////////////////////////////////////////////////////////////////////////////
455

    
456
    public RubikPreRender getPreRender()
457
      {
458
      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
459
      return view.getPreRender();
460
      }
461

    
462
///////////////////////////////////////////////////////////////////////////////////////////////////
463

    
464
    public TwistyPreRender getTwistyPreRender()
465
      {
466
      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
467
      return view.getPreRender();
468
      }
469

    
470
///////////////////////////////////////////////////////////////////////////////////////////////////
471

    
472
    public RubikSurfaceView getSurfaceView()
473
      {
474
      return findViewById(R.id.rubikSurfaceView);
475
      }
476

    
477
///////////////////////////////////////////////////////////////////////////////////////////////////
478

    
479
    public int getScreenWidthInPixels()
480
      {
481
      return mScreenWidth;
482
      }
483

    
484
///////////////////////////////////////////////////////////////////////////////////////////////////
485

    
486
    public int getScreenHeightInPixels()
487
      {
488
      return mScreenHeight;
489
      }
490

    
491
///////////////////////////////////////////////////////////////////////////////////////////////////
492

    
493
    public void changeObject(ObjectList newObject, int newSize, boolean reportChange)
494
      {
495
      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
496
      RubikPreRender pre = view.getPreRender();
497

    
498
      if( reportChange )
499
        {
500
        TwistyObject oldObject = pre.getObject();
501

    
502
        if( oldObject!=null )
503
          {
504
          ObjectList oldList = oldObject.getObjectList();
505
          int oldNum = oldObject.getNumLayers();
506
          float fps = view.getRenderer().getFPS();
507
          fps = (int)(fps+0.5f);
508
          StringBuilder name = new StringBuilder();
509
          name.append(oldList.name());
510
          name.append('_');
511
          name.append(oldNum);
512
          name.append(' ');
513
          name.append(fps);
514
          name.append(" --> ");
515
          name.append(newObject.name());
516
          name.append('_');
517
          name.append(newSize);
518

    
519
          if( BuildConfig.DEBUG )
520
            {
521
            android.util.Log.e("rubik", name.toString());
522
            }
523
          else
524
            {
525
            FirebaseAnalytics analytics = getAnalytics();
526

    
527
            if( analytics!=null )
528
              {
529
              Bundle bundle = new Bundle();
530
              bundle.putString(FirebaseAnalytics.Param.ITEM_NAME, name.toString());
531
              analytics.logEvent(FirebaseAnalytics.Event.SELECT_ITEM, bundle);
532
              }
533
            }
534
          }
535
        }
536

    
537
      pre.changeObject(newObject,newSize);
538
      }
539

    
540
///////////////////////////////////////////////////////////////////////////////////////////////////
541

    
542
    public void setupObject(ObjectList object, int size, int[][] moves)
543
      {
544
      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
545
      RubikPreRender pre = view.getPreRender();
546
      pre.setupObject(object,size,moves);
547
      }
548

    
549
///////////////////////////////////////////////////////////////////////////////////////////////////
550

    
551
    public static int getDrawableSize()
552
      {
553
      if( mScreenHeight<1000 )
554
        {
555
        return 0;
556
        }
557
      if( mScreenHeight<1600 )
558
        {
559
        return 1;
560
        }
561
      if( mScreenHeight<1900 )
562
        {
563
        return 2;
564
        }
565

    
566
      return 3;
567
      }
568

    
569
///////////////////////////////////////////////////////////////////////////////////////////////////
570

    
571
    public static int getDrawable(int small, int medium, int big, int huge)
572
      {
573
      int size = getDrawableSize();
574

    
575
      switch(size)
576
        {
577
        case 0 : return small;
578
        case 1 : return medium;
579
        case 2 : return big;
580
        default: return huge;
581
        }
582
      }
583

    
584
///////////////////////////////////////////////////////////////////////////////////////////////////
585

    
586
    public void setControlState(boolean on)
587
      {
588
      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
589
      RubikRenderer renderer = view.getRenderer();
590
      renderer.setControlState(on);
591
      }
592

    
593
///////////////////////////////////////////////////////////////////////////////////////////////////
594

    
595
    public void acceptPrivacy()
596
      {
597
      mPolicyAccepted = true;
598
      }
599

    
600
///////////////////////////////////////////////////////////////////////////////////////////////////
601

    
602
    public void declinePrivacy()
603
      {
604
      finish();
605
      }
606

    
607
///////////////////////////////////////////////////////////////////////////////////////////////////
608

    
609
    public static boolean localeIsChinese()
610
      {
611
      String language;
612

    
613
      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
614
        {
615
        language= LocaleList.getDefault().get(0).getLanguage();
616
        }
617
      else
618
        {
619
        language= Locale.getDefault().getLanguage();
620
        }
621

    
622
      return language.equals("zh");
623
      }
624

    
625
///////////////////////////////////////////////////////////////////////////////////////////////////
626

    
627
    public boolean isVertical()
628
      {
629
      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
630
      return view.isVertical();
631
      }
632

    
633
///////////////////////////////////////////////////////////////////////////////////////////////////
634

    
635
    public void blockEverything(int place)
636
      {
637
      setLock();
638

    
639
      TwistyPreRender pre = getPreRender();
640
      pre.blockEverything(place);
641

    
642
      RubikScreenPlay play = (RubikScreenPlay) ScreenList.PLAY.getScreenClass();
643
      play.setLockState(this);
644
      }
645

    
646
///////////////////////////////////////////////////////////////////////////////////////////////////
647

    
648
    public void unblockEverything()
649
      {
650
      unsetLock();
651

    
652
      TwistyPreRender pre = getPreRender();
653
      pre.unblockEverything();
654

    
655
      RubikScreenPlay play = (RubikScreenPlay) ScreenList.PLAY.getScreenClass();
656
      play.setLockState(this);
657
      }
658

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

    
661
    public Static4D getCurrQuat()
662
      {
663
      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
664
      return view.getQuat();
665
      }
666

    
667
///////////////////////////////////////////////////////////////////////////////////////////////////
668

    
669
    public void switchTutorial(String url, ObjectList object, int size)
670
      {
671
      Intent myIntent = new Intent(this, TutorialActivity.class);
672
      myIntent.putExtra("url", url);
673
      myIntent.putExtra("obj", object.ordinal());
674
      myIntent.putExtra("siz", size);
675
      startActivity(myIntent);
676
      }
677

    
678
///////////////////////////////////////////////////////////////////////////////////////////////////
679

    
680
  public static TwistyObject create(ObjectList object, int size, Static4D quat, int[][] moves, Resources res, int scrWidth)
681
    {
682
    DistortedTexture texture = new DistortedTexture();
683
    DistortedEffects effects = new DistortedEffects();
684
    MeshSquare mesh          = new MeshSquare(20,20);   // mesh of the node, not of the cubits
685

    
686
    switch(object.ordinal())
687
      {
688
      case  0: return new TwistyCube           (size, quat, texture, mesh, effects, moves, res, scrWidth);
689
      case  1: return new TwistyJing           (size, quat, texture, mesh, effects, moves, res, scrWidth);
690
      case  2: return new TwistyPyraminx       (size, quat, texture, mesh, effects, moves, res, scrWidth);
691
      case  3: return new TwistyKilominx       (size, quat, texture, mesh, effects, moves, res, scrWidth);
692
      case  4: return new TwistyMegaminx       (size, quat, texture, mesh, effects, moves, res, scrWidth);
693
      case  5: return new TwistyUltimate       (size, quat, texture, mesh, effects, moves, res, scrWidth);
694
      case  6: return new TwistyDiamond        (size, quat, texture, mesh, effects, moves, res, scrWidth);
695
      case  7: return new TwistyDino6          (size, quat, texture, mesh, effects, moves, res, scrWidth);
696
      case  8: return new TwistyDino4          (size, quat, texture, mesh, effects, moves, res, scrWidth);
697
      case  9: return new TwistyRedi           (size, quat, texture, mesh, effects, moves, res, scrWidth);
698
      case 10: return new TwistyHelicopter     (size, quat, texture, mesh, effects, moves, res, scrWidth);
699
      case 11: return new TwistySkewb          (size, quat, texture, mesh, effects, moves, res, scrWidth);
700
      case 12: return new TwistyIvy            (size, quat, texture, mesh, effects, moves, res, scrWidth);
701
      case 13: return new TwistyRex            (size, quat, texture, mesh, effects, moves, res, scrWidth);
702
      case 14: return new TwistyBandagedFused  (size, quat, texture, mesh, effects, moves, res, scrWidth);
703
      case 15: return new TwistyBandaged2Bar   (size, quat, texture, mesh, effects, moves, res, scrWidth);
704
      case 16: return new TwistyBandaged3Plate (size, quat, texture, mesh, effects, moves, res, scrWidth);
705
      case 17: return new TwistyBandagedEvil   (size, quat, texture, mesh, effects, moves, res, scrWidth);
706
      case 18: return new TwistySquare1        (size, quat, texture, mesh, effects, moves, res, scrWidth);
707
      case 19: return new TwistySquare2        (size, quat, texture, mesh, effects, moves, res, scrWidth);
708
      case 20: return new TwistyMirror         (size, quat, texture, mesh, effects, moves, res, scrWidth);
709
      }
710

    
711
    return null;
712
    }
713
}
(1-1/4)