Project

General

Profile

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

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

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.screens.RubikScreenSolving;
52
import org.distorted.screens.ScreenList;
53
import org.distorted.screens.RubikScreenPlay;
54
import org.distorted.tutorials.TutorialActivity;
55

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

    
58
///////////////////////////////////////////////////////////////////////////////////////////////////
59

    
60
public class RubikActivity extends AppCompatActivity
61
{
62
    public static final boolean SHOW_DOWNLOADED_DEBUG = false;
63

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

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

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

    
96
    private static final String KEY_PLAY = "movesController_play";
97
    private static final String KEY_SOLV = "movesController_solv";
98

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

    
106
///////////////////////////////////////////////////////////////////////////////////////////////////
107

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

    
114
      setTheme(R.style.MaterialThemeNoActionBar);
115
      setContentView(R.layout.main);
116

    
117
      mJustStarted = true;
118
      mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);
119
      mIsChinese = localeIsChinese();
120

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

    
126
      hideNavigationBar();
127
      cutoutHack();
128
      computeBarHeights();
129

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

    
139
      thread.start();
140
      }
141

    
142
///////////////////////////////////////////////////////////////////////////////////////////////////
143
// this does not include possible insets
144

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

    
151
      LinearLayout layoutTop = findViewById(R.id.upperBar);
152
      LinearLayout layoutBot = findViewById(R.id.lowerBar);
153

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

    
162
///////////////////////////////////////////////////////////////////////////////////////////////////
163

    
164
    private void hideNavigationBar()
165
      {
166
      mCurrentApiVersion = Build.VERSION.SDK_INT;
167

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

    
172
        decorView.setSystemUiVisibility(FLAGS);
173

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

    
188
///////////////////////////////////////////////////////////////////////////////////////////////////
189

    
190
    @Override
191
    public void onAttachedToWindow()
192
      {
193
      super.onAttachedToWindow();
194

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

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

    
208
///////////////////////////////////////////////////////////////////////////////////////////////////
209
// do not avoid cutouts
210

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

    
219
///////////////////////////////////////////////////////////////////////////////////////////////////
220

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

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

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

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

    
256
      ScreenList.setScreen(this);
257
      unblockEverything();
258

    
259
      restoreMoves();
260

    
261
      if( mJustStarted )
262
        {
263
        mJustStarted = false;
264
        RubikScores scores = RubikScores.getInstance();
265
        scores.incrementNumRuns();
266
        scores.setCountry(this);
267
        SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
268
        RubikObjectList.restoreMeshState(preferences);
269
        }
270

    
271
      int object = RubikObjectList.getCurrObject();
272
      changeIfDifferent(object,view.getObjectControl());
273

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

    
286
///////////////////////////////////////////////////////////////////////////////////////////////////
287

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

    
301
///////////////////////////////////////////////////////////////////////////////////////////////////
302

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

    
308
      editor.putBoolean("policyAccepted", mPolicyAccepted);
309
      editor.putString("appVersion", getAppVers() );
310

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

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

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

    
327
      ScreenList curr = ScreenList.getCurrentScreen();
328

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

    
340
      editor.apply();
341
      }
342

    
343
///////////////////////////////////////////////////////////////////////////////////////////////////
344

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

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

    
352
      RubikObjectList.restorePreferences(this,preferences);
353

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

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

    
364
      ScreenList.restorePreferences(preferences);
365
      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
366

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

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

    
381
      RubikScores scores = RubikScores.getInstance();
382

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

    
390
///////////////////////////////////////////////////////////////////////////////////////////////////
391

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

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

    
409
///////////////////////////////////////////////////////////////////////////////////////////////////
410

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

    
417
///////////////////////////////////////////////////////////////////////////////////////////////////
418

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

    
425
///////////////////////////////////////////////////////////////////////////////////////////////////
426
// PUBLIC API
427
///////////////////////////////////////////////////////////////////////////////////////////////////
428

    
429
    public FirebaseAnalytics getAnalytics()
430
      {
431
      return mFirebaseAnalytics;
432
      }
433

    
434
///////////////////////////////////////////////////////////////////////////////////////////////////
435

    
436
    public int getHeightUpperBar()
437
      {
438
      return mHeightUpperBar;
439
      }
440

    
441
///////////////////////////////////////////////////////////////////////////////////////////////////
442

    
443
    public int getHeightLowerBar()
444
      {
445
      return mHeightLowerBar;
446
      }
447

    
448
///////////////////////////////////////////////////////////////////////////////////////////////////
449

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

    
456
///////////////////////////////////////////////////////////////////////////////////////////////////
457

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

    
464
///////////////////////////////////////////////////////////////////////////////////////////////////
465

    
466
    public int getScreenWidthInPixels()
467
      {
468
      return mScreenWidth;
469
      }
470

    
471
///////////////////////////////////////////////////////////////////////////////////////////////////
472

    
473
    public int getScreenHeightInPixels()
474
      {
475
      return mScreenHeight;
476
      }
477

    
478
///////////////////////////////////////////////////////////////////////////////////////////////////
479

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

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

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

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

    
518
///////////////////////////////////////////////////////////////////////////////////////////////////
519

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

    
529
      control.changeIfDifferent(ordinal,name,meshState,iconMode,jsonStream,meshStream);
530
      }
531

    
532
///////////////////////////////////////////////////////////////////////////////////////////////////
533

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

    
549
      return 3;
550
      }
551

    
552
///////////////////////////////////////////////////////////////////////////////////////////////////
553

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

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

    
567
///////////////////////////////////////////////////////////////////////////////////////////////////
568

    
569
    public void acceptPrivacy()
570
      {
571
      mPolicyAccepted = true;
572
      }
573

    
574
///////////////////////////////////////////////////////////////////////////////////////////////////
575

    
576
    public void declinePrivacy()
577
      {
578
      finish();
579
      }
580

    
581
///////////////////////////////////////////////////////////////////////////////////////////////////
582

    
583
    public static boolean localeIsChinese()
584
      {
585
      String language;
586

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

    
596
      return language.equals("zh");
597
      }
598

    
599
///////////////////////////////////////////////////////////////////////////////////////////////////
600

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

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

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

    
615
      RubikScreenPlay play = (RubikScreenPlay) ScreenList.PLAY.getScreenClass();
616
      play.setLockState(this);
617
      }
618

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

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

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

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

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

    
641
///////////////////////////////////////////////////////////////////////////////////////////////////
642

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

    
650
///////////////////////////////////////////////////////////////////////////////////////////////////
651

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

    
658
///////////////////////////////////////////////////////////////////////////////////////////////////
659

    
660
    public void reloadObject(String shortName)
661
      {
662
      TwistyObject currObject = getObject();
663
      String name = currObject==null ? "" : currObject.getShortName();
664

    
665
      if( name.toLowerCase(Locale.ENGLISH).equals(shortName) )
666
        {
667
        RubikObject object = RubikObjectList.getObject(name);
668

    
669
        if( object!=null )
670
          {
671
          int meshState = object.getMeshState();
672
          int iconMode  = TwistyObject.MODE_NORM;
673
          InputStream jsonStream = object.getObjectStream(this);
674
          InputStream meshStream = object.getMeshStream(this);
675
          ObjectControl control = getControl();
676
          control.changeObject(-1,meshState,iconMode,jsonStream,meshStream);
677
          }
678
        }
679
      }
680
}
(1-1/4)