commit a96b92677508834cd168df88fe2cb3d5ed510d48
Author: leszek <leszek@koltunski.pl>
Date:   Sat Nov 16 22:42:09 2024 +0100

    minor

diff --git a/src/main/java/org/distorted/phasedsolver/SolverActivity.java b/src/main/java/org/distorted/phasedsolver/SolverActivity.java
index ec60cb7..4b4f595 100644
--- a/src/main/java/org/distorted/phasedsolver/SolverActivity.java
+++ b/src/main/java/org/distorted/phasedsolver/SolverActivity.java
@@ -18,8 +18,12 @@ import android.view.View;
 import androidx.preference.PreferenceManager;
 
 import org.distorted.library.main.DistortedLibrary;
+import org.distorted.library.type.Static3D;
+import org.distorted.objectlib.algsolvers.PhasedSolver;
+import org.distorted.objectlib.algsolvers.SolvedObject;
 import org.distorted.objectlib.main.InitAssets;
 import org.distorted.objectlib.main.ObjectControl;
+import org.distorted.objectlib.main.TwistyObject;
 import org.distorted.objectlib.metadata.ListObjects;
 import org.distorted.os.OSInterface;
 
@@ -29,6 +33,7 @@ public class SolverActivity extends Activity
 {
     private InitAssets mAsset;
     private SharedPreferences mPreferences;
+    private SolverLowerPane mLowerPane;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
@@ -42,6 +47,7 @@ public class SolverActivity extends Activity
       SolverSurfaceView view = findViewById(R.id.solverView);
       OSInterface os = view.getInterface();
       mAsset = new InitAssets(null,null,os);
+      mLowerPane = new SolverLowerPane(this);
       }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -84,7 +90,7 @@ public class SolverActivity extends Activity
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-    private ObjectControl getControl()
+    ObjectControl getControl()
       {
       SolverSurfaceView view = findViewById(R.id.solverView);
       return view.getObjectControl();
@@ -117,27 +123,69 @@ public class SolverActivity extends Activity
 
     public void Reset(View v)
       {
-
+      ObjectControl control = getControl();
+      control.solveObject();
+      mLowerPane.clearMoves(this);
       }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
     public void Solve(View v)
       {
-
+      TwistyObject object = getControl().getObject();
+
+      int[] numL      = object.getNumLayers();
+      float[][] pos   = object.getCubitPositions(numL);
+      Static3D[] axis = object.getRotationAxis();
+      int[][] angles  = object.getBasicAngles();
+      float[][] cuts  = object.getCuts(numL);
+      boolean[][] rot = object.getLayerRotatable(numL);
+
+      SolvedObject so = new SolvedObject(pos,axis,angles,cuts,rot);
+      int numCubits = pos.length;
+      int[] qi = new int[numCubits];
+      for(int i=0; i<numCubits; i++) qi[i] = object.getCubitQuatIndex(i);
+
+      int[][] moves = so.getMoveTable();
+
+      int[][] params = {{12,13,16,17}};
+      int[] modes  = { PhasedSolver.MODE_ALL_AT_ONCE_OP };
+      PhasedSolver ps = new PhasedSolver(so,params,modes);
+
+      runOnUiThread(new Runnable()
+        {
+        @Override
+        public void run()
+          {
+          int[][] sol = ps.solution(qi);
+          int numPhases = sol.length;
+          android.util.Log.e("D", "Solution, num of phases: "+numPhases);
+
+          for(int p=0; p<numPhases; p++)
+            {
+            int numMoves = sol[p]==null ? -1 : sol[p].length;
+            android.util.Log.e("D", "Phase "+p+" numMoves="+numMoves);
+
+            for(int m=0; m<numMoves; m++)
+              {
+              android.util.Log.e("D", "move "+m+" : "+sol[p][m]);
+              }
+            }
+          }
+        });
       }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
     public void Left(View v)
       {
-
+      mLowerPane.backMove(this);
       }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
     public void Right(View v)
       {
-
+      mLowerPane.makeMove(this);
       }
 }
diff --git a/src/main/java/org/distorted/phasedsolver/SolverLowerPane.java b/src/main/java/org/distorted/phasedsolver/SolverLowerPane.java
new file mode 100644
index 0000000..5b8e2e0
--- /dev/null
+++ b/src/main/java/org/distorted/phasedsolver/SolverLowerPane.java
@@ -0,0 +1,116 @@
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// Copyright 2024 Leszek Koltunski                                                               //
+//                                                                                               //
+// This file is part of Magic Cube.                                                              //
+//                                                                                               //
+// Magic Cube is proprietary software licensed under an EULA which you should have received      //
+// along with the code. If not, check https://distorted.org/magic/License-Magic-Cube.html        //
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+package org.distorted.phasedsolver;
+
+import android.widget.TextView;
+
+import org.distorted.objectlib.helpers.MovesFinished;
+import org.distorted.objectlib.main.ObjectControl;
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+public class SolverLowerPane implements MovesFinished
+{
+  private static final int MOVES_PLACE_0 = 100;
+  private static final int MOVES_PLACE_1 = 101;
+  private static final int MILLIS_PER_DEGREE = 6;
+
+  private int[][] mMoves;
+  private int mNumMoves;
+  private int mCurrMove;
+  private boolean mCanMove;
+  private final TextView mText;
+  private ObjectControl mControl;
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  SolverLowerPane(SolverActivity act)
+    {
+    mText = act.findViewById(R.id.solverText);
+    mCanMove = true;
+    setMoves(act,null);
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  private void setText(SolverActivity act)
+    {
+    act.runOnUiThread(new Runnable()
+      {
+      @Override
+      public void run()
+        {
+        mText.setText((mCurrMove+1)+"/"+mNumMoves);
+        }
+      });
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  void setMoves(SolverActivity act, int[][] moves)
+    {
+    mMoves    = moves;
+    mNumMoves = moves==null ? 0 : moves.length;
+    mCurrMove = moves==null ?-1 : 0;
+
+    setText(act);
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  void clearMoves(SolverActivity act)
+    {
+    setMoves(act,null);
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  void backMove(SolverActivity act)
+    {
+    if( mCanMove && mCurrMove>0 )
+      {
+      mCanMove = false;
+      mCurrMove--;
+      setText(act);
+
+      int[] move = mMoves[mCurrMove];
+
+      mControl = act.getControl();
+      mControl.blockTouch(MOVES_PLACE_0);
+      mControl.addRotation(this, move[0], (1<<move[1]), -move[2], MILLIS_PER_DEGREE);
+      }
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  void makeMove(SolverActivity act)
+    {
+    if( mCanMove && mCurrMove<mNumMoves-1 )
+      {
+      mCanMove = false;
+      mCurrMove++;
+      setText(act);
+
+      int[] move = mMoves[mCurrMove];
+
+      mControl = act.getControl();
+      mControl.blockTouch(MOVES_PLACE_1);
+      mControl.addRotation(this, move[0], (1<<move[1]), move[2], MILLIS_PER_DEGREE);
+      }
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  public void onActionFinished(final long effectID)
+    {
+    mCanMove = true;
+    mControl.unblockRotation();
+    }
+}
diff --git a/src/main/res/layout/mainlayout.xml b/src/main/res/layout/mainlayout.xml
index 4fa60e4..3364a81 100644
--- a/src/main/res/layout/mainlayout.xml
+++ b/src/main/res/layout/mainlayout.xml
@@ -66,7 +66,9 @@
             android:id="@+id/solverText"
             android:layout_width="0dp"
             android:layout_height="match_parent"
-            android:layout_weight="4.0"/>
+            android:layout_weight="5.0"
+            android:gravity="center"
+            android:textSize="40sp"/>
 
         <ImageButton
             android:id="@+id/solverRight"
