OSDN Git Service

Dismiss mode drawer when tapped outside
authorDoris Liu <tianliu@google.com>
Thu, 20 Feb 2014 02:06:00 +0000 (18:06 -0800)
committerDoris Liu <tianliu@google.com>
Thu, 20 Feb 2014 22:22:13 +0000 (14:22 -0800)
Change shutter button alpha to disabled alpha when mode
drawer is open

Bug: 13084332
Bug: 13084982
Change-Id: Ic6f8c0b910e653045b3f8c1c6f22dca3420f6802

res/layout/mode_selector.xml
src/com/android/camera/ShutterButton.java
src/com/android/camera/app/CameraAppUI.java
src/com/android/camera/ui/ModeListView.java

index d686d5c..edba66f 100644 (file)
@@ -20,7 +20,8 @@
     android:layout_height="@dimen/mode_selector_item_height"
     android:paddingLeft="16dp"
     android:paddingTop="6dp"
-    android:paddingBottom="6dp">
+    android:paddingBottom="6dp"
+    android:paddingRight="12dp">
     <TextView
         android:id="@+id/selector_text"
         android:layout_gravity="left|center_vertical"
index a1bbb1a..be4a240 100755 (executable)
@@ -29,6 +29,8 @@ import android.widget.ImageView;
  */
 public class ShutterButton extends ImageView {
 
+    public static final float ALPHA_WHEN_ENABLED = 1f;
+    public static final float ALPHA_WHEN_DISABLED = 0.2f;
     private boolean mTouchEnabled = true;
 
     /**
index 46b73f5..42f1fb4 100644 (file)
@@ -395,6 +395,7 @@ public class CameraAppUI implements ModeListView.ModeSwitchListener,
     private final FilmstripLayout mFilmstripLayout;
     private TextureView mTextureView;
     private FrameLayout mModuleUI;
+    private View mShutterButton;
     private BottomBar mBottomBar;
     private ModeOptionsOverlay mModeOptionsOverlay;
     private boolean mShouldShowShimmy = false;
@@ -835,6 +836,11 @@ public class CameraAppUI implements ModeListView.ModeSwitchListener,
         progress = 1 - progress;
         float interpolatedProgress = Gusterpolator.INSTANCE.getInterpolation(progress);
         mModeOptionsToggle.setAlpha(interpolatedProgress);
+        // Change shutter button alpha linearly based on the mode list open progress:
+        // set the alpha to disabled alpha when list is fully open, to enabled alpha
+        // when the list is fully closed.
+        mShutterButton.setAlpha(progress * ShutterButton.ALPHA_WHEN_ENABLED
+                + (1 - progress) * ShutterButton.ALPHA_WHEN_DISABLED);
     }
 
     @Override
@@ -842,6 +848,7 @@ public class CameraAppUI implements ModeListView.ModeSwitchListener,
         // Make sure the alpha on mode options ellipse is reset when mode drawer
         // is closed.
         mModeOptionsToggle.setAlpha(1f);
+        mShutterButton.setAlpha(ShutterButton.ALPHA_WHEN_ENABLED);
     }
 
     /**
@@ -1003,6 +1010,7 @@ public class CameraAppUI implements ModeListView.ModeSwitchListener,
         mModeOptionsToggle = mCameraRootView.findViewById(R.id.mode_options_toggle);
         mBottomBar.addOnLayoutChangeListener(mBottomBarLayoutChangeListener);
         mFocusOverlay = mCameraRootView.findViewById(R.id.focus_overlay);
+        mShutterButton = mCameraRootView.findViewById(R.id.shutter_button);
     }
 
     /**
index 4718fc0..9e0d9fd 100644 (file)
@@ -309,6 +309,7 @@ public class ModeListView extends FrameLayout
             float x = ev.getX() - mListView.getX();
             float y = ev.getY() - mListView.getY();
             if (x < 0 || x > mListView.getWidth() || y < 0 || y > mListView.getHeight()) {
+                snapBack(true);
                 return false;
             }