commit d90c55ccc91b9490cfaf601b38ce0e6569d65162
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Tue Sep 7 13:00:24 2021 +0200

    Make the 'Play' popup always fit within the window height.

diff --git a/src/main/java/org/distorted/objects/TwistyCube.java b/src/main/java/org/distorted/objects/TwistyCube.java
index 3531481b..812dfb45 100644
--- a/src/main/java/org/distorted/objects/TwistyCube.java
+++ b/src/main/java/org/distorted/objects/TwistyCube.java
@@ -62,8 +62,8 @@ class TwistyCube extends TwistyObject
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-  TwistyCube(int size, Static4D quat, DistortedTexture texture,
-             MeshSquare mesh, DistortedEffects effects, int[][] moves, Resources res, int scrWidth)
+  TwistyCube(int size, Static4D quat, DistortedTexture texture, MeshSquare mesh,
+             DistortedEffects effects, int[][] moves, Resources res, int scrWidth)
     {
     super(size, size, quat, texture, mesh, effects, moves, ObjectList.CUBE, res, scrWidth);
 
@@ -186,7 +186,7 @@ class TwistyCube extends TwistyObject
 
     int[][] vert_indices = new int[][]
           {
-              {2,3,1,0},   // counterclockwise!
+              {2,3,1,0},
               {7,6,4,5},
               {4,0,1,5},
               {7,3,2,6},
@@ -364,7 +364,7 @@ class TwistyCube extends TwistyObject
 
   public int[] getBasicAngle()
     {
-    if( mBasicAngle ==null ) mBasicAngle = new int[] { 4,4,4 };
+    if( mBasicAngle==null ) mBasicAngle = new int[] { 4,4,4 };
     return mBasicAngle;
     }
 
diff --git a/src/main/java/org/distorted/screens/RubikScreenPlay.java b/src/main/java/org/distorted/screens/RubikScreenPlay.java
index 6ef77d4d..7de62722 100644
--- a/src/main/java/org/distorted/screens/RubikScreenPlay.java
+++ b/src/main/java/org/distorted/screens/RubikScreenPlay.java
@@ -110,7 +110,7 @@ public class RubikScreenPlay extends RubikScreenBase
     layoutTop.addView(mMenuButton);
 
     setupPlayWindow(act,width);
-    setupPlayButton(act,width);
+    setupPlayButton(act,width,height);
     layoutTop.addView(mPlayButton);
 
     setupSolveButton(act,width);
@@ -148,9 +148,12 @@ public class RubikScreenPlay extends RubikScreenBase
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-  private void setupPlayButton(final RubikActivity act, final float width)
+  private void setupPlayButton(final RubikActivity act, final float width, final float height)
     {
-    final int margin  = (int)(width*RubikActivity.MARGIN);
+    final int margin   = (int)(width*RubikActivity.MARGIN);
+    int upperBarHeight = act.getHeightUpperBar();
+    final int maxHeight= (int)(0.9f*(height-upperBarHeight) );
+
     mPlayButton = new TransparentButton(act, R.string.play, mButtonSize, width);
 
     mPlayButton.setOnClickListener( new View.OnClickListener()
@@ -166,9 +169,10 @@ public class RubikScreenPlay extends RubikScreenBase
           final int sizeIndex = ObjectList.getSizeIndex(mObject,mSize);
           final int dbLevel = ObjectList.getDBLevel(mObject, sizeIndex);
           final int levelsShown = Math.min(dbLevel,LEVELS_SHOWN);
+          final int popupHeight = (int)(levelsShown*(mMenuItemSize+margin)+3*margin+mMenuItemSize*(LAST_BUTTON-1.0f));
 
           mPlayPopup.showAsDropDown(view, margin, margin);
-          mPlayPopup.update(view, mPlayLayoutWidth, (int)(levelsShown*(mMenuItemSize+margin)+3*margin+mMenuItemSize*(LAST_BUTTON-1.0f)));
+          mPlayPopup.update(view, mPlayLayoutWidth, Math.min(popupHeight,maxHeight));
           mPlayPopup.setFocusable(true);
           mPlayPopup.update();
           }
