Merge "Fix border bug and filter application - fix layout (use framelayout) - fix copy imagepreset - added a current image state panel - remove title for border images for now" into gb-ub-photos-arches
diff --git a/res/layout/filtershow_activity.xml b/res/layout/filtershow_activity.xml
index 06583d8..0dead60 100644
--- a/res/layout/filtershow_activity.xml
+++ b/res/layout/filtershow_activity.xml
@@ -14,16 +14,44 @@
      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>
@@ -286,4 +316,4 @@
         </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
index 0000000..2e9b1bf
--- /dev/null
+++ b/res/layout/filtershow_imagestate_row.xml
@@ -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
diff --git a/res/menu/filtershow_activity_menu.xml b/res/menu/filtershow_activity_menu.xml
index f0c0f32..8987e48 100644
--- a/res/menu/filtershow_activity_menu.xml
+++ b/res/menu/filtershow_activity_menu.xml
@@ -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"/>
 
diff --git a/res/values/filtershow_strings.xml b/res/values/filtershow_strings.xml
index 0a3e93d..7d86138 100644
--- a/res/values/filtershow_strings.xml
+++ b/res/values/filtershow_strings.xml
@@ -16,37 +16,72 @@
 
 <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>
-    <string name="show_history_panel">Show History</string>
-    <string name="hide_history_panel">Hide History</string>
-    <string name="reset">Reset</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>
-    <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>
-    <string name="sharpen">Sharpen</string>
-    <string name="contrast">Contrast</string>
-    <string name="vibrance">Vibrance</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>
+
+    <!--  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>
+    <!--  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
diff --git a/src/com/android/gallery3d/filtershow/presets/ImagePreset.java b/src/com/android/gallery3d/filtershow/presets/ImagePreset.java
index 6659eae..69b3f09 100644
--- a/src/com/android/gallery3d/filtershow/presets/ImagePreset.java
+++ b/src/com/android/gallery3d/filtershow/presets/ImagePreset.java
@@ -7,6 +7,7 @@
 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 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 @@
             // 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 @@
         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 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 @@
         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 @@
         return bitmap;
     }
 
- }
+    public void fillImageStateAdapter(ImageStateAdapter imageStateAdapter) {
+        if (imageStateAdapter == null) {
+            return;
+        }
+        imageStateAdapter.clear();
+        imageStateAdapter.addAll(mFilters);
+        imageStateAdapter.notifyDataSetChanged();
+    }
+
+}