commit c5fca790ad6676bb42c99aa7f4c44fbd913ce800
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Fri Jul 1 23:16:24 2022 +0200

    Progress with new UI

diff --git a/src/main/java/org/distorted/objects/MainEntry.java b/src/main/java/org/distorted/objects/MainEntry.java
new file mode 100644
index 00000000..c221ecd3
--- /dev/null
+++ b/src/main/java/org/distorted/objects/MainEntry.java
@@ -0,0 +1,105 @@
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// Copyright 2022 Leszek Koltunski                                                               //
+//                                                                                               //
+// This file is part of Magic Cube.                                                              //
+//                                                                                               //
+// Magic Cube is free software: you can redistribute it and/or modify                            //
+// it under the terms of the GNU General Public License as published by                          //
+// the Free Software Foundation, either version 2 of the License, or                             //
+// (at your option) any later version.                                                           //
+//                                                                                               //
+// Magic Cube is distributed in the hope that it will be useful,                                 //
+// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
+// GNU General Public License for more details.                                                  //
+//                                                                                               //
+// You should have received a copy of the GNU General Public License                             //
+// along with Magic Cube.  If not, see <http://www.gnu.org/licenses/>.                           //
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+package org.distorted.objects;
+
+import android.app.Activity;
+import android.graphics.drawable.Drawable;
+import android.widget.ImageButton;
+
+import org.distorted.main.RubikActivity;
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+public class MainEntry
+{
+  public final static int TYPE_OBJECT  = 0;
+  public final static int TYPE_CREATOR = 1;
+
+  private final RubikObject mObject;
+  private final int mType;
+  private final int mIconID;
+  private Drawable mIconDrawable;
+  private boolean mPrepared;
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  MainEntry(RubikObject object)
+    {
+    mType         = TYPE_OBJECT;
+    mIconID       = 0;
+    mIconDrawable = null;
+    mObject       = object;
+    mPrepared     = false;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  MainEntry(int type, int iconID)
+    {
+    mType         = type;
+    mIconID       = iconID;
+    mIconDrawable = null;
+    mObject       = null;
+    mPrepared     = false;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  private void prepare(Activity act)
+    {
+    mIconDrawable = act.getDrawable(mIconID);
+    mPrepared = true;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// PUBLIC API
+
+  public void setIconTo(RubikActivity act, ImageButton button)
+    {
+    if( mType==TYPE_OBJECT )
+      {
+      if( mObject!=null ) mObject.setIconTo(act,button);
+      else android.util.Log.e("D", "MainListEntry: object null!!");
+      }
+    else if( mType==TYPE_CREATOR )
+      {
+      if( !mPrepared ) prepare(act);
+      button.setBackground(mIconDrawable);
+      }
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  public void onClick(RubikActivity act)
+    {
+    if( mType==TYPE_OBJECT )
+      {
+      if( mObject!=null )
+        {
+        android.util.Log.e("D", "clicked on "+ mObject.getLowerName());
+        }
+      else android.util.Log.e("D", "MainListEntry: object null!!");
+      }
+    else if( mType==TYPE_CREATOR )
+      {
+      act.switchToBandagedCreator();
+      }
+    }
+}
diff --git a/src/main/java/org/distorted/objects/MainEntryList.java b/src/main/java/org/distorted/objects/MainEntryList.java
new file mode 100644
index 00000000..904bf2c1
--- /dev/null
+++ b/src/main/java/org/distorted/objects/MainEntryList.java
@@ -0,0 +1,87 @@
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// Copyright 2022 Leszek Koltunski                                                               //
+//                                                                                               //
+// This file is part of Magic Cube.                                                              //
+//                                                                                               //
+// Magic Cube is free software: you can redistribute it and/or modify                            //
+// it under the terms of the GNU General Public License as published by                          //
+// the Free Software Foundation, either version 2 of the License, or                             //
+// (at your option) any later version.                                                           //
+//                                                                                               //
+// Magic Cube is distributed in the hope that it will be useful,                                 //
+// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
+// GNU General Public License for more details.                                                  //
+//                                                                                               //
+// You should have received a copy of the GNU General Public License                             //
+// along with Magic Cube.  If not, see <http://www.gnu.org/licenses/>.                           //
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+package org.distorted.objects;
+
+import java.util.ArrayList;
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+public class MainEntryList
+{
+  private final ArrayList<MainEntry> mList;
+  private static MainEntryList mThis;
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  private MainEntryList()
+    {
+    mList = new ArrayList<>();
+
+    int numObjects = RubikObjectList.getNumObjects();
+
+    for(int i=0; i<numObjects; i++)
+      {
+      RubikObject object = RubikObjectList.getObject(i);
+
+      if( object!=null )
+        {
+        MainEntry entry = new MainEntry(object);
+        mList.add(entry);
+
+        String name = object.getLowerName();
+
+        if( name!=null && name.equals("ban4_3") )
+          {
+          MainEntry creator = new MainEntry(MainEntry.TYPE_CREATOR, org.distorted.main.R.drawable.gl);
+          mList.add(creator);
+          }
+        }
+      }
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  public static MainEntryList getInstance()
+    {
+    if( mThis==null ) mThis = new MainEntryList();
+    return mThis;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  public void addEntry(MainEntry entry)
+    {
+    mList.add(entry);
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  public int getNumOfEntries()
+    {
+    return mList.size();
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  public MainEntry getEntry(int index)
+    {
+    return mList.get(index);
+    }
+}
diff --git a/src/main/java/org/distorted/objects/RubikObjectList.java b/src/main/java/org/distorted/objects/RubikObjectList.java
index 035d40ca..1bb80400 100644
--- a/src/main/java/org/distorted/objects/RubikObjectList.java
+++ b/src/main/java/org/distorted/objects/RubikObjectList.java
@@ -29,8 +29,6 @@ import org.distorted.external.RubikFiles;
 import org.distorted.main.RubikActivity;
 import org.distorted.objectlib.main.ObjectSignatures;
 import org.distorted.objectlib.main.ObjectType;
-import org.distorted.screens.RubikScreenPlay;
-import org.distorted.screens.ScreenList;
 
 import static org.distorted.objectlib.main.TwistyObject.MESH_NICE;
 import static org.distorted.objectlib.main.ObjectType.NUM_OBJECTS;
@@ -395,7 +393,7 @@ public class RubikObjectList
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-  public static boolean setCurrObject(RubikActivity act, int ordinal)
+  public static boolean setCurrObject(int ordinal)
     {
     if( mObject!=ordinal )
       {
diff --git a/src/main/java/org/distorted/screens/RubikScreenPattern.java b/src/main/java/org/distorted/screens/RubikScreenPattern.java
index 422dbc6b..cf2a74b2 100644
--- a/src/main/java/org/distorted/screens/RubikScreenPattern.java
+++ b/src/main/java/org/distorted/screens/RubikScreenPattern.java
@@ -62,7 +62,7 @@ public class RubikScreenPattern extends RubikScreenAbstract
     {
     int object = RubikPatternList.getObject(mPatternOrdinal);
 
-    if( !RubikObjectList.setCurrObject(act,object) )
+    if( !RubikObjectList.setCurrObject(object) )
       {
       act.changeObject(object,false);
       }
diff --git a/src/main/java/org/distorted/screens/RubikScreenPlay.java b/src/main/java/org/distorted/screens/RubikScreenPlay.java
index 4fccada7..6fc126c0 100644
--- a/src/main/java/org/distorted/screens/RubikScreenPlay.java
+++ b/src/main/java/org/distorted/screens/RubikScreenPlay.java
@@ -42,8 +42,8 @@ import org.distorted.main.R;
 import org.distorted.main.RubikActivity;
 import org.distorted.dialogs.RubikDialogAbout;
 import org.distorted.helpers.TransparentImageButton;
-import org.distorted.objects.RubikObject;
-import org.distorted.objects.RubikObjectList;
+import org.distorted.objects.MainEntry;
+import org.distorted.objects.MainEntryList;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
@@ -56,7 +56,7 @@ public class RubikScreenPlay extends RubikScreenAbstract implements RubikNetwork
   private TextView mBubbleUpdates;
   private int mCurrentBubbleNumber;
   private int mLevelValue;
-  private int mColCount, mRowCount;
+  private int mColCount, mRowCount, mNumObjects;
   private float mScreenWidth;
   private WeakReference<RubikActivity> mWeakAct;
 
@@ -75,14 +75,12 @@ public class RubikScreenPlay extends RubikScreenAbstract implements RubikNetwork
     {
     act.switchRenderingOff();
     mWeakAct = new WeakReference<>(act);
-    int numObjects = RubikObjectList.getNumObjects();
     mScreenWidth = act.getScreenWidthInPixels();
     int screenHeight= act.getScreenHeightInPixels();
     int upperBarHeight = act.getHeightUpperBar();
     int lowerBarHeight = act.getHeightLowerBar();
 
-    mRowCount = (numObjects + NUM_COLUMNS-1) / NUM_COLUMNS;
-    mColCount = NUM_COLUMNS;
+    computeRowAndColCounts();
 
     float titleSize = mScreenWidth*RubikActivity.TITLE_TEXT_SIZE;
     LayoutInflater inflater = act.getLayoutInflater();
@@ -228,23 +226,21 @@ public class RubikScreenPlay extends RubikScreenAbstract implements RubikNetwork
       colSpecs[col] = GridLayout.spec(col);
       }
 
-    int numObjects = RubikObjectList.getNumObjects();
+    MainEntryList list = MainEntryList.getInstance();
 
-    for(int object=0; object<numObjects; object++)
+    for(int index=0; index<mNumObjects; index++)
       {
-      final int ordinal = object;
-      RubikObject rObject = RubikObjectList.getObject(ordinal);
-      int row = object/NUM_COLUMNS;
+      MainEntry entry = list.getEntry(index);
+      int row = index/NUM_COLUMNS;
       ImageButton button = new ImageButton(act);
-      if( rObject!=null ) rObject.setIconTo(act,button);
+      if( entry!=null ) entry.setIconTo(act,button);
 
       button.setOnClickListener( new View.OnClickListener()
         {
         @Override
         public void onClick(View v)
           {
-          // TODO
-          android.util.Log.e("D", "object "+ordinal+" clicked");
+          entry.onClick(act);
           }
         });
 
@@ -290,10 +286,7 @@ public class RubikScreenPlay extends RubikScreenAbstract implements RubikNetwork
 
   public void recreateListOfObjects()
     {
-    int numObjects = RubikObjectList.getNumObjects();
-    mRowCount = (numObjects + NUM_COLUMNS-1) / NUM_COLUMNS;
-    mColCount = NUM_COLUMNS;
-
+    computeRowAndColCounts();
     RubikActivity act = mWeakAct.get();
     LayoutInflater inflater = act.getLayoutInflater();
 
@@ -314,6 +307,16 @@ public class RubikScreenPlay extends RubikScreenAbstract implements RubikNetwork
       });
     }
 
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  private void computeRowAndColCounts()
+    {
+    MainEntryList list = MainEntryList.getInstance();
+    mNumObjects = list.getNumOfEntries();
+    mRowCount = (mNumObjects + NUM_COLUMNS-1) / NUM_COLUMNS;
+    mColCount = NUM_COLUMNS;
+    }
+
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
   private void updateNumberOfNewObjects()
diff --git a/src/main/java/org/distorted/screens/RubikScreenSolver.java b/src/main/java/org/distorted/screens/RubikScreenSolver.java
index 8781a53f..0cdf71c4 100644
--- a/src/main/java/org/distorted/screens/RubikScreenSolver.java
+++ b/src/main/java/org/distorted/screens/RubikScreenSolver.java
@@ -87,7 +87,7 @@ public class RubikScreenSolver extends RubikScreenAbstract
     act.changeIfDifferent(currentObject,control);
     control.solveOnly();
 
-    RubikObjectList.setCurrObject(act, currentObject);
+    RubikObjectList.setCurrObject(currentObject);
 
     generateFaceColors();
 
