Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(826)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/widget/bottomsheet/BottomSheet.java

Issue 2810713002: 🏡 Disable BottomSheet touches while context menu is open. (Closed)
Patch Set: Add some comments. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/suggestions/SuggestionsRecyclerView.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/suggestions/SuggestionsRecyclerView.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698