Project

General

Profile

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

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

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();
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
      editor.apply();
343
      }
344

    
345
///////////////////////////////////////////////////////////////////////////////////////////////////
346

    
347
    private void restorePreferences()
348
      {
349
      SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
350

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

    
354
      RubikObjectList.restorePreferences(this,preferences);
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
      ScreenList.restorePreferences(preferences);
367
      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
368

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

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

    
383
      RubikScores scores = RubikScores.getInstance();
384

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

    
392
///////////////////////////////////////////////////////////////////////////////////////////////////
393

    
394
    private void restoreMoves()
395
      {
396
      SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
397
      ScreenList curr = ScreenList.getCurrentScreen();
398

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

    
411
///////////////////////////////////////////////////////////////////////////////////////////////////
412

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

    
419
///////////////////////////////////////////////////////////////////////////////////////////////////
420

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

    
427
///////////////////////////////////////////////////////////////////////////////////////////////////
428
// PUBLIC API
429
///////////////////////////////////////////////////////////////////////////////////////////////////
430

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

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

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

    
443
///////////////////////////////////////////////////////////////////////////////////////////////////
444

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

    
450
///////////////////////////////////////////////////////////////////////////////////////////////////
451

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

    
458
///////////////////////////////////////////////////////////////////////////////////////////////////
459

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

    
466
///////////////////////////////////////////////////////////////////////////////////////////////////
467

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

    
473
///////////////////////////////////////////////////////////////////////////////////////////////////
474

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

    
480
///////////////////////////////////////////////////////////////////////////////////////////////////
481

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

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

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

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

    
520
///////////////////////////////////////////////////////////////////////////////////////////////////
521

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

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

    
534
///////////////////////////////////////////////////////////////////////////////////////////////////
535

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

    
551
      return 3;
552
      }
553

    
554
///////////////////////////////////////////////////////////////////////////////////////////////////
555

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

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

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

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

    
576
///////////////////////////////////////////////////////////////////////////////////////////////////
577

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

    
583
///////////////////////////////////////////////////////////////////////////////////////////////////
584

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

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

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

    
601
///////////////////////////////////////////////////////////////////////////////////////////////////
602

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

    
609
///////////////////////////////////////////////////////////////////////////////////////////////////
610

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

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

    
621
///////////////////////////////////////////////////////////////////////////////////////////////////
622

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

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

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

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

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

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

    
652
///////////////////////////////////////////////////////////////////////////////////////////////////
653

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

    
660
///////////////////////////////////////////////////////////////////////////////////////////////////
661

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

    
669
///////////////////////////////////////////////////////////////////////////////////////////////////
670

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

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

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