| Index: chrome/android/java/src/org/chromium/chrome/browser/widget/bottomsheet/BottomSheet.java
|
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/widget/bottomsheet/BottomSheet.java b/chrome/android/java/src/org/chromium/chrome/browser/widget/bottomsheet/BottomSheet.java
|
| index 45ffb7fa91b240010d40e84748bd6d04fc740019..229fcb8b16e7abb51a4cb6e630aa710508dc8bfa 100644
|
| --- a/chrome/android/java/src/org/chromium/chrome/browser/widget/bottomsheet/BottomSheet.java
|
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/widget/bottomsheet/BottomSheet.java
|
| @@ -183,6 +183,9 @@ public class BottomSheet
|
| */
|
| private View mDefaultToolbarView;
|
|
|
| + /** Whether the {@link BottomSheet} and its children should react to touch events. */
|
| + private boolean mIsTouchEnabled = true;
|
| +
|
| /** Whether the sheet is currently open. */
|
| private boolean mIsSheetOpen;
|
|
|
| @@ -334,8 +337,19 @@ public class BottomSheet
|
| addObserver(mMetrics);
|
| }
|
|
|
| + /**
|
| + * Sets whether the {@link BottomSheet} and its children should react to touch events.
|
| + */
|
| + public void setTouchEnabled(boolean enabled) {
|
| + mIsTouchEnabled = enabled;
|
| + }
|
| +
|
| @Override
|
| public boolean onInterceptTouchEvent(MotionEvent e) {
|
| + // If touch is disabled, act like a black hole and consume touch events without doing
|
| + // anything with them.
|
| + if (!mIsTouchEnabled) return true;
|
| +
|
| if (!canMoveSheet()) return false;
|
|
|
| // The incoming motion event may have been adjusted by the view sending it down. Create a
|
| @@ -347,6 +361,10 @@ public class BottomSheet
|
|
|
| @Override
|
| public boolean onTouchEvent(MotionEvent e) {
|
| + // If touch is disabled, act like a black hole and consume touch events without doing
|
| + // anything with them.
|
| + if (!mIsTouchEnabled) return true;
|
| +
|
| if (isToolbarAndroidViewHidden()) return false;
|
|
|
| // The down event is interpreted above in onInterceptTouchEvent, it does not need to be
|
| @@ -998,6 +1016,10 @@ public class BottomSheet
|
| @Override
|
| public void onFadingViewVisibilityChanged(boolean visible) {}
|
|
|
| + /**
|
| + * Checks whether the sheet can be moved. It cannot be moved when the activity is in overview
|
| + * mode, when "find in page" is visible, or when the toolbar is hidden.
|
| + */
|
| private boolean canMoveSheet() {
|
| boolean isInOverviewMode = mTabModelSelector != null
|
| && (mTabModelSelector.getCurrentTab() == null
|
|
|