Project

General

Profile

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

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

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 PATTERN_GROUP_TEXT  = 0.03f;
81
    public static final float PATTERN_CHILD_TEXT  = 0.02f;
82
    public static final float SCORES_LEVEL_TEXT   = 0.035f;
83
    public static final float SCORES_ITEM_TEXT    = 0.030f;
84
    public static final float TUTORIAL_ITEM_TEXT  = 0.100f;
85
    public static final float DIALOG_BUTTON_SIZE  = 0.06f;
86
    public static final float MENU_BIG_TEXT_SIZE  = 0.05f;
87
    public static final float MENU_MAIN_TEXT_SIZE = 0.047f;
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
    public static final float MENU_BUTTON_HEIGHT  = 0.120f;
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

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

    
114
///////////////////////////////////////////////////////////////////////////////////////////////////
115

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

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

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

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

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

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

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

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

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

    
159
///////////////////////////////////////////////////////////////////////////////////////////////////
160

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

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

    
169
        decorView.setSystemUiVisibility(FLAGS);
170

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

    
185
///////////////////////////////////////////////////////////////////////////////////////////////////
186

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

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

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

    
205
///////////////////////////////////////////////////////////////////////////////////////////////////
206
// do not avoid cutouts
207

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

    
216
///////////////////////////////////////////////////////////////////////////////////////////////////
217

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

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

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

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

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

    
256
      restoreMoves();
257

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

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

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

    
283
///////////////////////////////////////////////////////////////////////////////////////////////////
284

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

    
298
///////////////////////////////////////////////////////////////////////////////////////////////////
299

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

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

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

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

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

    
324
      ScreenList curr = ScreenList.getCurrentScreen();
325

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

    
337
      editor.apply();
338
      }
339

    
340
///////////////////////////////////////////////////////////////////////////////////////////////////
341

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

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

    
349
      RubikObjectList.restorePreferences(this,preferences);
350

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

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

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

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

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

    
378
      RubikScores scores = RubikScores.getInstance();
379

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

    
387
///////////////////////////////////////////////////////////////////////////////////////////////////
388

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

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

    
406
///////////////////////////////////////////////////////////////////////////////////////////////////
407

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

    
414
///////////////////////////////////////////////////////////////////////////////////////////////////
415

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

    
422
///////////////////////////////////////////////////////////////////////////////////////////////////
423
// PUBLIC API
424
///////////////////////////////////////////////////////////////////////////////////////////////////
425

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

    
431
///////////////////////////////////////////////////////////////////////////////////////////////////
432

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

    
438
///////////////////////////////////////////////////////////////////////////////////////////////////
439

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

    
445
///////////////////////////////////////////////////////////////////////////////////////////////////
446

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

    
453
///////////////////////////////////////////////////////////////////////////////////////////////////
454

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

    
461
///////////////////////////////////////////////////////////////////////////////////////////////////
462

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

    
468
///////////////////////////////////////////////////////////////////////////////////////////////////
469

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

    
475
///////////////////////////////////////////////////////////////////////////////////////////////////
476

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

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

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

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

    
515
///////////////////////////////////////////////////////////////////////////////////////////////////
516

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

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

    
529
///////////////////////////////////////////////////////////////////////////////////////////////////
530

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

    
546
      return 3;
547
      }
548

    
549
///////////////////////////////////////////////////////////////////////////////////////////////////
550

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

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

    
564
///////////////////////////////////////////////////////////////////////////////////////////////////
565

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

    
571
///////////////////////////////////////////////////////////////////////////////////////////////////
572

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

    
578
///////////////////////////////////////////////////////////////////////////////////////////////////
579

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

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

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

    
596
///////////////////////////////////////////////////////////////////////////////////////////////////
597

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

    
604
///////////////////////////////////////////////////////////////////////////////////////////////////
605

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

    
612
      RubikScreenPlay play = (RubikScreenPlay) ScreenList.PLAY.getScreenClass();
613
      play.setLockState(this);
614
      }
615

    
616
///////////////////////////////////////////////////////////////////////////////////////////////////
617

    
618
    public void unblockEverything()
619
      {
620
      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
621
      ObjectControl control = view.getObjectControl();
622
      control.unblockEverything();
623

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

    
628
///////////////////////////////////////////////////////////////////////////////////////////////////
629

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

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

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

    
647
///////////////////////////////////////////////////////////////////////////////////////////////////
648

    
649
    public void switchToBandagedCreator()
650
      {
651
      Intent intent = new Intent(this, BandagedCreatorActivity.class);
652
      startActivity(intent);
653
      }
654

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

    
657
    public void reloadObject(String shortName)
658
      {
659
      TwistyObject currObject = getObject();
660
      String name = currObject==null ? "" : currObject.getShortName();
661

    
662
      if( name.toLowerCase(Locale.ENGLISH).equals(shortName) )
663
        {
664
        RubikObject object = RubikObjectList.getObject(name);
665

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