summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWu-cheng Li <wuchengli@google.com>2011-08-09 16:14:08 +0800
committerWu-cheng Li <wuchengli@google.com>2011-08-09 16:46:28 +0800
commite5fe56fec047dec5ccb12c2001bacfd9455352da (patch)
tree1ae640d448057b5f01d4ab3333b4a00ccc72f861
parent16ca94d73bfe07f280e381595709b56c2681b2bc (diff)
downloadLegacyCamera-e5fe56fec047dec5ccb12c2001bacfd9455352da.zip
LegacyCamera-e5fe56fec047dec5ccb12c2001bacfd9455352da.tar.gz
LegacyCamera-e5fe56fec047dec5ccb12c2001bacfd9455352da.tar.bz2
Fix shutter button state is not reset.
Change-Id: I80402befad3ad827efa9f1441699b72032b2b3ce
-rw-r--r--src/com/android/camera/ui/IndicatorWheel.java27
1 files changed, 18 insertions, 9 deletions
diff --git a/src/com/android/camera/ui/IndicatorWheel.java b/src/com/android/camera/ui/IndicatorWheel.java
index ac1305e..3ee3f5c 100644
--- a/src/com/android/camera/ui/IndicatorWheel.java
+++ b/src/com/android/camera/ui/IndicatorWheel.java
@@ -56,8 +56,8 @@ public class IndicatorWheel extends IndicatorControl {
private double mSectorInitialRadians[];
private Paint mBackgroundPaint;
private RectF mBackgroundRect;
- // The index of the indicator that is being pressed. This starts from 0.
- // -1 means no indicator is being pressed.
+ // The index of the child that is being pressed. -1 means no child is being
+ // pressed.
private int mPressedIndex = -1;
// Time lapse recording variables.
@@ -93,11 +93,20 @@ public class IndicatorWheel extends IndicatorControl {
// Check if the event should be dispatched to the shutter button.
if (radius <= mShutterButtonRadius) {
if (action == MotionEvent.ACTION_DOWN || action == MotionEvent.ACTION_UP) {
+ mPressedIndex = (action == MotionEvent.ACTION_DOWN) ? 0 : -1;
return mShutterButton.dispatchTouchEvent(event);
}
return false;
}
+ // Send cancel to the shutter button if it was pressed.
+ if (mPressedIndex == 0) {
+ event.setAction(MotionEvent.ACTION_CANCEL);
+ mShutterButton.dispatchTouchEvent(event);
+ mPressedIndex = -1;
+ return true;
+ }
+
// Ignore the event if it's too near to the shutter button or too far
// from the shutter button.
if (radius <= mWheelRadius + mStrokeWidth) {
@@ -105,9 +114,9 @@ public class IndicatorWheel extends IndicatorControl {
if (delta < 0) delta += Math.PI * 2;
// Check which sector is pressed.
if (delta > mSectorInitialRadians[0]) {
- for (int i = 0; i < getChildCount() - 1; i++) {
- if (delta < mSectorInitialRadians[i + 1]) {
- View child = getChildAt(i + 1);
+ for (int i = 1; i < getChildCount(); i++) {
+ if (delta < mSectorInitialRadians[i]) {
+ View child = getChildAt(i);
if (action == MotionEvent.ACTION_DOWN) {
if (child instanceof AbstractIndicatorButton) {
AbstractIndicatorButton b = (AbstractIndicatorButton) child;
@@ -134,7 +143,7 @@ public class IndicatorWheel extends IndicatorControl {
dismissSettingPopup();
// Cancel the previous one.
if (mPressedIndex != -1) {
- View cancelChild = getChildAt(mPressedIndex + 1);
+ View cancelChild = getChildAt(mPressedIndex);
event.setAction(MotionEvent.ACTION_CANCEL);
cancelChild.dispatchTouchEvent(event);
mPressedIndex = -1;
@@ -158,7 +167,7 @@ public class IndicatorWheel extends IndicatorControl {
// The event is not on any of the child.
dismissSettingPopup();
if (mPressedIndex != -1) {
- View cancelChild = getChildAt(mPressedIndex + 1);
+ View cancelChild = getChildAt(mPressedIndex);
event.setAction(MotionEvent.ACTION_CANCEL);
cancelChild.dispatchTouchEvent(event);
mPressedIndex = -1;
@@ -290,7 +299,7 @@ public class IndicatorWheel extends IndicatorControl {
int selectedIndex = getSelectedIndicatorIndex();
// Draw the highlight arc if an indicator is selected or being pressed.
- if (selectedIndex >= 0 || mPressedIndex >= 0) {
+ if (selectedIndex >= 0 || mPressedIndex > 0) {
int count = getChildCount();
float initialDegrees = 90.0f;
float intervalDegrees = (count <= 2) ? 0.0f : 180.0f / (count - 2);
@@ -298,7 +307,7 @@ public class IndicatorWheel extends IndicatorControl {
if (selectedIndex >= 0) {
degree = initialDegrees + intervalDegrees * (selectedIndex - 1);
} else {
- degree = initialDegrees + intervalDegrees * mPressedIndex;
+ degree = initialDegrees + intervalDegrees * (mPressedIndex - 1);
}
mBackgroundPaint.setStrokeWidth(HIGHLIGHT_WIDTH);
mBackgroundPaint.setStrokeCap(Paint.Cap.ROUND);