Project

General

Profile

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

magiccube / src / main / java / org / distorted / main_old / RubikActivity.java @ b42c8399

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2019 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// Magic Cube is proprietary software licensed under an EULA which you should have received      //
7
// along with the code. If not, check https://distorted.org/magic/License-Magic-Cube.html        //
8
///////////////////////////////////////////////////////////////////////////////////////////////////
9

    
10
package org.distorted.main_old;
11

    
12
import java.io.InputStream;
13
import java.util.Locale;
14

    
15
import android.content.Intent;
16
import android.content.SharedPreferences;
17
import android.content.pm.PackageInfo;
18
import android.content.pm.PackageManager;
19
import android.os.Build;
20
import android.os.Bundle;
21

    
22
import android.util.DisplayMetrics;
23
import android.view.DisplayCutout;
24
import android.view.View;
25
import android.view.ViewGroup;
26
import android.view.WindowManager;
27
import android.widget.LinearLayout;
28

    
29
import androidx.appcompat.app.AppCompatActivity;
30
import androidx.preference.PreferenceManager;
31

    
32
import com.google.firebase.analytics.FirebaseAnalytics;
33
import com.google.firebase.inappmessaging.FirebaseInAppMessaging;
34

    
35
import org.distorted.config.ConfigActivity;
36
import org.distorted.bandaged.BandagedCreatorActivity;
37
import org.distorted.dialogs.RubikDialogAbout;
38
import org.distorted.library.main.DistortedLibrary;
39

    
40
import org.distorted.library.main.DistortedScreen;
41
import org.distorted.main.BuildConfig;
42
import org.distorted.main.R;
43
import org.distorted.messaging.RubikInAppMessanging;
44
import org.distorted.objectlib.helpers.OperatingSystemInterface;
45
import org.distorted.objectlib.main.InitAssets;
46
import org.distorted.objectlib.main.ObjectControl;
47
import org.distorted.objectlib.main.TwistyObject;
48

    
49
import org.distorted.dialogs.RubikDialogError;
50
import org.distorted.external.RubikScores;
51
import org.distorted.external.RubikNetwork;
52
import org.distorted.objects.RubikObject;
53
import org.distorted.objects.RubikObjectList;
54
import org.distorted.os.OSInterface;
55
import org.distorted.purchase.PurchaseActivity;
56
import org.distorted.screens.RubikScreenSolving;
57
import org.distorted.screens.ScreenList;
58
import org.distorted.screens.RubikScreenPlay;
59
import org.distorted.tutorials.TutorialActivity;
60

    
61
import static org.distorted.objectlib.main.TwistyObject.MESH_NICE;
62

    
63
///////////////////////////////////////////////////////////////////////////////////////////////////
64

    
65
public class RubikActivity extends AppCompatActivity
66
{
67
    public static final boolean SHOW_DOWNLOADED_DEBUG = false;
68
    public static final boolean SHOW_IAP_DEBUG        = false;
69
    public static final boolean USE_IAP               = false;
70

    
71
    public static final float PADDING             = 0.010f;
72
    public static final float SMALL_MARGIN        = 0.004f;
73
    public static final float BUTTON_TEXT_SIZE    = 0.050f;
74
    public static final float TITLE_TEXT_SIZE     = 0.060f;
75
    public static final float PATTERN_GROUP_TEXT  = 0.030f;
76
    public static final float PATTERN_CHILD_TEXT  = 0.020f;
77
    public static final float SCORES_LEVEL_TEXT   = 0.035f;
78
    public static final float SCORES_ITEM_TEXT    = 0.025f;
79
    public static final float TAB_WIDTH           = 0.066f;
80
    public static final float TAB_HEIGHT          = 0.066f;
81
    public static final float POPUP_PADDING       = 0.028f;
82
    public static final float POPUP_MARGIN        = 0.016f;
83
    public static final float POPUP_BOTTOM        = 0.090f;
84
    public static final float RATIO_BAR           = 0.100f;
85

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

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

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

    
98
    private boolean mJustStarted;
99
    private FirebaseAnalytics mFirebaseAnalytics;
100
    private static int mScreenWidth, mScreenHeight;
101
    private int mCurrentApiVersion;
102
    private int mHeightUpperBar;
103
    private int mOldVersion1, mOldVersion2, mOldVersion3;
104
    private String mOldVersion, mCurrVersion;
105
    private int mSolverIndex;
106

    
107
///////////////////////////////////////////////////////////////////////////////////////////////////
108

    
109
    @Override
110
    protected void onCreate(Bundle savedState)
111
      {
112
      super.onCreate(savedState);
113
      DistortedLibrary.onCreate(ACTIVITY_NUMBER);
114
      setTheme(R.style.MaterialThemeNoActionBar);
115
      setContentView(R.layout.main);
116
      hideNavigationBar();
117

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

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

    
126
      cutoutHack();
127
      computeBarHeights();
128

    
129
      mCurrVersion = getAppVers();
130
      mSolverIndex = 0;
131

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

    
141
      thread.start();
142
      }
143

    
144
///////////////////////////////////////////////////////////////////////////////////////////////////
145
// this does not include possible insets
146

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

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

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

    
163
///////////////////////////////////////////////////////////////////////////////////////////////////
164

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

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

    
173
        decorView.setSystemUiVisibility(FLAGS);
174

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

    
189
///////////////////////////////////////////////////////////////////////////////////////////////////
190

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

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

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

    
209
///////////////////////////////////////////////////////////////////////////////////////////////////
210
// do not avoid cutouts
211

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

    
220
///////////////////////////////////////////////////////////////////////////////////////////////////
221

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

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

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

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

    
256
      SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
257
      restorePreferences(preferences,mJustStarted);
258
      ScreenList.setScreen(this);
259
      restoreMoves(preferences);
260

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

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

    
273
      if( !mOldVersion.equals(mCurrVersion) ) displayNovelties();
274
      else if( USE_IAP ) view.setShowStars();
275
      }
276

    
277
///////////////////////////////////////////////////////////////////////////////////////////////////
278

    
279
    private void displayNovelties()
280
      {
281
      Bundle bundle = new Bundle();
282
      bundle.putString("argument",mOldVersion);
283
      RubikDialogAbout newDialog = new RubikDialogAbout();
284
      newDialog.setArguments(bundle);
285
      newDialog.show(getSupportFragmentManager(), RubikDialogAbout.getDialogTag() );
286
      }
287

    
288
///////////////////////////////////////////////////////////////////////////////////////////////////
289
    
290
    @Override
291
    protected void onDestroy() 
292
      {
293
      DistortedLibrary.onDestroy(ACTIVITY_NUMBER);
294
      super.onDestroy();
295
      }
296

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

    
299
    private String getAppVers()
300
      {
301
      try
302
        {
303
        PackageInfo pInfo = getPackageManager().getPackageInfo( getPackageName(), 0);
304
        return pInfo.versionName;
305
        }
306
      catch (PackageManager.NameNotFoundException e)
307
        {
308
        return "unknown";
309
        }
310
      }
311

    
312
///////////////////////////////////////////////////////////////////////////////////////////////////
313

    
314
    private void savePreferences()
315
      {
316
      SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
317
      SharedPreferences.Editor editor = preferences.edit();
318

    
319
      editor.putString("appVersion", mCurrVersion );
320
      editor.putInt("solverIndex", mSolverIndex );
321

    
322
      for( int i=0; i< ScreenList.LENGTH; i++ )
323
        {
324
        ScreenList.getScreen(i).getScreenClass().savePreferences(editor);
325
        }
326

    
327
      RubikObjectList.savePreferences(editor);
328
      RubikObjectList.saveMeshState(editor);
329
      ScreenList.savePreferences(editor);
330
      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
331
      OSInterface os = view.getInterface();
332
      os.setEditor(editor);
333
      view.getObjectControl().savePreferences();
334

    
335
      ScreenList curr = ScreenList.getCurrentScreen();
336

    
337
      if( curr==ScreenList.PLAY )
338
        {
339
        RubikScreenPlay play = (RubikScreenPlay)ScreenList.PLAY.getScreenClass();
340
        play.saveMovePreferences(KEY_PLAY,editor);
341
        }
342
      if( curr==ScreenList.SOLV )
343
        {
344
        RubikScreenSolving solv = (RubikScreenSolving)ScreenList.SOLV.getScreenClass();
345
        solv.saveMovePreferences(KEY_SOLV,editor);
346
        }
347

    
348
      boolean success = editor.commit();
349
      if( !success ) android.util.Log.e("D", "Failed to save preferences");
350
      }
351

    
352
///////////////////////////////////////////////////////////////////////////////////////////////////
353

    
354
    private void restorePreferences(SharedPreferences preferences, boolean justStarted)
355
      {
356
      mOldVersion = preferences.getString("appVersion","");
357
      mSolverIndex = preferences.getInt("solverIndex",0);
358

    
359
      parseOldVersion(mOldVersion);
360

    
361
      RubikObjectList.restorePreferences(this,preferences,justStarted);
362

    
363
      for (int i=0; i<ScreenList.LENGTH; i++)
364
        {
365
        ScreenList.getScreen(i).getScreenClass().restorePreferences(preferences);
366
        }
367

    
368
      RubikScores scores = RubikScores.getInstance();
369

    
370
      if( scores.isVerified() )
371
        {
372
        FirebaseAnalytics analytics = getAnalytics();
373
        analytics.setUserId(scores.getName());
374
        }
375

    
376
      // all old users upgrading from version <1.11.4, where there was no concept of 'stars',
377
      // get all the stars they have earned
378
      int numStars = scores.getNumStars();
379

    
380
      if( justStarted && numStars==0 && oldVersionLessThan(1,11,4) )
381
        {
382
        scores.correctNumStars();
383
        }
384

    
385
      // in 1.11.5 we have introduced IAP. When upgrading from something less than 1.11.5 to
386
      // something at least 1.11.5, mark all solved objects as free.
387
      // this needs to be after the above ScreenList.getScreen(i).getScreenClass().restorePreferences()
388
      // as that restores the Records which we need here
389
      // also needs to be after RubikObjectList.restorePreferences()
390
      if( USE_IAP && justStarted && oldVersionLessThan(1,11,5) && !mCurrVersion.equals("1.11.4") )
391
        {
392
        RubikObjectList.firstUpgradeMarkAllSolvedAsFree();
393
        }
394

    
395
      ScreenList.restorePreferences(preferences);
396

    
397
      // Versions <= 1.8.6 did not save their 'appVersion' to preferences, therefore in their
398
      // case the 'mOldVersion' - version of the app which saved the preferences on the last
399
      // go - is empty.
400
      // Between versions 1.8.6 and 1.9.0, the order of the cubits in TwistyCube has changed.
401
      // If someone has scrambled the cube with v. 1.8.6, then upgraded to 1.9.0 and re-started
402
      // the app, because of the different order of the cubits - his cube would be messed up.
403
      // So in such case, i.e. on fresh upgrade from version<=1.8.6 to version>=1.9.0, do not
404
      // restore the object scrambling.
405

    
406
      if( !mOldVersion.equals("") )
407
        {
408
        RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
409
        OSInterface os = view.getInterface();
410
        os.setPreferences(preferences);
411
        view.getObjectControl().restorePreferences();
412
        }
413
      }
414

    
415
///////////////////////////////////////////////////////////////////////////////////////////////////
416

    
417
    private void parseOldVersion(String version)
418
      {
419
      if( version==null ) return;
420

    
421
      try
422
        {
423
        String[] parts = version.split("\\.");
424

    
425
        if( parts.length==3 )
426
          {
427
          mOldVersion1 = Integer.parseInt(parts[0]);
428
          mOldVersion2 = Integer.parseInt(parts[1]);
429
          mOldVersion3 = Integer.parseInt(parts[2]);
430
          }
431
        }
432
      catch(Exception ignored)
433
        {
434
        mOldVersion1 = 0;
435
        mOldVersion2 = 0;
436
        mOldVersion3 = 0;
437
        }
438
      }
439

    
440
///////////////////////////////////////////////////////////////////////////////////////////////////
441

    
442
    private boolean oldVersionLessThan(int v1, int v2, int v3)
443
      {
444
      if( mOldVersion1<v1 ) return true;
445
      if( mOldVersion1>v1 ) return false;
446
      if( mOldVersion2<v2 ) return true;
447
      if( mOldVersion2>v2 ) return false;
448
      return mOldVersion3<v3;
449
      }
450

    
451
///////////////////////////////////////////////////////////////////////////////////////////////////
452

    
453
    private void restoreMoves(SharedPreferences preferences)
454
      {
455
      ScreenList curr = ScreenList.getCurrentScreen();
456

    
457
      if( curr==ScreenList.PLAY )
458
        {
459
        RubikScreenPlay play = (RubikScreenPlay)ScreenList.PLAY.getScreenClass();
460
        play.restoreMovePreferences(this,KEY_PLAY,preferences);
461
        }
462
      if( curr==ScreenList.SOLV )
463
        {
464
        RubikScreenSolving solv = (RubikScreenSolving)ScreenList.SOLV.getScreenClass();
465
        solv.restoreMovePreferences(this,KEY_SOLV,preferences);
466
        }
467
      }
468

    
469
///////////////////////////////////////////////////////////////////////////////////////////////////
470

    
471
    void OpenGLError()
472
      {
473
      RubikDialogError errDiag = new RubikDialogError();
474
      errDiag.show(getSupportFragmentManager(), null);
475
      }
476

    
477
///////////////////////////////////////////////////////////////////////////////////////////////////
478
// PUBLIC API
479
///////////////////////////////////////////////////////////////////////////////////////////////////
480

    
481
    public FirebaseAnalytics getAnalytics()
482
      {
483
      return mFirebaseAnalytics;
484
      }
485

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

    
488
    public int getHeightUpperBar()
489
      {
490
      return mHeightUpperBar;
491
      }
492

    
493
///////////////////////////////////////////////////////////////////////////////////////////////////
494

    
495
    public TwistyObject getObject()
496
      {
497
      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
498
      return view.getObjectControl().getObject();
499
      }
500

    
501
///////////////////////////////////////////////////////////////////////////////////////////////////
502

    
503
    public DistortedScreen getScreen()
504
      {
505
      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
506
      return view.getRenderer().getScreen();
507
      }
508

    
509
///////////////////////////////////////////////////////////////////////////////////////////////////
510

    
511
    public ObjectControl getControl()
512
      {
513
      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
514
      return view.getObjectControl();
515
      }
516

    
517
///////////////////////////////////////////////////////////////////////////////////////////////////
518

    
519
    public int getScreenWidthInPixels()
520
      {
521
      return mScreenWidth;
522
      }
523

    
524
///////////////////////////////////////////////////////////////////////////////////////////////////
525

    
526
    public int getScreenHeightInPixels()
527
      {
528
      return mScreenHeight;
529
      }
530

    
531
///////////////////////////////////////////////////////////////////////////////////////////////////
532

    
533
    public void changeObject(int newObject, boolean reportChange)
534
      {
535
      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
536
      ObjectControl control = view.getObjectControl();
537
      TwistyObject oldObject = control.getObject();
538
      changeIfDifferent(newObject,control);
539

    
540
      if( reportChange && oldObject!=null )
541
        {
542
        RubikObject robject = RubikObjectList.getObject(newObject);
543
        String newName = robject==null ? "NULL" : robject.getUpperName();
544
        float fps = view.getRenderer().getFPS();
545
        fps = (int)(fps+0.5f);
546
        StringBuilder name = new StringBuilder();
547
        name.append(oldObject.getShortName());
548
        name.append(' ');
549
        name.append(fps);
550
        name.append(" --> ");
551
        name.append(newName);
552

    
553
        if( BuildConfig.DEBUG )
554
          {
555
          android.util.Log.e("rubik", name.toString());
556
          }
557
        else
558
          {
559
          FirebaseAnalytics analytics = getAnalytics();
560

    
561
          if( analytics!=null )
562
            {
563
            Bundle bundle = new Bundle();
564
            bundle.putString(FirebaseAnalytics.Param.ITEM_NAME, name.toString());
565
            analytics.logEvent(FirebaseAnalytics.Event.SELECT_ITEM, bundle);
566
            }
567
          }
568
        }
569
      }
570

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

    
573
    public void changeIfDifferent(int ordinal, ObjectControl control)
574
      {
575
      RubikObject object = RubikObjectList.getObject(ordinal);
576
      int meshState = object!=null ? object.getMeshState() : MESH_NICE;
577
      int iconMode  = TwistyObject.MODE_NORM;
578
      InputStream jsonStream = object==null ? null : object.getObjectStream(this);
579
      InputStream meshStream = object==null ? null : object.getMeshStream(this);
580
      String name = object==null ? "NULL" : object.getUpperName();
581
      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
582
      OSInterface os = view.getInterface();
583
      InitAssets asset = new InitAssets(jsonStream,meshStream,os);
584

    
585
      control.changeIfDifferent(ordinal,name,meshState,iconMode,asset);
586
      }
587

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

    
590
    public void switchToTutorial(String url, int objectOrdinal)
591
      {
592
      Intent intent = new Intent(this, TutorialActivity.class);
593
      intent.putExtra("url", url);
594
      intent.putExtra("obj", objectOrdinal);
595
      startActivity(intent);
596
      }
597

    
598
///////////////////////////////////////////////////////////////////////////////////////////////////
599

    
600
    public void switchToConfig(int objectOrdinal)
601
      {
602
      Intent intent = new Intent(this, ConfigActivity.class);
603
      intent.putExtra("obj", objectOrdinal);
604
      startActivity(intent);
605
      }
606

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

    
609
    public void switchToBandagedCreator(int objectOrdinal)
610
      {
611
      Intent intent = new Intent(this, BandagedCreatorActivity.class);
612
      intent.putExtra("obj", objectOrdinal);
613
      startActivity(intent);
614
      }
615

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

    
618
    public void switchToPurchase(int objectOrdinal)
619
      {
620
      Intent intent = new Intent(this, PurchaseActivity.class);
621
      intent.putExtra("obj", objectOrdinal);
622
      startActivity(intent);
623
      }
624

    
625
///////////////////////////////////////////////////////////////////////////////////////////////////
626

    
627
    public void reloadObject(String shortName)
628
      {
629
      TwistyObject currObject = getObject();
630
      String name = currObject==null ? "" : currObject.getShortName();
631

    
632
      if( name.toLowerCase(Locale.ENGLISH).equals(shortName) )
633
        {
634
        RubikObject object = RubikObjectList.getObject(name);
635

    
636
        if( object!=null )
637
          {
638
          int meshState = object.getMeshState();
639
          int iconMode  = TwistyObject.MODE_NORM;
640
          InputStream jsonStream = object.getObjectStream(this);
641
          InputStream meshStream = object.getMeshStream(this);
642
          RubikSurfaceView view  = findViewById(R.id.rubikSurfaceView);
643
          OSInterface os         = view.getInterface();
644
          InitAssets asset       = new InitAssets(jsonStream,meshStream,os);
645
          ObjectControl control  = getControl();
646
          control.changeObject(-1,meshState,iconMode,asset);
647
          }
648
        }
649
      }
650

    
651
///////////////////////////////////////////////////////////////////////////////////////////////////
652

    
653
    public void setSolverIndex(int index)
654
      {
655
      mSolverIndex = index;
656
      }
657

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

    
660
    public int getSolverIndex()
661
      {
662
      return mSolverIndex;
663
      }
664

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

    
667
   public OperatingSystemInterface getInterface()
668
     {
669
     RubikSurfaceView view  = findViewById(R.id.rubikSurfaceView);
670
     return view.getInterface();
671
     }
672
}
(1-1/4)