commit 8aece7f2e6f05f5a28720cfd15d0b2e66f9d59c2
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Fri Aug 14 13:10:05 2020 +0100

    Progress with the MeshFile app.

diff --git a/src/main/java/org/distorted/examples/meshfile/MeshFileActivity.java b/src/main/java/org/distorted/examples/meshfile/MeshFileActivity.java
index f684146..9ae47fb 100644
--- a/src/main/java/org/distorted/examples/meshfile/MeshFileActivity.java
+++ b/src/main/java/org/distorted/examples/meshfile/MeshFileActivity.java
@@ -25,11 +25,12 @@ import android.os.Bundle;
 import android.view.View;
 import android.widget.AdapterView;
 import android.widget.ArrayAdapter;
-import android.widget.Button;
+import android.widget.CompoundButton;
 import android.widget.LinearLayout;
 import android.widget.SeekBar;
 import android.widget.Spinner;
 import android.widget.TextView;
+import android.widget.ToggleButton;
 
 import org.distorted.examples.R;
 import org.distorted.library.main.DistortedLibrary;
@@ -38,11 +39,8 @@ import org.distorted.library.mesh.MeshFile;
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
 public class MeshFileActivity extends Activity implements AdapterView.OnItemSelectedListener,
-                                                          SeekBar.OnSeekBarChangeListener,
-                                                          View.OnClickListener
+                                                          SeekBar.OnSeekBarChangeListener
 {
-    private static final int OFFSET = 100000;
-
     private LinearLayout mLayout;
     private int mResource;
     private String[] mNames = new String[] { "deferredjob",
@@ -145,7 +143,7 @@ public class MeshFileActivity extends Activity implements AdapterView.OnItemSele
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-    private View createComponentView(MeshFileRenderer renderer, int component)
+    private View createComponentView(MeshFileRenderer renderer, final int component)
       {
       View view = getLayoutInflater().inflate(R.layout.meshfilecomponent, null);
 
@@ -156,13 +154,19 @@ public class MeshFileActivity extends Activity implements AdapterView.OnItemSele
       TextView index = view.findViewById(R.id.meshfileComponentText);
       index.setText(String.valueOf(endIndex));
 
-      Button disappear = view.findViewById(R.id.meshfileComponentDisappear);
-      disappear.setId(component);
-      disappear.setOnClickListener(this);
+      final ToggleButton toggle = view.findViewById(R.id.meshfileComponentToggle);
 
-      Button appear = view.findViewById(R.id.meshfileComponentAppear);
-      appear.setId(component+OFFSET);
-      appear.setOnClickListener(this);
+      toggle.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener()
+        {
+        @Override
+        public void onCheckedChanged(CompoundButton toggleButton, boolean isChecked)
+          {
+          MeshFileSurfaceView view = findViewById(R.id.meshfileSurfaceView);
+          MeshFileRenderer renderer = view.getRenderer();
+          MeshFile mesh = renderer.getMesh();
+          mesh.setEffectAssociation(component,isChecked ? 1:0,component);
+          }
+        }) ;
 
       return view;
       }
@@ -195,29 +199,6 @@ public class MeshFileActivity extends Activity implements AdapterView.OnItemSele
       {
       }
 
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-    @Override
-    public void onClick(View v)
-      {
-      int id = v.getId();
-
-      MeshFileSurfaceView view = findViewById(R.id.meshfileSurfaceView);
-      MeshFileRenderer renderer = view.getRenderer();
-
-      MeshFile mesh = renderer.getMesh();
-
-      if( id>=OFFSET )
-        {
-        id -= OFFSET;
-        mesh.setEffectAssociation(id,0,id);
-        }
-      else
-        {
-        mesh.setEffectAssociation(id,1,id);
-        }
-      }
-
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
     public void onProgressChanged(SeekBar bar, int progress, boolean fromUser)
diff --git a/src/main/res/layout/meshfilecomponent.xml b/src/main/res/layout/meshfilecomponent.xml
index 6e09211..bd382a4 100644
--- a/src/main/res/layout/meshfilecomponent.xml
+++ b/src/main/res/layout/meshfilecomponent.xml
@@ -22,23 +22,15 @@
           android:layout_marginTop="5dp"
           android:layout_weight="1"/>
 
-     <Button
-          android:id="@+id/meshfileComponentAppear"
-          android:text="@string/appear"
+     <ToggleButton
+          android:id="@+id/meshfileComponentToggle"
+          android:textOn="@string/off"
+          android:textOff="@string/on"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:layout_weight="0.2"
           android:layout_marginEnd="5dp"
           android:layout_marginStart="5dp"
-          android:layout_marginTop="5dp"/>
+          android:layout_marginTop="2dp"/>
 
-     <Button
-          android:id="@+id/meshfileComponentDisappear"
-          android:text="@string/disappear"
-          android:layout_width="wrap_content"
-          android:layout_height="wrap_content"
-          android:layout_weight="0.2"
-          android:layout_marginEnd="5dp"
-          android:layout_marginStart="5dp"
-          android:layout_marginTop="5dp"/>
 </LinearLayout>
diff --git a/src/main/res/layout/meshfilelayout.xml b/src/main/res/layout/meshfilelayout.xml
index 161fce4..0f47fd7 100644
--- a/src/main/res/layout/meshfilelayout.xml
+++ b/src/main/res/layout/meshfilelayout.xml
@@ -4,6 +4,15 @@
     android:layout_height="fill_parent"
     android:orientation="vertical" >
 
+    <SeekBar
+        android:id="@+id/meshfileScale"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:paddingLeft="10dp"
+        android:paddingRight="10dp"
+        android:paddingTop="10dp"
+        android:paddingBottom="10dp" />
+
     <org.distorted.examples.meshfile.MeshFileSurfaceView
         android:id="@+id/meshfileSurfaceView"
         android:layout_width="fill_parent"
@@ -33,13 +42,6 @@
 
     </LinearLayout>
 
-    <SeekBar
-            android:id="@+id/meshfileScale"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:paddingLeft="20dp"
-            android:paddingRight="20dp" />
-
     <LinearLayout
         android:orientation="horizontal"
         android:layout_width="match_parent"
diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml
index 87b8b99..d3830c9 100644
--- a/src/main/res/values/strings.xml
+++ b/src/main/res/values/strings.xml
@@ -90,8 +90,8 @@
     <string name="open">Open</string>
     <string name="vertices">Vert</string>
     <string name="time">Time</string>
-    <string name="disappear">Disappear</string>
-    <string name="appear">Appear</string>
+    <string name="on">On</string>
+    <string name="off">Off</string>
     <string name="effComponents">Effect Components</string>
 
     <string name="quality0">Highest</string>
