Revision 55e6be1d
Added by Leszek Koltunski almost 3 years ago
src/main/java/org/distorted/main/RubikActivity.java | ||
---|---|---|
25 | 25 |
import android.os.Bundle; |
26 | 26 |
import android.os.LocaleList; |
27 | 27 |
import android.preference.PreferenceManager; |
28 |
import androidx.appcompat.app.AppCompatActivity; |
|
29 | 28 |
|
30 | 29 |
import android.util.DisplayMetrics; |
31 | 30 |
import android.view.DisplayCutout; |
... | ... | |
39 | 38 |
import org.distorted.dialogs.RubikDialogError; |
40 | 39 |
import org.distorted.dialogs.RubikDialogPrivacy; |
41 | 40 |
import org.distorted.effects.BaseEffect; |
41 |
import org.distorted.helpers.TwistyActivity; |
|
42 |
import org.distorted.helpers.TwistyPreRender; |
|
42 | 43 |
import org.distorted.library.main.DistortedLibrary; |
43 | 44 |
|
44 | 45 |
import org.distorted.library.main.DistortedScreen; |
... | ... | |
54 | 55 |
|
55 | 56 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
56 | 57 |
|
57 |
public class RubikActivity extends AppCompatActivity
|
|
58 |
public class RubikActivity extends TwistyActivity
|
|
58 | 59 |
{ |
59 | 60 |
public static final float PADDING = 0.01f; |
60 | 61 |
public static final float MARGIN = 0.004f; |
... | ... | |
88 | 89 |
private static int mScreenWidth, mScreenHeight; |
89 | 90 |
private boolean mPolicyAccepted, mIsChinese; |
90 | 91 |
private int mCurrentApiVersion; |
91 |
private boolean mIsLocked, mRemLocked; |
|
92 | 92 |
|
93 | 93 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
94 | 94 |
|
... | ... | |
110 | 110 |
mScreenHeight=displaymetrics.heightPixels; |
111 | 111 |
|
112 | 112 |
mIsChinese = localeIsChinese(); |
113 |
mIsLocked = false;
|
|
113 |
unlock();
|
|
114 | 114 |
|
115 | 115 |
hideNavigationBar(); |
116 | 116 |
cutoutHack(); |
... | ... | |
402 | 402 |
return view.getPreRender(); |
403 | 403 |
} |
404 | 404 |
|
405 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
406 |
|
|
407 |
public TwistyPreRender getTwistyPreRender() |
|
408 |
{ |
|
409 |
RubikSurfaceView view = findViewById(R.id.rubikSurfaceView); |
|
410 |
return view.getPreRender(); |
|
411 |
} |
|
412 |
|
|
405 | 413 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
406 | 414 |
|
407 | 415 |
public RubikSurfaceView getSurfaceView() |
... | ... | |
561 | 569 |
return view.isVertical(); |
562 | 570 |
} |
563 | 571 |
|
564 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
565 |
|
|
566 |
public void toggleLock() |
|
567 |
{ |
|
568 |
mIsLocked = !mIsLocked; |
|
569 |
} |
|
570 |
|
|
571 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
572 |
|
|
573 |
public boolean isLocked() |
|
574 |
{ |
|
575 |
ScreenList state = ScreenList.getCurrentScreen(); |
|
576 |
|
|
577 |
if( state== ScreenList.PLAY || state== ScreenList.READ || state== ScreenList.SOLV ) |
|
578 |
{ |
|
579 |
return mIsLocked; |
|
580 |
} |
|
581 |
|
|
582 |
return false; |
|
583 |
} |
|
584 |
|
|
585 | 572 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
586 | 573 |
|
587 | 574 |
public void blockEverything() |
588 | 575 |
{ |
589 |
mRemLocked = mIsLocked; |
|
590 |
mIsLocked = true; |
|
576 |
setLock(); |
|
591 | 577 |
|
592 |
RubikPreRender pre = getPreRender();
|
|
578 |
TwistyPreRender pre = getPreRender();
|
|
593 | 579 |
pre.blockEverything(); |
594 | 580 |
|
595 | 581 |
RubikScreenPlay play = (RubikScreenPlay) ScreenList.PLAY.getScreenClass(); |
... | ... | |
600 | 586 |
|
601 | 587 |
public void unblockEverything() |
602 | 588 |
{ |
603 |
mIsLocked = mRemLocked;
|
|
589 |
unsetLock();
|
|
604 | 590 |
|
605 |
RubikPreRender pre = getPreRender();
|
|
591 |
TwistyPreRender pre = getPreRender();
|
|
606 | 592 |
pre.unblockEverything(); |
607 | 593 |
|
608 | 594 |
RubikScreenPlay play = (RubikScreenPlay) ScreenList.PLAY.getScreenClass(); |
609 | 595 |
play.setLockState(this); |
610 | 596 |
} |
611 | 597 |
|
612 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
613 |
|
|
614 |
public boolean retLocked() |
|
615 |
{ |
|
616 |
return mIsLocked; |
|
617 |
} |
|
618 |
|
|
619 | 598 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
620 | 599 |
|
621 | 600 |
public void switchTutorial(String url, ObjectList object, int size) |
Also available in: Unified diff
Abstract the part that controls the 'Locked' and 'Back Moves' buttons from the two activities: the main one and the tutorial one.
This code had been duplicated there.