commit 4235de9b477a67a911f8b5f7d2d5f87910d2cdf3
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Mon Feb 17 01:19:06 2020 +0000

    Major rearrangement of the UI.

diff --git a/src/main/java/org/distorted/magic/RubikActivity.java b/src/main/java/org/distorted/magic/RubikActivity.java
index 3e8b4049..ddc9029f 100644
--- a/src/main/java/org/distorted/magic/RubikActivity.java
+++ b/src/main/java/org/distorted/magic/RubikActivity.java
@@ -19,59 +19,17 @@
 
 package org.distorted.magic;
 
-import android.content.SharedPreferences;
-import android.opengl.GLSurfaceView;
 import android.os.Bundle;
-import android.preference.PreferenceManager;
 import android.support.v7.app.AppCompatActivity;
 import android.view.View;
 
-import org.distorted.component.HorizontalNumberPicker;
 import org.distorted.library.main.DistortedLibrary;
-import org.distorted.effect.BaseEffect;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
 public class RubikActivity extends AppCompatActivity implements View.OnClickListener
 {
-    public static final int MIN_SCRAMBLE =  1;
-    public static final int DEF_SCRAMBLE =  1;
-    public static final int MAX_SCRAMBLE = 18;
-
-    private HorizontalNumberPicker mPicker;
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-    private void savePreferences()
-      {
-      SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
-      SharedPreferences.Editor editor = preferences.edit();
-
-      for (int i=0; i< BaseEffect.Type.LENGTH; i++)
-        {
-        BaseEffect.Type.getType(i).savePreferences(editor);
-        }
-
-      editor.putInt("scramble", mPicker.getValue() );
-
-      editor.apply();
-      }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-    private void restorePreferences()
-      {
-      SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
-
-      for (int i=0; i< BaseEffect.Type.LENGTH; i++)
-        {
-        BaseEffect.Type.getType(i).restorePreferences(preferences);
-        }
-
-      int scramble= preferences.getInt("scramble", DEF_SCRAMBLE);
-
-      mPicker.setValue(scramble);
-      }
+    private RubikDialogMain mMain;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
@@ -81,15 +39,15 @@ public class RubikActivity extends AppCompatActivity implements View.OnClickList
       super.onCreate(savedState);
       setTheme(R.style.CustomActivityThemeNoActionBar);
       setContentView(R.layout.main);
-      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
-      view.addSizeButtons(this);
-      view.markButton(RubikSurfaceView.getRedButton());
 
-      mPicker = findViewById(R.id.rubikNumberPicker);
-      mPicker.setMin(MIN_SCRAMBLE);
-      mPicker.setMax(MAX_SCRAMBLE);
+      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
+      view.enterMainState(this);
 
-      restorePreferences();
+      if( savedState==null )
+        {
+        mMain = new RubikDialogMain();
+        mMain.show(getSupportFragmentManager(), null);
+        }
       }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -97,11 +55,11 @@ public class RubikActivity extends AppCompatActivity implements View.OnClickList
     @Override
     protected void onPause() 
       {
-      GLSurfaceView view = findViewById(R.id.rubikSurfaceView);
+      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
       view.onPause();
       DistortedLibrary.onPause();
       RubikScoresDownloader.onPause();
-      savePreferences();
+      view.savePreferences();
       super.onPause();
       }
 
@@ -111,8 +69,9 @@ public class RubikActivity extends AppCompatActivity implements View.OnClickList
     protected void onResume() 
       {
       super.onResume();
-      GLSurfaceView view = findViewById(R.id.rubikSurfaceView);
+      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
       view.onResume();
+      view.restorePreferences();
       }
     
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -143,10 +102,30 @@ public class RubikActivity extends AppCompatActivity implements View.OnClickList
           view.markButton(id);
           }
         }
+
+      if( id == RubikSurfaceView.BUTTON_ID_BACK )
+        {
+        RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
+        view.enterMainState(this);
+        mMain.show(getSupportFragmentManager(), null);
+        }
+      if( id == RubikSurfaceView.BUTTON_ID_EXIT )
+        {
+        finish();
+        }
       }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 // PUBLIC API
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+    public void Play(View v)
+      {
+      mMain.dismiss();
+      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
+      view.enterPlayState(this);
+      }
+
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
     public void Settings(View v)
@@ -159,9 +138,8 @@ public class RubikActivity extends AppCompatActivity implements View.OnClickList
 
     public void Scores(View v)
       {
-      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
       Bundle bundle = new Bundle();
-      bundle.putInt("tab", view.getRedButton());
+      bundle.putInt("tab", RubikSurfaceView.getRedButton());
 
       RubikDialogScores scores = new RubikDialogScores();
       scores.setArguments(bundle);
@@ -180,11 +158,8 @@ public class RubikActivity extends AppCompatActivity implements View.OnClickList
 
     public void Scramble(View v)
       {
-      int scramble = mPicker.getValue();
-
       RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
-      view.getRenderer().scrambleCube(scramble);
-      view.enterScrambleMode();
+      view.scramble();
       }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -193,6 +168,5 @@ public class RubikActivity extends AppCompatActivity implements View.OnClickList
       {
       RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
       view.getRenderer().solveCube();
-      view.leaveScrambleMode();
       }
 }
diff --git a/src/main/java/org/distorted/magic/RubikDialogAbout.java b/src/main/java/org/distorted/magic/RubikDialogAbout.java
index 3b0a9dd8..647b2d05 100644
--- a/src/main/java/org/distorted/magic/RubikDialogAbout.java
+++ b/src/main/java/org/distorted/magic/RubikDialogAbout.java
@@ -28,12 +28,27 @@ import android.support.v7.app.AlertDialog;
 import android.support.v7.app.AppCompatDialogFragment;
 import android.view.LayoutInflater;
 import android.view.View;
+import android.view.Window;
+import android.view.WindowManager;
 import android.widget.TextView;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
 public class RubikDialogAbout extends AppCompatDialogFragment
   {
+  @Override
+  public void onStart()
+    {
+    super.onStart();
+
+    Window window = getDialog().getWindow();
+    window.setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,
+                    WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);
+    window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
   @NonNull
   @Override
   public Dialog onCreateDialog(Bundle savedInstanceState)
@@ -43,7 +58,7 @@ public class RubikDialogAbout extends AppCompatDialogFragment
     AlertDialog.Builder builder = new AlertDialog.Builder(act);
 
     TextView tv = (TextView) inflater.inflate(R.layout.dialog_title, null);
-    tv.setText(R.string.about_title);
+    tv.setText(R.string.about);
     builder.setCustomTitle(tv);
 
     builder.setCancelable(true);
diff --git a/src/main/java/org/distorted/magic/RubikDialogMain.java b/src/main/java/org/distorted/magic/RubikDialogMain.java
index 171da73f..69a452ae 100644
--- a/src/main/java/org/distorted/magic/RubikDialogMain.java
+++ b/src/main/java/org/distorted/magic/RubikDialogMain.java
@@ -20,7 +20,6 @@
 package org.distorted.magic;
 
 import android.app.Dialog;
-import android.content.DialogInterface;
 import android.os.Bundle;
 import android.support.annotation.NonNull;
 import android.support.v4.app.FragmentActivity;
@@ -28,34 +27,36 @@ import android.support.v7.app.AlertDialog;
 import android.support.v7.app.AppCompatDialogFragment;
 import android.view.LayoutInflater;
 import android.view.View;
+import android.view.Window;
+import android.view.WindowManager;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
 public class RubikDialogMain extends AppCompatDialogFragment
   {
+  @Override
+  public void onStart()
+    {
+    super.onStart();
+
+    Window window = getDialog().getWindow();
+    window.setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,
+                    WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);
+    window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
   @NonNull
   @Override
   public Dialog onCreateDialog(Bundle savedInstanceState)
     {
     FragmentActivity act = getActivity();
     AlertDialog.Builder builder = new AlertDialog.Builder(act);
-
-    builder.setTitle(R.string.app_version);
-    builder.setIcon(R.drawable.button3);
-    builder.setCancelable(false);
-    builder.setPositiveButton( R.string.ok, new DialogInterface.OnClickListener()
-      {
-      @Override
-      public void onClick(DialogInterface dialog, int which)
-        {
-
-        }
-      });
-
     LayoutInflater inflater = act.getLayoutInflater();
-    final View view = inflater.inflate(R.layout.dialog_about, null);
+    final View view = inflater.inflate(R.layout.dialog_main, null);
     builder.setView(view);
 
     return builder.create();
     }
-  }
+  }
\ No newline at end of file
diff --git a/src/main/java/org/distorted/magic/RubikDialogScores.java b/src/main/java/org/distorted/magic/RubikDialogScores.java
index 5917e5e0..10e594cf 100644
--- a/src/main/java/org/distorted/magic/RubikDialogScores.java
+++ b/src/main/java/org/distorted/magic/RubikDialogScores.java
@@ -30,6 +30,8 @@ import android.support.v7.app.AppCompatDialogFragment;
 import android.support.design.widget.TabLayout;
 import android.view.LayoutInflater;
 import android.view.View;
+import android.view.Window;
+import android.view.WindowManager;
 import android.widget.ImageView;
 import android.widget.TextView;
 
@@ -39,6 +41,19 @@ public class RubikDialogScores extends AppCompatDialogFragment
   {
   RubikDialogScoresPagerAdapter mPagerAdapter;
 
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  @Override
+  public void onStart()
+    {
+    super.onStart();
+
+    Window window = getDialog().getWindow();
+    window.setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,
+                    WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);
+    window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
+    }
+
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
   @NonNull
@@ -50,7 +65,7 @@ public class RubikDialogScores extends AppCompatDialogFragment
 
     LayoutInflater layoutInflater = act.getLayoutInflater();
     TextView tv = (TextView) layoutInflater.inflate(R.layout.dialog_title, null);
-    tv.setText(R.string.scores_title);
+    tv.setText(R.string.scores);
     builder.setCustomTitle(tv);
 
     builder.setCancelable(true);
diff --git a/src/main/java/org/distorted/magic/RubikDialogScoresPagerAdapter.java b/src/main/java/org/distorted/magic/RubikDialogScoresPagerAdapter.java
index 723aa380..0d344f5e 100644
--- a/src/main/java/org/distorted/magic/RubikDialogScoresPagerAdapter.java
+++ b/src/main/java/org/distorted/magic/RubikDialogScoresPagerAdapter.java
@@ -81,7 +81,7 @@ class RubikDialogScoresPagerAdapter extends PagerAdapter implements RubikScoresD
 
   private void addPage(final RubikDialogScoresView view, final int[][] country, final String[][] name, final String[][] time)
     {
-    for(int section=0; section<RubikActivity.MAX_SCRAMBLE; section++)
+    for(int section=0; section<RubikSurfaceView.MAX_SCRAMBLE; section++)
       {
       final int sec = section;
       final int[] c = country[section];
diff --git a/src/main/java/org/distorted/magic/RubikDialogSettings.java b/src/main/java/org/distorted/magic/RubikDialogSettings.java
index 09176d18..1a199d77 100644
--- a/src/main/java/org/distorted/magic/RubikDialogSettings.java
+++ b/src/main/java/org/distorted/magic/RubikDialogSettings.java
@@ -31,6 +31,8 @@ import android.util.DisplayMetrics;
 import android.view.Gravity;
 import android.view.LayoutInflater;
 import android.view.View;
+import android.view.Window;
+import android.view.WindowManager;
 import android.widget.AdapterView;
 import android.widget.ArrayAdapter;
 import android.widget.LinearLayout;
@@ -57,20 +59,7 @@ public class RubikDialogSettings extends AppCompatDialogFragment implements Seek
     int textH=32;
     int layoH=36;
     int margH=10;
-/*
-    if( metrics.widthPixels > metrics.heightPixels )
-      {
-      textH = 18;
-      layoH = 25;
-      margH =  5;
-      }
-    else
-      {
-      textH = 32;
-      layoH = 36;
-      margH = 10;
-      }
-*/
+
     ///// OUTER LAYOUT ///////////////////////////////////////////////////////////////////
 
     int margin = (int)(scale*margH + 0.5f);
@@ -201,6 +190,19 @@ public class RubikDialogSettings extends AppCompatDialogFragment implements Seek
     mDurationText = new TextView[BaseEffect.Type.LENGTH];
     }
 
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  @Override
+  public void onStart()
+    {
+    super.onStart();
+
+    Window window = getDialog().getWindow();
+    window.setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,
+                    WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);
+    window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
+    }
+
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
   @NonNull
@@ -211,7 +213,7 @@ public class RubikDialogSettings extends AppCompatDialogFragment implements Seek
     LayoutInflater inflater = act.getLayoutInflater();
     AlertDialog.Builder builder = new AlertDialog.Builder(act);
     TextView tv = (TextView) inflater.inflate(R.layout.dialog_title, null);
-    tv.setText(R.string.settings_title);
+    tv.setText(R.string.settings);
     builder.setCustomTitle(tv);
 
     builder.setCancelable(true);
diff --git a/src/main/java/org/distorted/magic/RubikRenderer.java b/src/main/java/org/distorted/magic/RubikRenderer.java
index 9b7592e7..833ea422 100644
--- a/src/main/java/org/distorted/magic/RubikRenderer.java
+++ b/src/main/java/org/distorted/magic/RubikRenderer.java
@@ -242,7 +242,6 @@ public class RubikRenderer implements GLSurfaceView.Renderer, EffectListener
          mCanRotate      = false;
          mCanUI          = false;
          doEffectNow( BaseEffect.Type.WIN );
-         mView.leaveScrambleModeNonUI();
          }
        else
          {
diff --git a/src/main/java/org/distorted/magic/RubikScoresDownloader.java b/src/main/java/org/distorted/magic/RubikScoresDownloader.java
index 57d20b35..0a167f04 100644
--- a/src/main/java/org/distorted/magic/RubikScoresDownloader.java
+++ b/src/main/java/org/distorted/magic/RubikScoresDownloader.java
@@ -86,9 +86,9 @@ class RubikScoresDownloader implements Runnable
   private static String mPackageName;
 
   private static String mScores = "";
-  private static int[][][] mCountry = new int   [RubikSize.LENGTH][RubikActivity.MAX_SCRAMBLE][MAX_PLACES];
-  private static String[][][] mName = new String[RubikSize.LENGTH][RubikActivity.MAX_SCRAMBLE][MAX_PLACES];
-  private static String[][][] mTime = new String[RubikSize.LENGTH][RubikActivity.MAX_SCRAMBLE][MAX_PLACES];
+  private static int[][][] mCountry = new int   [RubikSize.LENGTH][RubikSurfaceView.MAX_SCRAMBLE][MAX_PLACES];
+  private static String[][][] mName = new String[RubikSize.LENGTH][RubikSurfaceView.MAX_SCRAMBLE][MAX_PLACES];
+  private static String[][][] mTime = new String[RubikSize.LENGTH][RubikSurfaceView.MAX_SCRAMBLE][MAX_PLACES];
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
@@ -129,7 +129,7 @@ class RubikScoresDownloader implements Runnable
         String country = row.substring(s5+1, s6);
         String realTime= String.valueOf(time/10.0f);
 
-        if(level>=0 && level<RubikActivity.MAX_SCRAMBLE && place>=0 && place<MAX_PLACES)
+        if(level>=0 && level<RubikSurfaceView.MAX_SCRAMBLE && place>=0 && place<MAX_PLACES)
           {
           int resID = mResources.getIdentifier( country, "drawable", mPackageName);
           mCountry[size][level][place] = resID!=0 ? resID:R.drawable.unk;
diff --git a/src/main/java/org/distorted/magic/RubikSurfaceView.java b/src/main/java/org/distorted/magic/RubikSurfaceView.java
index d05b9116..b7c66e9c 100644
--- a/src/main/java/org/distorted/magic/RubikSurfaceView.java
+++ b/src/main/java/org/distorted/magic/RubikSurfaceView.java
@@ -21,19 +21,25 @@ package org.distorted.magic;
 
 import android.app.ActivityManager;
 import android.content.Context;
+import android.content.SharedPreferences;
 import android.content.pm.ConfigurationInfo;
 import android.graphics.PorterDuff;
 import android.graphics.drawable.Drawable;
 import android.opengl.GLSurfaceView;
+import android.preference.PreferenceManager;
 import android.support.v4.content.ContextCompat;
 import android.util.AttributeSet;
 import android.util.DisplayMetrics;
+import android.view.LayoutInflater;
 import android.view.MotionEvent;
+import android.view.View;
 import android.view.ViewGroup;
 import android.widget.Button;
 import android.widget.ImageButton;
 import android.widget.LinearLayout;
 
+import org.distorted.component.HorizontalNumberPicker;
+import org.distorted.effect.BaseEffect;
 import org.distorted.library.type.Static2D;
 import org.distorted.library.type.Static4D;
 import org.distorted.object.RubikCube;
@@ -43,6 +49,13 @@ import org.distorted.object.RubikCubeMovement;
 
 public class RubikSurfaceView extends GLSurfaceView
 {
+    public static final int BUTTON_ID_BACK= 1023;
+    public static final int BUTTON_ID_EXIT= 1022;
+
+    public static final int MIN_SCRAMBLE =  1;
+    public static final int DEF_SCRAMBLE =  1;
+    public static final int MAX_SCRAMBLE = 18;
+
     // Moving the finger from the middle of the vertical screen to the right edge will rotate a
     // given face by SWIPING_SENSITIVITY/2 degrees.
     private final static int SWIPING_SENSITIVITY  = 240;
@@ -55,17 +68,60 @@ public class RubikSurfaceView extends GLSurfaceView
 
     private RubikRenderer mRenderer;
     private RubikCubeMovement mMovement;
-    private boolean mInScrambleMode;
     private boolean mDragging, mBeginningRotation, mContinuingRotation;
     private float mX, mY;
     private int mScreenWidth, mScreenHeight, mScreenMin;
 
+    private HorizontalNumberPicker mPicker;
+    private int mScrambleValue;
+
     private static int mButton = RubikSize.SIZE3.ordinal();
     private static Static4D mQuatCurrent    = new Static4D(0,0,0,1);
     private static Static4D mQuatAccumulated= new Static4D(-0.25189602f,0.3546389f,0.009657208f,0.90038127f);
     private static Static4D mTempCurrent    = new Static4D(0,0,0,1);
     private static Static4D mTempAccumulated= new Static4D(0,0,0,1);
 
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+    void scramble()
+      {
+      int scramble = mPicker.getValue();
+      mRenderer.scrambleCube(scramble);
+      }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+    void savePreferences()
+      {
+      RubikActivity act = (RubikActivity)getContext();
+      SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(act);
+      SharedPreferences.Editor editor = preferences.edit();
+
+      for (int i = 0; i< BaseEffect.Type.LENGTH; i++)
+        {
+        BaseEffect.Type.getType(i).savePreferences(editor);
+        }
+
+      editor.putInt("scramble", mScrambleValue );
+
+      editor.apply();
+      }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+    void restorePreferences()
+      {
+      RubikActivity act = (RubikActivity)getContext();
+      SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(act);
+
+      for (int i=0; i< BaseEffect.Type.LENGTH; i++)
+        {
+        BaseEffect.Type.getType(i).restorePreferences(preferences);
+        }
+
+      mScrambleValue= preferences.getInt("scramble", DEF_SCRAMBLE);
+      }
+
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
     void setScreenSize(int width, int height)
@@ -224,12 +280,65 @@ public class RubikSurfaceView extends GLSurfaceView
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-    void addSizeButtons(RubikActivity act)
+    void enterMainState(RubikActivity act)
+      {
+      LayoutInflater inflater = act.getLayoutInflater();
+
+      // TOP ////////////////////////////
+      LinearLayout layoutTop = act.findViewById(R.id.mainTitle);
+      layoutTop.removeAllViews();
+      final View viewTop = inflater.inflate(R.layout.main_title, null);
+      layoutTop.addView(viewTop);
+
+      // BOT ////////////////////////////
+      LinearLayout layoutBot = act.findViewById(R.id.mainBar);
+      layoutBot.removeAllViews();
+
+      DisplayMetrics metrics = getResources().getDisplayMetrics();
+      float scale = metrics.density;
+      int size = (int)(60*scale +0.5f);
+      int padding = (int)(5*scale + 0.5f);
+      LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,size,0.5f);
+
+      Button buttonL = new Button(act);
+      buttonL.setLayoutParams(params);
+      buttonL.setId(BUTTON_ID_EXIT);
+      buttonL.setPadding(padding,0,padding,0);
+      buttonL.setText(R.string.back);
+      buttonL.setOnClickListener(act);
+      layoutBot.addView(buttonL);
+
+      Button buttonR = new Button(act);
+      buttonR.setLayoutParams(params);
+      buttonR.setId(BUTTON_ID_EXIT);
+      buttonR.setPadding(padding,0,padding,0);
+      buttonR.setText(R.string.exit);
+      buttonR.setOnClickListener(act);
+      layoutBot.addView(buttonR);
+
+      buttonL.setVisibility(INVISIBLE);
+      }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+    void enterPlayState(RubikActivity act)
       {
-      LinearLayout layout = act.findViewById(R.id.sizeLayout);
+      LayoutInflater inflater = act.getLayoutInflater();
+
+      // TOP ////////////////////////////
+      LinearLayout layoutTop = act.findViewById(R.id.mainTitle);
+      layoutTop.removeAllViews();
+
+      final View viewTop = inflater.inflate(R.layout.play_title, null);
+      layoutTop.addView(viewTop);
+
+      // BOT ////////////////////////////
+      LinearLayout layoutBot = act.findViewById(R.id.mainBar);
+      layoutBot.removeAllViews();
+
       DisplayMetrics metrics = getResources().getDisplayMetrics();
       float scale = metrics.density;
-      int size = (int)(64*scale +0.5f);
+      int size = (int)(60*scale +0.5f);
       int padding = (int)(3*scale + 0.5f);
       ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(size,size);
 
@@ -242,78 +351,31 @@ public class RubikSurfaceView extends GLSurfaceView
         int iconID = RubikSize.getSize(i).getIconID();
         button.setImageResource(iconID);
         button.setOnClickListener(act);
-        layout.addView(button);
+        layoutBot.addView(button);
         }
-      }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-    void enterScrambleMode()
-      {
-      if( !mInScrambleMode )
-        {
-        mInScrambleMode = true;
 
-        android.util.Log.e("view", "entering scramble mode");
+      ViewGroup.LayoutParams params2 = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,size);
 
-        RubikActivity act = (RubikActivity)getContext();
+      Button button = new Button(act);
+      button.setLayoutParams(params2);
+      button.setId(BUTTON_ID_BACK);
+      button.setPadding(padding,0,padding,0);
+      button.setText(R.string.back);
+      button.setOnClickListener(act);
+      layoutBot.addView(button);
 
-        Button scrambleButt = act.findViewById(R.id.rubikScramble);
+      markButton(mButton);
 
-        if( scrambleButt!=null )
-          {
-          scrambleButt.setClickable(false);
-          scrambleButt.setVisibility(INVISIBLE);
-          }
-        else
-          {
-          android.util.Log.e("view", "button null!");
-          }
-        }
-      }
+      mPicker = act.findViewById(R.id.rubikNumberPicker);
 
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-    void leaveScrambleMode()
-      {
-      if( mInScrambleMode )
+      if( mPicker!=null )
         {
-        mInScrambleMode = false;
-
-        android.util.Log.e("view", "leaving scramble mode");
-
-        RubikActivity act = (RubikActivity)getContext();
-
-        Button scrambleButt = act.findViewById(R.id.rubikScramble);
-
-        if( scrambleButt!=null )
-          {
-          scrambleButt.setClickable(true);
-          scrambleButt.setVisibility(VISIBLE);
-          }
-        else
-          {
-          android.util.Log.e("view", "button null!");
-          }
+        mPicker.setMin(MIN_SCRAMBLE);
+        mPicker.setMax(MAX_SCRAMBLE);
+        mPicker.setValue(mScrambleValue);
         }
       }
 
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-    void leaveScrambleModeNonUI()
-      {
-      RubikActivity act = (RubikActivity)getContext();
-
-      act.runOnUiThread(new Runnable()
-        {
-        @Override
-        public void run()
-          {
-          leaveScrambleMode();
-          }
-        });
-      }
-
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 // PUBLIC API
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -324,7 +386,6 @@ public class RubikSurfaceView extends GLSurfaceView
 
       if(!isInEditMode())
         {
-        mInScrambleMode = false;
         mRenderer = new RubikRenderer(this);
         mMovement = new RubikCubeMovement();
 
diff --git a/src/main/res/layout/dialog_main.xml b/src/main/res/layout/dialog_main.xml
index 720c6cff..82567e7b 100644
--- a/src/main/res/layout/dialog_main.xml
+++ b/src/main/res/layout/dialog_main.xml
@@ -1,43 +1,55 @@
 <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:gravity="center_horizontal"
-    android:orientation="vertical">
+     android:layout_width="fill_parent"
+     android:layout_height="fill_parent"
+     android:gravity="center|fill_horizontal"
+     android:layout_marginLeft="10dp"
+     android:layout_marginRight="10dp"
+     android:layout_marginTop="10dp"
+     android:layout_marginBottom="10dp"
+     android:background="@color/grey"
+     android:orientation="vertical">
 
+     <Button
+         android:id="@+id/rubikPlay"
+         android:layout_width="fill_parent"
+         android:layout_height="fill_parent"
+         android:layout_weight="1"
+         android:onClick="Play"
+         android:layout_marginTop="10dp"
+         android:layout_marginLeft="10dp"
+         android:layout_marginRight="10dp"
+         android:text="@string/play" />
 
-    <LinearLayout
-        android:layout_width="fill_parent"
-        android:layout_height="fill_parent"
-        android:gravity="center|fill_horizontal"
-        android:layout_marginLeft="10dp"
-        android:layout_marginRight="10dp"
-        android:layout_marginTop="20dp"
-        android:background="@color/grey"
-        android:orientation="vertical">
+     <Button
+         android:id="@+id/rubikSettings"
+         android:layout_width="fill_parent"
+         android:layout_height="fill_parent"
+         android:layout_weight="1"
+         android:onClick="Settings"
+         android:layout_marginLeft="10dp"
+         android:layout_marginRight="10dp"
+         android:text="@string/settings" />
 
-        <TextView
-            android:layout_width="match_parent"
-            android:layout_height="fill_parent"
-            android:layout_weight="0.40"
-            android:layout_marginTop="10dp"
-            android:layout_marginLeft="10dp"
-            android:layout_marginRight="10dp"
-            android:layout_marginBottom="10dp"
-            android:text="@string/credits1"/>
+     <Button
+         android:id="@+id/rubikScores"
+         android:layout_width="fill_parent"
+         android:layout_height="fill_parent"
+         android:layout_weight="1"
+         android:onClick="Scores"
+         android:layout_marginLeft="10dp"
+         android:layout_marginRight="10dp"
+         android:text="@string/scores" />
 
-        <TextView
-            android:layout_width="match_parent"
-            android:layout_height="fill_parent"
-            android:layout_weight="0.60"
-            android:layout_marginBottom="10dp"
-            android:layout_marginTop="10dp"
-            android:layout_marginLeft="10dp"
-            android:layout_marginRight="10dp"
-            android:linksClickable="true"
-            android:autoLink="web"
-            android:text="@string/credits2"/>
-
-    </LinearLayout>
+     <Button
+         android:id="@+id/rubikAbout"
+         android:layout_width="fill_parent"
+         android:layout_height="fill_parent"
+         android:layout_weight="1"
+         android:onClick="About"
+         android:layout_marginLeft="10dp"
+         android:layout_marginRight="10dp"
+         android:layout_marginBottom="10dp"
+         android:text="@string/about" />
 
 </LinearLayout>
\ No newline at end of file
diff --git a/src/main/res/layout/main.xml b/src/main/res/layout/main.xml
index 2a29cda2..25720d1a 100644
--- a/src/main/res/layout/main.xml
+++ b/src/main/res/layout/main.xml
@@ -5,35 +5,11 @@
     android:orientation="vertical" >
 
     <LinearLayout
+        android:id="@+id/mainTitle"
         android:layout_width="fill_parent"
         android:layout_height="50dp"
-        android:gravity="center|fill_horizontal" >
-
-        <Button
-            android:id="@+id/rubikScramble"
-            android:layout_width="wrap_content"
-            android:layout_height="fill_parent"
-            android:layout_weight="0.5"
-            android:onClick="Scramble"
-            android:paddingLeft="5dp"
-            android:paddingRight="5dp"
-            android:text="@string/scramble" />
-
-        <org.distorted.component.HorizontalNumberPicker
-            android:id="@+id/rubikNumberPicker"
-            android:layout_width="192dp"
-            android:layout_height="fill_parent"/>
-
-        <Button
-            android:id="@+id/rubikSolve"
-            android:layout_width="wrap_content"
-            android:layout_height="fill_parent"
-            android:layout_weight="0.5"
-            android:onClick="Solve"
-            android:paddingLeft="5dp"
-            android:paddingRight="5dp"
-            android:text="@string/solve" />
-
+        android:gravity="center"
+        android:orientation="horizontal">
     </LinearLayout>
 
     <org.distorted.magic.RubikSurfaceView
@@ -43,48 +19,11 @@
         android:layout_weight="1" />
 
     <LinearLayout
-        android:id="@+id/sizeLayout"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:gravity="center"
-        android:orientation="horizontal">
-    </LinearLayout>
-
-    <LinearLayout
+        android:id="@+id/mainBar"
         android:layout_width="fill_parent"
-        android:layout_height="50dp"
-        android:gravity="center|fill_horizontal" >
-
-        <Button
-            android:id="@+id/rubikSettings"
-            android:layout_width="wrap_content"
-            android:layout_height="fill_parent"
-            android:layout_weight="1"
-            android:onClick="Settings"
-            android:paddingLeft="3dp"
-            android:paddingRight="3dp"
-            android:text="@string/settings" />
-
-        <Button
-            android:id="@+id/rubikScores"
-            android:layout_width="wrap_content"
-            android:layout_height="fill_parent"
-            android:layout_weight="1"
-            android:onClick="Scores"
-            android:paddingLeft="3dp"
-            android:paddingRight="3dp"
-            android:text="@string/scores" />
-
-        <Button
-            android:id="@+id/rubikAbout"
-            android:layout_width="wrap_content"
-            android:layout_height="fill_parent"
-            android:layout_weight="1"
-            android:onClick="About"
-            android:paddingLeft="3dp"
-            android:paddingRight="3dp"
-            android:text="@string/about" />
-
+        android:layout_height="60dp"
+        android:gravity="right"
+        android:orientation="horizontal">
     </LinearLayout>
 
 </LinearLayout>
diff --git a/src/main/res/layout/main_title.xml b/src/main/res/layout/main_title.xml
new file mode 100644
index 00000000..f8fc1480
--- /dev/null
+++ b/src/main/res/layout/main_title.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<TextView xmlns:android="http://schemas.android.com/apk/res/android"
+        android:layout_width="fill_parent"
+        android:layout_height="50dp"
+        android:textAlignment="center"
+        android:textSize="30sp"
+        android:text="@string/app_name"/>
diff --git a/src/main/res/layout/play.xml b/src/main/res/layout/play.xml
new file mode 100644
index 00000000..5f21efda
--- /dev/null
+++ b/src/main/res/layout/play.xml
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="fill_parent"
+    android:layout_height="fill_parent"
+    android:orientation="vertical" >
+
+    <LinearLayout
+        android:layout_width="fill_parent"
+        android:layout_height="50dp"
+        android:gravity="center|fill_horizontal" >
+
+        <Button
+            android:id="@+id/rubikScramble"
+            android:layout_width="wrap_content"
+            android:layout_height="fill_parent"
+            android:layout_weight="0.5"
+            android:onClick="Scramble"
+            android:paddingLeft="5dp"
+            android:paddingRight="5dp"
+            android:text="@string/scramble" />
+
+        <org.distorted.component.HorizontalNumberPicker
+            android:id="@+id/rubikNumberPicker"
+            android:layout_width="192dp"
+            android:layout_height="fill_parent"/>
+
+        <Button
+            android:id="@+id/rubikSolve"
+            android:layout_width="wrap_content"
+            android:layout_height="fill_parent"
+            android:layout_weight="0.5"
+            android:onClick="Solve"
+            android:paddingLeft="5dp"
+            android:paddingRight="5dp"
+            android:text="@string/solve" />
+
+    </LinearLayout>
+
+    <org.distorted.magic.RubikSurfaceView
+        android:id="@+id/rubikSurfaceView"
+        android:layout_width="fill_parent"
+        android:layout_height="0dp"
+        android:layout_weight="1" />
+
+    <LinearLayout
+        android:id="@+id/sizeLayout"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:gravity="center"
+        android:orientation="horizontal">
+    </LinearLayout>
+
+</LinearLayout>
diff --git a/src/main/res/layout/play_title.xml b/src/main/res/layout/play_title.xml
new file mode 100644
index 00000000..d950e886
--- /dev/null
+++ b/src/main/res/layout/play_title.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="fill_parent"
+    android:layout_height="fill_parent"
+    android:orientation="horizontal" >
+
+    <Button
+        android:id="@+id/rubikScramble"
+        android:layout_width="fill_parent"
+        android:layout_height="fill_parent"
+        android:layout_weight="0.2"
+        android:onClick="Scramble"
+        android:paddingLeft="5dp"
+        android:paddingRight="5dp"
+        android:text="@string/scramble" />
+
+    <org.distorted.component.HorizontalNumberPicker
+        android:id="@+id/rubikNumberPicker"
+        android:layout_width="192dp"
+        android:layout_height="fill_parent"/>
+
+    <Button
+        android:id="@+id/rubikSolve"
+        android:layout_width="fill_parent"
+        android:layout_height="fill_parent"
+        android:layout_weight="0.2"
+        android:onClick="Solve"
+        android:paddingLeft="5dp"
+        android:paddingRight="5dp"
+        android:text="@string/solve" />
+
+</LinearLayout>
diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml
index 11b9c760..54891260 100644
--- a/src/main/res/values/strings.xml
+++ b/src/main/res/values/strings.xml
@@ -4,12 +4,12 @@
     <string name="distorted">DISTORTED</string>
     <string name="scramble">Scramble</string>
     <string name="solve">Solve</string>
+    <string name="exit">Exit</string>
+    <string name="play">Play</string>
     <string name="settings">Settings</string>
-    <string name="scores">Scores</string>
-    <string name="scores_title">High Scores</string>
-    <string name="settings_title">Settings</string>
-    <string name="about_title">About</string>
+    <string name="scores">High Scores</string>
     <string name="about">About</string>
+    <string name="back">Back</string>
     <string name="save">SAVE</string>
     <string name="ok">OK</string>
     <string name="sizechange_effect">Size Change Effect</string>
