commit 280dc7947860175e9b62341e45516cfcd288b0db
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Thu Jan 6 14:53:28 2022 +0100

    Improve the behaviour of the Config and Tutorial activities when in the 'PopUpMode'. Also, remember the current object in the COnfig activity so that when we put it to the background and resume - the object stays.

diff --git a/src/main/java/org/distorted/config/ConfigActivity.java b/src/main/java/org/distorted/config/ConfigActivity.java
index 459fba7c..cff0c33b 100644
--- a/src/main/java/org/distorted/config/ConfigActivity.java
+++ b/src/main/java/org/distorted/config/ConfigActivity.java
@@ -35,13 +35,8 @@ import org.distorted.dialogs.RubikDialogError;
 import org.distorted.dmesh.ObjectMesh;
 import org.distorted.jsons.ObjectJson;
 import org.distorted.library.main.DistortedLibrary;
-import org.distorted.library.type.Static4D;
 import org.distorted.main.R;
 import org.distorted.objectlib.main.ObjectControl;
-import org.distorted.objectlib.main.ShapeDodecahedron;
-import org.distorted.objectlib.main.ShapeHexahedron;
-import org.distorted.objectlib.main.ShapeOctahedron;
-import org.distorted.objectlib.main.ShapeTetrahedron;
 import org.distorted.objects.RubikObject;
 import org.distorted.objects.RubikObjectList;
 
@@ -138,17 +133,6 @@ public class ConfigActivity extends AppCompatActivity
         }
       }
 
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-    @Override
-    public void onAttachedToWindow()
-      {
-      super.onAttachedToWindow();
-
-      if( mScreen==null ) mScreen = new ConfigScreen();
-      mScreen.onAttachedToWindow(this,mObjectOrdinal);
-      }
-
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 // do not avoid cutouts
 
@@ -194,6 +178,9 @@ public class ConfigActivity extends AppCompatActivity
       ConfigSurfaceView view = findViewById(R.id.configSurfaceView);
       view.onResume();
 
+      if( mScreen==null ) mScreen = new ConfigScreen();
+      mScreen.onAttachedToWindow(this,mObjectOrdinal);
+
       if( mObjectOrdinal>=0 && mObjectOrdinal< RubikObjectList.getNumObjects() )
         {
         RubikObject object = RubikObjectList.getObject(mObjectOrdinal);
@@ -240,8 +227,10 @@ public class ConfigActivity extends AppCompatActivity
 // PUBLIC API
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-    public void changeObject(RubikObject object)
+    public void changeObject(int ordinal)
       {
+      mObjectOrdinal = ordinal;
+      RubikObject object = RubikObjectList.getObject(ordinal);
       ConfigSurfaceView view = findViewById(R.id.configSurfaceView);
       ObjectControl control = view.getObjectControl();
       changeIfDifferent(object,control);
diff --git a/src/main/java/org/distorted/config/ConfigScreen.java b/src/main/java/org/distorted/config/ConfigScreen.java
index bd55c401..29529cf7 100644
--- a/src/main/java/org/distorted/config/ConfigScreen.java
+++ b/src/main/java/org/distorted/config/ConfigScreen.java
@@ -117,7 +117,7 @@ public class ConfigScreen
           if( act.getControl().isUINotBlocked() && mObjectOrdinal!=ordinal )
             {
             mObjectOrdinal = ordinal;
-            act.changeObject(rubikObject);
+            act.changeObject(mObjectOrdinal);
             mMovesText.setText(act.getString(R.string.mo_placeholder,mObjectOrdinal+1,numObjects));
             mPane.updatePane(act,mObjectOrdinal);
             }
@@ -241,9 +241,7 @@ public class ConfigScreen
     mObjectOrdinal--;
     if( mObjectOrdinal<0 ) mObjectOrdinal=numObjects-1;
 
-    RubikObject object = RubikObjectList.getObject(mObjectOrdinal);
-    act.changeObject(object);
-
+    act.changeObject(mObjectOrdinal);
     mPane.updatePane(act,mObjectOrdinal);
     }
 
@@ -254,9 +252,7 @@ public class ConfigScreen
     mObjectOrdinal++;
     if( mObjectOrdinal>=numObjects ) mObjectOrdinal=0;
 
-    RubikObject object = RubikObjectList.getObject(mObjectOrdinal);
-    act.changeObject(object);
-
+    act.changeObject(mObjectOrdinal);
     mPane.updatePane(act,mObjectOrdinal);
     }
 
diff --git a/src/main/java/org/distorted/tutorials/TutorialActivity.java b/src/main/java/org/distorted/tutorials/TutorialActivity.java
index 50063099..79044b91 100644
--- a/src/main/java/org/distorted/tutorials/TutorialActivity.java
+++ b/src/main/java/org/distorted/tutorials/TutorialActivity.java
@@ -134,20 +134,12 @@ public class TutorialActivity extends AppCompatActivity
       {
       super.onAttachedToWindow();
 
-      float width = getScreenWidthInPixels();
-
-      LinearLayout viewR = findViewById(R.id.tutorialRightBar);
-      ViewGroup.LayoutParams paramsR = viewR.getLayoutParams();
-      paramsR.width = (int)(width*BAR_RATIO);
-      viewR.setLayoutParams(paramsR);
-
-      if( mScreen==null ) mScreen = new TutorialScreen();
-
-      mScreen.createRightPane(this);
-
-      WebView videoView = findViewById(R.id.tutorialVideoView);
-      mWebView = new TutorialWebView(videoView);
-      mWebView.load(URL+mURL);
+      if( mWebView==null )
+        {
+        WebView videoView = findViewById(R.id.tutorialVideoView);
+        mWebView = new TutorialWebView(videoView);
+        mWebView.load(URL+mURL);
+        }
       }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -198,6 +190,17 @@ public class TutorialActivity extends AppCompatActivity
       TutorialSurfaceView view = findViewById(R.id.tutorialSurfaceView);
       view.onResume();
 
+      float width = getScreenWidthInPixels();
+
+      LinearLayout viewR = findViewById(R.id.tutorialRightBar);
+      ViewGroup.LayoutParams paramsR = viewR.getLayoutParams();
+      paramsR.width = (int)(width*BAR_RATIO);
+      viewR.setLayoutParams(paramsR);
+
+      if( mScreen==null ) mScreen = new TutorialScreen();
+
+      mScreen.createRightPane(this);
+
       if( mWebView!=null ) mWebView.onResume();
 
       if( mObjectOrdinal>=0 && mObjectOrdinal< RubikObjectList.getNumObjects() )
