Revision 85038b84
Added by Leszek Koltunski almost 2 years ago
src/main/java/org/distorted/main/RubikActivity.java | ||
---|---|---|
56 | 56 |
import org.distorted.external.RubikNetwork; |
57 | 57 |
import org.distorted.objects.RubikObject; |
58 | 58 |
import org.distorted.objects.RubikObjectList; |
59 |
import org.distorted.screens.RubikScreenFreePlay; |
|
59 | 60 |
import org.distorted.screens.RubikScreenSolving; |
60 | 61 |
import org.distorted.screens.ScreenList; |
61 |
import org.distorted.screens.RubikScreenPlay; |
|
62 | 62 |
import org.distorted.tutorials.TutorialActivity; |
63 | 63 |
|
64 | 64 |
import static org.distorted.objectlib.main.TwistyObject.MESH_NICE; |
... | ... | |
126 | 126 |
mIsChinese = localeIsChinese(); |
127 | 127 |
|
128 | 128 |
DisplayMetrics displaymetrics = new DisplayMetrics(); |
129 |
getWindowManager().getDefaultDisplay().getMetrics(displaymetrics); |
|
130 |
mScreenWidth =displaymetrics.widthPixels; |
|
131 |
mScreenHeight=displaymetrics.heightPixels; |
|
132 |
mScreenHeight = (int)(1.07f*mScreenHeight); // add 7% for the upper bar |
|
133 |
// which is not yet hidden. |
|
134 |
// TODO: figure this out exactly. |
|
129 |
getWindowManager().getDefaultDisplay().getRealMetrics(displaymetrics); |
|
130 |
mScreenWidth = (int)(displaymetrics.widthPixels); |
|
131 |
mScreenHeight = (int)(displaymetrics.heightPixels); |
|
132 |
|
|
135 | 133 |
hideNavigationBar(); |
136 | 134 |
cutoutHack(); |
137 | 135 |
computeBarHeights(); |
... | ... | |
142 | 140 |
|
143 | 141 |
private void computeBarHeights() |
144 | 142 |
{ |
145 |
float height = mScreenHeight; |
|
146 |
int barHeight = (int)(height*RATIO_BAR); |
|
143 |
int barHeight = (int)(mScreenHeight*RATIO_BAR); |
|
147 | 144 |
mHeightLowerBar = barHeight; |
148 | 145 |
mHeightUpperBar = barHeight; |
149 | 146 |
|
... | ... | |
242 | 239 |
} |
243 | 240 |
|
244 | 241 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
245 |
|
|
242 |
|
|
246 | 243 |
@Override |
247 | 244 |
protected void onResume() |
248 | 245 |
{ |
... | ... | |
325 | 322 |
|
326 | 323 |
ScreenList curr = ScreenList.getCurrentScreen(); |
327 | 324 |
|
328 |
if( curr==ScreenList.PLAY )
|
|
325 |
if( curr==ScreenList.FREE )
|
|
329 | 326 |
{ |
330 |
RubikScreenPlay play = (RubikScreenPlay)ScreenList.PLAY.getScreenClass();
|
|
331 |
play.saveMovePreferences(KEY_PLAY,editor);
|
|
327 |
RubikScreenFreePlay free = (RubikScreenFreePlay)ScreenList.FREE.getScreenClass();
|
|
328 |
free.saveMovePreferences(KEY_PLAY,editor);
|
|
332 | 329 |
} |
333 | 330 |
if( curr==ScreenList.SOLV ) |
334 | 331 |
{ |
... | ... | |
393 | 390 |
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); |
394 | 391 |
ScreenList curr = ScreenList.getCurrentScreen(); |
395 | 392 |
|
396 |
if( curr==ScreenList.PLAY )
|
|
393 |
if( curr==ScreenList.FREE )
|
|
397 | 394 |
{ |
398 |
RubikScreenPlay play = (RubikScreenPlay)ScreenList.PLAY.getScreenClass();
|
|
399 |
play.restoreMovePreferences(this,KEY_PLAY,preferences);
|
|
395 |
RubikScreenFreePlay free = (RubikScreenFreePlay)ScreenList.FREE.getScreenClass();
|
|
396 |
free.restoreMovePreferences(this,KEY_PLAY,preferences);
|
|
400 | 397 |
} |
401 | 398 |
if( curr==ScreenList.SOLV ) |
402 | 399 |
{ |
... | ... | |
421 | 418 |
errDiag.show(getSupportFragmentManager(), null); |
422 | 419 |
} |
423 | 420 |
|
424 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
425 |
|
|
426 |
void setScreenSize(int width, int height) |
|
427 |
{ |
|
428 |
mScreenWidth = width; |
|
429 |
mScreenHeight= height; |
|
430 |
} |
|
431 |
|
|
432 | 421 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
433 | 422 |
// PUBLIC API |
434 | 423 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
618 | 607 |
RubikSurfaceView view = findViewById(R.id.rubikSurfaceView); |
619 | 608 |
ObjectControl control = view.getObjectControl(); |
620 | 609 |
control.blockEverything(place); |
610 |
ScreenList curr = ScreenList.getCurrentScreen(); |
|
621 | 611 |
|
622 |
RubikScreenPlay play = (RubikScreenPlay) ScreenList.PLAY.getScreenClass(); |
|
623 |
play.setLockState(this); |
|
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 |
} |
|
624 | 622 |
} |
625 | 623 |
|
626 | 624 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
630 | 628 |
RubikSurfaceView view = findViewById(R.id.rubikSurfaceView); |
631 | 629 |
ObjectControl control = view.getObjectControl(); |
632 | 630 |
control.unblockEverything(); |
631 |
ScreenList curr = ScreenList.getCurrentScreen(); |
|
633 | 632 |
|
634 |
RubikScreenPlay play = (RubikScreenPlay) ScreenList.PLAY.getScreenClass(); |
|
635 |
play.setLockState(this); |
|
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 |
} |
|
636 | 643 |
} |
637 | 644 |
|
638 | 645 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
662 | 669 |
startActivity(intent); |
663 | 670 |
} |
664 | 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 |
|
|
665 | 690 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
666 | 691 |
|
667 | 692 |
public void reloadObject(String shortName) |
Also available in: Unified diff
New UI