android:id="@+id/blocker"
android:layout_height="match_parent"
android:layout_width="@dimen/switcher_size"
- android:clickable="true"
android:layout_gravity="right" />
<include layout="@layout/menu_indicators"
android:id="@+id/blocker"
android:layout_width="match_parent"
android:layout_height="@dimen/switcher_size"
- android:layout_gravity="bottom"
- android:clickable="true" />
+ android:layout_gravity="bottom" />
<include layout="@layout/menu_indicators"
android:layout_width="80dip"
}
// Preview area is touched. Handle touch focus.
+ // Touch to focus is handled by PreviewGestures, this function call
+ // is no longer needed. TODO: Clean it up in the next refactor
@Override
protected void onSingleTapUp(View view, int x, int y) {
- mCurrentModule.onSingleTapUp(view, x, y);
}
@Override
if (pressed && !canTakePicture()) return;
if (pressed) {
- if (mSceneMode == Util.SCENE_MODE_HDR) {
- mActivity.hideSwitcher();
- mActivity.setSwipingEnabled(false);
- }
mFocusManager.onShutterDown();
} else {
// for countdown mode, we need to postpone the shutter release
}
Log.v(TAG, "onShutterButtonClick: mCameraState=" + mCameraState);
+ if (mSceneMode == Util.SCENE_MODE_HDR) {
+ mActivity.hideSwitcher();
+ mActivity.setSwipingEnabled(false);
+ }
// If the user wants to do a snapshot while the previous one is still
// in progress, remember the fact and do it after we finish the previous
// one and re-start the preview. Snapshot in progress also includes the
mGestures = new PreviewGestures(mActivity, this, mZoomRenderer, mPieRenderer,
this);
}
- mGestures.clearTouchReceivers();
+ mGestures.reset();
mGestures.setRenderOverlay(mRenderOverlay);
mGestures.addTouchReceiver(mMenuButton);
- mGestures.addTouchReceiver(mBlocker);
+ mGestures.addUnclickableArea(mBlocker);
// make sure to add touch targets for image capture
if (mController.isImageCaptureIntent()) {
if (mReviewCancelButton != null) {
private MotionEvent mCurrent;
private ScaleGestureDetector mScale;
private List<View> mReceivers;
+ private List<View> mUnclickableAreas;
private int mMode;
private int mSlop;
private int mTapTimeout;
mReceivers.add(v);
}
+ public void addUnclickableArea(View v) {
+ if (mUnclickableAreas == null) {
+ mUnclickableAreas = new ArrayList<View>();
+ }
+ mUnclickableAreas.add(v);
+ }
+
public void clearTouchReceivers() {
if (mReceivers != null) {
mReceivers.clear();
}
}
+ public void clearUnclickableAreas() {
+ if (mUnclickableAreas != null) {
+ mUnclickableAreas.clear();
+ }
+ }
+
+ private boolean checkClickable(MotionEvent m) {
+ if (mUnclickableAreas != null) {
+ for (View v : mUnclickableAreas) {
+ if (isInside(m, v)) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ public void reset() {
+ clearTouchReceivers();
+ clearUnclickableAreas();
+ }
+
public boolean dispatchTouch(MotionEvent m) {
if (!mEnabled) {
return mActivity.superDispatchTouchEvent(m);
mMode = MODE_PIE;
return sendToPie(m);
}
- if (mPie != null && !mZoomOnly) {
+ if (mPie != null && !mZoomOnly && checkClickable(m)) {
mHandler.sendEmptyMessageDelayed(MSG_PIE, TIMEOUT_PIE);
}
if (mZoom != null) {
}
if (MotionEvent.ACTION_UP == m.getActionMasked()) {
cancelPie();
- cancelActivityTouchHandling(m);
// must have been tap
- if (m.getEventTime() - mDown.getEventTime() < mTapTimeout) {
+ if (m.getEventTime() - mDown.getEventTime() < mTapTimeout
+ && checkClickable(m)) {
+ cancelActivityTouchHandling(m);
mTapListener.onSingleTapUp(null,
(int) mDown.getX() - mOverlay.getWindowPositionX(),
(int) mDown.getY() - mOverlay.getWindowPositionY());
mGestures = new PreviewGestures(mActivity, this, mZoomRenderer, mPieRenderer, this);
}
mGestures.setRenderOverlay(mRenderOverlay);
- mGestures.clearTouchReceivers();
+ mGestures.reset();
mGestures.addTouchReceiver(mMenu);
- mGestures.addTouchReceiver(mBlocker);
+ mGestures.addUnclickableArea(mBlocker);
if (mController.isVideoCaptureIntent()) {
if (mReviewCancelButton != null) {
mGestures.addTouchReceiver(mReviewCancelButton);