commit 79c7c950a850da1cd13329e3cd17e6c2994d2212
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Wed Apr 5 01:39:54 2023 +0200

    Move the SharedPreferences to the OSInterface

diff --git a/src/main/java/org/distorted/objectlib/effects/BaseEffect.java b/src/main/java/org/distorted/objectlib/effects/BaseEffect.java
index a87ac97d..ebf3da67 100644
--- a/src/main/java/org/distorted/objectlib/effects/BaseEffect.java
+++ b/src/main/java/org/distorted/objectlib/effects/BaseEffect.java
@@ -11,7 +11,6 @@ package org.distorted.objectlib.effects;
 
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
-import android.content.SharedPreferences;
 
 import org.distorted.objectlib.effects.fastscramble.FastScrambleEffect;
 import org.distorted.objectlib.effects.present.PresentEffect;
@@ -21,6 +20,7 @@ import org.distorted.objectlib.effects.objectchange.ObjectChangeEffect;
 import org.distorted.objectlib.effects.solve.SolveEffect;
 import org.distorted.objectlib.effects.win.WinEffect;
 import org.distorted.objectlib.R;
+import org.distorted.objectlib.helpers.OperatingSystemInterface;
 import org.distorted.objectlib.main.ObjectPreRender;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -104,22 +104,22 @@ public class BaseEffect
 
   ////////////////////////////////////////////////////////////////////////////////
 
-    public void savePreferences(SharedPreferences.Editor editor)
+    public void savePreferences(OperatingSystemInterface os)
       {
       String name = name();
 
-      editor.putInt(name+"_Pos" , mCurrentPos );
-      editor.putInt(name+"_Type", mCurrentType);
+      os.putInt(name+"_Pos" , mCurrentPos );
+      os.putInt(name+"_Type", mCurrentType);
       }
 
   ////////////////////////////////////////////////////////////////////////////////
 
-    public void restorePreferences(SharedPreferences preferences)
+    public void restorePreferences(OperatingSystemInterface os)
       {
       String name = name();
 
-      mCurrentPos  = preferences.getInt(name+"_Pos" , mDefaultPos );
-      mCurrentType = preferences.getInt(name+"_Type", mDefaultType);
+      mCurrentPos  = os.getInt(name+"_Pos" , mDefaultPos );
+      mCurrentType = os.getInt(name+"_Type", mDefaultType);
       }
 
   ////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/java/org/distorted/objectlib/main/ObjectControl.java b/src/main/java/org/distorted/objectlib/main/ObjectControl.java
index cedac715..0210f675 100644
--- a/src/main/java/org/distorted/objectlib/main/ObjectControl.java
+++ b/src/main/java/org/distorted/objectlib/main/ObjectControl.java
@@ -11,8 +11,6 @@ package org.distorted.objectlib.main;
 
 import static org.distorted.objectlib.helpers.OperatingSystemInterface.*;
 
-import android.content.SharedPreferences;
-
 import org.distorted.library.main.QuatHelper;
 import org.distorted.library.type.Static4D;
 
@@ -784,25 +782,32 @@ public class ObjectControl
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-    public void savePreferences(SharedPreferences.Editor editor)
+    public OperatingSystemInterface getOS()
+      {
+      return mOS;
+      }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+    public void savePreferences()
       {
-      mPreRender.savePreferences(editor);
+      mPreRender.savePreferences(mOS);
 
       for( int i=0; i< BaseEffect.Type.LENGTH; i++ )
         {
-        BaseEffect.Type.getType(i).savePreferences(editor);
+        BaseEffect.Type.getType(i).savePreferences(mOS);
         }
       }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-    public void restorePreferences(SharedPreferences preferences)
+    public void restorePreferences()
       {
-      mPreRender.restorePreferences(preferences);
+      mPreRender.restorePreferences(mOS);
 
       for (int i=0; i<BaseEffect.Type.LENGTH; i++)
         {
-        BaseEffect.Type.getType(i).restorePreferences(preferences);
+        BaseEffect.Type.getType(i).restorePreferences(mOS);
         }
       }
 
diff --git a/src/main/java/org/distorted/objectlib/main/ObjectPreRender.java b/src/main/java/org/distorted/objectlib/main/ObjectPreRender.java
index 99796cce..b4e2249f 100644
--- a/src/main/java/org/distorted/objectlib/main/ObjectPreRender.java
+++ b/src/main/java/org/distorted/objectlib/main/ObjectPreRender.java
@@ -9,8 +9,6 @@
 
 package org.distorted.objectlib.main;
 
-import android.content.SharedPreferences;
-
 import org.distorted.library.message.EffectListener;
 import org.distorted.library.type.Static3D;
 
@@ -20,6 +18,7 @@ import org.distorted.objectlib.effects.BaseEffect;
 import org.distorted.objectlib.effects.scramble.ScrambleEffect;
 import org.distorted.objectlib.helpers.BlockController;
 import org.distorted.objectlib.helpers.MovesFinished;
+import org.distorted.objectlib.helpers.OperatingSystemInterface;
 import org.distorted.objectlib.shape.ShapeDodecahedron;
 import org.distorted.objectlib.shape.ShapeHexahedron;
 import org.distorted.objectlib.shape.ShapeOctahedron;
@@ -35,7 +34,7 @@ public class ObjectPreRender implements EffectListener
   private InitAssets mAsset;
   private int mOrdinal;
   private TwistyObject mOldObject, mNewObject;
-  private SharedPreferences mPreferences;
+  private OperatingSystemInterface mOS;
   private MovesFinished mAddActionListener;
   private final BlockController mBlockController;
   private final ObjectLibInterface mInterface;
@@ -137,10 +136,10 @@ public class ObjectPreRender implements EffectListener
         mController.setTouchControl(mNewObject);
         mNewObject.setObjectRatioNow(mScale, mController.getScalingSize() );
 
-        if( mPreferences!=null )
+        if( mOS!=null )
           {
-          mNewObject.restorePreferences(mPreferences);
-          mPreferences = null;
+          mNewObject.restorePreferences(mOS);
+          mOS = null;
           }
 
         mIsSolved = mNewObject.isSolved();
@@ -511,19 +510,19 @@ public class ObjectPreRender implements EffectListener
 // PUBLIC API
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-  public void savePreferences(SharedPreferences.Editor editor)
+  public void savePreferences(OperatingSystemInterface os)
     {
     if( mNewObject!=null )
       {
-      mNewObject.savePreferences(editor);
+      mNewObject.savePreferences(os);
       }
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-  public void restorePreferences(SharedPreferences preferences)
+  public void restorePreferences(OperatingSystemInterface os)
     {
-    mPreferences = preferences;
+    mOS = os;
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/java/org/distorted/objectlib/main/TwistyObject.java b/src/main/java/org/distorted/objectlib/main/TwistyObject.java
index bb563d41..ba21a395 100644
--- a/src/main/java/org/distorted/objectlib/main/TwistyObject.java
+++ b/src/main/java/org/distorted/objectlib/main/TwistyObject.java
@@ -14,7 +14,6 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.util.Random;
 
-import android.content.SharedPreferences;
 import android.graphics.Bitmap;
 import android.graphics.Canvas;
 import android.graphics.Paint;
@@ -1385,14 +1384,14 @@ public abstract class TwistyObject
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-  synchronized void restorePreferences(SharedPreferences preferences)
+  synchronized void restorePreferences(OperatingSystemInterface os)
     {
     boolean error = false;
     String key = getShortName();
 
     for(int i=0; i<mNumCubits; i++)
       {
-      mQuatDebug[i] = mCubits[i].restorePreferences(key,preferences);
+      mQuatDebug[i] = mCubits[i].restorePreferences(key,os);
 
       if( mQuatDebug[i]>=0 && mQuatDebug[i]<mNumQuats )
         {
@@ -1429,18 +1428,18 @@ public abstract class TwistyObject
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-  void savePreferences(SharedPreferences.Editor editor)
+  void savePreferences(OperatingSystemInterface os)
     {
     String key = getShortName();
-    for(int i=0; i<mNumCubits; i++) mCubits[i].savePreferences(key,editor);
+    for(int i=0; i<mNumCubits; i++) mCubits[i].savePreferences(key,os);
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-  public void removePreferences(SharedPreferences.Editor editor)
+  public void removePreferences(OperatingSystemInterface os)
     {
     String key = getShortName();
-    for(int i=0; i<mNumCubits; i++) mCubits[i].removePreferences(key,editor);
+    for(int i=0; i<mNumCubits; i++) mCubits[i].removePreferences(key,os);
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/java/org/distorted/objectlib/main/TwistyObjectCubit.java b/src/main/java/org/distorted/objectlib/main/TwistyObjectCubit.java
index 90962d36..898ed5ec 100644
--- a/src/main/java/org/distorted/objectlib/main/TwistyObjectCubit.java
+++ b/src/main/java/org/distorted/objectlib/main/TwistyObjectCubit.java
@@ -9,10 +9,9 @@
 
 package org.distorted.objectlib.main;
 
-import android.content.SharedPreferences;
-
 import org.distorted.library.main.QuatHelper;
 import org.distorted.library.type.Static4D;
+import org.distorted.objectlib.helpers.OperatingSystemInterface;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
@@ -175,23 +174,23 @@ public class TwistyObjectCubit
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-  void savePreferences(String key, SharedPreferences.Editor editor)
+  void savePreferences(String key, OperatingSystemInterface os)
     {
-    editor.putInt(createKey(key), mQuatIndex);
+    os.putInt(createKey(key), mQuatIndex);
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-  void removePreferences(String key, SharedPreferences.Editor editor)
+  void removePreferences(String key, OperatingSystemInterface os)
     {
-    editor.remove(createKey(key));
+    os.remove(createKey(key));
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-  int restorePreferences(String key, SharedPreferences preferences)
+  int restorePreferences(String key, OperatingSystemInterface os)
     {
-    mQuatIndex = preferences.getInt(createKey(key), 0);
+    mQuatIndex = os.getInt(createKey(key), 0);
     return mQuatIndex;
     }
 
