Project

General

Profile

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

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

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2019 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// Magic Cube is free software: you can redistribute it and/or modify                            //
7
// it under the terms of the GNU General Public License as published by                          //
8
// the Free Software Foundation, either version 2 of the License, or                             //
9
// (at your option) any later version.                                                           //
10
//                                                                                               //
11
// Magic Cube is distributed in the hope that it will be useful,                                 //
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
14
// GNU General Public License for more details.                                                  //
15
//                                                                                               //
16
// You should have received a copy of the GNU General Public License                             //
17
// along with Magic Cube.  If not, see <http://www.gnu.org/licenses/>.                           //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19

    
20
package org.distorted.main;
21

    
22
import java.io.InputStream;
23
import java.util.Locale;
24

    
25
import android.content.Intent;
26
import android.content.SharedPreferences;
27
import android.content.pm.PackageInfo;
28
import android.content.pm.PackageManager;
29
import android.os.Build;
30
import android.os.Bundle;
31
import android.os.LocaleList;
32
import android.preference.PreferenceManager;
33

    
34
import android.util.DisplayMetrics;
35
import android.view.DisplayCutout;
36
import android.view.View;
37
import android.view.ViewGroup;
38
import android.view.WindowManager;
39
import android.widget.LinearLayout;
40

    
41
import androidx.appcompat.app.AppCompatActivity;
42

    
43
import com.google.firebase.analytics.FirebaseAnalytics;
44

    
45
import org.distorted.config.ConfigActivity;
46
import org.distorted.bandaged.BandagedCreatorActivity;
47
import org.distorted.library.main.DistortedLibrary;
48

    
49
import org.distorted.objectlib.main.ObjectControl;
50
import org.distorted.objectlib.main.TwistyObject;
51
import org.distorted.objectlib.effects.BaseEffect;
52

    
53
import org.distorted.dialogs.RubikDialogError;
54
import org.distorted.dialogs.RubikDialogPrivacy;
55
import org.distorted.external.RubikScores;
56
import org.distorted.external.RubikNetwork;
57
import org.distorted.objects.RubikObject;
58
import org.distorted.objects.RubikObjectList;
59
import org.distorted.screens.RubikScreenFreePlay;
60
import org.distorted.screens.RubikScreenSolving;
61
import org.distorted.screens.ScreenList;
62
import org.distorted.screens.RubikScreenPlay;
63
import org.distorted.tutorials.TutorialActivity;
64

    
65
import static org.distorted.objectlib.main.TwistyObject.MESH_NICE;
66

    
67
///////////////////////////////////////////////////////////////////////////////////////////////////
68

    
69
public class RubikActivity extends AppCompatActivity
70
{
71
    public static final boolean SHOW_DOWNLOADED_DEBUG = false;
72

    
73
    public static final float PADDING             = 0.01f;
74
    public static final float SMALL_MARGIN        = 0.004f;
75
    public static final float MEDIUM_MARGIN       = 0.015f;
76
    public static final float LARGE_MARGIN        = 0.025f;
77
    public static final float BUTTON_TEXT_SIZE    = 0.05f;
78
    public static final float TITLE_TEXT_SIZE     = 0.06f;
79
    public static final float SOLVER_BMP_H_SIZE   = 0.11f;
80
    public static final float SOLVER_BMP_V_SIZE   = 0.06f;
81
    public static final float MENU_ITEM_SIZE      = 0.11f;
82
    public static final float PATTERN_GROUP_TEXT  = 0.03f;
83
    public static final float PATTERN_CHILD_TEXT  = 0.02f;
84
    public static final float SCORES_LEVEL_TEXT   = 0.035f;
85
    public static final float SCORES_ITEM_TEXT    = 0.030f;
86
    public static final float TUTORIAL_ITEM_TEXT  = 0.100f;
87
    public static final float DIALOG_BUTTON_SIZE  = 0.06f;
88
    public static final float MENU_BIG_TEXT_SIZE  = 0.05f;
89
    public static final float MENU_MED_TEXT_SIZE  = 0.04f;
90
    public static final float MENU_SMALL_TEXT_SIZE= 0.035f;
91
    public static final float TAB_WIDTH           = 0.100f;
92
    public static final float TAB_HEIGHT          = 0.100f;
93

    
94
    public static final int FLAGS =  View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
95
                                   | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
96
                                   | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
97
                                   | View.SYSTEM_UI_FLAG_FULLSCREEN
98
                                   | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
99

    
100
    private static final int ACTIVITY_NUMBER = 0;
101
    private static final float RATIO_BAR  = 0.10f;
102
    private static final float RATIO_INSET= 0.09f;
103

    
104
    private static final String KEY_PLAY = "movesController_play";
105
    private static final String KEY_SOLV = "movesController_solv";
106
    public  static final String KEY_FREE = "movesController_free";
107

    
108
    private boolean mJustStarted;
109
    private FirebaseAnalytics mFirebaseAnalytics;
110
    private static int mScreenWidth, mScreenHeight;
111
    private boolean mPolicyAccepted, mIsChinese;
112
    private int mCurrentApiVersion;
113
    private int mHeightUpperBar, mHeightLowerBar;
114

    
115
///////////////////////////////////////////////////////////////////////////////////////////////////
116

    
117
    @Override
118
    protected void onCreate(Bundle savedState)
119
      {
120
      super.onCreate(savedState);
121
      DistortedLibrary.onCreate(ACTIVITY_NUMBER);
122

    
123
      setTheme(R.style.MaterialThemeNoActionBar);
124
      setContentView(R.layout.main);
125

    
126
      mJustStarted = true;
127
      mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);
128
      mIsChinese = localeIsChinese();
129

    
130
      DisplayMetrics displaymetrics = new DisplayMetrics();
131
      getWindowManager().getDefaultDisplay().getRealMetrics(displaymetrics);
132
      mScreenWidth =displaymetrics.widthPixels;
133
      mScreenHeight=displaymetrics.heightPixels;
134

    
135
      hideNavigationBar();
136
      cutoutHack();
137
      computeBarHeights();
138
      }
139

    
140
///////////////////////////////////////////////////////////////////////////////////////////////////
141
// this does not include possible insets
142

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

    
149
      LinearLayout layoutTop = findViewById(R.id.upperBar);
150
      LinearLayout layoutBot = findViewById(R.id.lowerBar);
151

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

    
160
///////////////////////////////////////////////////////////////////////////////////////////////////
161

    
162
    private void hideNavigationBar()
163
      {
164
      mCurrentApiVersion = Build.VERSION.SDK_INT;
165

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

    
170
        decorView.setSystemUiVisibility(FLAGS);
171

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

    
186
///////////////////////////////////////////////////////////////////////////////////////////////////
187

    
188
    @Override
189
    public void onAttachedToWindow()
190
      {
191
      super.onAttachedToWindow();
192

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

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

    
206
///////////////////////////////////////////////////////////////////////////////////////////////////
207
// do not avoid cutouts
208

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

    
217
///////////////////////////////////////////////////////////////////////////////////////////////////
218

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

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

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

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

    
254
      ScreenList.setScreen(this);
255
      unblockEverything();
256

    
257
      restoreMoves();
258

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

    
269
      int object = RubikObjectList.getCurrObject();
270
      changeIfDifferent(object,view.getObjectControl());
271

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

    
284
///////////////////////////////////////////////////////////////////////////////////////////////////
285

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

    
299
///////////////////////////////////////////////////////////////////////////////////////////////////
300

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

    
306
      editor.putBoolean("policyAccepted", mPolicyAccepted);
307
      editor.putString("appVersion", getAppVers() );
308

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

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

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

    
325
      ScreenList curr = ScreenList.getCurrentScreen();
326

    
327
      if( curr==ScreenList.PLAY )
328
        {
329
        RubikScreenPlay play = (RubikScreenPlay)ScreenList.PLAY.getScreenClass();
330
        play.saveMovePreferences(KEY_PLAY,editor);
331
        }
332
      if( curr==ScreenList.SOLV )
333
        {
334
        RubikScreenSolving solv = (RubikScreenSolving)ScreenList.SOLV.getScreenClass();
335
        solv.saveMovePreferences(KEY_SOLV,editor);
336
        }
337
      if( curr==ScreenList.FREE )
338
        {
339
        RubikScreenFreePlay free = (RubikScreenFreePlay)ScreenList.FREE.getScreenClass();
340
        free.saveMovePreferences(KEY_FREE,editor);
341
        }
342

    
343
      editor.apply();
344
      }
345

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

    
348
    private void restorePreferences()
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);
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
      if( curr==ScreenList.FREE )
411
        {
412
        RubikScreenFreePlay free = (RubikScreenFreePlay)ScreenList.FREE.getScreenClass();
413
        free.restoreMovePreferences(this,KEY_FREE,preferences);
414
        }
415
      }
416

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

    
419
    private void PrivacyPolicy()
420
      {
421
      RubikDialogPrivacy priDiag = new RubikDialogPrivacy();
422
      priDiag.show(getSupportFragmentManager(), null);
423
      }
424

    
425
///////////////////////////////////////////////////////////////////////////////////////////////////
426

    
427
    void OpenGLError()
428
      {
429
      RubikDialogError errDiag = new RubikDialogError();
430
      errDiag.show(getSupportFragmentManager(), null);
431
      }
432

    
433
///////////////////////////////////////////////////////////////////////////////////////////////////
434
// PUBLIC API
435
///////////////////////////////////////////////////////////////////////////////////////////////////
436

    
437
    public FirebaseAnalytics getAnalytics()
438
      {
439
      return mFirebaseAnalytics;
440
      }
441

    
442
///////////////////////////////////////////////////////////////////////////////////////////////////
443

    
444
    public int getHeightUpperBar()
445
      {
446
      return mHeightUpperBar;
447
      }
448

    
449
///////////////////////////////////////////////////////////////////////////////////////////////////
450

    
451
    public int getHeightLowerBar()
452
      {
453
      return mHeightLowerBar;
454
      }
455

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

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

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

    
466
    public ObjectControl getControl()
467
      {
468
      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
469
      return view.getObjectControl();
470
      }
471

    
472
///////////////////////////////////////////////////////////////////////////////////////////////////
473

    
474
    public int getScreenWidthInPixels()
475
      {
476
      return mScreenWidth;
477
      }
478

    
479
///////////////////////////////////////////////////////////////////////////////////////////////////
480

    
481
    public int getScreenHeightInPixels()
482
      {
483
      return mScreenHeight;
484
      }
485

    
486
///////////////////////////////////////////////////////////////////////////////////////////////////
487

    
488
    public void changeObject(int newObject, boolean reportChange)
489
      {
490
      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
491
      ObjectControl control = view.getObjectControl();
492
      TwistyObject oldObject = control.getObject();
493
      changeIfDifferent(newObject,control);
494

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

    
508
        if( BuildConfig.DEBUG )
509
          {
510
          android.util.Log.e("rubik", name.toString());
511
          }
512
        else
513
          {
514
          FirebaseAnalytics analytics = getAnalytics();
515

    
516
          if( analytics!=null )
517
            {
518
            Bundle bundle = new Bundle();
519
            bundle.putString(FirebaseAnalytics.Param.ITEM_NAME, name.toString());
520
            analytics.logEvent(FirebaseAnalytics.Event.SELECT_ITEM, bundle);
521
            }
522
          }
523
        }
524
      }
525

    
526
///////////////////////////////////////////////////////////////////////////////////////////////////
527

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

    
537
      control.changeIfDifferent(ordinal,name,meshState,iconMode,jsonStream,meshStream);
538
      }
539

    
540
///////////////////////////////////////////////////////////////////////////////////////////////////
541

    
542
    public static int getDrawableSize()
543
      {
544
      if( mScreenHeight<1000 )
545
        {
546
        return 0;
547
        }
548
      if( mScreenHeight<1600 )
549
        {
550
        return 1;
551
        }
552
      if( mScreenHeight<1900 )
553
        {
554
        return 2;
555
        }
556

    
557
      return 3;
558
      }
559

    
560
///////////////////////////////////////////////////////////////////////////////////////////////////
561

    
562
    public static int getDrawable(int small, int medium, int big, int huge)
563
      {
564
      int size = getDrawableSize();
565

    
566
      switch(size)
567
        {
568
        case 0 : return small;
569
        case 1 : return medium;
570
        case 2 : return big;
571
        default: return huge;
572
        }
573
      }
574

    
575
///////////////////////////////////////////////////////////////////////////////////////////////////
576

    
577
    public void acceptPrivacy()
578
      {
579
      mPolicyAccepted = true;
580
      }
581

    
582
///////////////////////////////////////////////////////////////////////////////////////////////////
583

    
584
    public void declinePrivacy()
585
      {
586
      finish();
587
      }
588

    
589
///////////////////////////////////////////////////////////////////////////////////////////////////
590

    
591
    public static boolean localeIsChinese()
592
      {
593
      String language;
594

    
595
      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
596
        {
597
        language= LocaleList.getDefault().get(0).getLanguage();
598
        }
599
      else
600
        {
601
        language= Locale.getDefault().getLanguage();
602
        }
603

    
604
      return language.equals("zh");
605
      }
606

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

    
609
    public boolean isVertical()
610
      {
611
      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
612
      return view.isVertical();
613
      }
614

    
615
///////////////////////////////////////////////////////////////////////////////////////////////////
616

    
617
    public void blockEverything(int place)
618
      {
619
      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
620
      ObjectControl control = view.getObjectControl();
621
      control.blockEverything(place);
622

    
623
      RubikScreenPlay play = (RubikScreenPlay) ScreenList.PLAY.getScreenClass();
624
      play.setLockState(this);
625
      }
626

    
627
///////////////////////////////////////////////////////////////////////////////////////////////////
628

    
629
    public void unblockEverything()
630
      {
631
      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
632
      ObjectControl control = view.getObjectControl();
633
      control.unblockEverything();
634

    
635
      RubikScreenPlay play = (RubikScreenPlay) ScreenList.PLAY.getScreenClass();
636
      play.setLockState(this);
637
      }
638

    
639
///////////////////////////////////////////////////////////////////////////////////////////////////
640

    
641
    public void switchTutorial(String url, int objectOrdinal)
642
      {
643
      Intent intent = new Intent(this, TutorialActivity.class);
644
      intent.putExtra("url", url);
645
      intent.putExtra("obj", objectOrdinal);
646
      startActivity(intent);
647
      }
648

    
649
///////////////////////////////////////////////////////////////////////////////////////////////////
650

    
651
    public void switchConfig(int objectOrdinal)
652
      {
653
      Intent intent = new Intent(this, ConfigActivity.class);
654
      intent.putExtra("obj", objectOrdinal);
655
      startActivity(intent);
656
      }
657

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

    
660
    public void switchToBandagedCreator()
661
      {
662
      Intent intent = new Intent(this, BandagedCreatorActivity.class);
663
      startActivity(intent);
664
      }
665

    
666
///////////////////////////////////////////////////////////////////////////////////////////////////
667

    
668
    public void reloadObject(String shortName)
669
      {
670
      TwistyObject currObject = getObject();
671
      String name = currObject==null ? "" : currObject.getShortName();
672

    
673
      if( name.toLowerCase(Locale.ENGLISH).equals(shortName) )
674
        {
675
        RubikObject object = RubikObjectList.getObject(name);
676

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