Gallery2: revert filtershow panel layout to M style;

revert filtershow panel layout to M style according to UX specification
document.
delete filtershow_main_panel.xml in layout-land.

Change-Id: I33a031063d8392fecf4de071f62bf46b2aaa57e2
CRs-Fixed: 988029 987904
diff --git a/res/drawable/comparison_before.xml b/res/drawable/comparison_before.xml
index b846e03..9dd01fc 100644
--- a/res/drawable/comparison_before.xml
+++ b/res/drawable/comparison_before.xml
@@ -34,8 +34,8 @@
         android:viewportHeight="36.0">
     <path
         android:pathData="M18,1c9.389,0 17,7.611 17,17c0,9.388 -7.611,17 -17,17C8.612,35 1,27.388 1,18C1,8.611 8.612,1 18,1z"
-        android:fillAlpha="0.26"
-        android:fillColor="#FFFFFF"/>
+        android:fillAlpha="0.50"
+        android:fillColor="#000000"/>
     <path
         android:pathData="M9.258,16h1.333v-1.333H9.258V16zM10.591,23.999v-1.333H9.258C9.258,23.402 9.854,23.999 10.591,23.999zM9.258,13.334h1.333v-1.333C9.854,12.001 9.258,12.598 9.258,13.334zM9.258,21.333h1.333V20H9.258V21.333zM9.258,18.667h1.333v-1.334H9.258V18.667zM14.667,23.999H16v-1.333h-1.333V23.999zM25.408,12.001h-5.37v1.333h5.37v9.332h-5.37v1.333h5.37c0.737,0 1.334,-0.597 1.334,-1.333v-9.332C26.742,12.598 26.146,12.001 25.408,12.001zM17.334,25.332h1.333V10.667h-1.333V25.332zM15.97,12.001h-1.333v1.333h1.333V12.001zM11.955,13.334h1.334v-1.333h-1.334V13.334zM11.955,23.999h1.334v-1.333h-1.334V23.999z"
         android:fillColor="#FFFFFF"/>
diff --git a/res/layout-land/filtershow_main_panel.xml b/res/layout-land/filtershow_main_panel.xml
deleted file mode 100644
index 2d20df1..0000000
--- a/res/layout-land/filtershow_main_panel.xml
+++ /dev/null
@@ -1,180 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-     Copyright (C) 2013 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"
-    android:layout_width="match_parent"
-    android:layout_height="80dp"
-    android:animateLayoutChanges="true"
-    android:baselineAligned="false"
-    android:orientation="vertical"
-    android:visibility="visible" >
-
-
-    <com.android.gallery3d.filtershow.CenteredLinearLayout
-        xmlns:custom="http://schemas.android.com/apk/res/com.android.gallery3d"
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:layout_gravity="center|bottom"
-        android:orientation="vertical"
-        android:background="@color/edit_actionbar_background"
-        custom:max_width="400dip" >
-
-        <FrameLayout
-            android:id="@+id/category_panel_container"
-            android:layout_width="match_parent"
-            android:layout_height="0dip"
-            android:layout_weight="1"
-            android:visibility="gone" />
-
-        <LinearLayout
-            android:id="@+id/effectsContainer"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:paddingTop="10dp" >
-
-            <ImageButton
-                android:id="@+id/fxButton"
-                android:layout_width="@dimen/thumbnail_size"
-                android:layout_height="match_parent"
-                android:layout_weight="1"
-                android:background="@android:color/transparent"
-                android:scaleType="centerInside"
-                android:src="@drawable/color" />
-
-            <ImageButton
-                android:id="@+id/borderButton"
-                android:layout_width="@dimen/thumbnail_size"
-                android:layout_height="match_parent"
-                android:layout_weight="1"
-                android:background="@android:color/transparent"
-                android:padding="2dip"
-                android:scaleType="centerInside"
-                android:src="@drawable/frames" />
-
-            <ImageButton
-                android:id="@+id/geometryButton"
-                android:layout_width="@dimen/thumbnail_size"
-                android:layout_height="match_parent"
-                android:layout_weight="1"
-                android:background="@android:color/transparent"
-                android:padding="2dip"
-                android:scaleType="centerInside"
-                android:src="@drawable/crop" />
-
-            <ImageButton
-                android:id="@+id/colorsButton"
-                android:layout_width="@dimen/thumbnail_size"
-                android:layout_height="match_parent"
-                android:layout_weight="1"
-                android:background="@android:color/transparent"
-                android:padding="2dip"
-                android:scaleType="centerInside"
-                android:src="@drawable/exposure" />
-
-            <ImageButton
-                android:id="@+id/makeupButton"
-                android:layout_width="@dimen/thumbnail_size"
-                android:layout_height="match_parent"
-                android:layout_weight="1"
-                android:background="@android:color/transparent"
-                android:padding="2dip"
-                android:scaleType="centerInside"
-                android:src="@drawable/beautify"
-                android:visibility="gone" />
-            <ImageButton
-                    android:id="@+id/dualCamButton"
-                    android:layout_width="@dimen/thumbnail_size"
-                    android:layout_height="match_parent"
-                    android:layout_weight="1"
-                    android:background="@android:color/transparent"
-                    android:padding="2dip"
-                    android:scaleType="centerInside"
-                    android:src="@drawable/dualcamera"/>
-        </LinearLayout>
-
-        <LinearLayout
-            android:id="@+id/effectsText"
-            android:layout_width="wrap_content"
-            android:layout_height="match_parent"
-            android:paddingTop="5dp" >
-
-            <TextView
-                android:id="@+id/tvColor"
-                android:layout_width="@dimen/thumbnail_size"
-                android:layout_height="match_parent"
-                android:layout_weight="1"
-                android:text="@string/color"
-                android:textColor="#ffffff"
-                android:gravity="center"
-                android:textSize="@dimen/edit_main_font" />
-
-            <TextView
-                android:id="@+id/tvFrames"
-                android:layout_width="@dimen/thumbnail_size"
-                android:layout_height="match_parent"
-                android:layout_weight="1"
-                android:text="@string/frames"
-                android:textColor="#ffffff"
-                android:gravity="center"
-                android:textSize="@dimen/edit_main_font" />
-
-            <TextView
-                android:id="@+id/tvCrop"
-                android:layout_width="@dimen/thumbnail_size"
-                android:layout_height="match_parent"
-                android:layout_weight="1"
-                android:paddingLeft="12dp"
-                android:text="@string/crop"
-                android:textColor="#ffffff"
-                android:gravity="center"
-                android:textSize="@dimen/edit_main_font" />
-
-            <TextView
-                android:id="@+id/tvExposure"
-                android:layout_width="@dimen/thumbnail_size"
-                android:layout_height="match_parent"
-                android:layout_weight="1"
-                android:text="@string/exposure"
-                android:textColor="#ffffff"
-                android:gravity="center"
-                android:textSize="@dimen/edit_main_font" />
-
-            <TextView
-                android:id="@+id/tvBeautify"
-                android:layout_width="@dimen/thumbnail_size"
-                android:layout_height="match_parent"
-                android:layout_weight="1"
-                android:text="@string/beautify"
-                android:textColor="#ffffff"
-                android:gravity="center"
-                android:textSize="@dimen/edit_main_font"
-                android:visibility="gone" />
-
-            <TextView
-                android:id="@+id/tvDualCam"
-                android:layout_width="@dimen/thumbnail_size"
-                android:layout_height="wrap_content"
-                android:layout_weight="1"
-                android:text="@string/dualcam"
-                android:gravity="center"
-                android:textColor="#ffffff"
-                android:textSize="@dimen/edit_main_font"
-                android:visibility="gone" />
-        </LinearLayout>
-    </com.android.gallery3d.filtershow.CenteredLinearLayout>
-
-</LinearLayout>
\ No newline at end of file
diff --git a/res/layout/filtershow_activity.xml b/res/layout/filtershow_activity.xml
index d89f6b2..4663ce5 100644
--- a/res/layout/filtershow_activity.xml
+++ b/res/layout/filtershow_activity.xml
@@ -19,7 +19,7 @@
     android:id="@+id/mainView"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
-    android:background="#212121" >
+    android:background="@color/background_screen" >
 
         <FrameLayout
             android:layout_width="match_parent"
@@ -62,7 +62,7 @@
                 xmlns:custom="http://schemas.android.com/apk/res/com.android.gallery3d"
                 android:id="@+id/mainPanel"
                 android:layout_width="match_parent"
-                android:layout_height="80dp"
+                android:layout_height="wrap_content"
                 android:layout_gravity="center|bottom"
                 android:orientation="vertical"
                 custom:max_width="650dip" >
diff --git a/res/layout/filtershow_main_panel.xml b/res/layout/filtershow_main_panel.xml
index 00d63c1..bc42be2 100644
--- a/res/layout/filtershow_main_panel.xml
+++ b/res/layout/filtershow_main_panel.xml
@@ -20,51 +20,63 @@
 
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
-    android:layout_height="80dp"
+    android:layout_height="wrap_content"
     android:animateLayoutChanges="false"
     android:baselineAligned="false"
     android:orientation="vertical"
-    android:visibility="visible" >
+    android:visibility="visible"
+    android:background="@color/background_main_toolbar" >
+
+    <FrameLayout android:id="@+id/state_panel_container"
+                 android:layout_width="match_parent"
+                 android:layout_height="wrap_content"
+                 android:visibility="visible"
+                 android:layout_gravity="top"
+                 android:layout_weight="1" />
+
+    <FrameLayout android:id="@+id/category_panel_container"
+                 android:layout_width="match_parent"
+                 android:visibility="visible"
+                 android:layout_height="0dip"
+                 android:layout_gravity="center"
+                 android:layout_weight="1"/>
+
+    <View
+            android:background="@color/toolbar_separation_line"
+            android:layout_height="1dip"
+            android:layout_width="match_parent"/>
 
     <com.android.gallery3d.filtershow.CenteredLinearLayout
         xmlns:custom="http://schemas.android.com/apk/res/com.android.gallery3d"
         android:id="@+id/bottom_panel"
         android:layout_width="match_parent"
-        android:layout_height="match_parent"
+        android:layout_height="48dip"
         android:layout_gravity="center|bottom"
-        android:background="@color/edit_actionbar_background"
         android:orientation="vertical"
         custom:max_width="400dip" >
 
-        <FrameLayout
-            android:id="@+id/category_panel_container"
-            android:layout_width="match_parent"
-            android:layout_height="0dip"
-            android:layout_gravity="center"
-            android:layout_weight="1"
-            android:visibility="gone" />
-
         <LinearLayout
             android:id="@+id/effectsContainer"
             android:layout_width="match_parent"
-            android:layout_height="wrap_content"
+            android:layout_height="match_parent"
+            android:background="@color/background_main_toolbar"
             android:paddingTop="10dp" >
 
             <ImageButton
                 android:id="@+id/fxButton"
                 android:layout_width="0dp"
-                android:layout_height="wrap_content"
+                android:layout_height="match_parent"
                 android:layout_weight="1"
-                android:background="@android:color/transparent"
+                android:background="@drawable/filtershow_button_background"
                 android:scaleType="centerInside"
                 android:src="@drawable/color" />
 
             <ImageButton
                 android:id="@+id/borderButton"
                 android:layout_width="@dimen/thumbnail_size"
-                android:layout_height="wrap_content"
+                android:layout_height="match_parent"
                 android:layout_weight="1"
-                android:background="@android:color/transparent"
+                android:background="@drawable/filtershow_button_background"
                 android:padding="2dip"
                 android:scaleType="centerInside"
                 android:visibility="gone"
@@ -73,9 +85,9 @@
             <ImageButton
                 android:id="@+id/geometryButton"
                 android:layout_width="0dp"
-                android:layout_height="wrap_content"
+                android:layout_height="match_parent"
                 android:layout_weight="1"
-                android:background="@android:color/transparent"
+                android:background="@drawable/filtershow_button_background"
                 android:padding="2dip"
                 android:scaleType="centerInside"
                 android:src="@drawable/crop" />
@@ -83,19 +95,19 @@
             <ImageButton
                 android:id="@+id/colorsButton"
                 android:layout_width="0dp"
-                android:layout_height="wrap_content"
+                android:layout_height="match_parent"
                 android:layout_weight="1"
-                android:background="@android:color/transparent"
+                android:background="@drawable/filtershow_button_background"
                 android:padding="2dip"
                 android:scaleType="centerInside"
                 android:src="@drawable/exposure" />
 
             <ImageButton
                 android:id="@+id/makeupButton"
-                android:layout_width="@dimen/thumbnail_size"
-                android:layout_height="wrap_content"
+                android:layout_width="0dp"
+                android:layout_height="match_parent"
                 android:layout_weight="1"
-                android:background="@android:color/transparent"
+                android:background="@drawable/filtershow_button_background"
                 android:padding="2dip"
                 android:scaleType="centerInside"
                 android:src="@drawable/beautify"
@@ -103,10 +115,10 @@
 
            <ImageButton
                     android:id="@+id/dualCamButton"
-                    android:layout_width="@dimen/thumbnail_size"
-                    android:layout_height="wrap_content"
+                    android:layout_width="0dp"
+                    android:layout_height="match_parent"
                     android:layout_weight="1"
-                    android:background="@android:color/transparent"
+                    android:background="@drawable/filtershow_button_background"
                     android:padding="2dip"
                     android:scaleType="centerInside"
                     android:visibility="gone"
@@ -114,7 +126,7 @@
 
            <ImageButton
                 android:id="@+id/trueScannerButton"
-                android:layout_width="@dimen/thumbnail_size"
+                android:layout_width="0dp"
                 android:layout_height="wrap_content"
                 android:layout_weight="1"
                 android:background="@android:color/transparent"
@@ -124,7 +136,7 @@
 
            <ImageButton
                 android:id="@+id/hazeBusterButton"
-                android:layout_width="@dimen/thumbnail_size"
+                android:layout_width="0dp"
                 android:layout_height="wrap_content"
                 android:layout_weight="1"
                 android:background="@android:color/transparent"
@@ -134,7 +146,7 @@
 
             <ImageButton
                 android:id="@+id/seeStraightButton"
-                android:layout_width="@dimen/thumbnail_size"
+                android:layout_width="0dp"
                 android:layout_height="wrap_content"
                 android:layout_weight="1"
                 android:background="@drawable/filtershow_button_background"
@@ -142,105 +154,5 @@
                 android:scaleType="centerInside"
                 android:src="@drawable/seestraight"/>
         </LinearLayout>
-
-        <LinearLayout
-            android:id="@+id/effectsText"
-            android:layout_width="match_parent"
-            android:layout_height="match_parent"
-            android:paddingTop="5dp" >
-
-            <TextView
-                android:id="@+id/tvColor"
-                android:layout_width="0dp"
-                android:layout_height="wrap_content"
-                android:layout_weight="1"
-                android:text="@string/color"
-                android:textColor="#ffffff"
-                android:gravity="center"
-                android:textSize="@dimen/edit_main_font" />
-
-            <TextView
-                android:id="@+id/tvFrames"
-                android:layout_width="@dimen/thumbnail_size"
-                android:layout_height="wrap_content"
-                android:layout_weight="1"
-                android:text="@string/frames"
-                android:textColor="#ffffff"
-                android:gravity="center"
-                android:visibility="gone"
-                android:textSize="@dimen/edit_main_font" />
-
-            <TextView
-                android:id="@+id/tvCrop"
-                android:layout_width="0dp"
-                android:layout_height="wrap_content"
-                android:layout_weight="1"
-                android:text="@string/crop"
-                android:textColor="#ffffff"
-                android:gravity="center"
-                android:textSize="@dimen/edit_main_font" />
-
-            <TextView
-                android:id="@+id/tvExposure"
-                android:layout_width="0dp"
-                android:layout_height="wrap_content"
-                android:layout_weight="1"
-                android:text="@string/exposure"
-                android:gravity="center"
-                android:textColor="#ffffff"
-                android:textSize="@dimen/edit_main_font" />
-
-            <TextView
-                android:id="@+id/tvBeautify"
-                android:layout_width="@dimen/thumbnail_size"
-                android:layout_height="wrap_content"
-                android:layout_weight="1"
-                android:text="@string/beautify"
-                android:textColor="#ffffff"
-                android:gravity="center"
-                android:textSize="@dimen/edit_main_font"
-                android:visibility="gone" />
-
-             <TextView
-                android:id="@+id/tvDualCam"
-                android:layout_width="@dimen/thumbnail_size"
-                android:layout_height="wrap_content"
-                android:layout_weight="1"
-                android:text="@string/dualcam"
-                android:gravity="center"
-                android:textColor="#ffffff"
-                android:textSize="@dimen/edit_main_font"
-                android:visibility="gone" />
-
-            <TextView
-                android:id="@+id/tvTrueScanner"
-                android:layout_width="@dimen/thumbnail_size"
-                android:layout_height="wrap_content"
-                android:layout_weight="1"
-                android:text="@string/trueScanner"
-                android:gravity="center"
-                android:textColor="#ffffff"
-                android:textSize="@dimen/edit_main_font" />
-
-            <TextView
-                android:id="@+id/tvHazeBuster"
-                android:layout_width="@dimen/thumbnail_size"
-                android:layout_height="wrap_content"
-                android:layout_weight="1"
-                android:text="@string/hazeBuster"
-                android:gravity="center"
-                android:textColor="#ffffff"
-                android:textSize="@dimen/edit_main_font" />
-
-            <TextView
-                android:id="@+id/tvSeeStraight"
-                android:layout_width="@dimen/thumbnail_size"
-                android:layout_height="wrap_content"
-                android:layout_weight="1"
-                android:text="@string/seeStraight"
-                android:gravity="center"
-                android:textColor="#ffffff"
-                android:textSize="@dimen/edit_main_font" />
-        </LinearLayout>
     </com.android.gallery3d.filtershow.CenteredLinearLayout>
 </LinearLayout>
diff --git a/src/com/android/gallery3d/filtershow/FilterShowActivity.java b/src/com/android/gallery3d/filtershow/FilterShowActivity.java
index 54b637e..32981f1 100644
--- a/src/com/android/gallery3d/filtershow/FilterShowActivity.java
+++ b/src/com/android/gallery3d/filtershow/FilterShowActivity.java
@@ -206,9 +206,6 @@
     private DialogInterface mCurrentDialog = null;
     private PopupMenu mCurrentMenu = null;
     private boolean mReleaseDualCamOnDestory = true;
-    private FrameLayout mCategoryFragment;
-    private View mEffectsContainer;
-    private View mEffectsTextContainer;
     private ImageButton imgComparison;
     private String mPopUpText, mExit;
     RelativeLayout rlImageContainer;
@@ -317,8 +314,6 @@
         if (findViewById(R.id.main_panel_container) == null) {
             return;
         }
-        Fragment main = getSupportFragmentManager().findFragmentByTag(
-                        MainPanel.FRAGMENT_TAG);
         MainPanel panel = new MainPanel();
         Bundle bundle = new Bundle();
         bundle.putBoolean(MainPanel.EDITOR_TAG, isComingFromEditorScreen);
@@ -453,9 +448,6 @@
             if (mMenu != null) {
                 mMenu.clear();
             }
-            final Fragment main = getSupportFragmentManager().findFragmentByTag(
-                    MainPanel.FRAGMENT_TAG);
-
             actionBar.setCustomView(R.layout.filtershow_actionbar_new);
             mCancelButton = actionBar.getCustomView().findViewById(
                     R.id.imgCancel);
@@ -463,8 +455,6 @@
             mCancelButton.setOnClickListener(new OnClickListener() {
                 @Override
                 public void onClick(View view) {
-                    MainPanel mainPanel = (MainPanel) main;
-                    mainPanel.toggleEffectsTrayVisibility(true);
                     setActionBar(false);
                     HistoryManager adapter = mMasterImage.getHistory();
                     int position = adapter.undoCurrentFilter();
@@ -478,15 +468,12 @@
                 @Override
                 public void onClick(View view) {
                     // saveImage();
-                    MainPanel mainPanel = (MainPanel) main;
-                    mainPanel.toggleEffectsTrayVisibility(true);
                     setActionBar(false);
                     HistoryManager adapter = mMasterImage
                             .getHistory();
                     adapter.resetActiveFilter();
                 }
             });
-            isEffectClicked = false;
         }
 
     }
@@ -545,18 +532,6 @@
         invalidateViews();
     }
 
-    private void toggleEffectsTrayVisibility(boolean isEffectTrayEnabled) {
-        if (isEffectTrayEnabled) {
-            mCategoryFragment.setVisibility(View.VISIBLE);
-            mEffectsContainer.setVisibility(View.GONE);
-            mEffectsTextContainer.setVisibility(View.GONE);
-        } else {
-            mCategoryFragment.setVisibility(View.GONE);
-            mEffectsContainer.setVisibility(View.VISIBLE);
-            mEffectsTextContainer.setVisibility(View.VISIBLE);
-        }
-    }
-
     public void adjustCompareButton(boolean scaled) {
         Resources r = getResources();
         int marginTop, marginRight;
@@ -1178,7 +1153,7 @@
 
         public LoadBitmapTask() {
             mBitmapSize = getScreenImageSize();
-            Log.d(LOGTAG, "FilterShowActivity.LoadBtimapTask(): mBitmapSize is " + mBitmapSize);
+            Log.d(LOGTAG, "FilterShowActivity.LoadBitmapTask(): mBitmapSize is " + mBitmapSize);
         }
 
         @Override
@@ -1222,8 +1197,8 @@
                 return;
             }
 
-            if (null == CachingPipeline.getRenderScriptContext()){
-                Log.v(LOGTAG,"RenderScript context destroyed during load");
+            if (null == CachingPipeline.getRenderScriptContext()) {
+                Log.v(LOGTAG, "RenderScript context destroyed during load");
                 return;
             }
             final View imageShow = findViewById(R.id.imageShow);
@@ -1264,7 +1239,7 @@
 
             MasterImage.getImage().resetGeometryImages(true);
 
-            if (mAction == TINY_PLANET_ACTION) {
+            if (mAction.equals(TINY_PLANET_ACTION)) {
                 showRepresentation(mCategoryFiltersAdapter.getTinyPlanet());
             }
             mHiResBitmapTask = new LoadHighresBitmapTask();
@@ -1433,7 +1408,7 @@
         if (mShareActionProvider != null) {
             mShareActionProvider.setOnShareTargetSelectedListener(this);
         }
-        if(SimpleMakeupImageFilter.HAS_TS_MAKEUP) {
+        if (SimpleMakeupImageFilter.HAS_TS_MAKEUP) {
             MakeupEngine.getMakeupObj();
         }
 
@@ -1745,69 +1720,38 @@
                 MainPanel.FRAGMENT_TAG);
 
         if (currentPanel instanceof MainPanel) {
-            MainPanel mainPanel = (MainPanel) currentPanel;
-            if (mainPanel.isCategoryPanelVisible()) {
-                if (mImageShow.hasModifications()) {
-                    AlertDialog.Builder builder = new AlertDialog.Builder(this);
-                    builder.setMessage(R.string.unsaved).setTitle(
-                            R.string.save_before_exit);
-                    builder.setPositiveButton(mPopUpText,
-                            new DialogInterface.OnClickListener() {
-                                @Override
-                                public void onClick(DialogInterface dialog,
-                                        int id) {
-                                    done();
-                                }
-                            });
-                    builder.setNegativeButton(mExit,
-                            new DialogInterface.OnClickListener() {
-                                @Override
-                                public void onClick(DialogInterface dialog,
-                                        int id) {
-                                    HistoryManager adapter = mMasterImage
-                                            .getHistory();
-                                    int position = adapter.undoCurrentFilter();
-                                     mMasterImage.onHistoryItemClick(position);
-                                     adapter.resetActiveFilter();
-                                    backToMain();
-                                    invalidateViews();
-                                }
-                            });
-                    builder.show();
-                }
-                setActionBar(false);
-                mainPanel.toggleEffectsTrayVisibility(true);
-                invalidateOptionsMenu();
-                if (MasterImage.getImage().getScaleFactor() < 1)
-                    setScaleImage(false);
-                adjustCompareButton(false);
-
+            if (mImageShow.hasModifications()) {
+                AlertDialog.Builder builder = new AlertDialog.Builder(this);
+                builder.setMessage(R.string.unsaved).setTitle(
+                        R.string.save_before_exit);
+                builder.setPositiveButton(mPopUpText,
+                        new DialogInterface.OnClickListener() {
+                            @Override
+                            public void onClick(DialogInterface dialog, int id) {
+                                done();
+                            }
+                        });
+                builder.setNegativeButton(mExit,
+                        new DialogInterface.OnClickListener() {
+                            @Override
+                            public void onClick(DialogInterface dialog, int id) {
+                                HistoryManager adapter = mMasterImage.getHistory();
+                                int position = adapter.undoCurrentFilter();
+                                mMasterImage.onHistoryItemClick(position);
+                                adapter.resetActiveFilter();
+                                backToMain();
+                                invalidateViews();
+                            }
+                        });
+                builder.show();
             } else {
-                if (!mImageShow.hasModifications()) {
-                    done();
-                } else {
-                    AlertDialog.Builder builder = new AlertDialog.Builder(this);
-                    builder.setMessage(R.string.unsaved).setTitle(
-                            R.string.save_before_exit);
-                    builder.setPositiveButton(R.string.save_and_exit,
-                            new DialogInterface.OnClickListener() {
-                                @Override
-                                public void onClick(DialogInterface dialog,
-                                        int id) {
-                                    saveImage();
-                                }
-                            });
-                    builder.setNegativeButton(R.string.exit,
-                            new DialogInterface.OnClickListener() {
-                                @Override
-                                public void onClick(DialogInterface dialog,
-                                        int id) {
-                                    done();
-                                }
-                            });
-                    builder.show();
-                }
+                done();
             }
+            setActionBar(false);
+            invalidateOptionsMenu();
+            if (MasterImage.getImage().getScaleFactor() < 1)
+                setScaleImage(false);
+            adjustCompareButton(false);
         } else {
             isComingFromEditorScreen = true;
             backToMain();
@@ -1985,6 +1929,6 @@
     }
 
     public void setScaleImage(boolean isScaled) {
-        mImageShow.scaleImage(isScaled,getBaseContext());
+        mImageShow.scaleImage(isScaled, getBaseContext());
     }
 }
diff --git a/src/com/android/gallery3d/filtershow/category/MainPanel.java b/src/com/android/gallery3d/filtershow/category/MainPanel.java
index c5f9c6e..0f6b661 100644
--- a/src/com/android/gallery3d/filtershow/category/MainPanel.java
+++ b/src/com/android/gallery3d/filtershow/category/MainPanel.java
@@ -22,11 +22,8 @@
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
-import android.widget.FrameLayout;
 import android.widget.ImageButton;
 import android.widget.LinearLayout;
-import android.widget.TextView;
-import android.util.Log;
 
 import com.android.gallery3d.R;
 import com.android.gallery3d.filtershow.FilterShowActivity;
@@ -36,7 +33,6 @@
 import com.android.gallery3d.filtershow.filters.TrueScannerActs;
 import com.android.gallery3d.filtershow.imageshow.MasterImage;
 import com.android.gallery3d.filtershow.state.StatePanel;
-import com.android.gallery3d.filtershow.tools.DualCameraNativeEngine;
 import com.android.gallery3d.filtershow.tools.DualCameraNativeEngine.DdmStatus;
 
 public class MainPanel extends Fragment {
@@ -50,10 +46,6 @@
     private ImageButton filtersButton;
     private ImageButton dualCamButton;
     private ImageButton makeupButton;
-    private View mEffectsContainer;
-    private View mEffectsTextContainer;
-    private FrameLayout mCategoryFragment;
-    private View mBottomView;
     private ImageButton trueScannerButton;
     private ImageButton hazeBusterButton;
     private ImageButton seeStraightButton;
@@ -142,21 +134,9 @@
         geometryButton = (ImageButton) mMainView.findViewById(R.id.geometryButton);
         filtersButton = (ImageButton) mMainView.findViewById(R.id.colorsButton);
         dualCamButton = (ImageButton) mMainView.findViewById(R.id.dualCamButton);
-        mCategoryFragment = (FrameLayout) mMainView
-                .findViewById(R.id.category_panel_container);
-        mBottomView = mMainView.findViewById(R.id.bottom_panel);
-        mEffectsContainer = mMainView.findViewById(R.id.effectsContainer);
-        mEffectsTextContainer = mMainView.findViewById(R.id.effectsText);
         if (SimpleMakeupImageFilter.HAS_TS_MAKEUP) {
             makeupButton = (ImageButton) mMainView.findViewById(R.id.makeupButton);
             makeupButton.setVisibility(View.VISIBLE);
-            TextView beautify = (TextView) mEffectsTextContainer
-                    .findViewById(R.id.tvBeautify);
-            beautify.setVisibility(View.VISIBLE);
-        }
-        boolean showPanel = false;
-        if (getArguments() != null) {
-            showPanel = getArguments().getBoolean(EDITOR_TAG);
         }
 
         if (makeupButton != null) {
@@ -167,25 +147,19 @@
                 }
             });
         }
-        TextView trueScannerTv = (TextView) mMainView.findViewById(R.id.tvTrueScanner);
         trueScannerButton = (ImageButton) mMainView.findViewById(R.id.trueScannerButton);
         if (!TrueScannerActs.isTrueScannerEnabled()) {
-            trueScannerTv.setVisibility(View.GONE);
             trueScannerButton.setVisibility(View.GONE);
         }
 
         hazeBusterButton = (ImageButton) mMainView.findViewById(R.id.hazeBusterButton);
-        TextView hazeBusterTv = (TextView) mMainView.findViewById(R.id.tvHazeBuster);
         if(!HazeBusterActs.isHazeBusterEnabled()) {
-            hazeBusterTv.setVisibility(View.GONE);
             hazeBusterButton.setVisibility(View.GONE);
         }
 
         seeStraightButton = (ImageButton) mMainView.findViewById(R.id.seeStraightButton);
-        TextView seeStraightTv = (TextView) mMainView.findViewById(R.id.tvSeeStraight);
         if(!SeeStraightActs.isSeeStraightEnabled()) {
             seeStraightButton.setVisibility(View.GONE);
-            seeStraightTv.setVisibility(View.GONE);
         }
 
         looksButton.setOnClickListener(new View.OnClickListener() {
@@ -243,10 +217,8 @@
         });
 
         FilterShowActivity activity = (FilterShowActivity) getActivity();
-        //showImageStatePanel(activity.isShowingImageStatePanel());
-        if (showPanel) {
-            showPanel(activity.getCurrentPanel());
-        }
+        showImageStatePanel(activity.isShowingImageStatePanel());
+        showPanel(activity.getCurrentPanel());
         return mMainView;
     }
 
@@ -257,22 +229,6 @@
         return true;
     }
 
-    public boolean isCategoryPanelVisible() {
-        return (View.VISIBLE == mCategoryFragment.getVisibility());
-    }
-
-    public void toggleEffectsTrayVisibility(boolean isCategoryTrayVisible) {
-        if (isCategoryTrayVisible) {
-            mCategoryFragment.setVisibility(View.GONE);
-            mEffectsContainer.setVisibility(View.VISIBLE);
-            mEffectsTextContainer.setVisibility(View.VISIBLE);
-        } else {
-            mCategoryFragment.setVisibility(View.VISIBLE);
-            mEffectsContainer.setVisibility(View.GONE);
-            mEffectsTextContainer.setVisibility(View.GONE);
-        }
-    }
-
     private void setCategoryFragment(CategoryPanel category, boolean fromRight) {
         FragmentTransaction transaction = getChildFragmentManager().beginTransaction();
         FilterShowActivity activity = (FilterShowActivity) getActivity();
@@ -282,13 +238,10 @@
             transaction.setCustomAnimations(R.anim.slide_in_left, R.anim.slide_out_left);
         }
         if (isEffectClicked) {
-            toggleEffectsTrayVisibility(false);
-            activity.setActionBar(isEffectClicked);
+            activity.setActionBar(true);
             isEffectClicked = false;
         } else {
-            toggleEffectsTrayVisibility(true);
-            activity.setActionBar(isEffectClicked);
-
+            activity.setActionBar(false);
         }
         transaction.replace(R.id.category_panel_container, category, CategoryPanel.FRAGMENT_TAG);
         transaction.commitAllowingStateLoss();
@@ -308,9 +261,9 @@
     }
 
     public void loadCategoryBorderPanel() {
-        /*if (mCurrentSelected == BORDERS) {
+        if (mCurrentSelected == BORDERS) {
             return;
-        }*/
+        }
         boolean fromRight = isRightAnimation(BORDERS);
         selection(mCurrentSelected, false);
         CategoryPanel categoryPanel = new CategoryPanel();
@@ -334,9 +287,9 @@
     }
 
     public void loadCategoryGeometryPanel() {
-        /*if (mCurrentSelected == GEOMETRY) {
+        if (mCurrentSelected == GEOMETRY) {
             return;
-        }*/
+        }
         if (MasterImage.getImage().hasTinyPlanet()) {
             return;
         }
@@ -380,9 +333,9 @@
     }
 
     public void loadCategoryFiltersPanel() {
-        /*if (mCurrentSelected == FILTERS) {
+        if (mCurrentSelected == FILTERS) {
             return;
-        }*/
+        }
         boolean fromRight = isRightAnimation(FILTERS);
         selection(mCurrentSelected, false);
         CategoryPanel categoryPanel = new CategoryPanel();
@@ -393,9 +346,9 @@
     }
 
     public void loadCategoryVersionsPanel() {
-        /*if (mCurrentSelected == VERSIONS) {
+        if (mCurrentSelected == VERSIONS) {
             return;
-        }*/
+        }
         FilterShowActivity activity = (FilterShowActivity) getActivity();
         activity.updateVersions();
         boolean fromRight = isRightAnimation(VERSIONS);
@@ -408,9 +361,9 @@
     }
 
     public void loadCategoryDualCamPanel() {
-        /*if (mCurrentSelected == DUALCAM) {
+        if (mCurrentSelected == DUALCAM) {
             return;
-        }*/
+        }
         boolean fromRight = isRightAnimation(DUALCAM);
         selection(mCurrentSelected, false);
         CategoryPanel categoryPanel = new CategoryPanel();
@@ -431,7 +384,7 @@
         FilterShowActivity activity = (FilterShowActivity) getActivity();
         switch (currentPanel) {
             case LOOKS: {
-                loadCategoryLookPanel(true);
+                loadCategoryLookPanel(false);
                 break;
             }
             case BORDERS: {
@@ -471,7 +424,7 @@
                 break;
             }
         }
-     if (currentPanel > 0) {
+        if (currentPanel > 0) {
             activity.setScaleImage(true);
             activity.adjustCompareButton(true);
         } else {
@@ -540,9 +493,6 @@
             boolean enable = (status == DdmStatus.DDM_LOADING || 
                                status == DdmStatus.DDM_LOADED);
             dualCamButton.setVisibility(enable?View.VISIBLE:View.GONE);
-            TextView tvDualCam = (TextView) mEffectsTextContainer
-                    .findViewById(R.id.tvDualCam);
-            tvDualCam.setVisibility(enable?View.VISIBLE:View.GONE);
         }
     }
 }