commit 8e1231ae64d413bc9814b32627730ac0c0ce6e02
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Thu Feb 20 15:26:53 2020 +0000

    Saving Cube state: done

diff --git a/src/main/java/org/distorted/object/RubikCube.java b/src/main/java/org/distorted/object/RubikCube.java
index f4c7c533..3724da86 100644
--- a/src/main/java/org/distorted/object/RubikCube.java
+++ b/src/main/java/org/distorted/object/RubikCube.java
@@ -373,17 +373,48 @@ public class RubikCube extends DistortedNode
       }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
+// mSize already saved as RubikStatePlay.mButton
 
    public void savePreferences(SharedPreferences.Editor editor)
      {
-     android.util.Log.e("cube", "saving Preferences");
+     float qx,qy,qz,qw;
+
+     for(int x=0; x<mSize; x++)
+        for(int y=0; y<mSize; y++)
+          for(int z=0; z<mSize; z++)
+            if( x==0 || x==mSize-1 || y==0 || y==mSize-1 || z==0 || z==mSize-1 )
+              {
+              qx = mQuatScramble[x][y][z].get0();
+              qy = mQuatScramble[x][y][z].get1();
+              qz = mQuatScramble[x][y][z].get2();
+              qw = mQuatScramble[x][y][z].get3();
+
+              editor.putFloat("qx_"+x+"_"+y+"_"+z, qx);
+              editor.putFloat("qy_"+x+"_"+y+"_"+z, qy);
+              editor.putFloat("qz_"+x+"_"+y+"_"+z, qz);
+              editor.putFloat("qw_"+x+"_"+y+"_"+z, qw);
+              }
      }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
    public void restorePreferences(SharedPreferences preferences)
      {
-     android.util.Log.e("cube", "restoring Preferences");
+     float qx,qy,qz,qw;
+
+     for(int x=0; x<mSize; x++)
+        for(int y=0; y<mSize; y++)
+          for(int z=0; z<mSize; z++)
+            if( x==0 || x==mSize-1 || y==0 || y==mSize-1 || z==0 || z==mSize-1 )
+              {
+              qx = preferences.getFloat("qx_"+x+"_"+y+"_"+z, 0.0f);
+              qy = preferences.getFloat("qy_"+x+"_"+y+"_"+z, 0.0f);
+              qz = preferences.getFloat("qz_"+x+"_"+y+"_"+z, 0.0f);
+              qw = preferences.getFloat("qw_"+x+"_"+y+"_"+z, 1.0f);
+
+              mQuatScramble[x][y][z].set(qx,qy,qz,qw);
+              modifyCurrentPosition(x, y, z, mQuatScramble[x][y][z]);
+              }
      }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/java/org/distorted/uistate/RubikStatePlay.java b/src/main/java/org/distorted/uistate/RubikStatePlay.java
index 0e911693..a381a480 100644
--- a/src/main/java/org/distorted/uistate/RubikStatePlay.java
+++ b/src/main/java/org/distorted/uistate/RubikStatePlay.java
@@ -43,10 +43,11 @@ public class RubikStatePlay extends RubikStateAbstract
   private static final int MIN_SCRAMBLE =  1;
   private static final int DEF_SCRAMBLE =  1;
   public  static final int MAX_SCRAMBLE = 18;
+  private static final int DEF_BUTTON   = RubikObject.CUBE3.ordinal();
 
   private HorizontalNumberPicker mPicker;
   private int mPickerValue;
-  private int mButton = RubikObject.CUBE3.ordinal();
+  private int mButton = DEF_BUTTON;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
@@ -120,6 +121,8 @@ public class RubikStatePlay extends RubikStateAbstract
       {
       editor.putInt("scramble", mPicker.getValue() );
       }
+
+    editor.putInt("button", mButton);
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -127,6 +130,7 @@ public class RubikStatePlay extends RubikStateAbstract
   public void restorePreferences(SharedPreferences preferences)
     {
     mPickerValue= preferences.getInt("scramble", DEF_SCRAMBLE);
+    mButton     = preferences.getInt("button"  , DEF_BUTTON  );
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
