Project

General

Profile

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

magiccube / src / main / java / org / distorted / main / RubikActivity.java @ b4cbe056

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2019 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// Magic Cube is proprietary software licensed under an EULA which you should have received      //
7
// along with the code. If not, check https://distorted.org/magic/License-Magic-Cube.html        //
8
///////////////////////////////////////////////////////////////////////////////////////////////////
9

    
10
package org.distorted.main;
11

    
12
import java.io.InputStream;
13
import java.util.Locale;
14

    
15
import android.content.Intent;
16
import android.content.SharedPreferences;
17
import android.content.pm.PackageInfo;
18
import android.content.pm.PackageManager;
19
import android.os.Build;
20
import android.os.Bundle;
21
import android.os.LocaleList;
22
import android.preference.PreferenceManager;
23

    
24
import android.util.DisplayMetrics;
25
import android.view.DisplayCutout;
26
import android.view.View;
27
import android.view.ViewGroup;
28
import android.view.WindowManager;
29
import android.widget.LinearLayout;
30

    
31
import androidx.appcompat.app.AppCompatActivity;
32

    
33
import com.google.firebase.analytics.FirebaseAnalytics;
34
import com.google.firebase.inappmessaging.FirebaseInAppMessaging;
35

    
36
import org.distorted.config.ConfigActivity;
37
import org.distorted.bandaged.BandagedCreatorActivity;
38
import org.distorted.library.main.DistortedLibrary;
39

    
40
import org.distorted.library.main.DistortedScreen;
41
import org.distorted.messaging.RubikInAppMessanging;
42
import org.distorted.objectlib.main.ObjectControl;
43
import org.distorted.objectlib.main.TwistyObject;
44
import org.distorted.objectlib.effects.BaseEffect;
45

    
46
import org.distorted.dialogs.RubikDialogError;
47
import org.distorted.dialogs.RubikDialogPrivacy;
48
import org.distorted.external.RubikScores;
49
import org.distorted.external.RubikNetwork;
50
import org.distorted.objects.RubikObject;
51
import org.distorted.objects.RubikObjectList;
52
import org.distorted.purchase.PurchaseActivity;
53
import org.distorted.screens.RubikScreenSolving;
54
import org.distorted.screens.ScreenList;
55
import org.distorted.screens.RubikScreenPlay;
56
import org.distorted.tutorials.TutorialActivity;
57

    
58
import static org.distorted.objectlib.main.TwistyObject.MESH_NICE;
59

    
60
///////////////////////////////////////////////////////////////////////////////////////////////////
61

    
62
public class RubikActivity extends AppCompatActivity
63
{
64
    public static final boolean SHOW_DOWNLOADED_DEBUG = false;
65
    public static final boolean SHOW_SOLVED_DEBUG     = true;
66

    
67
    public static final float PADDING             = 0.01f;
68
    public static final float SMALL_MARGIN        = 0.004f;
69
    public static final float MEDIUM_MARGIN       = 0.015f;
70
    public static final float LARGE_MARGIN        = 0.025f;
71
    public static final float POPUP_PADDING       = 0.045f;
72
    public static final float BUTTON_TEXT_SIZE    = 0.05f;
73
    public static final float TITLE_TEXT_SIZE     = 0.06f;
74
    public static final float SOLVER_BMP_H_SIZE   = 0.11f;
75
    public static final float SOLVER_BMP_V_SIZE   = 0.06f;
76
    public static final float PATTERN_GROUP_TEXT  = 0.03f;
77
    public static final float PATTERN_CHILD_TEXT  = 0.02f;
78
    public static final float SCORES_LEVEL_TEXT   = 0.035f;
79
    public static final float SCORES_ITEM_TEXT    = 0.030f;
80
    public static final float TUTORIAL_ITEM_TEXT  = 0.100f;
81
    public static final float DIALOG_BUTTON_SIZE  = 0.06f;
82
    public static final float MENU_BIG_TEXT_SIZE  = 0.05f;
83
    public static final float MENU_MAIN_TEXT_SIZE = 0.047f;
84
    public static final float MENU_MED_TEXT_SIZE  = 0.04f;
85
    public static final float MENU_SMALL_TEXT_SIZE= 0.035f;
86
    public static final float TAB_WIDTH           = 0.100f;
87
    public static final float TAB_HEIGHT          = 0.100f;
88
    public static final float MENU_BUTTON_HEIGHT  = 0.115f;
89

    
90
    public static final int FLAGS =  View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
91
                                   | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
92
                                   | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
93
                                   | View.SYSTEM_UI_FLAG_FULLSCREEN
94
                                   | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
95

    
96
    private static final int ACTIVITY_NUMBER = 0;
97
    private static final float RATIO_BAR  = 0.10f;
98
    private static final float RATIO_INSET= 0.09f;
99

    
100
    private static final String KEY_PLAY = "movesController_play";
101
    private static final String KEY_SOLV = "movesController_solv";
102

    
103
    private boolean mJustStarted;
104
    private FirebaseAnalytics mFirebaseAnalytics;
105
    private static int mScreenWidth, mScreenHeight;
106
    private boolean mPolicyAccepted, mIsChinese;
107
    private int mCurrentApiVersion;
108
    private int mHeightUpperBar, mHeightLowerBar;
109

    
110
///////////////////////////////////////////////////////////////////////////////////////////////////
111

    
112
    @Override
113
    protected void onCreate(Bundle savedState)
114
      {
115
      super.onCreate(savedState);
116
      DistortedLibrary.onCreate(ACTIVITY_NUMBER);
117

    
118
      setTheme(R.style.MaterialThemeNoActionBar);
119
      setContentView(R.layout.main);
120

    
121
      mJustStarted = true;
122
      mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);
123
      mIsChinese = localeIsChinese();
124

    
125
      DisplayMetrics displaymetrics = new DisplayMetrics();
126
      getWindowManager().getDefaultDisplay().getRealMetrics(displaymetrics);
127
      mScreenWidth =displaymetrics.widthPixels;
128
      mScreenHeight=displaymetrics.heightPixels;
129

    
130
      hideNavigationBar();
131
      cutoutHack();
132
      computeBarHeights();
133

    
134
      Thread thread = new Thread()
135
        {
136
        public void run()
137
          {
138
          RubikInAppMessanging listener = new RubikInAppMessanging();
139
          FirebaseInAppMessaging.getInstance().addClickListener(listener);
140
          }
141
        };
142

    
143
      thread.start();
144
      }
145

    
146
///////////////////////////////////////////////////////////////////////////////////////////////////
147
// this does not include possible insets
148

    
149
    private void computeBarHeights()
150
      {
151
      int barHeight = (int)(mScreenHeight*RATIO_BAR);
152
      mHeightLowerBar = barHeight;
153
      mHeightUpperBar = barHeight;
154

    
155
      LinearLayout layoutTop = findViewById(R.id.upperBar);
156
      LinearLayout layoutBot = findViewById(R.id.lowerBar);
157

    
158
      ViewGroup.LayoutParams paramsTop = layoutTop.getLayoutParams();
159
      paramsTop.height = mHeightUpperBar;
160
      layoutTop.setLayoutParams(paramsTop);
161
      ViewGroup.LayoutParams paramsBot = layoutBot.getLayoutParams();
162
      paramsBot.height = mHeightLowerBar;
163
      layoutBot.setLayoutParams(paramsBot);
164
      }
165

    
166
///////////////////////////////////////////////////////////////////////////////////////////////////
167

    
168
    private void hideNavigationBar()
169
      {
170
      mCurrentApiVersion = Build.VERSION.SDK_INT;
171

    
172
      if(mCurrentApiVersion >= Build.VERSION_CODES.KITKAT)
173
        {
174
        final View decorView = getWindow().getDecorView();
175

    
176
        decorView.setSystemUiVisibility(FLAGS);
177

    
178
        decorView.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener()
179
          {
180
          @Override
181
          public void onSystemUiVisibilityChange(int visibility)
182
            {
183
            if((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0)
184
              {
185
              decorView.setSystemUiVisibility(FLAGS);
186
              }
187
            }
188
          });
189
        }
190
      }
191

    
192
///////////////////////////////////////////////////////////////////////////////////////////////////
193

    
194
    @Override
195
    public void onAttachedToWindow()
196
      {
197
      super.onAttachedToWindow();
198

    
199
      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P)
200
        {
201
        DisplayCutout cutout = getWindow().getDecorView().getRootWindowInsets().getDisplayCutout();
202
        int insetHeight = cutout!=null ? cutout.getSafeInsetTop() : 0;
203

    
204
        LinearLayout layoutHid = findViewById(R.id.hiddenBar);
205
        ViewGroup.LayoutParams paramsHid = layoutHid.getLayoutParams();
206
        paramsHid.height = (int)(insetHeight*RATIO_INSET);
207
        layoutHid.setLayoutParams(paramsHid);
208
        mHeightUpperBar += paramsHid.height;
209
        }
210
      }
211

    
212
///////////////////////////////////////////////////////////////////////////////////////////////////
213
// do not avoid cutouts
214

    
215
    private void cutoutHack()
216
      {
217
      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P)
218
        {
219
        getWindow().getAttributes().layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
220
        }
221
      }
222

    
223
///////////////////////////////////////////////////////////////////////////////////////////////////
224

    
225
    @Override
226
    public void onWindowFocusChanged(boolean hasFocus)
227
      {
228
      super.onWindowFocusChanged(hasFocus);
229

    
230
      if(mCurrentApiVersion >= Build.VERSION_CODES.KITKAT && hasFocus)
231
        {
232
        getWindow().getDecorView().setSystemUiVisibility(FLAGS);
233
        }
234
      }
235

    
236
///////////////////////////////////////////////////////////////////////////////////////////////////
237
    
238
    @Override
239
    protected void onPause() 
240
      {
241
      super.onPause();
242
      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
243
      view.onPause();
244
      DistortedLibrary.onPause(ACTIVITY_NUMBER);
245
      RubikNetwork.onPause();
246
      savePreferences();
247
      }
248

    
249
///////////////////////////////////////////////////////////////////////////////////////////////////
250
    
251
    @Override
252
    protected void onResume() 
253
      {
254
      super.onResume();
255
      DistortedLibrary.onResume(ACTIVITY_NUMBER);
256
      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
257
      view.onResume();
258

    
259
      SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
260
      restorePreferences(preferences,mJustStarted);
261
      ScreenList.setScreen(this);
262
      unblockEverything();
263
      restoreMoves(preferences);
264

    
265
      if( mJustStarted )
266
        {
267
        mJustStarted = false;
268
        RubikScores scores = RubikScores.getInstance();
269
        scores.incrementNumRuns();
270
        scores.setCountry(this);
271
        RubikObjectList.restoreMeshState(preferences);
272
        }
273

    
274
      int object = RubikObjectList.getCurrObject();
275
      changeIfDifferent(object,view.getObjectControl());
276

    
277
      if( mIsChinese && !mPolicyAccepted ) PrivacyPolicy();
278
      }
279
    
280
///////////////////////////////////////////////////////////////////////////////////////////////////
281
    
282
    @Override
283
    protected void onDestroy() 
284
      {
285
      DistortedLibrary.onDestroy(ACTIVITY_NUMBER);
286
      super.onDestroy();
287
      }
288

    
289
///////////////////////////////////////////////////////////////////////////////////////////////////
290

    
291
    private String getAppVers()
292
      {
293
      try
294
        {
295
        PackageInfo pInfo = getPackageManager().getPackageInfo( getPackageName(), 0);
296
        return pInfo.versionName;
297
        }
298
      catch (PackageManager.NameNotFoundException e)
299
        {
300
        return "unknown";
301
        }
302
      }
303

    
304
///////////////////////////////////////////////////////////////////////////////////////////////////
305

    
306
    private void savePreferences()
307
      {
308
      SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
309
      SharedPreferences.Editor editor = preferences.edit();
310

    
311
      editor.putBoolean("policyAccepted", mPolicyAccepted);
312
      editor.putString("appVersion", getAppVers() );
313

    
314
      for (int i=0; i<BaseEffect.Type.LENGTH; i++)
315
        {
316
        BaseEffect.Type.getType(i).savePreferences(editor);
317
        }
318

    
319
      for (int i = 0; i< ScreenList.LENGTH; i++)
320
        {
321
        ScreenList.getScreen(i).getScreenClass().savePreferences(editor);
322
        }
323

    
324
      RubikObjectList.savePreferences(editor);
325
      RubikObjectList.saveMeshState(editor);
326
      ScreenList.savePreferences(editor);
327
      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
328
      view.getObjectControl().savePreferences(editor);
329

    
330
      ScreenList curr = ScreenList.getCurrentScreen();
331

    
332
      if( curr==ScreenList.PLAY )
333
        {
334
        RubikScreenPlay play = (RubikScreenPlay)ScreenList.PLAY.getScreenClass();
335
        play.saveMovePreferences(KEY_PLAY,editor);
336
        }
337
      if( curr==ScreenList.SOLV )
338
        {
339
        RubikScreenSolving solv = (RubikScreenSolving)ScreenList.SOLV.getScreenClass();
340
        solv.saveMovePreferences(KEY_SOLV,editor);
341
        }
342

    
343
      boolean success = editor.commit();
344
      if( !success ) android.util.Log.e("D", "Failed to save preferences");
345
      }
346

    
347
///////////////////////////////////////////////////////////////////////////////////////////////////
348

    
349
    private void restorePreferences(SharedPreferences preferences, boolean justStarted)
350
      {
351
      mPolicyAccepted = preferences.getBoolean("policyAccepted", false);
352
      String oldVersion = preferences.getString("appVersion","");
353

    
354
      RubikObjectList.restorePreferences(this,preferences,justStarted);
355

    
356
      for (int i=0; i<BaseEffect.Type.LENGTH; i++)
357
        {
358
        BaseEffect.Type.getType(i).restorePreferences(preferences);
359
        }
360

    
361
      for (int i=0; i<ScreenList.LENGTH; i++)
362
        {
363
        ScreenList.getScreen(i).getScreenClass().restorePreferences(preferences);
364
        }
365

    
366
      // this needs to be after the above ScreenList.restore as that restores the Records which we need here
367
      if( justStarted ) RubikObjectList.setObjectFreeState();
368

    
369
      ScreenList.restorePreferences(preferences);
370
      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
371

    
372
      // Versions <= 1.8.6 did not save their 'appVersion' to preferences, therefore in their
373
      // case the 'mOldVersion' - version of the app which saved the preferences on the last
374
      // go - is empty.
375
      // Between versions 1.8.6 and 1.9.0, the order of the cubits in TwistyCube has changed.
376
      // If someone has scrambled the cube with v. 1.8.6, then upgraded to 1.9.0 and re-started
377
      // the app, because of the different order of the cubits - his cube would be messed up.
378
      // So in such case, i.e. on fresh upgrade from version<=1.8.6 to version>=1.9.0, do not
379
      // restore the object scrambling.
380

    
381
      if( !oldVersion.equals("") )
382
        {
383
        view.getObjectControl().restorePreferences(preferences);
384
        }
385

    
386
      RubikScores scores = RubikScores.getInstance();
387

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

    
395
///////////////////////////////////////////////////////////////////////////////////////////////////
396

    
397
    private void restoreMoves(SharedPreferences preferences)
398
      {
399
      ScreenList curr = ScreenList.getCurrentScreen();
400

    
401
      if( curr==ScreenList.PLAY )
402
        {
403
        RubikScreenPlay play = (RubikScreenPlay)ScreenList.PLAY.getScreenClass();
404
        play.restoreMovePreferences(this,KEY_PLAY,preferences);
405
        }
406
      if( curr==ScreenList.SOLV )
407
        {
408
        RubikScreenSolving solv = (RubikScreenSolving)ScreenList.SOLV.getScreenClass();
409
        solv.restoreMovePreferences(this,KEY_SOLV,preferences);
410
        }
411
      }
412

    
413
///////////////////////////////////////////////////////////////////////////////////////////////////
414

    
415
    private void PrivacyPolicy()
416
      {
417
      RubikDialogPrivacy priDiag = new RubikDialogPrivacy();
418
      priDiag.show(getSupportFragmentManager(), null);
419
      }
420

    
421
///////////////////////////////////////////////////////////////////////////////////////////////////
422

    
423
    void OpenGLError()
424
      {
425
      RubikDialogError errDiag = new RubikDialogError();
426
      errDiag.show(getSupportFragmentManager(), null);
427
      }
428

    
429
///////////////////////////////////////////////////////////////////////////////////////////////////
430
// PUBLIC API
431
///////////////////////////////////////////////////////////////////////////////////////////////////
432

    
433
    public FirebaseAnalytics getAnalytics()
434
      {
435
      return mFirebaseAnalytics;
436
      }
437

    
438
///////////////////////////////////////////////////////////////////////////////////////////////////
439

    
440
    public int getHeightUpperBar()
441
      {
442
      return mHeightUpperBar;
443
      }
444

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

    
447
    public int getHeightLowerBar()
448
      {
449
      return mHeightLowerBar;
450
      }
451

    
452
///////////////////////////////////////////////////////////////////////////////////////////////////
453

    
454
    public TwistyObject getObject()
455
      {
456
      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
457
      return view.getObjectControl().getObject();
458
      }
459

    
460
///////////////////////////////////////////////////////////////////////////////////////////////////
461

    
462
    public DistortedScreen getScreen()
463
      {
464
      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
465
      return view.getRenderer().getScreen();
466
      }
467

    
468
///////////////////////////////////////////////////////////////////////////////////////////////////
469

    
470
    public ObjectControl getControl()
471
      {
472
      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
473
      return view.getObjectControl();
474
      }
475

    
476
///////////////////////////////////////////////////////////////////////////////////////////////////
477

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

    
483
///////////////////////////////////////////////////////////////////////////////////////////////////
484

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

    
490
///////////////////////////////////////////////////////////////////////////////////////////////////
491

    
492
    public void changeObject(int newObject, boolean reportChange)
493
      {
494
      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
495
      ObjectControl control = view.getObjectControl();
496
      TwistyObject oldObject = control.getObject();
497
      changeIfDifferent(newObject,control);
498

    
499
      if( reportChange && oldObject!=null )
500
        {
501
        RubikObject robject = RubikObjectList.getObject(newObject);
502
        String newName = robject==null ? "NULL" : robject.getUpperName();
503
        float fps = view.getRenderer().getFPS();
504
        fps = (int)(fps+0.5f);
505
        StringBuilder name = new StringBuilder();
506
        name.append(oldObject.getShortName());
507
        name.append(' ');
508
        name.append(fps);
509
        name.append(" --> ");
510
        name.append(newName);
511

    
512
        if( BuildConfig.DEBUG )
513
          {
514
          android.util.Log.e("rubik", name.toString());
515
          }
516
        else
517
          {
518
          FirebaseAnalytics analytics = getAnalytics();
519

    
520
          if( analytics!=null )
521
            {
522
            Bundle bundle = new Bundle();
523
            bundle.putString(FirebaseAnalytics.Param.ITEM_NAME, name.toString());
524
            analytics.logEvent(FirebaseAnalytics.Event.SELECT_ITEM, bundle);
525
            }
526
          }
527
        }
528
      }
529

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

    
532
    public void changeIfDifferent(int ordinal, ObjectControl control)
533
      {
534
      RubikObject object = RubikObjectList.getObject(ordinal);
535
      int meshState = object!=null ? object.getMeshState() : MESH_NICE;
536
      int iconMode  = TwistyObject.MODE_NORM;
537
      InputStream jsonStream = object==null ? null : object.getObjectStream(this);
538
      InputStream meshStream = object==null ? null : object.getMeshStream(this);
539
      String name = object==null ? "NULL" : object.getUpperName();
540

    
541
      control.changeIfDifferent(ordinal,name,meshState,iconMode,jsonStream,meshStream);
542
      }
543

    
544
///////////////////////////////////////////////////////////////////////////////////////////////////
545

    
546
    public static int getDrawableSize()
547
      {
548
      if( mScreenHeight<1000 )
549
        {
550
        return 0;
551
        }
552
      if( mScreenHeight<1600 )
553
        {
554
        return 1;
555
        }
556
      if( mScreenHeight<1900 )
557
        {
558
        return 2;
559
        }
560

    
561
      return 3;
562
      }
563

    
564
///////////////////////////////////////////////////////////////////////////////////////////////////
565

    
566
    public static int getDrawable(int small, int medium, int big, int huge)
567
      {
568
      int size = getDrawableSize();
569

    
570
      switch(size)
571
        {
572
        case 0 : return small;
573
        case 1 : return medium;
574
        case 2 : return big;
575
        default: return huge;
576
        }
577
      }
578

    
579
///////////////////////////////////////////////////////////////////////////////////////////////////
580

    
581
    public void acceptPrivacy()
582
      {
583
      mPolicyAccepted = true;
584
      }
585

    
586
///////////////////////////////////////////////////////////////////////////////////////////////////
587

    
588
    public void declinePrivacy()
589
      {
590
      finish();
591
      }
592

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

    
595
    public static boolean localeIsChinese()
596
      {
597
      String language;
598

    
599
      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
600
        {
601
        language= LocaleList.getDefault().get(0).getLanguage();
602
        }
603
      else
604
        {
605
        language= Locale.getDefault().getLanguage();
606
        }
607

    
608
      return language.equals("zh");
609
      }
610

    
611
///////////////////////////////////////////////////////////////////////////////////////////////////
612

    
613
    public boolean isVertical()
614
      {
615
      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
616
      return view.isVertical();
617
      }
618

    
619
///////////////////////////////////////////////////////////////////////////////////////////////////
620

    
621
    public void blockEverything(int place)
622
      {
623
      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
624
      ObjectControl control = view.getObjectControl();
625
      control.blockEverything(place);
626

    
627
      RubikScreenPlay play = (RubikScreenPlay) ScreenList.PLAY.getScreenClass();
628
      play.setLockState(this);
629
      }
630

    
631
///////////////////////////////////////////////////////////////////////////////////////////////////
632

    
633
    public void unblockEverything()
634
      {
635
      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
636
      ObjectControl control = view.getObjectControl();
637
      control.unblockEverything();
638

    
639
      RubikScreenPlay play = (RubikScreenPlay) ScreenList.PLAY.getScreenClass();
640
      play.setLockState(this);
641
      }
642

    
643
///////////////////////////////////////////////////////////////////////////////////////////////////
644

    
645
    public void switchTutorial(String url, int objectOrdinal)
646
      {
647
      Intent intent = new Intent(this, TutorialActivity.class);
648
      intent.putExtra("url", url);
649
      intent.putExtra("obj", objectOrdinal);
650
      startActivity(intent);
651
      }
652

    
653
///////////////////////////////////////////////////////////////////////////////////////////////////
654

    
655
    public void switchConfig(int objectOrdinal)
656
      {
657
      Intent intent = new Intent(this, ConfigActivity.class);
658
      intent.putExtra("obj", objectOrdinal);
659
      startActivity(intent);
660
      }
661

    
662
///////////////////////////////////////////////////////////////////////////////////////////////////
663

    
664
    public void switchToBandagedCreator()
665
      {
666
      Intent intent = new Intent(this, BandagedCreatorActivity.class);
667
      startActivity(intent);
668
      }
669

    
670
///////////////////////////////////////////////////////////////////////////////////////////////////
671

    
672
    public void switchToPurchase(int objectOrdinal)
673
      {
674
      Intent intent = new Intent(this, PurchaseActivity.class);
675
      intent.putExtra("obj", objectOrdinal);
676
      startActivity(intent);
677
      }
678

    
679
///////////////////////////////////////////////////////////////////////////////////////////////////
680

    
681
    public void reloadObject(String shortName)
682
      {
683
      TwistyObject currObject = getObject();
684
      String name = currObject==null ? "" : currObject.getShortName();
685

    
686
      if( name.toLowerCase(Locale.ENGLISH).equals(shortName) )
687
        {
688
        RubikObject object = RubikObjectList.getObject(name);
689

    
690
        if( object!=null )
691
          {
692
          int meshState = object.getMeshState();
693
          int iconMode  = TwistyObject.MODE_NORM;
694
          InputStream jsonStream = object.getObjectStream(this);
695
          InputStream meshStream = object.getMeshStream(this);
696
          ObjectControl control = getControl();
697
          control.changeObject(-1,meshState,iconMode,jsonStream,meshStream);
698
          }
699
        }
700
      }
701
}
(1-1/4)