Project

General

Profile

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

magiccube / src / main / java / org / distorted / main_old / RubikActivity.java @ 337f4660

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
///////////////////////////////////////////////////////////////////////////////////////////////////
62

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

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

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

    
90
    private static final int ACTIVITY_NUMBER = 0;
91
    private static final float RATIO_INSET= 0.09f;
92

    
93
    private static final String KEY_PLAY = "movesController_play";
94
    private static final String KEY_SOLV = "movesController_solv";
95

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

    
105
///////////////////////////////////////////////////////////////////////////////////////////////////
106

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

    
116
      mJustStarted = true;
117
      mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);
118

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

    
124
      cutoutHack();
125
      computeBarHeights();
126

    
127
      mCurrVersion = getAppVers();
128
      mSolverIndex = 0;
129

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

    
139
      thread.start();
140
      }
141

    
142
///////////////////////////////////////////////////////////////////////////////////////////////////
143
// this does not include possible insets
144

    
145
    private void computeBarHeights()
146
      {
147
      int barHeight = (int)(mScreenHeight*RATIO_BAR);
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 = barHeight;
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

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

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

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

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

    
275
///////////////////////////////////////////////////////////////////////////////////////////////////
276

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

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

    
295
///////////////////////////////////////////////////////////////////////////////////////////////////
296

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

    
310
///////////////////////////////////////////////////////////////////////////////////////////////////
311

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

    
317
      editor.putString("appVersion", mCurrVersion );
318
      editor.putInt("solverIndex", mSolverIndex );
319

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

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

    
333
      ScreenList curr = ScreenList.getCurrentScreen();
334

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

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

    
350
///////////////////////////////////////////////////////////////////////////////////////////////////
351

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

    
357
      parseOldVersion(mOldVersion);
358

    
359
      RubikObjectList.restorePreferences(this,preferences,justStarted);
360

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

    
366
      RubikScores scores = RubikScores.getInstance();
367

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

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

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

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

    
393
      ScreenList.restorePreferences(preferences);
394

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

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

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

    
415
    private void parseOldVersion(String version)
416
      {
417
      if( version==null ) return;
418

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

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

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

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

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

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

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

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

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

    
475
///////////////////////////////////////////////////////////////////////////////////////////////////
476
// PUBLIC API
477
///////////////////////////////////////////////////////////////////////////////////////////////////
478

    
479
    public FirebaseAnalytics getAnalytics()
480
      {
481
      return mFirebaseAnalytics;
482
      }
483

    
484
///////////////////////////////////////////////////////////////////////////////////////////////////
485

    
486
    public int getHeightUpperBar()
487
      {
488
      return mHeightUpperBar;
489
      }
490

    
491
///////////////////////////////////////////////////////////////////////////////////////////////////
492

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

    
499
///////////////////////////////////////////////////////////////////////////////////////////////////
500

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

    
507
///////////////////////////////////////////////////////////////////////////////////////////////////
508

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

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

    
517
    public int getScreenWidthInPixels()
518
      {
519
      return mScreenWidth;
520
      }
521

    
522
///////////////////////////////////////////////////////////////////////////////////////////////////
523

    
524
    public int getScreenHeightInPixels()
525
      {
526
      return mScreenHeight;
527
      }
528

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

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

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

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

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

    
569
///////////////////////////////////////////////////////////////////////////////////////////////////
570

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

    
583
      control.changeIfDifferent(ordinal,name,iconMode,asset);
584
      }
585

    
586
///////////////////////////////////////////////////////////////////////////////////////////////////
587

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

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

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

    
605
///////////////////////////////////////////////////////////////////////////////////////////////////
606

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

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

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

    
623
///////////////////////////////////////////////////////////////////////////////////////////////////
624

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

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

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

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

    
650
    public void setSolverIndex(int index)
651
      {
652
      mSolverIndex = index;
653
      }
654

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

    
657
    public int getSolverIndex()
658
      {
659
      return mSolverIndex;
660
      }
661

    
662
///////////////////////////////////////////////////////////////////////////////////////////////////
663

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