commit 59535491e7f29e1e709ad32a40a3ed8cbada625b
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Fri Jun 26 22:10:34 2020 +0100

    Save the name of the current state to Shared Prefs (and not the ordinal which might change in the future!)

diff --git a/src/main/java/org/distorted/states/RubikState.java b/src/main/java/org/distorted/states/RubikState.java
index c6d5aa0c..f98b44ac 100644
--- a/src/main/java/org/distorted/states/RubikState.java
+++ b/src/main/java/org/distorted/states/RubikState.java
@@ -44,18 +44,18 @@ public enum RubikState
   private final RubikState mBack;
   private int mMode;
   private final RubikStateAbstract mClass;
-  private static final RubikState[] sizes;
+  private static final RubikState[] states;
 
   private static RubikState mCurrState;
 
   static
     {
     int i = 0;
-    sizes = new RubikState[LENGTH];
+    states = new RubikState[LENGTH];
 
-    for(RubikState size: RubikState.values())
+    for(RubikState state: RubikState.values())
       {
-      sizes[i] = size;
+      states[i] = state;
       i++;
       }
     }
@@ -64,7 +64,22 @@ public enum RubikState
 
   public static RubikState getState(int ordinal)
     {
-    return ordinal>=0 && ordinal<LENGTH ?  sizes[ordinal] : PLAY;
+    return ordinal>=0 && ordinal<LENGTH ?  states[ordinal] : PLAY;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  public static RubikState getStateFromName(String name)
+    {
+    for(int i=0; i<LENGTH; i++)
+      {
+      if( name.equals(states[i].name()) )
+        {
+        return states[i];
+        }
+      }
+
+    return PLAY;
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -85,15 +100,15 @@ public enum RubikState
 
   public static void savePreferences(SharedPreferences.Editor editor)
     {
-    editor.putInt("curr_state", mCurrState.ordinal() );
+    editor.putString("curr_state_name", mCurrState.name() );
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
   public static void restorePreferences(SharedPreferences preferences)
     {
-    int currState = preferences.getInt("curr_state", RubikState.PLAY.ordinal() );
-    mCurrState = getState(currState);
+    String currStateName = preferences.getString("curr_state_name", RubikState.PLAY.name() );
+    mCurrState = getStateFromName(currStateName);
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
