Project

General

Profile

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

magiccube / src / main / java / org / distorted / main / RubikActivity.java @ 85038b84

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.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().getRealMetrics(displaymetrics);
130
      mScreenWidth  = (int)(displaymetrics.widthPixels);
131
      mScreenHeight = (int)(displaymetrics.heightPixels);
132

    
133
      hideNavigationBar();
134
      cutoutHack();
135
      computeBarHeights();
136
      }
137

    
138
///////////////////////////////////////////////////////////////////////////////////////////////////
139
// this does not include possible insets
140

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

    
147
      LinearLayout layoutTop = findViewById(R.id.upperBar);
148
      LinearLayout layoutBot = findViewById(R.id.lowerBar);
149

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

    
158
///////////////////////////////////////////////////////////////////////////////////////////////////
159

    
160
    private void hideNavigationBar()
161
      {
162
      mCurrentApiVersion = Build.VERSION.SDK_INT;
163

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

    
168
        decorView.setSystemUiVisibility(FLAGS);
169

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

    
184
///////////////////////////////////////////////////////////////////////////////////////////////////
185

    
186
    @Override
187
    public void onAttachedToWindow()
188
      {
189
      super.onAttachedToWindow();
190

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

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

    
204
///////////////////////////////////////////////////////////////////////////////////////////////////
205
// do not avoid cutouts
206

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

    
215
///////////////////////////////////////////////////////////////////////////////////////////////////
216

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

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

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

    
241
///////////////////////////////////////////////////////////////////////////////////////////////////
242

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

    
252
      ScreenList.setScreen(this);
253
      unblockEverything();
254

    
255
      restoreMoves();
256

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

    
267
      int object = RubikObjectList.getCurrObject();
268
      changeIfDifferent(object,view.getObjectControl());
269

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

    
282
///////////////////////////////////////////////////////////////////////////////////////////////////
283

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

    
297
///////////////////////////////////////////////////////////////////////////////////////////////////
298

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

    
304
      editor.putBoolean("policyAccepted", mPolicyAccepted);
305
      editor.putString("appVersion", getAppVers() );
306

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

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

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

    
323
      ScreenList curr = ScreenList.getCurrentScreen();
324

    
325
      if( curr==ScreenList.FREE )
326
        {
327
        RubikScreenFreePlay free = (RubikScreenFreePlay)ScreenList.FREE.getScreenClass();
328
        free.saveMovePreferences(KEY_PLAY,editor);
329
        }
330
      if( curr==ScreenList.SOLV )
331
        {
332
        RubikScreenSolving solv = (RubikScreenSolving)ScreenList.SOLV.getScreenClass();
333
        solv.saveMovePreferences(KEY_SOLV,editor);
334
        }
335

    
336
      editor.apply();
337
      }
338

    
339
///////////////////////////////////////////////////////////////////////////////////////////////////
340

    
341
    private void restorePreferences()
342
      {
343
      SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
344

    
345
      mPolicyAccepted = preferences.getBoolean("policyAccepted", false);
346
      String oldVersion = preferences.getString("appVersion","");
347

    
348
      RubikObjectList.restorePreferences(this,preferences);
349

    
350
      for (int i=0; i<BaseEffect.Type.LENGTH; i++)
351
        {
352
        BaseEffect.Type.getType(i).restorePreferences(preferences);
353
        }
354

    
355
      for (int i=0; i<ScreenList.LENGTH; i++)
356
        {
357
        ScreenList.getScreen(i).getScreenClass().restorePreferences(preferences);
358
        }
359

    
360
      ScreenList.restorePreferences(preferences);
361
      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
362

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

    
372
      if( !oldVersion.equals("") )
373
        {
374
        view.getObjectControl().restorePreferences(preferences);
375
        }
376

    
377
      RubikScores scores = RubikScores.getInstance();
378

    
379
      if( scores.isVerified() )
380
        {
381
        FirebaseAnalytics analytics = getAnalytics();
382
        analytics.setUserId(scores.getName());
383
        }
384
      }
385

    
386
///////////////////////////////////////////////////////////////////////////////////////////////////
387

    
388
    private void restoreMoves()
389
      {
390
      SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
391
      ScreenList curr = ScreenList.getCurrentScreen();
392

    
393
      if( curr==ScreenList.FREE )
394
        {
395
        RubikScreenFreePlay free = (RubikScreenFreePlay)ScreenList.FREE.getScreenClass();
396
        free.restoreMovePreferences(this,KEY_PLAY,preferences);
397
        }
398
      if( curr==ScreenList.SOLV )
399
        {
400
        RubikScreenSolving solv = (RubikScreenSolving)ScreenList.SOLV.getScreenClass();
401
        solv.restoreMovePreferences(this,KEY_SOLV,preferences);
402
        }
403
      }
404

    
405
///////////////////////////////////////////////////////////////////////////////////////////////////
406

    
407
    private void PrivacyPolicy()
408
      {
409
      RubikDialogPrivacy priDiag = new RubikDialogPrivacy();
410
      priDiag.show(getSupportFragmentManager(), null);
411
      }
412

    
413
///////////////////////////////////////////////////////////////////////////////////////////////////
414

    
415
    void OpenGLError()
416
      {
417
      RubikDialogError errDiag = new RubikDialogError();
418
      errDiag.show(getSupportFragmentManager(), null);
419
      }
420

    
421
///////////////////////////////////////////////////////////////////////////////////////////////////
422
// PUBLIC API
423
///////////////////////////////////////////////////////////////////////////////////////////////////
424

    
425
    public FirebaseAnalytics getAnalytics()
426
      {
427
      return mFirebaseAnalytics;
428
      }
429

    
430
///////////////////////////////////////////////////////////////////////////////////////////////////
431

    
432
    public int getHeightUpperBar()
433
      {
434
      return mHeightUpperBar;
435
      }
436

    
437
///////////////////////////////////////////////////////////////////////////////////////////////////
438

    
439
    public int getHeightLowerBar()
440
      {
441
      return mHeightLowerBar;
442
      }
443

    
444
///////////////////////////////////////////////////////////////////////////////////////////////////
445

    
446
    public TwistyObject getObject()
447
      {
448
      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
449
      return view.getObjectControl().getObject();
450
      }
451

    
452
///////////////////////////////////////////////////////////////////////////////////////////////////
453

    
454
    public ObjectControl getControl()
455
      {
456
      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
457
      return view.getObjectControl();
458
      }
459

    
460
///////////////////////////////////////////////////////////////////////////////////////////////////
461

    
462
    public int getScreenWidthInPixels()
463
      {
464
      return mScreenWidth;
465
      }
466

    
467
///////////////////////////////////////////////////////////////////////////////////////////////////
468

    
469
    public int getScreenHeightInPixels()
470
      {
471
      return mScreenHeight;
472
      }
473

    
474
///////////////////////////////////////////////////////////////////////////////////////////////////
475

    
476
    public void changeObject(int newObject, boolean reportChange)
477
      {
478
      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
479
      ObjectControl control = view.getObjectControl();
480
      TwistyObject oldObject = control.getObject();
481
      changeIfDifferent(newObject,control);
482

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

    
496
        if( BuildConfig.DEBUG )
497
          {
498
          android.util.Log.e("rubik", name.toString());
499
          }
500
        else
501
          {
502
          FirebaseAnalytics analytics = getAnalytics();
503

    
504
          if( analytics!=null )
505
            {
506
            Bundle bundle = new Bundle();
507
            bundle.putString(FirebaseAnalytics.Param.ITEM_NAME, name.toString());
508
            analytics.logEvent(FirebaseAnalytics.Event.SELECT_ITEM, bundle);
509
            }
510
          }
511
        }
512
      }
513

    
514
///////////////////////////////////////////////////////////////////////////////////////////////////
515

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

    
525
      control.changeIfDifferent(ordinal,name,meshState,iconMode,jsonStream,meshStream);
526
      }
527

    
528
///////////////////////////////////////////////////////////////////////////////////////////////////
529

    
530
    public static int getDrawableSize()
531
      {
532
      if( mScreenHeight<1000 )
533
        {
534
        return 0;
535
        }
536
      if( mScreenHeight<1600 )
537
        {
538
        return 1;
539
        }
540
      if( mScreenHeight<1900 )
541
        {
542
        return 2;
543
        }
544

    
545
      return 3;
546
      }
547

    
548
///////////////////////////////////////////////////////////////////////////////////////////////////
549

    
550
    public static int getDrawable(int small, int medium, int big, int huge)
551
      {
552
      int size = getDrawableSize();
553

    
554
      switch(size)
555
        {
556
        case 0 : return small;
557
        case 1 : return medium;
558
        case 2 : return big;
559
        default: return huge;
560
        }
561
      }
562

    
563
///////////////////////////////////////////////////////////////////////////////////////////////////
564

    
565
    public void acceptPrivacy()
566
      {
567
      mPolicyAccepted = true;
568
      }
569

    
570
///////////////////////////////////////////////////////////////////////////////////////////////////
571

    
572
    public void declinePrivacy()
573
      {
574
      finish();
575
      }
576

    
577
///////////////////////////////////////////////////////////////////////////////////////////////////
578

    
579
    public static boolean localeIsChinese()
580
      {
581
      String language;
582

    
583
      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
584
        {
585
        language= LocaleList.getDefault().get(0).getLanguage();
586
        }
587
      else
588
        {
589
        language= Locale.getDefault().getLanguage();
590
        }
591

    
592
      return language.equals("zh");
593
      }
594

    
595
///////////////////////////////////////////////////////////////////////////////////////////////////
596

    
597
    public boolean isVertical()
598
      {
599
      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
600
      return view.isVertical();
601
      }
602

    
603
///////////////////////////////////////////////////////////////////////////////////////////////////
604

    
605
    public void blockEverything(int place)
606
      {
607
      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
608
      ObjectControl control = view.getObjectControl();
609
      control.blockEverything(place);
610
      ScreenList curr = ScreenList.getCurrentScreen();
611

    
612
      if( curr==ScreenList.FREE )
613
        {
614
        RubikScreenFreePlay free = (RubikScreenFreePlay)ScreenList.FREE.getScreenClass();
615
        free.setLockState(this);
616
        }
617
      if( curr==ScreenList.SOLV )
618
        {
619
        RubikScreenSolving solv = (RubikScreenSolving)ScreenList.SOLV.getScreenClass();
620
        solv.setLockState(this);
621
        }
622
      }
623

    
624
///////////////////////////////////////////////////////////////////////////////////////////////////
625

    
626
    public void unblockEverything()
627
      {
628
      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
629
      ObjectControl control = view.getObjectControl();
630
      control.unblockEverything();
631
      ScreenList curr = ScreenList.getCurrentScreen();
632

    
633
      if( curr==ScreenList.FREE )
634
        {
635
        RubikScreenFreePlay free = (RubikScreenFreePlay)ScreenList.FREE.getScreenClass();
636
        free.setLockState(this);
637
        }
638
      if( curr==ScreenList.SOLV )
639
        {
640
        RubikScreenSolving solv = (RubikScreenSolving)ScreenList.SOLV.getScreenClass();
641
        solv.setLockState(this);
642
        }
643
      }
644

    
645
///////////////////////////////////////////////////////////////////////////////////////////////////
646

    
647
    public void switchTutorial(String url, int objectOrdinal)
648
      {
649
      Intent intent = new Intent(this, TutorialActivity.class);
650
      intent.putExtra("url", url);
651
      intent.putExtra("obj", objectOrdinal);
652
      startActivity(intent);
653
      }
654

    
655
///////////////////////////////////////////////////////////////////////////////////////////////////
656

    
657
    public void switchConfig(int objectOrdinal)
658
      {
659
      Intent intent = new Intent(this, ConfigActivity.class);
660
      intent.putExtra("obj", objectOrdinal);
661
      startActivity(intent);
662
      }
663

    
664
///////////////////////////////////////////////////////////////////////////////////////////////////
665

    
666
    public void switchToBandagedCreator()
667
      {
668
      Intent intent = new Intent(this, BandagedCreatorActivity.class);
669
      startActivity(intent);
670
      }
671

    
672
///////////////////////////////////////////////////////////////////////////////////////////////////
673

    
674
    public void switchRenderingOff()
675
      {
676
      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
677
      RubikRenderer renderer = view.getRenderer();
678
      renderer.switchRendering(false);
679
      }
680

    
681
///////////////////////////////////////////////////////////////////////////////////////////////////
682

    
683
    public void switchRenderingOn()
684
      {
685
      RubikSurfaceView view  = findViewById(R.id.rubikSurfaceView);
686
      RubikRenderer renderer = view.getRenderer();
687
      renderer.switchRendering(true);
688
      }
689

    
690
///////////////////////////////////////////////////////////////////////////////////////////////////
691

    
692
    public void reloadObject(String shortName)
693
      {
694
      TwistyObject currObject = getObject();
695
      String name = currObject==null ? "" : currObject.getShortName();
696

    
697
      if( name.toLowerCase(Locale.ENGLISH).equals(shortName) )
698
        {
699
        RubikObject object = RubikObjectList.getObject(name);
700

    
701
        if( object!=null )
702
          {
703
          int meshState = object.getMeshState();
704
          int iconMode  = TwistyObject.MODE_NORM;
705
          InputStream jsonStream = object.getObjectStream(this);
706
          InputStream meshStream = object.getMeshStream(this);
707
          ObjectControl control = getControl();
708
          control.changeObject(-1,meshState,iconMode,jsonStream,meshStream);
709
          }
710
        }
711
      }
712
}
(1-1/4)