OSDN Git Service

Adding support for ICS
authornicolasroard <nicolasroard@google.com>
Tue, 12 Feb 2013 02:15:15 +0000 (18:15 -0800)
committernicolasroard <nicolasroard@google.com>
Tue, 12 Feb 2013 02:22:47 +0000 (18:22 -0800)
Change-Id: I550d461b08a4cc5ceb3cdefd82301d5986325184

src/com/android/gallery3d/filtershow/FilterShowActivity.java
src/com/android/gallery3d/filtershow/PanelController.java
src/com/android/gallery3d/filtershow/filters/ImageFilterBorder.java

index f061842..912446d 100644 (file)
@@ -83,7 +83,6 @@ import java.io.IOException;
 import java.lang.ref.WeakReference;
 import java.util.Vector;
 
-@TargetApi(16)
 public class FilterShowActivity extends Activity implements OnItemClickListener,
         OnShareTargetSelectedListener {
 
@@ -464,9 +463,11 @@ public class FilterShowActivity extends Activity implements OnItemClickListener,
             loading.setVisibility(View.GONE);
             final View filters = findViewById(R.id.filtersPanel);
             filters.setVisibility(View.VISIBLE);
-            float y = filters.getY();
-            filters.setY(y + filters.getHeight());
-            filters.animate().setDuration(600).y(y).withLayer().start();
+            if (PanelController.useAnimations()) {
+                float y = filters.getY();
+                filters.setY(y + filters.getHeight());
+                filters.animate().setDuration(600).y(y).withLayer().start();
+            }
             final View imageShow = findViewById(R.id.imageShow);
             imageShow.setVisibility(View.VISIBLE);
 
@@ -859,7 +860,8 @@ public class FilterShowActivity extends Activity implements OnItemClickListener,
         int translate = translateMainPanel(viewList);
         if (!mShowingImageStatePanel) {
             mShowingImageStatePanel = true;
-            view.animate().setDuration(200).x(translate)
+            if (PanelController.useAnimations()) {
+                view.animate().setDuration(200).x(translate)
                     .withLayer().withEndAction(new Runnable() {
                         @Override
                         public void run() {
@@ -869,11 +871,18 @@ public class FilterShowActivity extends Activity implements OnItemClickListener,
                                     .alpha(1.0f).start();
                         }
                     }).start();
+            } else {
+                view.setX(translate);
+            }
         } else {
             mShowingImageStatePanel = false;
             viewList.setVisibility(View.INVISIBLE);
-            view.animate().setDuration(200).x(0).withLayer()
+            if (PanelController.useAnimations()) {
+                view.animate().setDuration(200).x(0).withLayer()
                     .start();
+            } else {
+                view.setX(0);
+            }
         }
         invalidateOptionsMenu();
     }
@@ -917,7 +926,8 @@ public class FilterShowActivity extends Activity implements OnItemClickListener,
         int translate = translateMainPanel(viewList);
         if (!mShowingHistoryPanel) {
             mShowingHistoryPanel = true;
-            view.animate().setDuration(200).x(translate)
+            if (PanelController.useAnimations()) {
+                view.animate().setDuration(200).x(translate)
                     .withLayer().withEndAction(new Runnable() {
                         @Override
                         public void run() {
@@ -927,11 +937,18 @@ public class FilterShowActivity extends Activity implements OnItemClickListener,
                                     .alpha(1.0f).start();
                         }
                     }).start();
+            } else {
+                view.setX(translate);
+            }
         } else {
             mShowingHistoryPanel = false;
             viewList.setVisibility(View.INVISIBLE);
-            view.animate().setDuration(200).x(0).withLayer()
+            if (PanelController.useAnimations()) {
+                view.animate().setDuration(200).x(0).withLayer()
                     .start();
+            } else {
+                view.setX(0);
+            }
         }
         invalidateOptionsMenu();
     }
index ce72162..a8ec3c2 100644 (file)
@@ -16,6 +16,7 @@
 
 package com.android.gallery3d.filtershow;
 
+import android.annotation.TargetApi;
 import android.content.Context;
 import android.text.Html;
 import android.view.View;
@@ -48,6 +49,10 @@ public class PanelController implements OnClickListener {
     private boolean mDisableFilterButtons = false;
     private boolean mFixedAspect = false;
 
+    public static boolean useAnimations() {
+        return true;
+    }
+
     public void setFixedAspect(boolean t) {
         mFixedAspect = t;
     }
@@ -86,16 +91,28 @@ public class PanelController implements OnClickListener {
                 } else {
                     delta = w;
                 }
-                anim.x(delta);
+                if (PanelController.useAnimations()) {
+                    anim.x(delta);
+                } else {
+                    mContainer.setX(delta);
+                }
             } else if (move == VERTICAL_MOVE) {
-                anim.y(h);
-            }
-            anim.setDuration(ANIM_DURATION).withLayer().withEndAction(new Runnable() {
-                @Override
-                public void run() {
-                    mContainer.setVisibility(View.GONE);
+                if (PanelController.useAnimations()) {
+                    anim.y(h);
+                } else {
+                    mContainer.setY(h);
                 }
-            });
+            }
+            if (PanelController.useAnimations()) {
+                anim.setDuration(ANIM_DURATION).withLayer().withEndAction(new Runnable() {
+                    @Override
+                    public void run() {
+                        mContainer.setVisibility(View.GONE);
+                        }
+                });
+            } else {
+                mContainer.setVisibility(View.GONE);
+            }
             return anim;
         }
 
@@ -107,18 +124,20 @@ public class PanelController implements OnClickListener {
             ViewPropertyAnimator anim = mContainer.animate();
             int w = mRowPanel.getWidth();
             int h = mRowPanel.getHeight();
-            if (move == HORIZONTAL_MOVE) {
-                if (oldPos < mPosition) {
-                    mContainer.setX(w);
-                } else {
-                    mContainer.setX(-w);
+            if (useAnimations()) {
+                if (move == HORIZONTAL_MOVE) {
+                    if (oldPos < mPosition) {
+                        mContainer.setX(w);
+                    } else {
+                        mContainer.setX(-w);
+                    }
+                    anim.x(0);
+                } else if (move == VERTICAL_MOVE) {
+                    mContainer.setY(h);
+                    anim.y(0);
                 }
-                anim.x(0);
-            } else if (move == VERTICAL_MOVE) {
-                mContainer.setY(h);
-                anim.y(0);
+                anim.setDuration(ANIM_DURATION).withLayer();
             }
-            anim.setDuration(ANIM_DURATION).withLayer();
             return anim;
         }
     }
@@ -368,10 +387,14 @@ public class PanelController implements OnClickListener {
         if (mUtilityPanel != null && mUtilityPanel.selected()) {
             ViewPropertyAnimator anim1 = mUtilityPanel.unselect();
             removedUtilityPanel = true;
-            anim1.start();
+            if (anim1 != null) {
+                anim1.start();
+            }
             if (mCurrentPanel == view) {
                 ViewPropertyAnimator anim2 = current.select(-1, VERTICAL_MOVE);
-                anim2.start();
+                if (anim2 != null) {
+                    anim2.start();
+                }
                 showDefaultImageView();
             }
         }
@@ -387,15 +410,22 @@ public class PanelController implements OnClickListener {
                 currentPos = current.getPosition();
             }
             ViewPropertyAnimator anim1 = panel.select(currentPos, HORIZONTAL_MOVE);
-            anim1.start();
+            if (anim1 != null) {
+                anim1.start();
+            }
             if (current != null) {
                 ViewPropertyAnimator anim2 = current.unselect(panel.getPosition(), HORIZONTAL_MOVE);
-                anim2.start();
+                if (anim2 != null) {
+                    anim2.start();
+                }
             }
         } else {
             ViewPropertyAnimator anim = panel.select(-1, VERTICAL_MOVE);
-            anim.start();
+            if (anim != null) {
+                anim.start();
+            }
         }
+
         showDefaultImageView();
         mCurrentPanel = view;
     }
@@ -481,13 +511,17 @@ public class PanelController implements OnClickListener {
             }
         }
 
-        if (mUtilityPanel != null && !mUtilityPanel.selected() && doPanelTransition ) {
+        if (mUtilityPanel != null && !mUtilityPanel.selected() && doPanelTransition) {
             Panel current = mPanels.get(mCurrentPanel);
             ViewPropertyAnimator anim1 = current.unselect(-1, VERTICAL_MOVE);
-            anim1.start();
+            if (anim1 != null) {
+                anim1.start();
+            }
             if (mUtilityPanel != null) {
                 ViewPropertyAnimator anim2 = mUtilityPanel.select();
-                anim2.start();
+                if (anim2 != null) {
+                    anim2.start();
+                }
             }
         }
 
index 0f1e8d6..416af94 100644 (file)
@@ -91,7 +91,7 @@ public class ImageFilterBorder extends ImageFilter {
 
     public Drawable getDrawable(int rsc) {
         Drawable drawable = mDrawables.get(rsc);
-        if (drawable == null && mResources != null) {
+        if (drawable == null && mResources != null && rsc != 0) {
             drawable = new BitmapDrawable(mResources, BitmapFactory.decodeResource(mResources, rsc));
             mDrawables.put(rsc, drawable);
         }