From af8631a31e1eeec0cb3e102f33c27008b93e6c80 Mon Sep 17 00:00:00 2001 From: Soren Stoutner Date: Thu, 22 Apr 2021 15:34:38 -0700 Subject: [PATCH] Prevent tapping on the bookmarks header from activating the buttons beneath it. https://redmine.stoutner.com/issues/622 --- .../activities/MainWebViewActivity.java | 11 ++++++++++- app/src/main/res/layout-w900dp/bookmarks_drawer.xml | 1 + app/src/main/res/layout/bookmarks_drawer.xml | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java index d47cb5ae..bc31f566 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java @@ -3110,7 +3110,9 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook break; } } - + + // Remove the warning that `OnTouchListener()` needs to override `performClick()`, as the only purpose of setting the `OnTouchListener()` is to make it do nothing. + @SuppressLint("ClickableViewAccessibility") private void initializeApp() { // Get a handle for the input method. InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); @@ -3220,6 +3222,7 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook this.registerReceiver(orbotStatusBroadcastReceiver, new IntentFilter("org.torproject.android.intent.action.STATUS")); // Get handles for views that need to be modified. + LinearLayout bookmarksHeaderLinearLayout = findViewById(R.id.bookmarks_header_linearlayout); ListView bookmarksListView = findViewById(R.id.bookmarks_drawer_listview); FloatingActionButton launchBookmarksActivityFab = findViewById(R.id.launch_bookmarks_activity_fab); FloatingActionButton createBookmarkFolderFab = findViewById(R.id.create_bookmark_folder_fab); @@ -3286,6 +3289,12 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook } }); + // Set a touch listener on the bookmarks header linear layout so that touches don't pass through to the button underneath. + bookmarksHeaderLinearLayout.setOnTouchListener((view, motionEvent) -> { + // Consume the touch. + return true; + }); + // Set the launch bookmarks activity FAB to launch the bookmarks activity. launchBookmarksActivityFab.setOnClickListener(v -> { // Get a copy of the favorite icon bitmap. diff --git a/app/src/main/res/layout-w900dp/bookmarks_drawer.xml b/app/src/main/res/layout-w900dp/bookmarks_drawer.xml index 9ff91e7c..03c30f36 100644 --- a/app/src/main/res/layout-w900dp/bookmarks_drawer.xml +++ b/app/src/main/res/layout-w900dp/bookmarks_drawer.xml @@ -36,6 +36,7 @@