commit d78e2f1dc022486ea330fc01dafeb9dc68053497
Author: leszek <leszek@koltunski.pl>
Date:   Mon Jan 6 21:44:43 2025 +0100

    make it possible to see touched cubit and face.

diff --git a/src/main/java/org/distorted/phasedsolver/SolverActivity.java b/src/main/java/org/distorted/phasedsolver/SolverActivity.java
index f31532f..03fe26b 100644
--- a/src/main/java/org/distorted/phasedsolver/SolverActivity.java
+++ b/src/main/java/org/distorted/phasedsolver/SolverActivity.java
@@ -40,13 +40,10 @@ public class SolverActivity extends Activity implements SolutionListener, Adapte
   private InitAssets mAsset;
   private SharedPreferences mPreferences;
   private SolverLowerPane mLowerPane;
-  private TextView mTextMoves, mTextStickers;
+  private TextView mTextView;
   private SolvedObject mObject;
-  private String mMoves;
-  private int mNumMoves;
-  private String mStickers;
-  private int mNumStickers;
-  private int mCurrSolver;
+  private String mText;
+  private int mCurrSolver, mCurrMode;
   private PhasedSolverAbstract mSolver;
   private long mTime;
 
@@ -62,23 +59,26 @@ public class SolverActivity extends Activity implements SolutionListener, Adapte
     SolverSurfaceView view = findViewById(R.id.solverView);
     OSInterface os = view.getInterface();
     mAsset = new InitAssets(null, null, os);
-    mTextMoves = findViewById(R.id.solverMoves);
-    mTextStickers = findViewById(R.id.solverStickers);
-    mMoves = "";
-    mNumMoves = 0;
-    mStickers = "";
-    mNumStickers = 0;
-    Spinner objectSpinner = findViewById(R.id.solverSpinner);
-    objectSpinner.setOnItemSelectedListener(this);
+    mTextView = findViewById(R.id.solverTextView);
+    mText = "";
 
     mCurrSolver = 0;
+    Spinner objectSpinner = findViewById(R.id.solverSpinner);
+    objectSpinner.setOnItemSelectedListener(this);
     String[] solverNames = createSolverNames();
     ArrayAdapter<String> objAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, solverNames);
     objAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
     objectSpinner.setAdapter(objAdapter);
 
-    String[] phaseNames = createSolver();
+    mCurrMode = 0;
+    Spinner modeSpinner = findViewById(R.id.solverMode);
+    modeSpinner.setOnItemSelectedListener(this);
+    String[] solverMode = { "MOVE", "CUBIT" };
+    ArrayAdapter<String> modeAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, solverMode);
+    modeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+    modeSpinner.setAdapter(modeAdapter);
 
+    String[] phaseNames = createSolver();
     mLowerPane = new SolverLowerPane(this,phaseNames);
     }
 
@@ -133,6 +133,15 @@ public class SolverActivity extends Activity implements SolutionListener, Adapte
       int ordinal = getObjectOrdinal();
       ObjectControl control = getControl();
       control.changeObject(ordinal, MODE_NORM, mAsset);
+      resetTexts();
+      }
+
+    if( parent.getId()==R.id.solverMode && mCurrMode!=pos )
+      {
+      mCurrMode = pos;
+      resetTexts();
+      SolverSurfaceView sv = findViewById(R.id.solverView);
+      sv.switchMode();
       }
     }
 
@@ -267,12 +276,8 @@ public class SolverActivity extends Activity implements SolutionListener, Adapte
 
   private void resetTexts()
     {
-    mNumMoves = 0;
-    mMoves = "";
-    mTextMoves.setText(mMoves);
-    mNumStickers = 0;
-    mStickers = "";
-    mTextStickers.setText(mStickers);
+    mText = "";
+    mTextView.setText(mText);
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -299,42 +304,42 @@ public class SolverActivity extends Activity implements SolutionListener, Adapte
 
   void addSticker(int cubit, int face)
     {
-    mStickers += ("("+cubit+" "+face+") ");
-    mNumStickers++;
-
-    if( mNumStickers>6 )
+    if( mCurrMode==1 )
       {
-      int space = mStickers.indexOf(')');
-      mStickers = mStickers.substring(space+1);
-      mNumStickers--;
-      }
+      mText += ("("+cubit+" "+face+") ");
 
-    runOnUiThread(new Runnable()
-      {
-      @Override
-      public void run() { mTextStickers.setText(mStickers); }
-      });
+      while( mText.length()>32 )
+        {
+        int space = mText.indexOf(')');
+        mText = mText.substring(space+1);
+        }
+
+      runOnUiThread(new Runnable()
+        {
+        @Override public void run() { mTextView.setText(mText); }
+        });
+      }
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
   void addMove(int axis, int row, int angle)
     {
-    int move = mObject.findMove(axis,row,angle);
-    mMoves += (" "+move);
-    mNumMoves++;
-
-    if( mNumMoves>10 )
+    if( mCurrMode==0 )
       {
-      int space = mMoves.indexOf(' ');
-      mMoves = mMoves.substring(space+1);
-      mNumMoves--;
-      }
+      int move = mObject.findMove(axis,row,angle);
+      mText += (" " + move);
 
-    runOnUiThread(new Runnable()
-      {
-      @Override
-      public void run() { mTextMoves.setText(mMoves); }
-      });
+      while( mText.length()>28 )
+        {
+        int space = mText.indexOf(' ');
+        mText = mText.substring(space+1);
+        }
+
+      runOnUiThread(new Runnable()
+        {
+        @Override public void run() { mTextView.setText(mText); }
+        });
+      }
     }
 }
diff --git a/src/main/java/org/distorted/phasedsolver/SolverSurfaceView.java b/src/main/java/org/distorted/phasedsolver/SolverSurfaceView.java
index 2b5fa0d..1dc61c1 100644
--- a/src/main/java/org/distorted/phasedsolver/SolverSurfaceView.java
+++ b/src/main/java/org/distorted/phasedsolver/SolverSurfaceView.java
@@ -9,6 +9,7 @@
 
 package org.distorted.phasedsolver;
 
+import static org.distorted.objectlib.main.ObjectControl.MODE_REPLACE;
 import static org.distorted.objectlib.main.ObjectControl.MODE_ROTATE;
 
 import android.app.ActivityManager;
@@ -29,14 +30,13 @@ class SolverSurfaceView extends GLSurfaceView
     private ObjectControl mObjectController;
     private OSInterface mInterface;
     private SolverRenderer mRenderer;
-    private int mScreenWidth;
     private boolean mCreated;
+    private int mMode;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
     void setScreenSize(int width, int height)
       {
-      mScreenWidth = width;
       mObjectController.setScreenSizeAndScaling(width,height, Math.min(width,height) );
 
       if( !mCreated )
@@ -50,31 +50,9 @@ class SolverSurfaceView extends GLSurfaceView
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-    int getScreenWidth()
-      {
-      return mScreenWidth;
-      }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-    ObjectControl getObjectControl()
-      {
-      return mObjectController;
-      }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-    OSInterface getInterface()
-      {
-      return mInterface;
-      }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-    SolverRenderer getRenderer()
-      {
-      return mRenderer;
-      }
+    ObjectControl getObjectControl() { return mObjectController; }
+    OSInterface getInterface() { return mInterface; }
+    void switchMode() { mMode = (mMode==MODE_REPLACE) ? MODE_ROTATE : MODE_REPLACE; }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
@@ -83,6 +61,7 @@ class SolverSurfaceView extends GLSurfaceView
       super(context,attrs);
 
       mCreated = false;
+      mMode = MODE_ROTATE;
 
       if(!isInEditMode())
         {
@@ -124,7 +103,7 @@ class SolverSurfaceView extends GLSurfaceView
     public boolean onTouchEvent(MotionEvent event)
       {
       mInterface.setMotionEvent(event);
-      return mObjectController.onTouchEvent(MODE_ROTATE);
+      return mObjectController.onTouchEvent(mMode);
       }
 }
 
diff --git a/src/main/res/layout/mainlayout.xml b/src/main/res/layout/mainlayout.xml
index 22c281f..4c6a05b 100644
--- a/src/main/res/layout/mainlayout.xml
+++ b/src/main/res/layout/mainlayout.xml
@@ -46,7 +46,7 @@
             android:id="@+id/solverSolve"
             android:layout_width="0dp"
             android:layout_height="match_parent"
-            android:layout_weight="0.9"
+            android:layout_weight="0.8"
             android:gravity="center_vertical|center"
             android:text="@string/solve"
             android:onClick="Solve"
@@ -59,35 +59,36 @@
             android:layout_weight="1.0"/>
     </LinearLayout>
 
-    <TextView
-        android:id="@+id/solverMoves"
+    <LinearLayout
         android:layout_below="@id/upperBar"
         android:layout_width="match_parent"
-        android:layout_height="50dp"
-        android:singleLine="true"
-        android:background="@color/white"
-        android:textColor="@color/black"
-        android:layout_marginStart="3dp"
-        android:layout_marginEnd="3dp"
-        android:layout_marginTop="3dp"
-        android:layout_marginBottom="5dp"
-        android:textAppearance="?android:attr/textAppearanceLarge"
-        android:gravity="center_vertical|start"/>
-
-    <TextView
-        android:id="@+id/solverStickers"
-        android:layout_below="@id/solverMoves"
-        android:layout_width="match_parent"
-        android:layout_height="50dp"
-        android:singleLine="true"
-        android:background="@color/white"
-        android:textColor="@color/black"
-        android:layout_marginStart="3dp"
-        android:layout_marginEnd="3dp"
-        android:layout_marginTop="3dp"
-        android:layout_marginBottom="5dp"
-        android:textAppearance="?android:attr/textAppearanceLarge"
-        android:gravity="center_vertical|start"/>
+        android:layout_height="60dp"
+        android:gravity="center"
+        android:orientation="horizontal"
+        android:background="@android:color/transparent">
+
+        <TextView
+            android:id="@+id/solverTextView"
+            android:layout_width="0dp"
+            android:layout_height="match_parent"
+            android:layout_weight="2.6"
+            android:singleLine="true"
+            android:background="@color/white"
+            android:textColor="@color/black"
+            android:layout_marginStart="3dp"
+            android:layout_marginEnd="3dp"
+            android:layout_marginTop="3dp"
+            android:layout_marginBottom="5dp"
+            android:textAppearance="?android:attr/textAppearanceLarge"
+            android:gravity="center_vertical|start"/>
+
+        <Spinner
+            android:id="@+id/solverMode"
+            android:layout_width="0dp"
+            android:layout_height="match_parent"
+            android:layout_weight="1.0"/>
+
+    </LinearLayout>
 
     <LinearLayout
         android:id="@+id/phaseBar"
