diff options
author | Danny Baumann <dannybaumann@web.de> | 2017-01-27 10:12:41 +0100 |
---|---|---|
committer | Zhao Wei Liew <zhaoweiliew@gmail.com> | 2017-02-11 01:38:21 +0000 |
commit | f894729dac70ce8e486c7ea173e169eab41fef02 (patch) | |
tree | ed3f9a87378842547567b864d62440ea600b5a10 /src/com | |
parent | 7bfb43e641be631a6b5da8544d3e286d105e5def (diff) | |
download | android_packages_apps_Snap-f894729dac70ce8e486c7ea173e169eab41fef02.tar.gz android_packages_apps_Snap-f894729dac70ce8e486c7ea173e169eab41fef02.tar.bz2 android_packages_apps_Snap-f894729dac70ce8e486c7ea173e169eab41fef02.zip |
Fix shutter button pressed state tracking issues.
- Setting pressed state to false on enabling touch caused ripples to be
displayed too early
- Make sure pressed state is set to true on down event and set to false
on up event
- Correctly set ripple hotspot
Change-Id: I64bbd3be21f19f3027243514239733b57cebb81a
(cherry picked from commit 7cf0bf375ea7a06f02e922f1c205ffba92935695)
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/android/camera/ui/CameraControls.java | 20 | ||||
-rw-r--r-- | src/com/android/camera/ui/FilmStripView.java | 5 |
2 files changed, 22 insertions, 3 deletions
diff --git a/src/com/android/camera/ui/CameraControls.java b/src/com/android/camera/ui/CameraControls.java index c57c538f5..763abe914 100644 --- a/src/com/android/camera/ui/CameraControls.java +++ b/src/com/android/camera/ui/CameraControls.java @@ -37,6 +37,7 @@ import android.util.MathUtils; import android.util.Pair; import android.view.View; import android.view.ViewGroup; +import android.view.ViewParent; import android.view.animation.AccelerateInterpolator; import android.view.animation.DecelerateInterpolator; import android.widget.LinearLayout; @@ -147,9 +148,6 @@ public class CameraControls extends RotatableLayout { synchronized (mViews) { for (View v : mViews) { if (v.getVisibility() != View.GONE) { - if (enable) { - v.setPressed(false); - } v.setEnabled(enable); } } @@ -353,6 +351,7 @@ public class CameraControls extends RotatableLayout { if (background instanceof RippleDrawable) { RippleDrawable ripple = (RippleDrawable) background; if (enable) { + applyBoundsAsHotspot(ripple, mShutter, v); ripple.setState(new int[]{android.R.attr.state_pressed, android.R.attr.state_enabled}); } else { ripple.setState(new int[]{}); @@ -362,6 +361,21 @@ public class CameraControls extends RotatableLayout { }); } + private void applyBoundsAsHotspot(RippleDrawable d, View view, View targetParent) { + int left = view.getLeft(), right = view.getRight(); + int top = view.getTop(), bottom = view.getBottom(); + ViewParent parent = view.getParent(); + while (parent != targetParent && parent instanceof View) { + final View vp = (View) parent; + left += vp.getLeft(); + right += vp.getLeft(); + top += vp.getTop(); + bottom += vp.getTop(); + parent = vp.getParent(); + } + d.setHotspotBounds(left, top, right, bottom); + } + private void setLocation(int w, int h) { int rotation = getUnifiedRotation(); layoutToast(mRefocusToast, w, h, rotation); diff --git a/src/com/android/camera/ui/FilmStripView.java b/src/com/android/camera/ui/FilmStripView.java index 53cff67da..bd57317ea 100644 --- a/src/com/android/camera/ui/FilmStripView.java +++ b/src/com/android/camera/ui/FilmStripView.java @@ -889,6 +889,11 @@ public class FilmStripView extends ViewGroup implements BottomControlsListener { return false; } + @Override + public boolean shouldDelayChildPressedState() { + return !inCameraFullscreen(); + } + private int findTheNearestView(int pointX) { int nearest = 0; |