commit 146661ecde8e156e3712a085d309d12320ad3dc3
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Tue Jun 29 16:34:05 2021 +0200

    Change the 'Cube Back' icon when there are no moves to back.

diff --git a/src/main/java/org/distorted/helpers/MovesAndLockController.java b/src/main/java/org/distorted/helpers/MovesAndLockController.java
index f45dea33..bf0950ac 100644
--- a/src/main/java/org/distorted/helpers/MovesAndLockController.java
+++ b/src/main/java/org/distorted/helpers/MovesAndLockController.java
@@ -76,17 +76,43 @@ public class MovesAndLockController implements MovesFinished
     {
     if( act.retLocked() )
       {
-      return RubikActivity.getDrawable(R.drawable.ui_small_locked,R.drawable.ui_medium_locked, R.drawable.ui_big_locked, R.drawable.ui_huge_locked);
+      return RubikActivity.getDrawable(R.drawable.ui_small_locked,
+                                       R.drawable.ui_medium_locked,
+                                       R.drawable.ui_big_locked,
+                                       R.drawable.ui_huge_locked);
       }
     else
       {
-      return RubikActivity.getDrawable(R.drawable.ui_small_unlocked,R.drawable.ui_medium_unlocked, R.drawable.ui_big_unlocked, R.drawable.ui_huge_unlocked);
+      return RubikActivity.getDrawable(R.drawable.ui_small_unlocked,
+                                       R.drawable.ui_medium_unlocked,
+                                       R.drawable.ui_big_unlocked,
+                                       R.drawable.ui_huge_unlocked);
+      }
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  public int getPrevIcon(boolean on)
+    {
+    if( on )
+      {
+      return RubikActivity.getDrawable(R.drawable.ui_small_cube_back,
+                                       R.drawable.ui_medium_cube_back,
+                                       R.drawable.ui_big_cube_back,
+                                       R.drawable.ui_huge_cube_back);
+      }
+    else
+      {
+      return RubikActivity.getDrawable(R.drawable.ui_small_cube_grey,
+                                       R.drawable.ui_medium_cube_grey,
+                                       R.drawable.ui_big_cube_grey,
+                                       R.drawable.ui_huge_cube_grey);
       }
     }
 
 //////////////////////////////////////////////////////////////////////////////////////////////////
 
-  public void backMove(TwistyPreRender pre)
+  public void backMove(TwistyActivity act)
     {
     if( mCanPrevMove )
       {
@@ -103,22 +129,40 @@ public class MovesAndLockController implements MovesFinished
         if( angle!=0 )
           {
           mCanPrevMove = false;
-          mPre = pre;
-          pre.blockTouch();
-          pre.addRotation(this, axis, row, -angle, duration);
+          mPre = act.getTwistyPreRender();
+          mPre.blockTouch();
+          mPre.addRotation(this, axis, row, -angle, duration);
           }
         else
           {
           android.util.Log.e("solution", "error: trying to back move of angle 0");
           }
+
+        if( numMoves==1 ) changeBackMove(act, false);
         }
       }
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-  public void addMove(int axis, int row, int angle)
+  private void changeBackMove(TwistyActivity act, final boolean on)
+    {
+    act.runOnUiThread(new Runnable()
+      {
+      @Override
+      public void run()
+        {
+        if( mPrevButton!=null )
+          mPrevButton.setImageResource(getPrevIcon(on));
+        }
+      });
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  public void addMove(TwistyActivity act, int axis, int row, int angle)
     {
+    if( mMoves.isEmpty()) changeBackMove(act,true);
     mMoves.add(new Move(axis,row,angle));
     }
 
@@ -141,7 +185,7 @@ public class MovesAndLockController implements MovesFinished
 
   public void setupPrevButton(final TwistyActivity act, final float width)
     {
-    int icon = RubikActivity.getDrawable(R.drawable.ui_small_cube_back,R.drawable.ui_medium_cube_back, R.drawable.ui_big_cube_back, R.drawable.ui_huge_cube_back);
+    final int icon = getPrevIcon( !mMoves.isEmpty() );
     mPrevButton = new TransparentImageButton(act, icon, width, LinearLayout.LayoutParams.MATCH_PARENT);
 
     mPrevButton.setOnClickListener( new View.OnClickListener()
@@ -149,8 +193,7 @@ public class MovesAndLockController implements MovesFinished
       @Override
       public void onClick(View v)
         {
-        TwistyPreRender pre = act.getTwistyPreRender();
-        backMove(pre);
+        backMove(act);
         }
       });
     }
diff --git a/src/main/java/org/distorted/main/RubikSurfaceView.java b/src/main/java/org/distorted/main/RubikSurfaceView.java
index 3a61bc5c..5fc9ebeb 100644
--- a/src/main/java/org/distorted/main/RubikSurfaceView.java
+++ b/src/main/java/org/distorted/main/RubikSurfaceView.java
@@ -399,13 +399,15 @@ public class RubikSurfaceView extends GLSurfaceView
         {
         if( ScreenList.getCurrentScreen()== ScreenList.SOLV )
           {
+          RubikActivity act = (RubikActivity)getContext();
           RubikScreenSolving solving = (RubikScreenSolving) ScreenList.SOLV.getScreenClass();
-          solving.addMove(mCurrentAxis, mCurrentRow, angle);
+          solving.addMove(act, mCurrentAxis, mCurrentRow, angle);
           }
         if( ScreenList.getCurrentScreen()== ScreenList.PLAY )
           {
+          RubikActivity act = (RubikActivity)getContext();
           RubikScreenPlay play = (RubikScreenPlay) ScreenList.PLAY.getScreenClass();
-          play.addMove(mCurrentAxis, mCurrentRow, angle);
+          play.addMove(act, mCurrentAxis, mCurrentRow, angle);
           }
         }
 
diff --git a/src/main/java/org/distorted/screens/RubikScreenBase.java b/src/main/java/org/distorted/screens/RubikScreenBase.java
index ba414a67..83aaa692 100644
--- a/src/main/java/org/distorted/screens/RubikScreenBase.java
+++ b/src/main/java/org/distorted/screens/RubikScreenBase.java
@@ -23,6 +23,7 @@ import android.widget.ImageButton;
 import android.widget.LinearLayout;
 
 import org.distorted.helpers.MovesAndLockController;
+import org.distorted.helpers.TwistyActivity;
 import org.distorted.main.R;
 import org.distorted.main.RubikActivity;
 
@@ -36,8 +37,6 @@ abstract class RubikScreenBase extends RubikScreenAbstract
 
   void createBottomPane(final RubikActivity act, float width, ImageButton button)
     {
-    if( mController==null ) mController = new MovesAndLockController();
-
     LinearLayout layoutBot = act.findViewById(R.id.lowerBar);
     layoutBot.removeAllViews();
 
@@ -68,10 +67,18 @@ abstract class RubikScreenBase extends RubikScreenAbstract
     mController.setLockState(act);
     }
 
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// PUBLIC API
+
+  public RubikScreenBase()
+    {
+    mController = new MovesAndLockController();
+    }
+
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-  public void addMove(int axis, int row, int angle)
+  public void addMove(TwistyActivity act, int axis, int row, int angle)
     {
-    mController.addMove(axis,row,angle);
+    mController.addMove(act,axis,row,angle);
     }
   }
diff --git a/src/main/java/org/distorted/tutorials/TutorialState.java b/src/main/java/org/distorted/tutorials/TutorialState.java
index a2df7216..00a25b4a 100644
--- a/src/main/java/org/distorted/tutorials/TutorialState.java
+++ b/src/main/java/org/distorted/tutorials/TutorialState.java
@@ -24,6 +24,7 @@ import android.widget.ImageButton;
 import android.widget.LinearLayout;
 
 import org.distorted.helpers.MovesAndLockController;
+import org.distorted.helpers.TwistyActivity;
 import org.distorted.main.R;
 import org.distorted.main.RubikActivity;
 import org.distorted.objects.ObjectList;
@@ -36,7 +37,7 @@ import org.distorted.helpers.TransparentImageButton;
 public class TutorialState
 {
   private ImageButton mSolveButton, mScrambleButton, mBackButton;
-  private MovesAndLockController mController;
+  private final MovesAndLockController mController;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
@@ -100,8 +101,6 @@ public class TutorialState
 
   void createRightPane(final TutorialActivity act, float width)
     {
-    if( mController==null ) mController = new MovesAndLockController();
-
     LinearLayout layout = act.findViewById(R.id.tutorialRightBar);
     layout.removeAllViews();
 
@@ -120,8 +119,16 @@ public class TutorialState
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-  void addMove(int axis, int row, int angle)
+  void addMove(TwistyActivity act, int axis, int row, int angle)
+    {
+    mController.addMove(act, axis,row,angle);
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// PUBLIC API
+
+  public TutorialState()
     {
-    mController.addMove(axis,row,angle);
+    mController = new MovesAndLockController();
     }
 }
diff --git a/src/main/java/org/distorted/tutorials/TutorialSurfaceView.java b/src/main/java/org/distorted/tutorials/TutorialSurfaceView.java
index 0f4b8197..22e0dd71 100644
--- a/src/main/java/org/distorted/tutorials/TutorialSurfaceView.java
+++ b/src/main/java/org/distorted/tutorials/TutorialSurfaceView.java
@@ -373,7 +373,7 @@ public class TutorialSurfaceView extends GLSurfaceView
         {
         final TutorialActivity act = (TutorialActivity)getContext();
         TutorialState state = act.getState();
-        state.addMove(mCurrentAxis, mCurrentRow, angle);
+        state.addMove(act,mCurrentAxis, mCurrentRow, angle);
         }
 
       mContinuingRotation = false;
diff --git a/src/main/res/drawable-nodpi/ui_big_cube_grey.png b/src/main/res/drawable-nodpi/ui_big_cube_grey.png
new file mode 100644
index 00000000..7919378b
Binary files /dev/null and b/src/main/res/drawable-nodpi/ui_big_cube_grey.png differ
diff --git a/src/main/res/drawable-nodpi/ui_big_locked_red.png b/src/main/res/drawable-nodpi/ui_big_locked_red.png
new file mode 100644
index 00000000..9443c67d
Binary files /dev/null and b/src/main/res/drawable-nodpi/ui_big_locked_red.png differ
diff --git a/src/main/res/drawable-nodpi/ui_huge_cube_grey.png b/src/main/res/drawable-nodpi/ui_huge_cube_grey.png
new file mode 100644
index 00000000..2f95c0e6
Binary files /dev/null and b/src/main/res/drawable-nodpi/ui_huge_cube_grey.png differ
diff --git a/src/main/res/drawable-nodpi/ui_huge_locked_red.png b/src/main/res/drawable-nodpi/ui_huge_locked_red.png
new file mode 100644
index 00000000..aa6b60c6
Binary files /dev/null and b/src/main/res/drawable-nodpi/ui_huge_locked_red.png differ
diff --git a/src/main/res/drawable-nodpi/ui_medium_cube_grey.png b/src/main/res/drawable-nodpi/ui_medium_cube_grey.png
new file mode 100644
index 00000000..db5bfc22
Binary files /dev/null and b/src/main/res/drawable-nodpi/ui_medium_cube_grey.png differ
diff --git a/src/main/res/drawable-nodpi/ui_medium_locked_red.png b/src/main/res/drawable-nodpi/ui_medium_locked_red.png
new file mode 100644
index 00000000..f3a7ea35
Binary files /dev/null and b/src/main/res/drawable-nodpi/ui_medium_locked_red.png differ
diff --git a/src/main/res/drawable-nodpi/ui_small_cube_grey.png b/src/main/res/drawable-nodpi/ui_small_cube_grey.png
new file mode 100644
index 00000000..51563baa
Binary files /dev/null and b/src/main/res/drawable-nodpi/ui_small_cube_grey.png differ
diff --git a/src/main/res/drawable-nodpi/ui_small_locked_red.png b/src/main/res/drawable-nodpi/ui_small_locked_red.png
new file mode 100644
index 00000000..5ae8476a
Binary files /dev/null and b/src/main/res/drawable-nodpi/ui_small_locked_red.png differ
