]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/commitdiff
Prevent tapping on the bookmarks header from activating the buttons beneath it. https...
authorSoren Stoutner <soren@stoutner.com>
Thu, 22 Apr 2021 22:34:38 +0000 (15:34 -0700)
committerSoren Stoutner <soren@stoutner.com>
Thu, 22 Apr 2021 22:34:38 +0000 (15:34 -0700)
app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java
app/src/main/res/layout-w900dp/bookmarks_drawer.xml
app/src/main/res/layout/bookmarks_drawer.xml

index d47cb5ae0ffe9cda1ec0048628f913097180b319..bc31f56681583e564d004cd7233f65c40773ea19 100644 (file)
@@ -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.
index 9ff91e7c9533e161aa772cbc6c803562d5461d2f..03c30f36292b5a0762d657668d3b7dc63dbad343 100644 (file)
@@ -36,6 +36,7 @@
 
         <!-- A compound drawable doesn't work well because only the image view should execute the `onClick()`. -->
         <LinearLayout
+            android:id="@+id/bookmarks_header_linearlayout"
             android:layout_height="wrap_content"
             android:layout_width="match_parent"
             android:orientation="horizontal"
index 46eb252b0eed06e9113793cc5a6fe2bdc2be2d62..4ebce6dd6094f23dcf0c5cb9c71ed79ed7536cdb 100644 (file)
@@ -35,6 +35,7 @@
 
         <!-- A compound drawable doesn't work well because only the image view should execute the `onClick()`. -->
         <LinearLayout
+            android:id="@+id/bookmarks_header_linearlayout"
             android:layout_height="wrap_content"
             android:layout_width="match_parent"
             android:orientation="horizontal"