OSDN Git Service

Fix border bug and filter application
authornicolasroard <nicolasroard@google.com>
Sat, 29 Sep 2012 07:17:09 +0000 (00:17 -0700)
committernicolasroard <nicolasroard@google.com>
Sat, 29 Sep 2012 23:58:46 +0000 (16:58 -0700)
- fix layout (use framelayout)
- fix copy imagepreset
- added a current image state panel
- remove title for border images for now

bug:7256090
bug:7249672
bug:7234317
bug:7225150

Change-Id: I958628a1604c7e436e5d121556c8744f5748b1ec

25 files changed:
res/layout/filtershow_activity.xml
res/layout/filtershow_imagestate_row.xml [new file with mode: 0644]
res/menu/filtershow_activity_menu.xml
res/values/filtershow_strings.xml
src/com/android/gallery3d/filtershow/FilterShowActivity.java
src/com/android/gallery3d/filtershow/HistoryAdapter.java
src/com/android/gallery3d/filtershow/ImageStateAdapter.java [new file with mode: 0644]
src/com/android/gallery3d/filtershow/filters/ColorSpaceMatrix.java
src/com/android/gallery3d/filtershow/filters/ImageFilter.java
src/com/android/gallery3d/filtershow/filters/ImageFilterBW.java
src/com/android/gallery3d/filtershow/filters/ImageFilterBWBlue.java
src/com/android/gallery3d/filtershow/filters/ImageFilterBWGreen.java
src/com/android/gallery3d/filtershow/filters/ImageFilterBWRed.java
src/com/android/gallery3d/filtershow/filters/ImageFilterBorder.java
src/com/android/gallery3d/filtershow/filters/ImageFilterBrightness.java
src/com/android/gallery3d/filtershow/filters/ImageFilterContrast.java
src/com/android/gallery3d/filtershow/filters/ImageFilterCurves.java
src/com/android/gallery3d/filtershow/filters/ImageFilterGradient.java
src/com/android/gallery3d/filtershow/filters/ImageFilterHue.java
src/com/android/gallery3d/filtershow/filters/ImageFilterSaturated.java
src/com/android/gallery3d/filtershow/filters/ImageFilterStraighten.java
src/com/android/gallery3d/filtershow/filters/ImageFilterVignette.java
src/com/android/gallery3d/filtershow/imageshow/ImageShow.java
src/com/android/gallery3d/filtershow/imageshow/ImageSmallFilter.java
src/com/android/gallery3d/filtershow/presets/ImagePreset.java

index 06583d8..0dead60 100644 (file)
      limitations under the License.
 -->
 
-<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
     android:layout_height="match_parent" >
 
     <LinearLayout
+        android:id="@+id/imageStatePanel"
+        android:layout_width="200dip"
+        android:layout_height="match_parent"
+        android:orientation="vertical"
+        android:visibility="invisible"
+        android:layout_gravity="right">
+
+        <TextView
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:background="@android:color/transparent"
+            android:gravity="center"
+            android:padding="2dip"
+            android:text="@string/imageState"
+            android:textColor="@android:color/white"
+            android:textSize="24sp"
+            android:textStyle="bold" />
+
+        <ListView
+            android:id="@+id/imageStateList"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_weight="1" >
+        </ListView>
+    </LinearLayout>
+
+    <LinearLayout
         android:id="@+id/historyPanel"
         android:layout_width="200dip"
         android:layout_height="match_parent"
         android:orientation="vertical"
-        android:visibility="invisible" >
+        android:visibility="invisible"
+        android:layout_gravity="right">
 
         <TextView
             android:layout_width="match_parent"
@@ -49,6 +77,7 @@
             android:orientation="horizontal" >
 
             <Button
+                android:gravity="center"
                 android:id="@+id/resetOperationsButton"
                 style="@style/FilterShowHistoryButton"
                 android:text="@string/reset" />
@@ -56,6 +85,7 @@
             <Button
                 android:id="@+id/saveOperationsButton"
                 style="@style/FilterShowHistoryButton"
+                android:visibility="gone"
                 android:text="@string/save" />
         </LinearLayout>
     </LinearLayout>
         </LinearLayout>
     </LinearLayout>
 
-</AbsoluteLayout>
\ No newline at end of file
+</FrameLayout>
\ No newline at end of file
diff --git a/res/layout/filtershow_imagestate_row.xml b/res/layout/filtershow_imagestate_row.xml
new file mode 100644 (file)
index 0000000..2e9b1bf
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:orientation="horizontal"
+    android:background="@drawable/filtershow_button_background">
+
+    <TextView
+        xmlns:android="http://schemas.android.com/apk/res/android"
+        android:id="@+id/imagestate_label"
+        android:layout_width="wrap_content"
+        android:layout_height="match_parent"
+        android:layout_weight="1"
+        android:gravity="left"
+        android:padding="10dip"
+        android:textSize="16dip" >
+    </TextView>
+
+    <TextView
+        xmlns:android="http://schemas.android.com/apk/res/android"
+        android:id="@+id/imagestate_parameter"
+        android:layout_width="wrap_content"
+        android:layout_height="match_parent"
+        android:layout_weight="1"
+        android:gravity="right"
+        android:padding="10dip"
+        android:textSize="16dip"
+        android:textStyle="bold" >
+    </TextView>
+
+</LinearLayout>
\ No newline at end of file
index f0c0f32..8987e48 100644 (file)
@@ -8,21 +8,26 @@
     <item
         android:id="@+id/undoButton"
         android:icon="@drawable/filtershow_button_undo"
-        android:showAsAction="always"
+        android:showAsAction="never"
         android:title="@string/filtershow_undo"/>
     <item
         android:id="@+id/redoButton"
         android:icon="@drawable/filtershow_button_redo"
-        android:showAsAction="always"
+        android:showAsAction="never"
         android:title="@string/filtershow_redo"/>
     <item
         android:id="@+id/operationsButton"
         android:icon="@drawable/filtershow_button_operations"
-        android:showAsAction="ifRoom"
+        android:showAsAction="never"
         android:title="@string/show_history_panel"/>
     <item
+        android:id="@+id/showImageStateButton"
+        android:showAsAction="never"
+        android:title="@string/show_imagestate_panel" />
+    <item
         android:id="@+id/menu_settings"
         android:enabled="false"
+        android:showAsAction="never"
         android:orderInCategory="100"
         android:title="@string/menu_settings"/>
 
index 0a3e93d..7d86138 100644 (file)
 
 <resources>
 
+    <!--  Name for the image editor activity [CHAR LIMIT=NONE]-->
     <string name="app_name">FilterShow</string>
-    <string name="menu_settings">Settings</string>
+    <!--  Title for the image editor activity [CHAR LIMIT=NONE]-->
     <string name="title_activity_filter_show">FilterShowActivity</string>
-    <string name="save">Save</string>
+
+    <!--  actionbar menu -->
+
+    <!-- Text for the actionbar confirmation button [CHAR LIMIT=20] -->
     <string name="done">Done</string>
-    <string name="history">History</string>
+    <!--  Text for the undo menu item [CHAR LIMIT=20] -->
+    <string name="filtershow_undo">Undo</string>
+    <!--  Text for redo menu item [CHAR LIMIT=20] -->
+    <string name="filtershow_redo">Redo</string>
+    <!--  Text for the history panel menu item [CHAR LIMIT=20] -->
     <string name="show_history_panel">Show History</string>
+    <!--  Text for the history panel menu item [CHAR LIMIT=20] -->
     <string name="hide_history_panel">Hide History</string>
+    <!--  Text for the image state panel menu item [CHAR LIMIT=20] -->
+    <string name="show_imagestate_panel">Show Image State</string>
+    <!--  Text for the image state panel menu item [CHAR LIMIT=20] -->
+    <string name="hide_imagestate_panel">Hide Image State</string>
+    <!--  Name for the overflow menu item for settings [CHAR LIMIT=20] -->
+    <string name="menu_settings">Settings</string>
+
+    <!--  History Panel -->
+
+    <!--  Text for the history panel title [CHAR LIMIT=50] -->
+    <string name="history">History</string>
+    <!--  Text for the history panel reset button [CHAR LIMIT=20]-->
     <string name="reset">Reset</string>
-    <string name="filtershow_undo">Undo</string>
-    <string name="filtershow_redo">Redo</string>
-    <string name="straighten">Straighten</string>
-    <string name="crop">Crop</string>
-    <string name="rotate">Rotate</string>
-    <string name="flip">Flip</string>
-    <string name="vignette">Vignette</string>
-    <string name="curvesRGB">Curves</string>
-    <string name="curvesRed">Curves (Red)</string>
-    <string name="curvesGreen">Curves (Green)</string>
-    <string name="curvesBlue">Curves (Blue)</string>
+
+    <!--  Image state panel -->
+
+    <!--  Text for the image state panel title [CHAR LIMIT=50] -->
+    <string name="imageState">Current Image State</string>
+
+    <!--  Filters buttons -->
+
+    <!--  Label for the exposure filter button [CHAR LIMIT=15] -->
+    <string name="exposure">Exposure</string>
+    <!--  Label for the sharpen filter button [CHAR LIMIT=15] -->
     <string name="sharpen">Sharpen</string>
+    <!--  Label for the contrast filter button [CHAR LIMIT=15] -->
     <string name="contrast">Contrast</string>
+    <!--  Label for the vibrance filter button [CHAR LIMIT=15] -->
     <string name="vibrance">Vibrance</string>
-    <string name="exposure">Exposure</string>
+    <!--  Label for the saturation filter button [CHAR LIMIT=15] -->
     <string name="saturation">Saturation</string>
+    <!--  Label for the tint filter button [CHAR LIMIT=15] -->
     <string name="tint">Tint</string>
-    <string name="shadow_recovery">Shadow Recovery</string>
-    <string name="curves_channel">Channel</string>
+    <!--  Label for the shadow recovery filter button [CHAR LIMIT=15] -->
+    <string name="shadow_recovery">Shadows</string>
+    <!--  Label for the curves filter button [CHAR LIMIT=15] -->
+    <string name="curvesRGB">Curves</string>
+    <!--  Label for the vignette filter button [CHAR LIMIT=15] -->
+    <string name="vignette">Vignette</string>
+
+    <!--  Labels for the curves tool -->
+
+    <!--  Label for the curves tool, all channels (RGB) [CHAR LIMIT=3] -->
     <string name="curves_channel_rgb">RGB</string>
+    <!--  Label for the curves tool, Red color channel [CHAR LIMIT=10] -->
     <string name="curves_channel_red">Red</string>
+    <!--  Label for the curves tool, Green color channel [CHAR LIMIT=10] -->
     <string name="curves_channel_green">Green</string>
+    <!--  Label for the curves tool, Blue color channel [CHAR LIMIT=10] -->
     <string name="curves_channel_blue">Blue</string>
 
 </resources>
\ No newline at end of file
index e807e35..eb95d74 100644 (file)
@@ -35,6 +35,8 @@ import android.widget.AbsoluteLayout;
 import android.widget.AdapterView;
 import android.widget.AdapterView.OnItemClickListener;
 import android.widget.Button;
+import android.widget.FrameLayout;
+import android.widget.FrameLayout.LayoutParams;
 import android.widget.ImageButton;
 import android.widget.LinearLayout;
 import android.widget.ListView;
@@ -75,6 +77,8 @@ public class FilterShowActivity extends Activity implements OnItemClickListener
     protected static final boolean ANIMATE_PANELS = false;
 
     private boolean mShowingHistoryPanel = false;
+    private boolean mShowingImageStatePanel = false;
+
     private Vector<ImageShow> mImageViews = new Vector<ImageShow>();
     private Vector<View> mListViews = new Vector<View>();
     private Vector<ImageButton> mBottomPanelButtons = new Vector<ImageButton>();
@@ -179,9 +183,11 @@ public class FilterShowActivity extends Activity implements OnItemClickListener
                 createOnClickResetOperationsButton());
 
         ListView operationsList = (ListView) findViewById(R.id.operationsList);
-        operationsList.setAdapter(mImageShow.getListAdapter());
+        operationsList.setAdapter(mImageShow.getHistoryAdapter());
         operationsList.setOnItemClickListener(this);
-        mImageLoader.setAdapter((HistoryAdapter) mImageShow.getListAdapter());
+        ListView imageStateList = (ListView) findViewById(R.id.imageStateList);
+        imageStateList.setAdapter(mImageShow.getImageStateAdapter());
+        mImageLoader.setAdapter((HistoryAdapter) mImageShow.getHistoryAdapter());
 
         fillListImages(listFilters);
         fillListBorders(listBorders);
@@ -207,11 +213,17 @@ public class FilterShowActivity extends Activity implements OnItemClickListener
     @Override
     public boolean onCreateOptionsMenu(Menu menu) {
         getMenuInflater().inflate(R.menu.filtershow_activity_menu, menu);
-        MenuItem item = menu.findItem(R.id.operationsButton);
+        MenuItem showHistory = menu.findItem(R.id.operationsButton);
         if (mShowingHistoryPanel) {
-            item.setTitle(R.string.hide_history_panel);
+            showHistory.setTitle(R.string.hide_history_panel);
+        } else {
+            showHistory.setTitle(R.string.show_history_panel);
+        }
+        MenuItem showState = menu.findItem(R.id.showImageStateButton);
+        if (mShowingImageStatePanel) {
+            showState.setTitle(R.string.hide_imagestate_panel);
         } else {
-            item.setTitle(R.string.show_history_panel);
+            showState.setTitle(R.string.show_imagestate_panel);
         }
         return true;
     }
@@ -220,7 +232,7 @@ public class FilterShowActivity extends Activity implements OnItemClickListener
         switch (item.getItemId()) {
             case R.id.undoButton: {
                 HistoryAdapter adapter = (HistoryAdapter) mImageShow
-                        .getListAdapter();
+                        .getHistoryAdapter();
                 int position = adapter.undo();
                 mImageShow.onItemClick(position);
                 mImageShow.showToast("Undo");
@@ -229,13 +241,17 @@ public class FilterShowActivity extends Activity implements OnItemClickListener
             }
             case R.id.redoButton: {
                 HistoryAdapter adapter = (HistoryAdapter) mImageShow
-                        .getListAdapter();
+                        .getHistoryAdapter();
                 int position = adapter.redo();
                 mImageShow.onItemClick(position);
                 mImageShow.showToast("Redo");
                 invalidateViews();
                 return true;
             }
+            case R.id.showImageStateButton: {
+                toggleImageStatePanel();
+                return true;
+            }
             case R.id.operationsButton: {
                 toggleHistoryPanel();
                 return true;
@@ -303,6 +319,7 @@ public class FilterShowActivity extends Activity implements OnItemClickListener
             filter.setImageFilter(borders[i]);
             filter.setController(this);
             filter.setImageLoader(mImageLoader);
+            filter.setShowTitle(false);
             listBorders.addView(filter);
         }
     }
@@ -366,28 +383,54 @@ public class FilterShowActivity extends Activity implements OnItemClickListener
     }
 
     // //////////////////////////////////////////////////////////////////////////////
+    // imageState panel...
+
+    private void toggleImageStatePanel() {
+        final View view = findViewById(R.id.mainPanel);
+        final View viewList = findViewById(R.id.imageStatePanel);
+
+        if (mShowingHistoryPanel) {
+            findViewById(R.id.historyPanel).setVisibility(View.INVISIBLE);
+            mShowingHistoryPanel = false;
+        }
+
+        if (!mShowingImageStatePanel) {
+            mShowingImageStatePanel = true;
+            view.animate().setDuration(200).x(-viewList.getWidth())
+                    .withLayer().withEndAction(new Runnable() {
+                        public void run() {
+                            viewList.setAlpha(0);
+                            viewList.setVisibility(View.VISIBLE);
+                            viewList.animate().setDuration(100)
+                                    .alpha(1.0f).start();
+                        }
+                    }).start();
+        } else {
+            mShowingImageStatePanel = false;
+            viewList.setVisibility(View.INVISIBLE);
+            view.animate().setDuration(200).x(0).withLayer()
+                    .start();
+        }
+        invalidateOptionsMenu();
+    }
+
+    // //////////////////////////////////////////////////////////////////////////////
     // history panel...
 
     private void toggleHistoryPanel() {
         final View view = findViewById(R.id.mainPanel);
         final View viewList = findViewById(R.id.historyPanel);
-        View rootView = viewList.getRootView();
-
-        // TODO: use a custom layout instead of absolutelayout...
-        final AbsoluteLayout.LayoutParams lp = (AbsoluteLayout.LayoutParams) view
-                .getLayoutParams();
-        final AbsoluteLayout.LayoutParams lph = (AbsoluteLayout.LayoutParams) viewList
-                .getLayoutParams();
-        final int positionHistoryPanel = (int) (rootView.getWidth() - viewList
-                .getWidth());
+
+        if (mShowingImageStatePanel) {
+            findViewById(R.id.imageStatePanel).setVisibility(View.INVISIBLE);
+            mShowingImageStatePanel = false;
+        }
+
         if (!mShowingHistoryPanel) {
             mShowingHistoryPanel = true;
             view.animate().setDuration(200).x(-viewList.getWidth())
                     .withLayer().withEndAction(new Runnable() {
                         public void run() {
-                            view.setLayoutParams(lp);
-                            lph.x = positionHistoryPanel;
-                            viewList.setLayoutParams(lph);
                             viewList.setAlpha(0);
                             viewList.setVisibility(View.VISIBLE);
                             viewList.animate().setDuration(100)
@@ -398,19 +441,14 @@ public class FilterShowActivity extends Activity implements OnItemClickListener
             mShowingHistoryPanel = false;
             viewList.setVisibility(View.INVISIBLE);
             view.animate().setDuration(200).x(0).withLayer()
-                    .withEndAction(new Runnable() {
-                        public void run() {
-                            lp.x = 0;
-                            view.setLayoutParams(lp);
-                        }
-                    }).start();
+                    .start();
         }
         invalidateOptionsMenu();
     }
 
     private void resetHistory() {
         HistoryAdapter adapter = (HistoryAdapter) mImageShow
-                .getListAdapter();
+                .getHistoryAdapter();
         adapter.reset();
         ImagePreset original = new ImagePreset(adapter.getItem(0));
         mImageShow.setImagePreset(original);
@@ -560,7 +598,7 @@ public class FilterShowActivity extends Activity implements OnItemClickListener
                     ImageFilterVignette vignette = new ImageFilterVignette();
                     ImagePreset copy = new ImagePreset(preset);
                     copy.add(vignette);
-                    copy.setHistoryName(vignette.name());
+                    copy.setHistoryName(vignette.getName());
                     copy.setIsFx(false);
                     filter = copy.getFilter("Vignette");
                     mImageShow.setImagePreset(copy);
@@ -616,7 +654,7 @@ public class FilterShowActivity extends Activity implements OnItemClickListener
                     ImageFilterContrast contrast = new ImageFilterContrast();
                     ImagePreset copy = new ImagePreset(preset);
                     copy.add(contrast);
-                    copy.setHistoryName(contrast.name());
+                    copy.setHistoryName(contrast.getName());
                     copy.setIsFx(false);
                     filter = copy.getFilter("Contrast");
                     mImageShow.setImagePreset(copy);
@@ -642,7 +680,7 @@ public class FilterShowActivity extends Activity implements OnItemClickListener
                     ImageFilterSaturated sat = new ImageFilterSaturated();
                     ImagePreset copy = new ImagePreset(preset);
                     copy.add(sat);
-                    copy.setHistoryName(sat.name());
+                    copy.setHistoryName(sat.getName());
                     copy.setIsFx(false);
                     filter = copy.getFilter("Saturated");
                     mImageShow.setImagePreset(copy);
@@ -668,7 +706,7 @@ public class FilterShowActivity extends Activity implements OnItemClickListener
                     ImageFilterHue contrast = new ImageFilterHue();
                     ImagePreset copy = new ImagePreset(preset);
                     copy.add(contrast);
-                    copy.setHistoryName(contrast.name());
+                    copy.setHistoryName(contrast.getName());
                     copy.setIsFx(false);
                     filter = copy.getFilter("Hue");
                     mImageShow.setImagePreset(copy);
@@ -694,7 +732,7 @@ public class FilterShowActivity extends Activity implements OnItemClickListener
                     ImageFilterHue contrast = new ImageFilterHue();
                     ImagePreset copy = new ImagePreset(preset);
                     copy.add(contrast);
-                    copy.setHistoryName(contrast.name());
+                    copy.setHistoryName(contrast.getName());
                     copy.setIsFx(false);
                     filter = copy.getFilter("Hue");
                     mImageShow.setImagePreset(copy);
@@ -720,7 +758,7 @@ public class FilterShowActivity extends Activity implements OnItemClickListener
                     ImageFilterBrightness bright = new ImageFilterBrightness();
                     ImagePreset copy = new ImagePreset(preset);
                     copy.add(bright);
-                    copy.setHistoryName(bright.name());
+                    copy.setHistoryName(bright.getName());
                     copy.setIsFx(false);
                     filter = copy.getFilter("Brightness");
                     mImageShow.setImagePreset(copy);
@@ -746,7 +784,7 @@ public class FilterShowActivity extends Activity implements OnItemClickListener
                     ImageFilterHue contrast = new ImageFilterHue();
                     ImagePreset copy = new ImagePreset(preset);
                     copy.add(contrast);
-                    copy.setHistoryName(contrast.name());
+                    copy.setHistoryName(contrast.getName());
                     copy.setIsFx(false);
                     filter = copy.getFilter("Hue");
                     mImageShow.setImagePreset(copy);
@@ -787,11 +825,12 @@ public class FilterShowActivity extends Activity implements OnItemClickListener
         ImagePreset oldPreset = mImageShow.getImagePreset();
         ImagePreset copy = new ImagePreset(oldPreset);
         // TODO: use a numerical constant instead.
-        if (imageFilter.name().equalsIgnoreCase("Border")) {
+        if (imageFilter.getName().equalsIgnoreCase("Border")) {
             copy.remove("Border");
             copy.setHistoryName("Border");
         }
         copy.add(imageFilter);
+        mImageShow.setImagePreset(copy);
         invalidateViews();
     }
 
index ed5b26b..803c45f 100644 (file)
@@ -93,7 +93,6 @@ public class HistoryAdapter extends ArrayAdapter<ImagePreset> {
         if (item != null) {
             TextView itemView = (TextView) view.findViewById(R.id.rowTextView);
             if (itemView != null) {
-                // do whatever you want with your string and long
                 itemView.setText(item.historyName());
             }
             ImageView markView = (ImageView) view.findViewById(R.id.selectedMark);
diff --git a/src/com/android/gallery3d/filtershow/ImageStateAdapter.java b/src/com/android/gallery3d/filtershow/ImageStateAdapter.java
new file mode 100644 (file)
index 0000000..0bca9a3
--- /dev/null
@@ -0,0 +1,39 @@
+
+package com.android.gallery3d.filtershow;
+
+import com.android.gallery3d.R;
+import com.android.gallery3d.filtershow.filters.ImageFilter;
+import com.android.gallery3d.filtershow.presets.ImagePreset;
+
+import android.content.Context;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+import android.widget.TextView;
+
+public class ImageStateAdapter extends ArrayAdapter<ImageFilter> {
+    private static final String LOGTAG = "ImageStateAdapter";
+
+    public ImageStateAdapter(Context context, int textViewResourceId) {
+        super(context, textViewResourceId);
+    }
+
+    public View getView(int position, View convertView, ViewGroup parent) {
+        View view = convertView;
+        if (view == null) {
+            LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(
+                    Context.LAYOUT_INFLATER_SERVICE);
+            view = inflater.inflate(R.layout.filtershow_imagestate_row, null);
+        }
+        ImageFilter filter = getItem(position);
+        if (filter != null) {
+            TextView itemLabel = (TextView) view.findViewById(R.id.imagestate_label);
+            itemLabel.setText(filter.getName());
+            TextView itemParameter = (TextView) view.findViewById(R.id.imagestate_parameter);
+            itemParameter.setText("" + filter.getParameter());
+        }
+        return view;
+    }
+}
index f03a045..6791cd3 100644 (file)
@@ -4,7 +4,7 @@ package com.android.gallery3d.filtershow.filters;
 import java.util.Arrays;
 
 public class ColorSpaceMatrix {
-    private final float[] matrix = new float[16];
+    private final float[] mMatrix = new float[16];
     private static final float RLUM = 0.3086f;
     private static final float GLUM = 0.6094f;
     private static final float BLUM = 0.0820f;
@@ -14,26 +14,35 @@ public class ColorSpaceMatrix {
     }
 
     /**
+     * Copy constructor
+     *
+     * @param matrix
+     */
+    public ColorSpaceMatrix(ColorSpaceMatrix matrix) {
+        System.arraycopy(matrix.mMatrix, 0, mMatrix, 0, matrix.mMatrix.length);
+    }
+
+    /**
      * get the matrix
      *
      * @return the internal matrix
      */
     public float[] getMatrix() {
-        return matrix;
+        return mMatrix;
     }
 
     /**
      * set matrix to identity
      */
     public void identity() {
-        Arrays.fill(matrix, 0);
-        matrix[0] = matrix[5] = matrix[10] = matrix[15] = 1;
+        Arrays.fill(mMatrix, 0);
+        mMatrix[0] = mMatrix[5] = mMatrix[10] = mMatrix[15] = 1;
     }
 
     public void convertToLuminance() {
-        matrix[0] = matrix[1] = matrix[2] = 0.3086f;
-        matrix[4] = matrix[5] = matrix[6] = 0.6094f;
-        matrix[8] = matrix[9] = matrix[10] = 0.0820f;
+        mMatrix[0] = mMatrix[1] = mMatrix[2] = 0.3086f;
+        mMatrix[4] = mMatrix[5] = mMatrix[6] = 0.6094f;
+        mMatrix[8] = mMatrix[9] = mMatrix[10] = 0.0820f;
     }
 
     private void multiply(float[] a)
@@ -44,20 +53,20 @@ public class ColorSpaceMatrix {
         for (y = 0; y < 4; y++) {
             int y4 = y * 4;
             for (x = 0; x < 4; x++) {
-                temp[y4 + x] = matrix[y4 + 0] * a[x]
-                        + matrix[y4 + 1] * a[4 + x]
-                        + matrix[y4 + 2] * a[8 + x]
-                        + matrix[y4 + 3] * a[12 + x];
+                temp[y4 + x] = mMatrix[y4 + 0] * a[x]
+                        + mMatrix[y4 + 1] * a[4 + x]
+                        + mMatrix[y4 + 2] * a[8 + x]
+                        + mMatrix[y4 + 3] * a[12 + x];
             }
         }
         for (int i = 0; i < 16; i++)
-            matrix[i] = temp[i];
+            mMatrix[i] = temp[i];
     }
 
     private void xRotateMatrix(float rs, float rc)
     {
         ColorSpaceMatrix c = new ColorSpaceMatrix();
-        float[] tmp = c.matrix;
+        float[] tmp = c.mMatrix;
 
         tmp[5] = rc;
         tmp[6] = rs;
@@ -70,7 +79,7 @@ public class ColorSpaceMatrix {
     private void yRotateMatrix(float rs, float rc)
     {
         ColorSpaceMatrix c = new ColorSpaceMatrix();
-        float[] tmp = c.matrix;
+        float[] tmp = c.mMatrix;
 
         tmp[0] = rc;
         tmp[2] = -rs;
@@ -83,7 +92,7 @@ public class ColorSpaceMatrix {
     private void zRotateMatrix(float rs, float rc)
     {
         ColorSpaceMatrix c = new ColorSpaceMatrix();
-        float[] tmp = c.matrix;
+        float[] tmp = c.mMatrix;
 
         tmp[0] = rc;
         tmp[1] = rs;
@@ -95,7 +104,7 @@ public class ColorSpaceMatrix {
     private void zShearMatrix(float dx, float dy)
     {
         ColorSpaceMatrix c = new ColorSpaceMatrix();
-        float[] tmp = c.matrix;
+        float[] tmp = c.mMatrix;
 
         tmp[2] = dx;
         tmp[6] = dy;
@@ -139,15 +148,15 @@ public class ColorSpaceMatrix {
      * @param s
      */
     public void changeSaturation(float s) {
-        matrix[0] = (1 - s) * RLUM + s;
-        matrix[1] = (1 - s) * RLUM;
-        matrix[2] = (1 - s) * RLUM;
-        matrix[4] = (1 - s) * GLUM;
-        matrix[5] = (1 - s) * GLUM + s;
-        matrix[6] = (1 - s) * GLUM;
-        matrix[8] = (1 - s) * BLUM;
-        matrix[9] = (1 - s) * BLUM;
-        matrix[10] = (1 - s) * BLUM + s;
+        mMatrix[0] = (1 - s) * RLUM + s;
+        mMatrix[1] = (1 - s) * RLUM;
+        mMatrix[2] = (1 - s) * RLUM;
+        mMatrix[4] = (1 - s) * GLUM;
+        mMatrix[5] = (1 - s) * GLUM + s;
+        mMatrix[6] = (1 - s) * GLUM;
+        mMatrix[8] = (1 - s) * BLUM;
+        mMatrix[9] = (1 - s) * BLUM;
+        mMatrix[10] = (1 - s) * BLUM + s;
     }
 
     /**
@@ -159,7 +168,7 @@ public class ColorSpaceMatrix {
      * @return computed red pixel value
      */
     public float getRed(int r, int g, int b) {
-        return r * matrix[0] + g * matrix[4] + b * matrix[8] + matrix[12];
+        return r * mMatrix[0] + g * mMatrix[4] + b * mMatrix[8] + mMatrix[12];
     }
 
     /**
@@ -171,7 +180,7 @@ public class ColorSpaceMatrix {
      * @return computed green pixel value
      */
     public float getGreen(int r, int g, int b) {
-        return r * matrix[1] + g * matrix[5] + b * matrix[9] + matrix[13];
+        return r * mMatrix[1] + g * mMatrix[5] + b * mMatrix[9] + mMatrix[13];
     }
 
     /**
@@ -183,19 +192,19 @@ public class ColorSpaceMatrix {
      * @return computed blue pixel value
      */
     public float getBlue(int r, int g, int b) {
-        return r * matrix[2] + g * matrix[6] + b * matrix[10] + matrix[14];
+        return r * mMatrix[2] + g * mMatrix[6] + b * mMatrix[10] + mMatrix[14];
     }
 
     private float getRedf(float r, float g, float b) {
-        return r * matrix[0] + g * matrix[4] + b * matrix[8] + matrix[12];
+        return r * mMatrix[0] + g * mMatrix[4] + b * mMatrix[8] + mMatrix[12];
     }
 
     private float getGreenf(float r, float g, float b) {
-        return r * matrix[1] + g * matrix[5] + b * matrix[9] + matrix[13];
+        return r * mMatrix[1] + g * mMatrix[5] + b * mMatrix[9] + mMatrix[13];
     }
 
     private float getBluef(float r, float g, float b) {
-        return r * matrix[2] + g * matrix[6] + b * matrix[10] + matrix[14];
+        return r * mMatrix[2] + g * mMatrix[6] + b * mMatrix[10] + mMatrix[14];
     }
 
 }
index 3d96a33..c2bd952 100644 (file)
@@ -3,31 +3,41 @@ package com.android.gallery3d.filtershow.filters;
 
 import android.graphics.Bitmap;
 
-public class ImageFilter {
+public class ImageFilter implements Cloneable {
 
     protected int mParameter = 0;
+    protected String mName = "Original";
 
-    public String name() {
-        return "Original";
+    @Override
+    public ImageFilter clone() throws CloneNotSupportedException {
+        ImageFilter filter = (ImageFilter) super.clone();
+        filter.setName(getName());
+        filter.setParameter(getParameter());
+        return filter;
     }
 
-    // TODO: maybe use clone instead?
-    public ImageFilter copy() {
-        ImageFilter filter = new ImageFilter();
-        filter.setParameter(mParameter);
-        return filter;
+    public void setName(String name) {
+        mName = name;
+    }
+
+    public String getName() {
+        return mName;
     }
 
     public void apply(Bitmap bitmap) {
         // do nothing here, subclasses will implement filtering here
     }
 
+    public int getParameter() {
+        return mParameter;
+    }
+
     public void setParameter(int value) {
         mParameter = value;
     }
 
     public boolean same(ImageFilter filter) {
-        if (!filter.name().equalsIgnoreCase(name())) {
+        if (!filter.getName().equalsIgnoreCase(getName())) {
             return false;
         }
         return true;
index e997d3e..bc3dd09 100644 (file)
@@ -5,12 +5,8 @@ import android.graphics.Bitmap;
 
 public class ImageFilterBW extends ImageFilter {
 
-    public String name() {
-        return "Black & White";
-    }
-
-    public ImageFilter copy() {
-        return new ImageFilterBW();
+    public ImageFilterBW() {
+        mName = "Black & White";
     }
 
     native protected void nativeApplyFilter(Bitmap bitmap, int w, int h);
index 685b8ff..7368be5 100644 (file)
@@ -5,12 +5,8 @@ import android.graphics.Bitmap;
 
 public class ImageFilterBWBlue extends ImageFilter {
 
-    public String name() {
-        return "Black & White (Blue)";
-    }
-
-    public ImageFilter copy() {
-        return new ImageFilterBWBlue();
+    public ImageFilterBWBlue() {
+        mName = "Black & White (Blue)";
     }
 
     native protected void nativeApplyFilter(Bitmap bitmap, int w, int h);
index 9fa7386..f4e6c61 100644 (file)
@@ -5,12 +5,8 @@ import android.graphics.Bitmap;
 
 public class ImageFilterBWGreen extends ImageFilter {
 
-    public String name() {
-        return "Black & White (Green)";
-    }
-
-    public ImageFilter copy() {
-        return new ImageFilterBWGreen();
+    public ImageFilterBWGreen() {
+        mName = "Black & White (Green)";
     }
 
     native protected void nativeApplyFilter(Bitmap bitmap, int w, int h);
index c5e444f..bb7d661 100644 (file)
@@ -5,12 +5,8 @@ import android.graphics.Bitmap;
 
 public class ImageFilterBWRed extends ImageFilter {
 
-    public String name() {
-        return "Black & White (Red)";
-    }
-
-    public ImageFilter copy() {
-        return new ImageFilterBWRed();
+    public ImageFilterBWRed() {
+        mName = "Black & White (Red)";
     }
 
     native protected void nativeApplyFilter(Bitmap bitmap, int w, int h);
index 6a71417..7df7a2b 100644 (file)
@@ -12,16 +12,16 @@ import android.graphics.drawable.NinePatchDrawable;
 public class ImageFilterBorder extends ImageFilter {
     Drawable mNinePatch = null;
 
-    public ImageFilterBorder(Drawable ninePatch) {
-        mNinePatch = ninePatch;
-    }
-
-    public String name() {
-        return "Border";
+    @Override
+    public ImageFilter clone() throws CloneNotSupportedException {
+        ImageFilterBorder filter = (ImageFilterBorder) super.clone();
+        filter.setDrawable(mNinePatch);
+        return filter;
     }
 
-    public ImageFilter copy() {
-        return new ImageFilterBorder(mNinePatch);
+    public ImageFilterBorder(Drawable ninePatch) {
+        mName = "Border";
+        mNinePatch = ninePatch;
     }
 
     public boolean same(ImageFilter filter) {
index 8ec4dd0..ab61a00 100644 (file)
@@ -5,12 +5,8 @@ import android.graphics.Bitmap;
 
 public class ImageFilterBrightness extends ImageFilter {
 
-    public String name() {
-        return "Brightness";
-    }
-
-    public ImageFilter copy() {
-        return new ImageFilterBrightness();
+    public ImageFilterBrightness() {
+        mName = "Brightness";
     }
 
     native protected void nativeApplyFilter(Bitmap bitmap, int w, int h, float bright);
index dd072cb..b3ef74d 100644 (file)
@@ -5,12 +5,8 @@ import android.graphics.Bitmap;
 
 public class ImageFilterContrast extends ImageFilter {
 
-    public String name() {
-        return "Contrast";
-    }
-
-    public ImageFilter copy() {
-        return new ImageFilterContrast();
+    public ImageFilterContrast() {
+        mName = "Contrast";
     }
 
     native protected void nativeApplyFilter(Bitmap bitmap, int w, int h, float strength);
index c21ae1f..5de8ff4 100644 (file)
@@ -15,15 +15,18 @@ public class ImageFilterCurves extends ImageFilter {
     private boolean mUseRed = true;
     private boolean mUseGreen = true;
     private boolean mUseBlue = true;
-    private String mName = "Curves";
     private Spline mSpline = null;
 
-    public String name() {
-        return mName;
+    public ImageFilterCurves() {
+        mName = "Curves";
     }
 
-    public void setName(String name) {
-        mName = name;
+    @Override
+    public ImageFilter clone() throws CloneNotSupportedException {
+        ImageFilterCurves filter = (ImageFilterCurves) super.clone();
+        filter.setCurve(mCurve);
+        filter.setSpline(new Spline(mSpline));
+        return filter;
     }
 
     public void setUseRed(boolean value) {
@@ -60,14 +63,6 @@ public class ImageFilterCurves extends ImageFilter {
         return true;
     }
 
-    public ImageFilter copy() {
-        ImageFilterCurves curves = new ImageFilterCurves();
-        curves.setCurve(mCurve);
-        curves.setName(mName);
-        curves.setSpline(new Spline(mSpline));
-        return curves;
-    }
-
     public void populateArray(int[] array) {
         for (int i = 0; i < 256; i++) {
             array[i] = (int) (mCurve[i]);
index baa85e1..4e46943 100644 (file)
@@ -10,22 +10,25 @@ import android.graphics.Paint;
 import android.graphics.Paint.Style;
 import android.graphics.Shader.TileMode;
 
+import com.android.gallery3d.filtershow.ui.Spline;
+
 public class ImageFilterGradient extends ImageFilter {
 
     private Bitmap mGradientBitmap = null;
     private int[] mColors = null;
     private float[] mPositions = null;
 
-    public String name() {
-        return "Gradient";
+    public ImageFilterGradient() {
+        mName = "Gradient";
     }
 
-    public ImageFilter copy() {
-        ImageFilterGradient gradient = new ImageFilterGradient();
+    @Override
+    public ImageFilter clone() throws CloneNotSupportedException {
+        ImageFilterGradient filter = (ImageFilterGradient) super.clone();
         for (int i = 0; i < mColors.length; i++) {
-            gradient.addColor(mColors[i], mPositions[i]);
+            filter.addColor(mColors[i], mPositions[i]);
         }
-        return gradient;
+        return filter;
     }
 
     public void addColor(int color, float position) {
index 154ae29..874e7ec 100644 (file)
@@ -4,14 +4,18 @@ package com.android.gallery3d.filtershow.filters;
 import android.graphics.Bitmap;
 
 public class ImageFilterHue extends ImageFilter {
-    private ColorSpaceMatrix cmatrix = new ColorSpaceMatrix();
+    private ColorSpaceMatrix cmatrix = null;
 
-    public String name() {
-        return "Hue";
+    public ImageFilterHue() {
+        mName = "Hue";
+        cmatrix = new ColorSpaceMatrix();
     }
 
-    public ImageFilter copy() {
-        return new ImageFilterHue();
+    @Override
+    public ImageFilter clone() throws CloneNotSupportedException {
+        ImageFilterHue filter = (ImageFilterHue) super.clone();
+        filter.cmatrix = new ColorSpaceMatrix(cmatrix);
+        return filter;
     }
 
     native protected void nativeApplyFilter(Bitmap bitmap, int w, int h, float []matrix);
index f44c6a1..d3db441 100644 (file)
@@ -5,12 +5,8 @@ import android.graphics.Bitmap;
 
 public class ImageFilterSaturated extends ImageFilter {
 
-    public String name() {
-        return "Saturated";
-    }
-
-    public ImageFilter copy() {
-        return new ImageFilterSaturated();
+    public ImageFilterSaturated() {
+        mName = "Saturated";
     }
 
     native protected void nativeApplyFilter(Bitmap bitmap, int w, int h, float saturation);
index 09a3f22..483d901 100644 (file)
@@ -14,25 +14,29 @@ public class ImageFilterStraighten extends ImageFilter {
     private float mRotation;
     private float mZoomFactor;
 
-    public String name() {
-        return "Straighten";
+    public ImageFilterStraighten() {
+        mName = "Straighten";
     }
 
-    public void setRotation(float rotation) {
-        mRotation = rotation;
+    @Override
+    public ImageFilter clone() throws CloneNotSupportedException {
+        ImageFilterStraighten filter = (ImageFilterStraighten) super.clone();
+        filter.mRotation = mRotation;
+        filter.mZoomFactor = mZoomFactor;
+        return filter;
     }
 
-    public void setRotationZoomFactor(float zoomFactor) {
+    public ImageFilterStraighten(float rotation, float zoomFactor) {
+        mRotation = rotation;
         mZoomFactor = zoomFactor;
     }
 
-    public ImageFilterStraighten(float rotation, float zoomFactor) {
+    public void setRotation(float rotation) {
         mRotation = rotation;
-        mZoomFactor = zoomFactor;
     }
 
-    public ImageFilter copy() {
-        return new ImageFilterStraighten(mRotation, mZoomFactor);
+    public void setRotationZoomFactor(float zoomFactor) {
+        mZoomFactor = zoomFactor;
     }
 
     public void apply(Bitmap bitmap) {
index 74d5527..24699a2 100644 (file)
@@ -5,12 +5,8 @@ import android.graphics.Bitmap;
 
 public class ImageFilterVignette extends ImageFilter {
 
-    public String name() {
-        return "Vignette";
-    }
-
-    public ImageFilter copy() {
-        return new ImageFilterVignette();
+    public ImageFilterVignette() {
+        mName = "Vignette";
     }
 
     native protected void nativeApplyFilter(Bitmap bitmap, int w, int h, float strength);
index a221703..14bc0be 100644 (file)
@@ -3,6 +3,7 @@ package com.android.gallery3d.filtershow.imageshow;
 
 import com.android.gallery3d.filtershow.FilterShowActivity;
 import com.android.gallery3d.filtershow.HistoryAdapter;
+import com.android.gallery3d.filtershow.ImageStateAdapter;
 import com.android.gallery3d.filtershow.cache.ImageLoader;
 import com.android.gallery3d.filtershow.filters.ImageFilter;
 import com.android.gallery3d.filtershow.presets.ImagePreset;
@@ -45,7 +46,8 @@ public class ImageShow extends View implements SliderListener {
 
     protected SliderController mSliderController = new SliderController();
 
-    private HistoryAdapter mAdapter = null;
+    private HistoryAdapter mHistoryAdapter = null;
+    private ImageStateAdapter mImageStateAdapter = null;
 
     protected Rect mImageBounds = null;
     protected float mImageRotation = 0;
@@ -63,21 +65,26 @@ public class ImageShow extends View implements SliderListener {
         if (mCurrentFilter != null) {
             mCurrentFilter.setParameter(value);
         }
-        mImageLoader.resetImageForPreset(getImagePreset(), this);
+        if (mImagePreset != null) {
+            mImageLoader.resetImageForPreset(mImagePreset, this);
+            mImagePreset.fillImageStateAdapter(mImageStateAdapter);
+        }
         invalidate();
     }
 
     public ImageShow(Context context, AttributeSet attrs) {
         super(context, attrs);
         mSliderController.setListener(this);
-        mAdapter = new HistoryAdapter(context, R.layout.filtershow_history_operation_row,
+        mHistoryAdapter = new HistoryAdapter(context, R.layout.filtershow_history_operation_row,
                 R.id.rowTextView);
+        mImageStateAdapter = new ImageStateAdapter(context,
+                R.layout.filtershow_imagestate_row);
     }
 
     public ImageShow(Context context) {
         super(context);
         mSliderController.setListener(this);
-        mAdapter = new HistoryAdapter(context, R.layout.filtershow_history_operation_row,
+        mHistoryAdapter = new HistoryAdapter(context, R.layout.filtershow_history_operation_row,
                 R.id.rowTextView);
     }
 
@@ -94,7 +101,7 @@ public class ImageShow extends View implements SliderListener {
     }
 
     public void setAdapter(HistoryAdapter adapter) {
-        mAdapter = adapter;
+        mHistoryAdapter = adapter;
     }
 
     public void showToast(String text) {
@@ -166,7 +173,6 @@ public class ImageShow extends View implements SliderListener {
         if (mImageLoader != null) {
             filteredImage = mImageLoader.getImageForPreset(this,
                     getImagePreset(), showHires());
-//            Log.v(LOGTAG, "getImageForPreset " + getImagePreset() + " is: " + filteredImage);
         }
 
         if (filteredImage == null) {
@@ -247,14 +253,13 @@ public class ImageShow extends View implements SliderListener {
     public void setImagePreset(ImagePreset preset, boolean addToHistory) {
         mImagePreset = preset;
         if (getImagePreset() != null) {
-//            Log.v(LOGTAG, "add " + getImagePreset().name() + " " + getImagePreset());
             if (addToHistory) {
-                mAdapter.insert(getImagePreset(), 0);
+                mHistoryAdapter.insert(getImagePreset(), 0);
             }
             getImagePreset().setEndpoint(this);
             updateImage();
         }
-//        Log.v(LOGTAG, "invalidate from setImagePreset");
+        mImagePreset.fillImageStateAdapter(mImageStateAdapter);
         invalidate();
     }
 
@@ -281,8 +286,6 @@ public class ImageShow extends View implements SliderListener {
 
     public void updateFilteredImage(Bitmap bitmap) {
         mFilteredImage = bitmap;
-        // Log.v(LOGTAG, "invalidate from updateFilteredImage");
-        // invalidate();
     }
 
     public void saveImage(FilterShowActivity filterShowActivity) {
@@ -292,28 +295,24 @@ public class ImageShow extends View implements SliderListener {
     public boolean onTouchEvent(MotionEvent event) {
         super.onTouchEvent(event);
         mSliderController.onTouchEvent(event);
-        // Log.v(LOGTAG, "invalidate from onTouchEvent");
         invalidate();
         return true;
     }
 
     // listview stuff
 
-    public ArrayAdapter getListAdapter() {
-        return mAdapter;
+    public ArrayAdapter getHistoryAdapter() {
+        return mHistoryAdapter;
+    }
+
+    public ArrayAdapter getImageStateAdapter() {
+        return mImageStateAdapter;
     }
 
     public void onItemClick(int position) {
-        Log.v(LOGTAG, "Click on item " + position);
-        Log.v(LOGTAG, "item " + position + " is " + mAdapter.getItem(position));
-        setImagePreset(new ImagePreset(mAdapter.getItem(position)), false); // we
-                                                                            // need
-                                                                            // a
-                                                                            // copy
-                                                                            // from
-                                                                            // the
-                                                                            // history
-        mAdapter.setCurrentPreset(position);
+        setImagePreset(new ImagePreset(mHistoryAdapter.getItem(position)), false);
+        // we need a copy from the history
+        mHistoryAdapter.setCurrentPreset(position);
     }
 
     public void showOriginal(boolean show) {
index f879423..401d96f 100644 (file)
@@ -10,13 +10,16 @@ import android.graphics.Bitmap;
 import android.graphics.Canvas;
 import android.graphics.Paint;
 import android.util.AttributeSet;
+import android.util.Log;
 import android.view.View;
 import android.view.View.MeasureSpec;
 
 public class ImageSmallFilter extends ImageShow implements View.OnClickListener {
 
+    private static final String LOGTAG = "ImageSmallFilter";
     private FilterShowActivity mController = null;
     private ImageFilter mImageFilter = null;
+    private boolean mShowTitle = true;
 
     public ImageSmallFilter(Context context, AttributeSet attrs) {
         super(context, attrs);
@@ -44,11 +47,6 @@ public class ImageSmallFilter extends ImageShow implements View.OnClickListener
         setMeasuredDimension(parentHeight, parentHeight);
     }
 
-    /*
-     * protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
-     * setMeasuredDimension(256, 256); }
-     */
-
     public void onClick(View v) {
         if (mController != null) {
             if (mImageFilter != null) {
@@ -66,8 +64,13 @@ public class ImageSmallFilter extends ImageShow implements View.OnClickListener
         return mImageLoader.getOriginalBitmapSmall();
     }
 
+    public void setShowTitle(boolean value) {
+        mShowTitle = value;
+        invalidate();
+    }
+
     public boolean showTitle() {
-        return true;
+        return mShowTitle;
     }
 
     public boolean showControls() {
index 6659eae..69b3f09 100644 (file)
@@ -7,6 +7,7 @@ import android.graphics.Bitmap;
 import android.graphics.RectF;
 import android.util.Log;
 
+import com.android.gallery3d.filtershow.ImageStateAdapter;
 import com.android.gallery3d.filtershow.filters.ImageFilter;
 import com.android.gallery3d.filtershow.filters.ImageFilterStraighten;
 import com.android.gallery3d.filtershow.imageshow.ImageShow;
@@ -36,8 +37,12 @@ public class ImagePreset {
     }
 
     public ImagePreset(ImagePreset source) {
-        for (int i = 0; i < source.mFilters.size(); i++) {
-            add(source.mFilters.elementAt(i).copy());
+        try {
+            for (int i = 0; i < source.mFilters.size(); i++) {
+                add(source.mFilters.elementAt(i).clone());
+            }
+        } catch (java.lang.CloneNotSupportedException e) {
+            Log.v(LOGTAG, "Exception trying to clone: " + e);
         }
         mName = source.name();
         mHistoryName = source.name();
@@ -59,9 +64,6 @@ public class ImagePreset {
             // TODO
         }
 
-//        Log.v(LOGTAG, "applyGeometry with rotate " + mStraightenRotate + " and zoom "
- //               + mStraightenZoom);
-
         if (mStraightenRotate != 0) {
             // TODO: keep the instances around
             ImageFilter straighten = new ImageFilterStraighten(mStraightenRotate, mStraightenZoom);
@@ -117,8 +119,8 @@ public class ImagePreset {
         return mHistoryName;
     }
 
-    public void add(ImageFilter preset) {
-        mFilters.add(preset);
+    public void add(ImageFilter filter) {
+        mFilters.add(filter);
     }
 
     public void remove(String filterName) {
@@ -135,7 +137,7 @@ public class ImagePreset {
     public ImageFilter getFilter(String name) {
         for (int i = 0; i < mFilters.size(); i++) {
             ImageFilter filter = mFilters.elementAt(i);
-            if (filter.name().equalsIgnoreCase(name)) {
+            if (filter.getName().equalsIgnoreCase(name)) {
                 return filter;
             }
         }
@@ -158,7 +160,7 @@ public class ImagePreset {
         ImageFilter borderFilter = null;
         for (int i = 0; i < mFilters.size(); i++) {
             ImageFilter filter = mFilters.elementAt(i);
-            if (filter.name().equalsIgnoreCase("Border")) {
+            if (filter.getName().equalsIgnoreCase("Border")) {
                 // TODO don't use the name as an id
                 borderFilter = filter;
             } else {
@@ -174,4 +176,13 @@ public class ImagePreset {
         return bitmap;
     }
 
- }
+    public void fillImageStateAdapter(ImageStateAdapter imageStateAdapter) {
+        if (imageStateAdapter == null) {
+            return;
+        }
+        imageStateAdapter.clear();
+        imageStateAdapter.addAll(mFilters);
+        imageStateAdapter.notifyDataSetChanged();
+    }
+
+}