commit f548942f9ef62e662b95d5d869461a8e50ab0bbf
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Fri May 10 17:40:21 2019 +0100

    Progress with scrambling and solving cube.

diff --git a/src/main/java/org/distorted/component/HorizontalNumberPicker.java b/src/main/java/org/distorted/component/HorizontalNumberPicker.java
new file mode 100644
index 00000000..2a5f0ca5
--- /dev/null
+++ b/src/main/java/org/distorted/component/HorizontalNumberPicker.java
@@ -0,0 +1,141 @@
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// Copyright 2019 Leszek Koltunski                                                               //
+//                                                                                               //
+// This file is part of Distorted.                                                               //
+//                                                                                               //
+// Distorted 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.                                                           //
+//                                                                                               //
+// Distorted 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 Distorted.  If not, see <http://www.gnu.org/licenses/>.                            //
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+package org.distorted.component;
+
+import android.content.Context;
+import android.support.annotation.Nullable;
+import android.util.AttributeSet;
+import android.view.View;
+import android.widget.Button;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+import org.distorted.magic.R;
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+public class HorizontalNumberPicker extends LinearLayout
+{
+  private TextView mNumber;
+  private int mMin, mMax;
+
+  public HorizontalNumberPicker(Context context, @Nullable AttributeSet attrs)
+    {
+    super(context, attrs);
+
+    mMin = 0;
+    mMax = 5;
+
+    inflate(context, R.layout.numberpicker, this);
+
+    mNumber = findViewById(R.id.textNumber);
+
+    final Button btn_less = findViewById(R.id.buttonLess);
+    btn_less.setOnClickListener(new AddHandler(-1));
+
+    final Button btn_more = findViewById(R.id.buttonMore);
+    btn_more.setOnClickListener(new AddHandler( 1));
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  private class AddHandler implements OnClickListener
+    {
+    final int diff;
+
+    AddHandler(int diff)
+      {
+      this.diff = diff;
+      }
+
+    @Override
+    public void onClick(View v)
+      {
+      int newValue = getValue() + diff;
+
+      if (newValue < mMin)
+        {
+        newValue = mMin;
+        }
+      else if (newValue > mMax)
+        {
+        newValue = mMax;
+        }
+      setValue(newValue);
+      }
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  public int getValue()
+    {
+    if(mNumber != null)
+      {
+      try
+        {
+        final String value = mNumber.getText().toString();
+        return Integer.parseInt(value);
+        }
+      catch(NumberFormatException ex)
+        {
+        android.util.Log.e("HorizontalNumberPicker", ex.toString());
+        }
+      }
+    return 0;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  public void setValue(final int value)
+    {
+    if (mNumber != null)
+      {
+      mNumber.setText(String.valueOf(value));
+      }
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  public int getMin()
+    {
+    return mMin;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  public void setMin(int min)
+    {
+    mMin = min;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  public int getMax()
+    {
+    return mMax;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  public void setMax(int max)
+    {
+    mMax = max;
+    }
+}
\ No newline at end of file
diff --git a/src/main/java/org/distorted/effect/AppearEffect.java b/src/main/java/org/distorted/effect/AppearEffect.java
index 72d8434f..e37b2c49 100644
--- a/src/main/java/org/distorted/effect/AppearEffect.java
+++ b/src/main/java/org/distorted/effect/AppearEffect.java
@@ -33,7 +33,7 @@ public abstract class AppearEffect implements EffectListener
   {
   public enum Type
     {
-    EMPTY         (AppearEffectEmpty.class       ),
+    NONE          (AppearEffectNone.class        ),
     TRANSPARENCY  (AppearEffectTransparency.class),
     MOVE          (AppearEffectMove.class        ),
     ROUND         (AppearEffectRound.class       ),
diff --git a/src/main/java/org/distorted/effect/AppearEffectEmpty.java b/src/main/java/org/distorted/effect/AppearEffectEmpty.java
deleted file mode 100644
index dd049f60..00000000
--- a/src/main/java/org/distorted/effect/AppearEffectEmpty.java
+++ /dev/null
@@ -1,51 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////////////////////////
-// Copyright 2019 Leszek Koltunski                                                               //
-//                                                                                               //
-// This file is part of Distorted.                                                               //
-//                                                                                               //
-// Distorted 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.                                                           //
-//                                                                                               //
-// Distorted 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 Distorted.  If not, see <http://www.gnu.org/licenses/>.                            //
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-package org.distorted.effect;
-
-import org.distorted.library.effect.Effect;
-import org.distorted.library.effect.MatrixEffectMove;
-import org.distorted.library.type.Dynamic3D;
-import org.distorted.library.type.Static3D;
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-class AppearEffectEmpty extends AppearEffect
-  {
-  public int createEffects(int duration)
-    {
-    mCubeEffectPosition = new int[] {-1};
-    mCubeEffects        = new Effect[mCubeEffectPosition.length];
-
-    Dynamic3D oldCube0 = new Dynamic3D(1,0.5f);
-    oldCube0.add(new Static3D(0,0,0));
-    mCubeEffects[0] = new MatrixEffectMove(oldCube0);
-
-    return 1;
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-// enable all effects used in this Appear (here: none).  Called by reflection from the parent class.
-
-  @SuppressWarnings("unused")
-  static void enable()
-    {
-
-    }
-  }
diff --git a/src/main/java/org/distorted/effect/AppearEffectNone.java b/src/main/java/org/distorted/effect/AppearEffectNone.java
new file mode 100644
index 00000000..89ede0f6
--- /dev/null
+++ b/src/main/java/org/distorted/effect/AppearEffectNone.java
@@ -0,0 +1,51 @@
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// Copyright 2019 Leszek Koltunski                                                               //
+//                                                                                               //
+// This file is part of Distorted.                                                               //
+//                                                                                               //
+// Distorted 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.                                                           //
+//                                                                                               //
+// Distorted 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 Distorted.  If not, see <http://www.gnu.org/licenses/>.                            //
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+package org.distorted.effect;
+
+import org.distorted.library.effect.Effect;
+import org.distorted.library.effect.MatrixEffectMove;
+import org.distorted.library.type.Dynamic3D;
+import org.distorted.library.type.Static3D;
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+class AppearEffectNone extends AppearEffect
+  {
+  public int createEffects(int duration)
+    {
+    mCubeEffectPosition = new int[] {-1};
+    mCubeEffects        = new Effect[mCubeEffectPosition.length];
+
+    Dynamic3D oldCube0 = new Dynamic3D(1,0.5f);
+    oldCube0.add(new Static3D(0,0,0));
+    mCubeEffects[0] = new MatrixEffectMove(oldCube0);
+
+    return 1;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// enable all effects used in this Appear (here: none).  Called by reflection from the parent class.
+
+  @SuppressWarnings("unused")
+  static void enable()
+    {
+
+    }
+  }
diff --git a/src/main/java/org/distorted/effect/DisappearEffect.java b/src/main/java/org/distorted/effect/DisappearEffect.java
index 667d850d..610749fc 100644
--- a/src/main/java/org/distorted/effect/DisappearEffect.java
+++ b/src/main/java/org/distorted/effect/DisappearEffect.java
@@ -33,7 +33,7 @@ public abstract class DisappearEffect implements EffectListener
   {
   public enum Type
     {
-    EMPTY         (DisappearEffectEmpty.class       ),
+    NONE          (DisappearEffectNone.class       ),
     TRANSPARENCY  (DisappearEffectTransparency.class),
     MOVE          (DisappearEffectMove.class        ),
     ROUND         (DisappearEffectRound.class       ),
diff --git a/src/main/java/org/distorted/effect/DisappearEffectEmpty.java b/src/main/java/org/distorted/effect/DisappearEffectEmpty.java
deleted file mode 100644
index a2499c4a..00000000
--- a/src/main/java/org/distorted/effect/DisappearEffectEmpty.java
+++ /dev/null
@@ -1,51 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////////////////////////
-// Copyright 2019 Leszek Koltunski                                                               //
-//                                                                                               //
-// This file is part of Distorted.                                                               //
-//                                                                                               //
-// Distorted 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.                                                           //
-//                                                                                               //
-// Distorted 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 Distorted.  If not, see <http://www.gnu.org/licenses/>.                            //
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-package org.distorted.effect;
-
-import org.distorted.library.effect.Effect;
-import org.distorted.library.effect.MatrixEffectMove;
-import org.distorted.library.type.Dynamic3D;
-import org.distorted.library.type.Static3D;
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-class DisappearEffectEmpty extends DisappearEffect
-  {
-  public int createEffects(int duration)
-    {
-    mCubeEffectPosition = new int[] {-1};
-    mCubeEffects        = new Effect[mCubeEffectPosition.length];
-
-    Dynamic3D oldCube0 = new Dynamic3D(1,0.5f);
-    oldCube0.add(new Static3D(0,0,0));
-    mCubeEffects[0] = new MatrixEffectMove(oldCube0);
-
-    return 1;
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-// enable all effects used in this Appear (here: none).  Called by reflection from the parent class.
-
-  @SuppressWarnings("unused")
-  static void enable()
-    {
-
-    }
-  }
diff --git a/src/main/java/org/distorted/effect/DisappearEffectNone.java b/src/main/java/org/distorted/effect/DisappearEffectNone.java
new file mode 100644
index 00000000..79e75b89
--- /dev/null
+++ b/src/main/java/org/distorted/effect/DisappearEffectNone.java
@@ -0,0 +1,51 @@
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// Copyright 2019 Leszek Koltunski                                                               //
+//                                                                                               //
+// This file is part of Distorted.                                                               //
+//                                                                                               //
+// Distorted 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.                                                           //
+//                                                                                               //
+// Distorted 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 Distorted.  If not, see <http://www.gnu.org/licenses/>.                            //
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+package org.distorted.effect;
+
+import org.distorted.library.effect.Effect;
+import org.distorted.library.effect.MatrixEffectMove;
+import org.distorted.library.type.Dynamic3D;
+import org.distorted.library.type.Static3D;
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+class DisappearEffectNone extends DisappearEffect
+  {
+  public int createEffects(int duration)
+    {
+    mCubeEffectPosition = new int[] {-1};
+    mCubeEffects        = new Effect[mCubeEffectPosition.length];
+
+    Dynamic3D oldCube0 = new Dynamic3D(1,0.5f);
+    oldCube0.add(new Static3D(0,0,0));
+    mCubeEffects[0] = new MatrixEffectMove(oldCube0);
+
+    return 1;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// enable all effects used in this Appear (here: none).  Called by reflection from the parent class.
+
+  @SuppressWarnings("unused")
+  static void enable()
+    {
+
+    }
+  }
diff --git a/src/main/java/org/distorted/magic/RubikActivity.java b/src/main/java/org/distorted/magic/RubikActivity.java
index 43af0463..6ead1ef3 100644
--- a/src/main/java/org/distorted/magic/RubikActivity.java
+++ b/src/main/java/org/distorted/magic/RubikActivity.java
@@ -29,6 +29,7 @@ import android.support.v4.content.ContextCompat;
 import android.support.v7.app.AppCompatActivity;
 import android.view.View;
 
+import org.distorted.component.HorizontalNumberPicker;
 import org.distorted.effect.AppearEffect;
 import org.distorted.effect.DisappearEffect;
 import org.distorted.library.main.DistortedLibrary;
@@ -46,11 +47,16 @@ public class RubikActivity extends AppCompatActivity implements RubikSettings.On
     public static final int DEFAULT_APPEAR_TYPE    = 1;
     public static final int DEFAULT_DISAPPEAR_TYPE = 1;
 
+    public static final int MIN_SCRAMBLE =  1;
+    public static final int MAX_SCRAMBLE = 10;
+
     private static int mSize = DEFAULT_SIZE;
 
     private int mAppearPos, mDisappearPos;
     private int mAppearType, mDisappearType;
 
+    private HorizontalNumberPicker mPicker;
+
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
     @Override
@@ -61,6 +67,10 @@ public class RubikActivity extends AppCompatActivity implements RubikSettings.On
       setContentView(R.layout.main);
       markButton(mSize);
 
+      mPicker = findViewById(R.id.rubikNumberPicker);
+      mPicker.setMin(MIN_SCRAMBLE);
+      mPicker.setMax(MAX_SCRAMBLE);
+
       restorePreferences();
       applyPreferences();
       }
@@ -131,15 +141,18 @@ public class RubikActivity extends AppCompatActivity implements RubikSettings.On
 
     public void Scramble(View v)
       {
+      int scramble = mPicker.getValue();
+
       RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
-      view.getRenderer().scrambleCube();
+      view.getRenderer().scrambleCube(scramble);
       }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
     public void Solve(View v)
       {
-
+      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
+      view.getRenderer().solveCube();
       }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -208,6 +221,7 @@ public class RubikActivity extends AppCompatActivity implements RubikSettings.On
      editor.putInt("disappearPos" , mDisappearPos );
      editor.putInt("appearType"   , mAppearType   );
      editor.putInt("disappearType", mDisappearType);
+     editor.putInt("scramble"     , mPicker.getValue() );
 
      editor.apply();
      }
@@ -222,6 +236,9 @@ public class RubikActivity extends AppCompatActivity implements RubikSettings.On
      mDisappearPos  = preferences.getInt("disappearPos" , DEFAULT_DISAPPEAR_POS );
      mAppearType    = preferences.getInt("appearType"   , DEFAULT_APPEAR_TYPE   );
      mDisappearType = preferences.getInt("disappearType", DEFAULT_DISAPPEAR_TYPE);
+     int scramble   = preferences.getInt("scramble"     , MIN_SCRAMBLE          );
+
+     mPicker.setValue(scramble);
      }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/java/org/distorted/magic/RubikRenderer.java b/src/main/java/org/distorted/magic/RubikRenderer.java
index 642bfb05..ebe4511f 100644
--- a/src/main/java/org/distorted/magic/RubikRenderer.java
+++ b/src/main/java/org/distorted/magic/RubikRenderer.java
@@ -326,9 +326,16 @@ public class RubikRenderer implements GLSurfaceView.Renderer, EffectListener
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-   void scrambleCube()
+   void scrambleCube(int num)
      {
+     android.util.Log.e("renderer","scrambling "+num+" times");
+     }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
 
+   void solveCube()
+     {
+     android.util.Log.e("renderer","solving cube");
      }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/res/layout/main.xml b/src/main/res/layout/main.xml
index 3dee7f07..2e74e049 100644
--- a/src/main/res/layout/main.xml
+++ b/src/main/res/layout/main.xml
@@ -5,7 +5,6 @@
     android:orientation="vertical" >
 
     <LinearLayout
-        android:id="@+id/linearLayout"
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
         android:gravity="center|fill_horizontal" >
@@ -23,7 +22,7 @@
         <ImageButton
             android:id="@+id/rubikSize2"
             android:layout_width="64dp"
-            android:layout_height="wrap_content"
+            android:layout_height="64dp"
             android:onClick="setSize"
             android:paddingLeft="5dp"
             android:paddingRight="5dp"
@@ -32,7 +31,7 @@
         <ImageButton
             android:id="@+id/rubikSize3"
             android:layout_width="64dp"
-            android:layout_height="wrap_content"
+            android:layout_height="64dp"
             android:onClick="setSize"
             android:paddingLeft="5dp"
             android:paddingRight="5dp"
@@ -41,7 +40,7 @@
         <ImageButton
             android:id="@+id/rubikSize4"
             android:layout_width="64dp"
-            android:layout_height="wrap_content"
+            android:layout_height="64dp"
             android:onClick="setSize"
             android:paddingLeft="5dp"
             android:paddingRight="5dp"
@@ -59,6 +58,38 @@
 
     </LinearLayout>
 
+    <LinearLayout
+        android:layout_width="fill_parent"
+        android:layout_height="64dp"
+        android:gravity="center|fill_horizontal" >
+
+        <Button
+            android:id="@+id/rubikScramble"
+            android:layout_width="wrap_content"
+            android:layout_height="fill_parent"
+            android:layout_weight="0.5"
+            android:onClick="Scramble"
+            android:paddingLeft="5dp"
+            android:paddingRight="5dp"
+            android:text="@string/scramble" />
+
+        <org.distorted.component.HorizontalNumberPicker
+            android:id="@+id/rubikNumberPicker"
+            android:layout_width="192dp"
+            android:layout_height="fill_parent"/>
+
+        <Button
+            android:id="@+id/rubikSolve"
+            android:layout_width="wrap_content"
+            android:layout_height="fill_parent"
+            android:layout_weight="0.5"
+            android:onClick="Solve"
+            android:paddingLeft="5dp"
+            android:paddingRight="5dp"
+            android:text="@string/solve" />
+
+    </LinearLayout>
+
     <org.distorted.magic.RubikSurfaceView
         android:id="@+id/rubikSurfaceView"
         android:layout_width="fill_parent"
diff --git a/src/main/res/layout/numberpicker.xml b/src/main/res/layout/numberpicker.xml
new file mode 100644
index 00000000..bc6a5507
--- /dev/null
+++ b/src/main/res/layout/numberpicker.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:orientation="horizontal">
+
+    <Button
+        android:id="@+id/buttonLess"
+        android:layout_width="0sp"
+        android:layout_height="match_parent"
+        android:layout_weight="1"
+        android:text="-" />
+
+    <TextView
+        android:id="@+id/textNumber"
+        android:layout_width="0sp"
+        android:layout_height="match_parent"
+        android:layout_weight="1"
+        android:inputType="number"
+        android:text="0"
+        android:textAlignment="center"
+        android:textSize="48sp" />
+
+    <Button
+        android:id="@+id/buttonMore"
+        android:layout_width="0sp"
+        android:layout_height="match_parent"
+        android:layout_weight="1"
+        android:text="+" />
+</LinearLayout>
\ No newline at end of file
