Project

General

Profile

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

magiccube / src / main / java / org / distorted / main / RubikActivity.java @ 7480fbab

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

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

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

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

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

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

    
108
///////////////////////////////////////////////////////////////////////////////////////////////////
109

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

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

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

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

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

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

    
141
      thread.start();
142
      }
143

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

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

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

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

    
164
///////////////////////////////////////////////////////////////////////////////////////////////////
165

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

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

    
174
        decorView.setSystemUiVisibility(FLAGS);
175

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

    
190
///////////////////////////////////////////////////////////////////////////////////////////////////
191

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

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

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

    
210
///////////////////////////////////////////////////////////////////////////////////////////////////
211
// do not avoid cutouts
212

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

    
221
///////////////////////////////////////////////////////////////////////////////////////////////////
222

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

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

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

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

    
258
      ScreenList.setScreen(this);
259
      unblockEverything();
260

    
261
      restoreMoves();
262

    
263
      if( mJustStarted )
264
        {
265
        mJustStarted = false;
266
        RubikScores scores = RubikScores.getInstance();
267
        scores.incrementNumRuns();
268
        scores.setCountry(this);
269
        SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(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(boolean justStarted)
349
      {
350
      SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
351

    
352
      mPolicyAccepted = preferences.getBoolean("policyAccepted", false);
353
      String oldVersion = preferences.getString("appVersion","");
354

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

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

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

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

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

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

    
384
      RubikScores scores = RubikScores.getInstance();
385

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

    
393
///////////////////////////////////////////////////////////////////////////////////////////////////
394

    
395
    private void restoreMoves()
396
      {
397
      SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
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)