commit 0b458a909f742cdf0561d4cb6053470c621994e7
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Mon Jul 11 19:26:49 2022 +0200

    Progress with central menu popup.

diff --git a/src/main/java/org/distorted/main/RubikActivity.java b/src/main/java/org/distorted/main/RubikActivity.java
index dcec9211..6bd1c775 100644
--- a/src/main/java/org/distorted/main/RubikActivity.java
+++ b/src/main/java/org/distorted/main/RubikActivity.java
@@ -78,7 +78,6 @@ public class RubikActivity extends AppCompatActivity
     public static final float TITLE_TEXT_SIZE     = 0.06f;
     public static final float SOLVER_BMP_H_SIZE   = 0.11f;
     public static final float SOLVER_BMP_V_SIZE   = 0.06f;
-    public static final float MENU_ITEM_SIZE      = 0.11f;
     public static final float PATTERN_GROUP_TEXT  = 0.03f;
     public static final float PATTERN_CHILD_TEXT  = 0.02f;
     public static final float SCORES_LEVEL_TEXT   = 0.035f;
@@ -90,6 +89,7 @@ public class RubikActivity extends AppCompatActivity
     public static final float MENU_SMALL_TEXT_SIZE= 0.035f;
     public static final float TAB_WIDTH           = 0.100f;
     public static final float TAB_HEIGHT          = 0.100f;
+    public static final float MENU_BUTTON_HEIGHT  = 0.120f;
 
     public static final int FLAGS =  View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                                    | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
diff --git a/src/main/java/org/distorted/screens/RubikScreenPlay.java b/src/main/java/org/distorted/screens/RubikScreenPlay.java
index ffb347f2..3a5fa79f 100644
--- a/src/main/java/org/distorted/screens/RubikScreenPlay.java
+++ b/src/main/java/org/distorted/screens/RubikScreenPlay.java
@@ -41,7 +41,6 @@ import android.widget.TextView;
 import org.distorted.dialogs.RubikDialogUpdates;
 import org.distorted.external.RubikNetwork;
 import org.distorted.external.RubikUpdates;
-import org.distorted.objectlib.main.ObjectControl;
 
 import org.distorted.main.R;
 import org.distorted.main.RubikActivity;
@@ -49,9 +48,7 @@ import org.distorted.dialogs.RubikDialogAbout;
 import org.distorted.dialogs.RubikDialogPattern;
 import org.distorted.dialogs.RubikDialogScores;
 import org.distorted.dialogs.RubikDialogTutorial;
-import org.distorted.helpers.TransparentButton;
 import org.distorted.helpers.TransparentImageButton;
-import org.distorted.external.RubikScores;
 import org.distorted.objects.MainEntry;
 import org.distorted.objects.MainEntryList;
 import org.distorted.objects.RubikObject;
@@ -65,25 +62,16 @@ public class RubikScreenPlay extends RubikScreenBase implements RubikNetwork.Upd
   {
   public static final int NUM_COLUMNS  = 5;
   public static final int LEVELS_SHOWN = 8;
+  private static final int NUM_BUTTONS = 5;
 
-  private static final int[] BUTTON_LABELS = { R.string.scores,
-                                               R.string.patterns,
-                                               R.string.solver,
-                                               R.string.tutorials,
-                                               R.string.about };
-  private static final int NUM_BUTTONS = BUTTON_LABELS.length;
-
-  private static final float BIG_BUTTON = 1.5f;
   private static final int[] mLocation = new int[2];
 
   private TransparentImageButton mObjButton, mMenuButton, mSolveButton, mScrambleButton;
-  private TransparentButton mPlayButton;
   private PopupWindow mObjectPopup, mMenuPopup, mPlayPopup;
-  private LinearLayout mPlayLayout;
+
   private TextView mBubbleUpdates;
-  private int mObjectSize, mMenuLayoutWidth, mMenuLayoutHeight, mPlayLayoutWidth;
+  private int mObjectSize, mMenuLayoutWidth, mMenuLayoutHeight, mMenuButtonHeight;
   private int mLevelValue;
-  private float mButtonSize, mMenuItemSize, mMenuTextSize;
   private int mColCount, mRowCount, mMaxRowCount;
   private int mUpperBarHeight;
   private boolean mShouldReactToEndOfScrambling;
@@ -107,9 +95,7 @@ public class RubikScreenPlay extends RubikScreenBase implements RubikNetwork.Upd
     mScreenWidth = act.getScreenWidthInPixels();
     mUpperBarHeight = act.getHeightUpperBar();
 
-    mMenuTextSize = mScreenWidth*RubikActivity.MENU_MED_TEXT_SIZE;
-    mButtonSize   = mScreenWidth*RubikActivity.BUTTON_TEXT_SIZE;
-    mMenuItemSize = mScreenWidth*RubikActivity.MENU_ITEM_SIZE;
+    mMenuButtonHeight = (int)(mScreenWidth*RubikActivity.MENU_BUTTON_HEIGHT);
 
     mRowCount = (numObjects + NUM_COLUMNS-1) / NUM_COLUMNS;
     mColCount = NUM_COLUMNS;
@@ -162,43 +148,6 @@ public class RubikScreenPlay extends RubikScreenBase implements RubikNetwork.Upd
       });
     }
 
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  private void setupPlayButton(final RubikActivity act, final float width)
-    {
-    final int margin = (int)(width*RubikActivity.SMALL_MARGIN);
-
-    mPlayButton = new TransparentButton(act, R.string.play, mButtonSize);
-
-    mPlayButton.setOnClickListener( new View.OnClickListener()
-      {
-      @Override
-      public void onClick(View view)
-        {
-        if( mPlayPopup==null )
-          {
-          float width = act.getScreenWidthInPixels();
-          setupPlayWindow(act,width);
-          }
-
-        if( act.getControl().isUINotBlocked())
-          {
-          adjustSolvedIcons();
-          float height= act.getScreenHeightInPixels();
-          final int maxHeight= (int)(0.9f*(height-mUpperBarHeight) );
-          View popupView = mPlayPopup.getContentView();
-          popupView.setSystemUiVisibility(RubikActivity.FLAGS);
-          final int object  = RubikObjectList.getCurrObject();
-          final int dbLevel = RubikObjectList.getDBLevel(object);
-          final int levelsShown = Math.min(dbLevel,LEVELS_SHOWN)+1;
-          final int popupHeight = (int)(levelsShown*(mMenuItemSize+margin)+4*margin+2*mMenuItemSize*(BIG_BUTTON-1.0f));
-          final int realHeight = Math.min(popupHeight,maxHeight);
-          displayPopup(act,view,mPlayPopup,mPlayLayoutWidth,realHeight,margin,margin);
-          }
-        }
-      });
-    }
-
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
   private void setupMenuButton(final RubikActivity act, final float width)
@@ -223,7 +172,7 @@ public class RubikScreenPlay extends RubikScreenBase implements RubikNetwork.Upd
           {
           View popupView = mMenuPopup.getContentView();
           popupView.setSystemUiVisibility(RubikActivity.FLAGS);
-          displayPopup(act,view,mMenuPopup,mMenuLayoutWidth,mMenuLayoutHeight,(int)(-width/12),margin);
+          displayPopup(act,view,mMenuPopup,mMenuLayoutWidth,mMenuLayoutHeight,(int)(-mMenuLayoutWidth/2 + width/6),margin);
           }
         }
       });
@@ -290,7 +239,7 @@ public class RubikScreenPlay extends RubikScreenBase implements RubikNetwork.Upd
               int ordinal = mainEntry.getOrdinal();
               RubikObjectList.setCurrObject(act,ordinal);
               act.changeObject(ordinal,true);
-              if( mPlayLayout!=null ) adjustLevels(act);
+              if( mMenuPopup!=null ) adjustLevels(act);
               mMovesController.clearMoves(act);
               }
             else if( type==MainEntry.TYPE_CREATOR )
@@ -427,84 +376,81 @@ public class RubikScreenPlay extends RubikScreenBase implements RubikNetwork.Upd
     {
     LayoutInflater layoutInflater = (LayoutInflater)act.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
     final View layout = layoutInflater.inflate(R.layout.popup_menu, null);
-    LinearLayout menuLayout = layout.findViewById(R.id.menuGrid);
 
     mMenuPopup = new PopupWindow(act);
     mMenuPopup.setContentView(layout);
     mMenuPopup.setFocusable(true);
     int margin  = (int)(width*RubikActivity.SMALL_MARGIN);
-    int padding = (int)(width*RubikActivity.PADDING);
-
-    mMenuLayoutWidth = (int)(width/2);
-    mMenuLayoutHeight= (int)(2*margin + NUM_BUTTONS*(mMenuItemSize+margin));
+    int padding = (int)(width*RubikActivity.MEDIUM_MARGIN);
 
-    LinearLayout.LayoutParams p = new LinearLayout.LayoutParams( mMenuLayoutWidth - 2*padding, (int)mMenuItemSize);
+    mMenuLayoutWidth = (int)(width*0.6f);
+    mMenuLayoutHeight= (int)(2*padding + NUM_BUTTONS*(mMenuButtonHeight+margin));
 
-    for(int i=0; i<NUM_BUTTONS; i++)
-      {
-      final int but = i;
-      Button button = new Button(act);
-      button.setLayoutParams(p);
-      button.setText(BUTTON_LABELS[i]);
-      button.setTextSize(TypedValue.COMPLEX_UNIT_PX, mMenuTextSize);
+    layout.setPadding(padding,0,padding,0);
 
-      button.setOnClickListener( new View.OnClickListener()
+    Button highScores = layout.findViewById(R.id.menuHighScores);
+    highScores.setOnClickListener( new View.OnClickListener()
         {
         @Override
         public void onClick(View v)
           {
           mMenuPopup.dismiss();
-          MenuAction(act,but);
+          Bundle sBundle = new Bundle();
+          int currObject = RubikObjectList.getCurrObject();
+          sBundle.putInt("tab", currObject );
+          sBundle.putBoolean("submitting", false);
+          RubikDialogScores scores = new RubikDialogScores();
+          scores.setArguments(sBundle);
+          scores.show(act.getSupportFragmentManager(), null);
           }
         });
 
-      menuLayout.addView(button);
-      }
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  private void setupPlayWindow(final RubikActivity act, final float width)
-    {
-    LayoutInflater layoutInflater = (LayoutInflater)act.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
-    final View layout = layoutInflater.inflate(R.layout.popup_play, null);
-    mPlayLayout = layout.findViewById(R.id.playGrid);
-
-    mPlayLayoutWidth = (int)(width*0.4f);
-
-    mPlayPopup = new PopupWindow(act);
-    mPlayPopup.setContentView(layout);
-    mPlayPopup.setFocusable(true);
+    Button prettyPatterns = layout.findViewById(R.id.menuPrettyPatterns);
+    prettyPatterns.setOnClickListener( new View.OnClickListener()
+        {
+        @Override
+        public void onClick(View v)
+          {
+          mMenuPopup.dismiss();
+          RubikDialogPattern pDiag = new RubikDialogPattern();
+          pDiag.show( act.getSupportFragmentManager(), RubikDialogPattern.getDialogTag() );
+          }
+        });
 
-    adjustLevels(act);
-    }
+    Button solver = layout.findViewById(R.id.menuSolver);
+    solver.setOnClickListener( new View.OnClickListener()
+        {
+        @Override
+        public void onClick(View v)
+          {
+          mMenuPopup.dismiss();
+          ScreenList.switchScreen(act, ScreenList.SVER);
+          }
+        });
 
-///////////////////////////////////////////////////////////////////////////////////////////////////
+    Button tutorials = layout.findViewById(R.id.menuTutorials);
+    tutorials.setOnClickListener( new View.OnClickListener()
+        {
+        @Override
+        public void onClick(View v)
+          {
+          mMenuPopup.dismiss();
+          RubikDialogTutorial tDiag = new RubikDialogTutorial();
+          tDiag.show( act.getSupportFragmentManager(), RubikDialogTutorial.getDialogTag() );
+          }
+        });
 
-  private void MenuAction(RubikActivity act, int button)
-    {
-    switch(button)
-      {
-      case 0: Bundle sBundle = new Bundle();
-              int currObject = RubikObjectList.getCurrObject();
-              sBundle.putInt("tab", currObject );
-              sBundle.putBoolean("submitting", false);
-              RubikDialogScores scores = new RubikDialogScores();
-              scores.setArguments(sBundle);
-              scores.show(act.getSupportFragmentManager(), null);
-              break;
-      case 1: RubikDialogPattern pDiag = new RubikDialogPattern();
-              pDiag.show( act.getSupportFragmentManager(), RubikDialogPattern.getDialogTag() );
-              break;
-      case 2: ScreenList.switchScreen(act, ScreenList.SVER);
-              break;
-      case 3: RubikDialogTutorial tDiag = new RubikDialogTutorial();
-              tDiag.show( act.getSupportFragmentManager(), RubikDialogTutorial.getDialogTag() );
-              break;
-      case 4: RubikDialogAbout aDiag = new RubikDialogAbout();
-              aDiag.show(act.getSupportFragmentManager(), null);
-              break;
-      }
+    Button about = layout.findViewById(R.id.menuAbout);
+    about.setOnClickListener( new View.OnClickListener()
+        {
+        @Override
+        public void onClick(View v)
+          {
+          mMenuPopup.dismiss();
+          RubikDialogAbout aDiag = new RubikDialogAbout();
+          aDiag.show(act.getSupportFragmentManager(), null);
+          }
+        });
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -565,7 +511,7 @@ public class RubikScreenPlay extends RubikScreenBase implements RubikNetwork.Upd
 
   public void setCurrObject(RubikActivity act)
     {
-    if( mPlayLayout!=null ) adjustLevels(act);
+    if( mMenuPopup!=null ) adjustLevels(act);
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -614,7 +560,7 @@ public class RubikScreenPlay extends RubikScreenBase implements RubikNetwork.Upd
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
-
+/*
   private void adjustSolvedIcons()
     {
     if( mPlayLayout!=null )
@@ -634,11 +580,12 @@ public class RubikScreenPlay extends RubikScreenBase implements RubikNetwork.Upd
         }
       }
     }
-
+*/
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
   private void adjustLevels(final RubikActivity act)
     {
+    /*
     int currObject = RubikObjectList.getCurrObject();
     int dbLevel = RubikObjectList.getDBLevel(currObject);
     RubikObject object = RubikObjectList.getObject(currObject);
@@ -656,7 +603,7 @@ public class RubikScreenPlay extends RubikScreenBase implements RubikNetwork.Upd
     float width  = act.getScreenWidthInPixels();
     int margin   = (int)(width*RubikActivity.SMALL_MARGIN);
     int padding  = (int)(width*RubikActivity.PADDING);
-    int butWidth = mPlayLayoutWidth - 2*padding;
+    int butWidth = 0;//mPlayLayoutWidth - 2*padding;
     int butHeight= (int)mMenuItemSize;
     int bigButH  = (int)(mMenuItemSize*BIG_BUTTON) ;
 
@@ -705,6 +652,8 @@ public class RubikScreenPlay extends RubikScreenBase implements RubikNetwork.Upd
 
       mPlayLayout.addView(button);
       }
+
+     */
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/res/layout/popup_menu.xml b/src/main/res/layout/popup_menu.xml
index 11f19ba1..143cffb9 100644
--- a/src/main/res/layout/popup_menu.xml
+++ b/src/main/res/layout/popup_menu.xml
@@ -5,4 +5,64 @@
    android:layout_height="wrap_content"
    android:gravity="center"
    android:orientation="vertical">
+
+   <Button
+      android:id="@+id/menuHighScores"
+      android:text="@string/scores"
+      android:layout_width="match_parent"
+      android:layout_height="0dp"
+      android:layout_weight="1.0"
+      android:paddingRight="10dp"
+      android:paddingLeft="10dp"
+      android:singleLine="true"
+      android:backgroundTint="@color/dark_grey"
+      android:gravity="center"/>
+
+   <Button
+      android:id="@+id/menuPrettyPatterns"
+      android:text="@string/patterns"
+      android:layout_width="match_parent"
+      android:layout_height="0dp"
+      android:layout_weight="1.0"
+      android:paddingRight="10dp"
+      android:paddingLeft="10dp"
+      android:singleLine="true"
+      android:backgroundTint="@color/dark_grey"
+      android:gravity="center"/>
+
+   <Button
+      android:id="@+id/menuSolver"
+      android:text="@string/solver"
+      android:layout_width="match_parent"
+      android:layout_height="0dp"
+      android:layout_weight="1.0"
+      android:paddingRight="10dp"
+      android:paddingLeft="10dp"
+      android:singleLine="true"
+      android:backgroundTint="@color/dark_grey"
+      android:gravity="center"/>
+
+   <Button
+      android:id="@+id/menuTutorials"
+      android:text="@string/tutorials"
+      android:layout_width="match_parent"
+      android:layout_height="0dp"
+      android:layout_weight="1.0"
+      android:paddingRight="10dp"
+      android:paddingLeft="10dp"
+      android:singleLine="true"
+      android:backgroundTint="@color/dark_grey"
+      android:gravity="center"/>
+
+   <Button
+      android:id="@+id/menuAbout"
+      android:text="@string/about"
+      android:layout_width="match_parent"
+      android:layout_height="0dp"
+      android:layout_weight="1.0"
+      android:paddingRight="10dp"
+      android:paddingLeft="10dp"
+      android:singleLine="true"
+      android:backgroundTint="@color/dark_grey"
+      android:gravity="center"/>
 </LinearLayout>
\ No newline at end of file
