Project

General

Profile

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

magiccube / src / main / java / org / distorted / main / RubikActivity.java @ 6142069a

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.messaging.RubikInAppMessanging;
41
import org.distorted.objectlib.main.ObjectControl;
42
import org.distorted.objectlib.main.TwistyObject;
43
import org.distorted.objectlib.effects.BaseEffect;
44

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

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

    
59
///////////////////////////////////////////////////////////////////////////////////////////////////
60

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

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

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

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

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

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

    
109
///////////////////////////////////////////////////////////////////////////////////////////////////
110

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

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

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

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

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

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

    
142
      thread.start();
143
      }
144

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

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

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

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

    
165
///////////////////////////////////////////////////////////////////////////////////////////////////
166

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

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

    
175
        decorView.setSystemUiVisibility(FLAGS);
176

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

    
191
///////////////////////////////////////////////////////////////////////////////////////////////////
192

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

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

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

    
211
///////////////////////////////////////////////////////////////////////////////////////////////////
212
// do not avoid cutouts
213

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

    
222
///////////////////////////////////////////////////////////////////////////////////////////////////
223

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

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

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

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

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

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

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

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

    
288
///////////////////////////////////////////////////////////////////////////////////////////////////
289

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

    
303
///////////////////////////////////////////////////////////////////////////////////////////////////
304

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

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

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

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

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

    
329
      ScreenList curr = ScreenList.getCurrentScreen();
330

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

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

    
346
///////////////////////////////////////////////////////////////////////////////////////////////////
347

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

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

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

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

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

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

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

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

    
385
      RubikScores scores = RubikScores.getInstance();
386

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

    
394
///////////////////////////////////////////////////////////////////////////////////////////////////
395

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

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

    
412
///////////////////////////////////////////////////////////////////////////////////////////////////
413

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

    
420
///////////////////////////////////////////////////////////////////////////////////////////////////
421

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

    
428
///////////////////////////////////////////////////////////////////////////////////////////////////
429
// PUBLIC API
430
///////////////////////////////////////////////////////////////////////////////////////////////////
431

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

    
437
///////////////////////////////////////////////////////////////////////////////////////////////////
438

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

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

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

    
451
///////////////////////////////////////////////////////////////////////////////////////////////////
452

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

    
459
///////////////////////////////////////////////////////////////////////////////////////////////////
460

    
461
    public ObjectControl getControl()
462
      {
463
      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
464
      return view.getObjectControl();
465
      }
466

    
467
///////////////////////////////////////////////////////////////////////////////////////////////////
468

    
469
    public int getScreenWidthInPixels()
470
      {
471
      return mScreenWidth;
472
      }
473

    
474
///////////////////////////////////////////////////////////////////////////////////////////////////
475

    
476
    public int getScreenHeightInPixels()
477
      {
478
      return mScreenHeight;
479
      }
480

    
481
///////////////////////////////////////////////////////////////////////////////////////////////////
482

    
483
    public void changeObject(int newObject, boolean reportChange)
484
      {
485
      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
486
      ObjectControl control = view.getObjectControl();
487
      TwistyObject oldObject = control.getObject();
488
      changeIfDifferent(newObject,control);
489

    
490
      if( reportChange && oldObject!=null )
491
        {
492
        RubikObject robject = RubikObjectList.getObject(newObject);
493
        String newName = robject==null ? "NULL" : robject.getUpperName();
494
        float fps = view.getRenderer().getFPS();
495
        fps = (int)(fps+0.5f);
496
        StringBuilder name = new StringBuilder();
497
        name.append(oldObject.getShortName());
498
        name.append(' ');
499
        name.append(fps);
500
        name.append(" --> ");
501
        name.append(newName);
502

    
503
        if( BuildConfig.DEBUG )
504
          {
505
          android.util.Log.e("rubik", name.toString());
506
          }
507
        else
508
          {
509
          FirebaseAnalytics analytics = getAnalytics();
510

    
511
          if( analytics!=null )
512
            {
513
            Bundle bundle = new Bundle();
514
            bundle.putString(FirebaseAnalytics.Param.ITEM_NAME, name.toString());
515
            analytics.logEvent(FirebaseAnalytics.Event.SELECT_ITEM, bundle);
516
            }
517
          }
518
        }
519
      }
520

    
521
///////////////////////////////////////////////////////////////////////////////////////////////////
522

    
523
    public void changeIfDifferent(int ordinal, ObjectControl control)
524
      {
525
      RubikObject object = RubikObjectList.getObject(ordinal);
526
      int meshState = object!=null ? object.getMeshState() : MESH_NICE;
527
      int iconMode  = TwistyObject.MODE_NORM;
528
      InputStream jsonStream = object==null ? null : object.getObjectStream(this);
529
      InputStream meshStream = object==null ? null : object.getMeshStream(this);
530
      String name = object==null ? "NULL" : object.getUpperName();
531

    
532
      control.changeIfDifferent(ordinal,name,meshState,iconMode,jsonStream,meshStream);
533
      }
534

    
535
///////////////////////////////////////////////////////////////////////////////////////////////////
536

    
537
    public static int getDrawableSize()
538
      {
539
      if( mScreenHeight<1000 )
540
        {
541
        return 0;
542
        }
543
      if( mScreenHeight<1600 )
544
        {
545
        return 1;
546
        }
547
      if( mScreenHeight<1900 )
548
        {
549
        return 2;
550
        }
551

    
552
      return 3;
553
      }
554

    
555
///////////////////////////////////////////////////////////////////////////////////////////////////
556

    
557
    public static int getDrawable(int small, int medium, int big, int huge)
558
      {
559
      int size = getDrawableSize();
560

    
561
      switch(size)
562
        {
563
        case 0 : return small;
564
        case 1 : return medium;
565
        case 2 : return big;
566
        default: return huge;
567
        }
568
      }
569

    
570
///////////////////////////////////////////////////////////////////////////////////////////////////
571

    
572
    public void acceptPrivacy()
573
      {
574
      mPolicyAccepted = true;
575
      }
576

    
577
///////////////////////////////////////////////////////////////////////////////////////////////////
578

    
579
    public void declinePrivacy()
580
      {
581
      finish();
582
      }
583

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

    
586
    public static boolean localeIsChinese()
587
      {
588
      String language;
589

    
590
      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
591
        {
592
        language= LocaleList.getDefault().get(0).getLanguage();
593
        }
594
      else
595
        {
596
        language= Locale.getDefault().getLanguage();
597
        }
598

    
599
      return language.equals("zh");
600
      }
601

    
602
///////////////////////////////////////////////////////////////////////////////////////////////////
603

    
604
    public boolean isVertical()
605
      {
606
      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
607
      return view.isVertical();
608
      }
609

    
610
///////////////////////////////////////////////////////////////////////////////////////////////////
611

    
612
    public void blockEverything(int place)
613
      {
614
      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
615
      ObjectControl control = view.getObjectControl();
616
      control.blockEverything(place);
617

    
618
      RubikScreenPlay play = (RubikScreenPlay) ScreenList.PLAY.getScreenClass();
619
      play.setLockState(this);
620
      }
621

    
622
///////////////////////////////////////////////////////////////////////////////////////////////////
623

    
624
    public void unblockEverything()
625
      {
626
      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
627
      ObjectControl control = view.getObjectControl();
628
      control.unblockEverything();
629

    
630
      RubikScreenPlay play = (RubikScreenPlay) ScreenList.PLAY.getScreenClass();
631
      play.setLockState(this);
632
      }
633

    
634
///////////////////////////////////////////////////////////////////////////////////////////////////
635

    
636
    public void switchTutorial(String url, int objectOrdinal)
637
      {
638
      Intent intent = new Intent(this, TutorialActivity.class);
639
      intent.putExtra("url", url);
640
      intent.putExtra("obj", objectOrdinal);
641
      startActivity(intent);
642
      }
643

    
644
///////////////////////////////////////////////////////////////////////////////////////////////////
645

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

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

    
655
    public void switchToBandagedCreator()
656
      {
657
      Intent intent = new Intent(this, BandagedCreatorActivity.class);
658
      startActivity(intent);
659
      }
660

    
661
///////////////////////////////////////////////////////////////////////////////////////////////////
662

    
663
    public void switchToPurchase(int objectOrdinal)
664
      {
665
      Intent intent = new Intent(this, PurchaseActivity.class);
666
      intent.putExtra("obj", objectOrdinal);
667
      startActivity(intent);
668
      }
669

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

    
672
    public void reloadObject(String shortName)
673
      {
674
      TwistyObject currObject = getObject();
675
      String name = currObject==null ? "" : currObject.getShortName();
676

    
677
      if( name.toLowerCase(Locale.ENGLISH).equals(shortName) )
678
        {
679
        RubikObject object = RubikObjectList.getObject(name);
680

    
681
        if( object!=null )
682
          {
683
          int meshState = object.getMeshState();
684
          int iconMode  = TwistyObject.MODE_NORM;
685
          InputStream jsonStream = object.getObjectStream(this);
686
          InputStream meshStream = object.getMeshStream(this);
687
          ObjectControl control = getControl();
688
          control.changeObject(-1,meshState,iconMode,jsonStream,meshStream);
689
          }
690
        }
691
      }
692
}
(1-1/4)