Project

General

Profile

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

magiccube / src / main / java / org / distorted / main / RubikActivity.java @ 5e048300

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.RubikScreenSolving;
60
import org.distorted.screens.ScreenList;
61
import org.distorted.screens.RubikScreenPlay;
62
import org.distorted.tutorials.TutorialActivity;
63

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

    
66
///////////////////////////////////////////////////////////////////////////////////////////////////
67

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

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

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

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

    
103
    private static final String KEY_PLAY = "movesController_play";
104
    private static final String KEY_SOLV = "movesController_solv";
105

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

    
113
///////////////////////////////////////////////////////////////////////////////////////////////////
114

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

    
121
      setTheme(R.style.MaterialThemeNoActionBar);
122
      setContentView(R.layout.main);
123

    
124
      mJustStarted = true;
125
      mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);
126
      mIsChinese = localeIsChinese();
127

    
128
      DisplayMetrics displaymetrics = new DisplayMetrics();
129
      getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
130
      mScreenWidth =displaymetrics.widthPixels;
131
      mScreenHeight=displaymetrics.heightPixels;
132
      mScreenHeight = (int)(1.07f*mScreenHeight); // add 7% for the upper bar
133
                                                  // which is not yet hidden.
134
                                                  // TODO: figure this out exactly.
135
      hideNavigationBar();
136
      cutoutHack();
137
      computeBarHeights();
138
      }
139

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

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

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

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

    
161
///////////////////////////////////////////////////////////////////////////////////////////////////
162

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

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

    
171
        decorView.setSystemUiVisibility(FLAGS);
172

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

    
187
///////////////////////////////////////////////////////////////////////////////////////////////////
188

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

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

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

    
207
///////////////////////////////////////////////////////////////////////////////////////////////////
208
// do not avoid cutouts
209

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

    
218
///////////////////////////////////////////////////////////////////////////////////////////////////
219

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

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

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

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

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

    
258
      restoreMoves();
259

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

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

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

    
285
///////////////////////////////////////////////////////////////////////////////////////////////////
286

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

    
300
///////////////////////////////////////////////////////////////////////////////////////////////////
301

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

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

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

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

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

    
326
      ScreenList curr = ScreenList.getCurrentScreen();
327

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

    
339
      editor.apply();
340
      }
341

    
342
///////////////////////////////////////////////////////////////////////////////////////////////////
343

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

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

    
351
      RubikObjectList.restorePreferences(this,preferences);
352

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

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

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

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

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

    
380
      RubikScores scores = RubikScores.getInstance();
381

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

    
389
///////////////////////////////////////////////////////////////////////////////////////////////////
390

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

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

    
408
///////////////////////////////////////////////////////////////////////////////////////////////////
409

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

    
416
///////////////////////////////////////////////////////////////////////////////////////////////////
417

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

    
424
///////////////////////////////////////////////////////////////////////////////////////////////////
425

    
426
    void setScreenSize(int width, int height)
427
      {
428
      mScreenWidth = width;
429
      mScreenHeight= height;
430
      }
431

    
432
///////////////////////////////////////////////////////////////////////////////////////////////////
433
// PUBLIC API
434
///////////////////////////////////////////////////////////////////////////////////////////////////
435

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

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

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

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

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

    
455
///////////////////////////////////////////////////////////////////////////////////////////////////
456

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

    
463
///////////////////////////////////////////////////////////////////////////////////////////////////
464

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

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

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

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

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

    
485
///////////////////////////////////////////////////////////////////////////////////////////////////
486

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

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

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

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

    
525
///////////////////////////////////////////////////////////////////////////////////////////////////
526

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

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

    
539
///////////////////////////////////////////////////////////////////////////////////////////////////
540

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

    
556
      return 3;
557
      }
558

    
559
///////////////////////////////////////////////////////////////////////////////////////////////////
560

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

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

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

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

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

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

    
588
///////////////////////////////////////////////////////////////////////////////////////////////////
589

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

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

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

    
606
///////////////////////////////////////////////////////////////////////////////////////////////////
607

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

    
614
///////////////////////////////////////////////////////////////////////////////////////////////////
615

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

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

    
626
///////////////////////////////////////////////////////////////////////////////////////////////////
627

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

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

    
638
///////////////////////////////////////////////////////////////////////////////////////////////////
639

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

    
648
///////////////////////////////////////////////////////////////////////////////////////////////////
649

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

    
657
///////////////////////////////////////////////////////////////////////////////////////////////////
658

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

    
665
///////////////////////////////////////////////////////////////////////////////////////////////////
666

    
667
    public void reloadObject(String shortName)
668
      {
669
      TwistyObject currObject = getObject();
670
      String name = currObject.getShortName();
671

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

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