OSDN Git Service

Improves state/history panel behaviour
authornicolasroard <nicolasroard@google.com>
Tue, 5 Mar 2013 00:42:53 +0000 (16:42 -0800)
committernicolasroard <nicolasroard@google.com>
Tue, 5 Mar 2013 00:45:15 +0000 (16:45 -0800)
Change-Id: Icfd071aa5de11f1fe8cbba34f2837d5a850f9a68

res/layout-land/filtershow_activity.xml
src/com/android/gallery3d/filtershow/FilterShowActivity.java

index 8e74de9..81e4fba 100644 (file)
 
             </LinearLayout>
 
+            <LinearLayout
+                    android:id="@+id/historyPanel"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:orientation="vertical"
+                    android:layout_weight="1"
+                    android:visibility="gone" >
+
+                <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/history"
+                        android:textColor="@android:color/white"
+                        android:textSize="24sp"
+                        android:textStyle="bold" />
+
+                <ListView
+                        android:id="@+id/operationsList"
+                        android:layout_width="match_parent"
+                        android:layout_height="wrap_content"
+                        android:layout_weight="1" >
+                </ListView>
+
+                <LinearLayout
+                        android:layout_width="match_parent"
+                        android:layout_height="wrap_content"
+                        android:orientation="horizontal" >
+
+                    <Button
+                            android:id="@+id/resetOperationsButton"
+                            style="@style/FilterShowHistoryButton"
+                            android:gravity="center"
+                            android:text="@string/reset" />
+
+                    <Button
+                            android:id="@+id/saveOperationsButton"
+                            style="@style/FilterShowHistoryButton"
+                            android:text="@string/save"
+                            android:visibility="gone" />
+                </LinearLayout>
+            </LinearLayout>
+
 
             <FrameLayout
                     android:layout_gravity="bottom"
 
     </LinearLayout>
 
-    <LinearLayout
-            android:id="@+id/historyPanel"
-            android:layout_width="200dip"
-            android:layout_height="match_parent"
-            android:layout_gravity="right"
-            android:orientation="vertical"
-            android:visibility="invisible" >
-
-        <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/history"
-                android:textColor="@android:color/white"
-                android:textSize="24sp"
-                android:textStyle="bold" />
-
-        <ListView
-                android:id="@+id/operationsList"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:layout_weight="1" >
-        </ListView>
-
-        <LinearLayout
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:orientation="horizontal" >
-
-            <Button
-                    android:id="@+id/resetOperationsButton"
-                    style="@style/FilterShowHistoryButton"
-                    android:gravity="center"
-                    android:text="@string/reset" />
-
-            <Button
-                    android:id="@+id/saveOperationsButton"
-                    style="@style/FilterShowHistoryButton"
-                    android:text="@string/save"
-                    android:visibility="gone" />
-        </LinearLayout>
-    </LinearLayout>
-
 </FrameLayout>
index 2f9269f..e5d3ac6 100644 (file)
@@ -150,6 +150,11 @@ public class FilterShowActivity extends Activity implements OnItemClickListener,
         fillEditors();
 
         loadXML();
+        if (getResources().getConfiguration().orientation
+                == Configuration.ORIENTATION_LANDSCAPE) {
+            mShowingImageStatePanel = true;
+        }
+
         setDefaultPreset();
 
         processIntent();
@@ -842,7 +847,7 @@ public class FilterShowActivity extends Activity implements OnItemClickListener,
         final View viewList = findViewById(R.id.imageStatePanel);
 
         if (mShowingHistoryPanel) {
-            findViewById(R.id.historyPanel).setVisibility(View.INVISIBLE);
+            findViewById(R.id.historyPanel).setVisibility(View.GONE);
             mShowingHistoryPanel = false;
         }
 
@@ -862,6 +867,7 @@ public class FilterShowActivity extends Activity implements OnItemClickListener,
         super.onConfigurationChanged(newConfig);
         setDefaultValues();
         loadXML();
+        mShowingImageStatePanel = true;
         if (mShowingHistoryPanel) {
             toggleHistoryPanel();
         }
@@ -893,16 +899,18 @@ public class FilterShowActivity extends Activity implements OnItemClickListener,
         final View viewList = findViewById(R.id.historyPanel);
 
         if (mShowingImageStatePanel) {
-            findViewById(R.id.imageStatePanel).setVisibility(View.INVISIBLE);
+            findViewById(R.id.imageStatePanel).setVisibility(View.GONE);
             mShowingImageStatePanel = false;
         }
 
         int translate = translateMainPanel(viewList);
         if (!mShowingHistoryPanel) {
             mShowingHistoryPanel = true;
-            if (PanelController.useAnimations()) {
-                view.animate().setDuration(200).x(translate)
-                    .withLayer().withEndAction(new Runnable() {
+            if (getResources().getConfiguration().orientation
+                    == Configuration.ORIENTATION_PORTRAIT) {
+                if (PanelController.useAnimations()) {
+                    view.animate().setDuration(200).x(translate)
+                            .withLayer().withEndAction(new Runnable() {
                         @Override
                         public void run() {
                             viewList.setAlpha(0);
@@ -911,21 +919,29 @@ public class FilterShowActivity extends Activity implements OnItemClickListener,
                                     .alpha(1.0f).start();
                         }
                     }).start();
+                } else {
+                    view.setX(translate);
+                    viewList.setAlpha(0);
+                    viewList.setVisibility(View.VISIBLE);
+                    viewList.animate().setDuration(100)
+                            .alpha(1.0f).start();
+                }
             } else {
-                view.setX(translate);
-                viewList.setAlpha(0);
                 viewList.setVisibility(View.VISIBLE);
-                viewList.animate().setDuration(100)
-                        .alpha(1.0f).start();
             }
         } else {
             mShowingHistoryPanel = false;
-            viewList.setVisibility(View.INVISIBLE);
-            if (PanelController.useAnimations()) {
-                view.animate().setDuration(200).x(0).withLayer()
-                    .start();
+            if (getResources().getConfiguration().orientation
+                    == Configuration.ORIENTATION_PORTRAIT) {
+                viewList.setVisibility(View.INVISIBLE);
+                if (PanelController.useAnimations()) {
+                    view.animate().setDuration(200).x(0).withLayer()
+                            .start();
+                } else {
+                    view.setX(0);
+                }
             } else {
-                view.setX(0);
+                viewList.setVisibility(View.GONE);
             }
         }
         invalidateOptionsMenu();