diff options
author | Wu-cheng Li <wuchengli@google.com> | 2011-01-12 17:09:54 +0800 |
---|---|---|
committer | Wu-cheng Li <wuchengli@google.com> | 2011-01-14 20:04:14 +0800 |
commit | 4504e5b41a0f647ef3e16b1134e130fe3678aebf (patch) | |
tree | fd14fa14129b4ef5aa18ea26a6db30011a0ddb7d /src/com/android/camera | |
parent | 7341b9b5d8194c4ab7140977a8c5218e6d83d516 (diff) | |
download | LegacyCamera-4504e5b41a0f647ef3e16b1134e130fe3678aebf.zip LegacyCamera-4504e5b41a0f647ef3e16b1134e130fe3678aebf.tar.gz LegacyCamera-4504e5b41a0f647ef3e16b1134e130fe3678aebf.tar.bz2 |
Tapping a ring control with menu opened should close it.
bug:3324333
Change-Id: I6a82db8b36b293630e6a487c22d270e23651dfe4
Diffstat (limited to 'src/com/android/camera')
-rw-r--r-- | src/com/android/camera/Camera.java | 15 | ||||
-rw-r--r-- | src/com/android/camera/VideoCamera.java | 15 | ||||
-rw-r--r-- | src/com/android/camera/ui/IndicatorWheel.java | 71 |
3 files changed, 74 insertions, 27 deletions
diff --git a/src/com/android/camera/Camera.java b/src/com/android/camera/Camera.java index 1a39d6b..60c0ac1 100644 --- a/src/com/android/camera/Camera.java +++ b/src/com/android/camera/Camera.java @@ -483,7 +483,7 @@ public class Camera extends NoSearchActivity implements View.OnClickListener, return result; } - private int mPopupLocations[] = new int[2]; + private int mLocation[] = new int[2]; private class PopupGestureListener extends GestureDetector.SimpleOnGestureListener { public boolean onDown(MotionEvent e) { @@ -495,10 +495,15 @@ public class Camera extends NoSearchActivity implements View.OnClickListener, int y = Math.round(e.getY()); // Dismiss the popup window if users touch on the outside. - v.getLocationOnScreen(mPopupLocations); - if (x < mPopupLocations[0] || x > mPopupLocations[0] + v.getWidth() - || y < mPopupLocations[1] || y > mPopupLocations[1] + v.getHeight()) { - mIndicatorWheel.dismissSettingPopup(); + v.getLocationOnScreen(mLocation); + if (x < mLocation[0] || (x > mLocation[0] + v.getWidth()) + || y < mLocation[1] || (y > mLocation[1] + v.getHeight())) { + // Let indicator wheel handle its own event. + mIndicatorWheel.getLocationOnScreen(mLocation); + if (x < mLocation[0] || (x > mLocation[0] + mIndicatorWheel.getWidth()) + || y < mLocation[1] || (y > mLocation[1] + mIndicatorWheel.getHeight())) { + mIndicatorWheel.dismissSettingPopup(); + } // Let event fall through. } return false; diff --git a/src/com/android/camera/VideoCamera.java b/src/com/android/camera/VideoCamera.java index 23e0b90..b867d99 100644 --- a/src/com/android/camera/VideoCamera.java +++ b/src/com/android/camera/VideoCamera.java @@ -1900,7 +1900,7 @@ public class VideoCamera extends NoSearchActivity return super.dispatchTouchEvent(m); } - private int mPopupLocations[] = new int[2]; + private int mLocation[] = new int[2]; private class PopupGestureListener extends GestureDetector.SimpleOnGestureListener { public boolean onDown(MotionEvent e) { @@ -1912,10 +1912,15 @@ public class VideoCamera extends NoSearchActivity int y = Math.round(e.getY()); // Dismiss the popup window if users touch on the outside. - v.getLocationOnScreen(mPopupLocations); - if (x < mPopupLocations[0] || x > mPopupLocations[0] + v.getWidth() - || y < mPopupLocations[1] || y > mPopupLocations[1] + v.getHeight()) { - mIndicatorWheel.dismissSettingPopup(); + v.getLocationOnScreen(mLocation); + if (x < mLocation[0] || (x > mLocation[0] + v.getWidth()) + || y < mLocation[1] || (y > mLocation[1] + v.getHeight())) { + // Let indicator wheel handle its own event. + mIndicatorWheel.getLocationOnScreen(mLocation); + if (x < mLocation[0] || (x > mLocation[0] + mIndicatorWheel.getWidth()) + || y < mLocation[1] || (y > mLocation[1] + mIndicatorWheel.getHeight())) { + mIndicatorWheel.dismissSettingPopup(); + } // Let event fall through. } return false; diff --git a/src/com/android/camera/ui/IndicatorWheel.java b/src/com/android/camera/ui/IndicatorWheel.java index dd96f25..2a3ee4c 100644 --- a/src/com/android/camera/ui/IndicatorWheel.java +++ b/src/com/android/camera/ui/IndicatorWheel.java @@ -64,7 +64,12 @@ public class IndicatorWheel extends ViewGroup implements private double mSectorInitialRadians[]; private Paint mBackgroundPaint; private RectF mBackgroundRect; + // The index of the indicator that is currently selected. private int mSelectedIndex = -1; + // The index of the indicator that has been just de-selected. If users click + // on the same indicator, we want to dismiss the popup window without + // opening it again. + private int mJustDeselectedIndex = -1; private Context mContext; private PreferenceGroup mPreferenceGroup; @@ -97,6 +102,22 @@ public class IndicatorWheel extends ViewGroup implements mBackgroundRect = new RectF(); } + public boolean onInterceptTouchEvent(MotionEvent ev) { + // If the event will go to shutter button, dismiss the popup window now. + // If not, handle it in onTouchEvent. + if (ev.getAction() == MotionEvent.ACTION_DOWN) { + float x = ev.getX(); + float y = ev.getY(); + float shutterButtonX = mShutterButton.getX(); + float shutterButtonY = mShutterButton.getY(); + if (x >= shutterButtonX && y >= shutterButtonY + && (x < shutterButtonX + mShutterButton.getWidth()) + && (y < shutterButtonY + mShutterButton.getHeight())) + dismissSettingPopup(); + } + return false; + } + @Override public boolean onTouchEvent(MotionEvent event) { if (!isEnabled()) return false; @@ -123,6 +144,15 @@ public class IndicatorWheel extends ViewGroup implements if (delta > mSectorInitialRadians[0]) { for (int i = 1; i < count; i++) { if (delta < mSectorInitialRadians[i]) { + // If the touch is moving around the same indicator with + // popup opened, return now to avoid redundent works. + if (action == MotionEvent.ACTION_MOVE && (mSelectedIndex == i - 1)) { + return false; + } + + int selectedIndex = mSelectedIndex; + dismissSettingPopup(); + // Do nothing if scene mode overrides the setting. View child = getChildAt(i); if (child instanceof IndicatorButton) { @@ -135,17 +165,24 @@ public class IndicatorWheel extends ViewGroup implements return true; } } - setHighlight(mSelectedIndex, false); - dismissSettingPopup(); - mSelectedIndex = i - 1; - showSettingPopup(); - setHighlight(mSelectedIndex, true); - invalidate(); + if (action == MotionEvent.ACTION_DOWN + && (selectedIndex == i - 1) && (mJustDeselectedIndex != i - 1)) { + // The same indicator is pressed with popup opened. + mJustDeselectedIndex = i - 1; + } else { + if ((mJustDeselectedIndex != i - 1) + || (selectedIndex == -1 && action == MotionEvent.ACTION_DOWN)) { + showSettingPopup(i - 1); + mJustDeselectedIndex = -1; + } + } return true; } } } } + dismissSettingPopup(); + mJustDeselectedIndex = -1; return false; } @@ -414,20 +451,25 @@ public class IndicatorWheel extends ViewGroup implements root.addView(mOtherSettingsPopup); } - private void showSettingPopup() { - if (mSelectedIndex < mBasicSettingPopups.length) { - if (mBasicSettingPopups[mSelectedIndex] == null) { - initializeSettingPopup(mSelectedIndex); + private void showSettingPopup(int index) { + if (index == mSelectedIndex) return; + + if (index < mBasicSettingPopups.length) { + if (mBasicSettingPopups[index] == null) { + initializeSettingPopup(index); } } else if (mOtherSettingsPopup == null) { initializeOtherSettingPopup(); } - if (mSelectedIndex == mBasicSettingPopups.length) { + if (index == mBasicSettingPopups.length) { mOtherSettingsPopup.setVisibility(View.VISIBLE); } else { - mBasicSettingPopups[mSelectedIndex].setVisibility(View.VISIBLE); + mBasicSettingPopups[index].setVisibility(View.VISIBLE); } + setHighlight(index, true); + mSelectedIndex = index; + invalidate(); } public boolean dismissSettingPopup() { @@ -445,11 +487,6 @@ public class IndicatorWheel extends ViewGroup implements return false; } - // Popup window is dismissed. - public void onDismiss() { - mSelectedIndex = -1; - } - public View getActivePopupWindow() { if (mSelectedIndex >= 0) { if (mSelectedIndex == mBasicSettingPopups.length) { |