]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/commitdiff
Disable swiping in the ViewPager. https://redmine.stoutner.com/issues/415
authorSoren Stoutner <soren@stoutner.com>
Tue, 7 May 2019 19:51:10 +0000 (12:51 -0700)
committerSoren Stoutner <soren@stoutner.com>
Tue, 7 May 2019 19:51:10 +0000 (12:51 -0700)
app/src/main/java/com/stoutner/privacybrowser/views/NoSwipeViewPager.java [new file with mode: 0644]
app/src/main/res/layout/about_coordinatorlayout.xml
app/src/main/res/layout/guide_coordinatorlayout.xml
app/src/main/res/layout/import_export_coordinatorlayout.xml
app/src/main/res/layout/main_framelayout.xml
app/src/main/res/layout/pinned_mismatch_linearlayout.xml

diff --git a/app/src/main/java/com/stoutner/privacybrowser/views/NoSwipeViewPager.java b/app/src/main/java/com/stoutner/privacybrowser/views/NoSwipeViewPager.java
new file mode 100644 (file)
index 0000000..cb6e065
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * Copyright © 2019 Soren Stoutner <soren@stoutner.com>.
+ *
+ * This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
+ *
+ * Privacy Browser is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Privacy Browser is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Privacy Browser.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package com.stoutner.privacybrowser.views;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.view.MotionEvent;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.viewpager.widget.ViewPager;
+
+public class NoSwipeViewPager extends ViewPager {
+    // The basic constructor
+    public NoSwipeViewPager(@NonNull Context context) {
+        // Roll up to the full constructor.
+        this(context, null);
+    }
+
+    // The full constructor.
+    public NoSwipeViewPager(@NonNull Context context, @Nullable AttributeSet attributeSet) {
+        // Run the default commands.
+        super(context, attributeSet);
+    }
+
+    // It is necessary to override `performClick()` when overriding `onTouchEvent()`
+    @Override
+    public boolean performClick() {
+        // Run the default commands.
+        super.performClick();
+
+        // Do not consume the events.
+        return false;
+    }
+
+    @Override
+    public boolean onTouchEvent(MotionEvent event) {
+        // `onTouchEvent()` requires calling `performClick()`.
+        performClick();
+
+        // Do not allow swiping.
+        return false;
+    }
+
+    @Override
+    public boolean onInterceptTouchEvent(MotionEvent event) {
+        // Do not allow swiping.
+        return false;
+    }
+}
\ No newline at end of file
index bc365d6baec32002bdd1b228a1a3ed7dc8352fd2..c9062d9e4ca715c640e7ce6775f4f9dce831edf9 100644 (file)
@@ -23,7 +23,7 @@
 <androidx.coordinatorlayout.widget.CoordinatorLayout
     android:id="@+id/about_coordinatorlayout"
     xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:android.support.design="http://schemas.android.com/apk/res-auto"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
     android:layout_height="match_parent"
     android:layout_width="match_parent"
     android:fitsSystemWindows="true">
@@ -54,8 +54,8 @@
                 android:id="@+id/about_tablayout"
                 android:layout_height="wrap_content"
                 android:layout_width="match_parent"
-                android.support.design:tabMode="scrollable"
-                android.support.design:tabIndicatorColor="?attr/tabIndicatorColor"
+                app:tabMode="scrollable"
+                app:tabIndicatorColor="?attr/tabIndicatorColor"
                 android:theme="?attr/tabLayoutTheme" />
         </com.google.android.material.appbar.AppBarLayout>
 
index b47501c91aa796f5114b4cd562040796bc8f83c4..a95e6a0c6b4b9414393cc4571107ef4737233521 100644 (file)
@@ -23,7 +23,7 @@ When it is specified the theme should include <item name="android:windowTransluc
 <androidx.coordinatorlayout.widget.CoordinatorLayout
     android:id="@+id/guide_coordinatorlayout"
     xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:android.support.design="http://schemas.android.com/apk/res-auto"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
     android:layout_height="match_parent"
     android:layout_width="match_parent"
     android:fitsSystemWindows="true" >
@@ -54,8 +54,8 @@ When it is specified the theme should include <item name="android:windowTransluc
                 android:id="@+id/guide_tablayout"
                 android:layout_height="wrap_content"
                 android:layout_width="match_parent"
-                android.support.design:tabMode="scrollable"
-                android.support.design:tabIndicatorColor="?attr/tabIndicatorColor"
+                app:tabMode="scrollable"
+                app:tabIndicatorColor="?attr/tabIndicatorColor"
                 android:theme="?attr/tabLayoutTheme" />
         </com.google.android.material.appbar.AppBarLayout>
 
index a38850aae5a5393bfe8410347ac38b8e2ab8b8c8..29b6fe89fccfe68227951737b7d456856feaaffe 100644 (file)
                                 android:onClick="onClickRadioButton" />
                         </RadioGroup>
 
-                        <!-- Align the EditText and the select file button horizontally. -->
+                        <!-- Align the edit text and the select file button horizontally. -->
                         <LinearLayout
                             android:id="@+id/file_name_linearlayout"
                             android:layout_height="wrap_content"
                             android:orientation="horizontal"
                             android:layout_marginTop="10dp">
 
-                            <!-- `android.support.design.widget.TextInputLayout` makes the `android:hint` float above the `EditText`. -->
+                            <!-- The text input layout makes the hint float above the edit text. -->
                             <com.google.android.material.textfield.TextInputLayout
                                 android:layout_height="wrap_content"
                                 android:layout_width="0dp"
index 925643b526fbfc387bd125a2ac712bfe3ab0b6e0..6e7c2aba3b3c579acaba8b52b3f69235f098a225 100644 (file)
@@ -20,7 +20,7 @@
 
 <FrameLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:android.support.design="http://schemas.android.com/apk/res-auto"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
     xmlns:tools="http://schemas.android.com/tools"
     android:id="@+id/root_framelayout"
     android:layout_height="match_parent"
@@ -62,7 +62,7 @@
                         android:id="@+id/toolbar"
                         android:layout_height="wrap_content"
                         android:layout_width="match_parent"
-                        android.support.design:layout_scrollFlags="scroll|enterAlways|snap" />
+                        app:layout_scrollFlags="scroll|enterAlways|snap" />
 
                     <!-- The find on page linear layout.  It is initially `visibility="gone"`. -->
                     <LinearLayout
@@ -71,7 +71,7 @@
                         android:layout_width="match_parent"
                         android:orientation="horizontal"
                         android:visibility="gone"
-                        android.support.design:layout_scrollFlags="scroll|enterAlways|snap" >
+                        app:layout_scrollFlags="scroll|enterAlways|snap" >
 
                         <!-- `android:imeOptions="actionDone"` sets the keyboard to have a `check mark` key instead of a `new line` key. -->
                         <EditText
                         android:layout_height="wrap_content"
                         android:layout_width="wrap_content"
                         android:orientation="horizontal"
-                        android.support.design:layout_scrollFlags="scroll|enterAlways|snap" >
+                        app:layout_scrollFlags="scroll|enterAlways|snap" >
 
                         <com.google.android.material.tabs.TabLayout
                             android:id="@+id/tablayout"
                             android:layout_height="wrap_content"
                             android:layout_width="0dp"
                             android:layout_weight="1"
-                            android.support.design:tabIndicatorGravity="top"
-                            android.support.design:tabMode="scrollable" />
+                            app:tabIndicatorGravity="top"
+                            app:tabMode="scrollable" />
 
                         <ImageView
                             android:layout_height="wrap_content"
                     android:id="@+id/swiperefreshlayout"
                     android:layout_width="match_parent"
                     android:layout_height="match_parent"
-                    android.support.design:layout_behavior="@string/appbar_scrolling_view_behavior" >
+                    app:layout_behavior="@string/appbar_scrolling_view_behavior" >
 
-                        <androidx.viewpager.widget.ViewPager
+                        <com.stoutner.privacybrowser.views.NoSwipeViewPager
                             android:id="@+id/webviewpager"
                             android:layout_width="match_parent"
                             android:layout_height="match_parent" />
             android:layout_height="match_parent"
             android:layout_width="wrap_content"
             android:layout_gravity="start"
-            android.support.design:headerLayout="@layout/navigation_header"
-            android.support.design:menu="@menu/webview_navigation_menu"
-            android.support.design:itemIconTint="?attr/navigationIconTintColor" />
+            app:headerLayout="@layout/navigation_header"
+            app:menu="@menu/webview_navigation_menu"
+            app:itemIconTint="?attr/navigationIconTintColor" />
 
         <!-- Include the bookmarks drawer, which varies based on screen width. -->
         <include layout="@layout/bookmarks_drawer" />
index be8db4c28ce6e2129ebe0378f0268864e20480fd..4154874eaea68c44d880145dbddfca3645a977e8 100644 (file)
@@ -20,7 +20,7 @@
 
 <LinearLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:android.support.design="http://schemas.android.com/apk/res-auto"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
     android:layout_height="wrap_content"
     android:layout_width="wrap_content"
     android:orientation="vertical">
@@ -29,7 +29,7 @@
         android:id="@+id/pinned_ssl_certificate_mismatch_tablayout"
         android:layout_height="wrap_content"
         android:layout_width="wrap_content"
-        android.support.design:tabMode="scrollable"
+        app:tabMode="scrollable"
         android:theme="?attr/dialogTabLayoutTheme" />
 
     <ScrollView