]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/commitdiff
Reimplement ActionBarDrawerToggle to get rid of the wasted padding. https://redmine...
authorSoren Stoutner <soren@stoutner.com>
Fri, 29 Dec 2023 00:02:20 +0000 (17:02 -0700)
committerSoren Stoutner <soren@stoutner.com>
Fri, 29 Dec 2023 00:02:20 +0000 (17:02 -0700)
14 files changed:
app/src/main/assets/de/about_licenses.html
app/src/main/assets/en/about_licenses.html
app/src/main/assets/es/about_licenses.html
app/src/main/assets/fr/about_licenses.html
app/src/main/assets/it/about_licenses.html
app/src/main/assets/pt-rBR/about_licenses.html
app/src/main/assets/ru/about_licenses.html
app/src/main/assets/shared_images/menu_rounded_weight400_grade0_24px.svg [new file with mode: 0644]
app/src/main/assets/tr/about_licenses.html
app/src/main/assets/zh-rCN/about_licenses.html
app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.kt
app/src/main/res/drawable/history.xml
app/src/main/res/drawable/menu.xml [new file with mode: 0644]
app/src/main/res/layout/url_app_bar.xml

index 933dce146b235c900a7fd44c0d701aeeb033a13b..3af3b7d8a9ecec20ac063c989430c1c28d2b9255 100644 (file)
         <p><svg class="icon"><use href="../shared_images/location_off.svg#icon"/></svg> location_off.</p>
         <p><svg class="icon"><use href="../shared_images/lock.svg#icon"/></svg> lock.</p>
         <p><svg class="icon"><use href="../shared_images/map.svg#icon"/></svg> map.</p>
+        <p><svg class="icon"><use href="../shared_images/menu_rounded_weight400_grade0_24px.svg#icon"/></svg> menu_<wbr>rounded_<wbr>weight400_<wbr>grade0_<wbr>24px.</p>
         <p><svg class="icon"><use href="../shared_images/more.svg#icon"/></svg> more.</p>
         <p><svg class="icon"><use href="../shared_images/new_releases.svg#icon"/></svg> new_releases.</p>
         <p><svg class="icon"><use href="../shared_images/open_in_browser.svg#icon"/></svg> open_in_browser.</p>
index a21861d16d76c4f817222e70a74f99ef3bbf3482..437ae6b4ae0a8e54edee9b0279d5240c506f18ee 100644 (file)
         <p><svg class="icon"><use href="../shared_images/location_off.svg#icon"/></svg> location_off.</p>
         <p><svg class="icon"><use href="../shared_images/lock.svg#icon"/></svg> lock.</p>
         <p><svg class="icon"><use href="../shared_images/map.svg#icon"/></svg> map.</p>
+        <p><svg class="icon"><use href="../shared_images/menu_rounded_weight400_grade0_24px.svg#icon"/></svg> menu_<wbr>rounded_<wbr>weight400_<wbr>grade0_<wbr>24px.</p>
         <p><svg class="icon"><use href="../shared_images/more.svg#icon"/></svg> more.</p>
         <p><svg class="icon"><use href="../shared_images/new_releases.svg#icon"/></svg> new_releases.</p>
         <p><svg class="icon"><use href="../shared_images/open_in_browser.svg#icon"/></svg> open_in_browser.</p>
index caf64bb9e4d6eef32301e98218e7867c79bdcdaf..a88798fe56dabfe1543df314028803a988150126 100644 (file)
         <p><svg class="icon"><use href="../shared_images/location_off.svg#icon"/></svg> location_off.</p>
         <p><svg class="icon"><use href="../shared_images/lock.svg#icon"/></svg> lock.</p>
         <p><svg class="icon"><use href="../shared_images/map.svg#icon"/></svg> map.</p>
+        <p><svg class="icon"><use href="../shared_images/menu_rounded_weight400_grade0_24px.svg#icon"/></svg> menu_<wbr>rounded_<wbr>weight400_<wbr>grade0_<wbr>24px.</p>
         <p><svg class="icon"><use href="../shared_images/more.svg#icon"/></svg> more.</p>
         <p><svg class="icon"><use href="../shared_images/new_releases.svg#icon"/></svg> new_releases.</p>
         <p><svg class="icon"><use href="../shared_images/open_in_browser.svg#icon"/></svg> open_in_browser.</p>
index ec49f4fecd556937648b2c699b8db61f6a599c20..fc2d04cf1458b76b051c49a3ff89429e3e4c0193 100644 (file)
         <p><svg class="icon"><use href="../shared_images/location_off.svg#icon"/></svg> location_off.</p>
         <p><svg class="icon"><use href="../shared_images/lock.svg#icon"/></svg> lock.</p>
         <p><svg class="icon"><use href="../shared_images/map.svg#icon"/></svg> map.</p>
+        <p><svg class="icon"><use href="../shared_images/menu_rounded_weight400_grade0_24px.svg#icon"/></svg> menu_<wbr>rounded_<wbr>weight400_<wbr>grade0_<wbr>24px.</p>
         <p><svg class="icon"><use href="../shared_images/more.svg#icon"/></svg> more.</p>
         <p><svg class="icon"><use href="../shared_images/new_releases.svg#icon"/></svg> new_releases.</p>
         <p><svg class="icon"><use href="../shared_images/open_in_browser.svg#icon"/></svg> open_in_browser.</p>
index 11ba61b6a6a12bd49489ebe609b6b0ef75181b39..466a4f6680552d513ca2fa038e95b5172060a6b4 100644 (file)
         <p><svg class="icon"><use href="../shared_images/location_off.svg#icon"/></svg> location_off.</p>
         <p><svg class="icon"><use href="../shared_images/lock.svg#icon"/></svg> lock.</p>
         <p><svg class="icon"><use href="../shared_images/map.svg#icon"/></svg> map.</p>
+        <p><svg class="icon"><use href="../shared_images/menu_rounded_weight400_grade0_24px.svg#icon"/></svg> menu_<wbr>rounded_<wbr>weight400_<wbr>grade0_<wbr>24px.</p>
         <p><svg class="icon"><use href="../shared_images/more.svg#icon"/></svg> more.</p>
         <p><svg class="icon"><use href="../shared_images/new_releases.svg#icon"/></svg> new_releases.</p>
         <p><svg class="icon"><use href="../shared_images/open_in_browser.svg#icon"/></svg> open_in_browser.</p>
index b1e10d513370f712b40dd92821715d5bae5929e1..bbc93151ec02ff8b5ba74d76afad828c280b8a01 100644 (file)
         <p><svg class="icon"><use href="../shared_images/location_off.svg#icon"/></svg> location_off.</p>
         <p><svg class="icon"><use href="../shared_images/lock.svg#icon"/></svg> lock.</p>
         <p><svg class="icon"><use href="../shared_images/map.svg#icon"/></svg> map.</p>
+        <p><svg class="icon"><use href="../shared_images/menu_rounded_weight400_grade0_24px.svg#icon"/></svg> menu_<wbr>rounded_<wbr>weight400_<wbr>grade0_<wbr>24px.</p>
         <p><svg class="icon"><use href="../shared_images/more.svg#icon"/></svg> more.</p>
         <p><svg class="icon"><use href="../shared_images/new_releases.svg#icon"/></svg> new_releases.</p>
         <p><svg class="icon"><use href="../shared_images/open_in_browser.svg#icon"/></svg> open_in_browser.</p>
index a536b0d003e61b0a7afb4abd8d67519095c85c9f..b2d58794d6f400fd3f93139995db12874f7df427 100644 (file)
         <p><svg class="icon"><use href="../shared_images/location_off.svg#icon"/></svg> location_off.</p>
         <p><svg class="icon"><use href="../shared_images/lock.svg#icon"/></svg> lock.</p>
         <p><svg class="icon"><use href="../shared_images/map.svg#icon"/></svg> map.</p>
+        <p><svg class="icon"><use href="../shared_images/menu_rounded_weight400_grade0_24px.svg#icon"/></svg> menu_<wbr>rounded_<wbr>weight400_<wbr>grade0_<wbr>24px.</p>
         <p><svg class="icon"><use href="../shared_images/more.svg#icon"/></svg> more.</p>
         <p><svg class="icon"><use href="../shared_images/new_releases.svg#icon"/></svg> new_releases.</p>
         <p><svg class="icon"><use href="../shared_images/open_in_browser.svg#icon"/></svg> open_in_browser.</p>
diff --git a/app/src/main/assets/shared_images/menu_rounded_weight400_grade0_24px.svg b/app/src/main/assets/shared_images/menu_rounded_weight400_grade0_24px.svg
new file mode 100644 (file)
index 0000000..044514e
--- /dev/null
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+
+<!--
+  Copyright 2023 Soren Stoutner <soren@stoutner.com>.
+
+  This file is part of Privacy Browser Android <https://www.stoutner.com/privacy-browser-android>.
+
+  It is a modified version of `map`, which is part of the Android Material icon set and is released under the Apache License 2.0.
+
+  Privacy Browser Android 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 Android 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 Android.  If not, see <http://www.gnu.org/licenses/>. -->
+
+<svg
+    xmlns="http://www.w3.org/2000/svg"
+    viewBox="0 -960 960 960"
+    id="icon" >
+
+    <path
+        d="M160-240q-17 0-28.5-11.5T120-280q0-17 11.5-28.5T160-320h640q17 0 28.5 11.5T840-280q0 17-11.5 28.5T800-240H160Zm0-200q-17 0-28.5-11.5T120-480q0-17 11.5-28.5T160-520h640q17 0 28.5 11.5T840-480q0 17-11.5 28.5T800-440H160Zm0-200q-17 0-28.5-11.5T120-680q0-17 11.5-28.5T160-720h640q17 0 28.5 11.5T840-680q0 17-11.5 28.5T800-640H160Z" />
+</svg>
index 25f128632a54588d4bf25dea6c62b2080f8f8ff6..509e35673ea8a1d3884a5d409f0470a392bc9a5a 100644 (file)
         <p><svg class="icon"><use href="../shared_images/location_off.svg#icon"/></svg> location_off.</p>
         <p><svg class="icon"><use href="../shared_images/lock.svg#icon"/></svg> lock.</p>
         <p><svg class="icon"><use href="../shared_images/map.svg#icon"/></svg> map.</p>
+        <p><svg class="icon"><use href="../shared_images/menu_rounded_weight400_grade0_24px.svg#icon"/></svg> menu_<wbr>rounded_<wbr>weight400_<wbr>grade0_<wbr>24px.</p>
         <p><svg class="icon"><use href="../shared_images/more.svg#icon"/></svg> more.</p>
         <p><svg class="icon"><use href="../shared_images/new_releases.svg#icon"/></svg> new_releases.</p>
         <p><svg class="icon"><use href="../shared_images/open_in_browser.svg#icon"/></svg> open_in_browser.</p>
index 8137f332efbd51a4c30111e24a9c0163a3951dc7..99ca707f1a0940f84059d114cc7b3ab4e68cd375 100644 (file)
         <p><svg class="icon"><use href="../shared_images/location_off.svg#icon"/></svg> location_off.</p>
         <p><svg class="icon"><use href="../shared_images/lock.svg#icon"/></svg> lock.</p>
         <p><svg class="icon"><use href="../shared_images/map.svg#icon"/></svg> map.</p>
+        <p><svg class="icon"><use href="../shared_images/menu_rounded_weight400_grade0_24px.svg#icon"/></svg> menu_<wbr>rounded_<wbr>weight400_<wbr>grade0_<wbr>24px.</p>
         <p><svg class="icon"><use href="../shared_images/more.svg#icon"/></svg> more.</p>
         <p><svg class="icon"><use href="../shared_images/new_releases.svg#icon"/></svg> new_releases.</p>
         <p><svg class="icon"><use href="../shared_images/open_in_browser.svg#icon"/></svg> open_in_browser.</p>
index 50e08d0dcc3e708802692fe79a0422e84ee71803..3e6acce2a0820758051297c0d18bfbee828abaaf 100644 (file)
@@ -93,7 +93,6 @@ import android.widget.TextView
 import androidx.activity.OnBackPressedCallback
 import androidx.activity.result.contract.ActivityResultContracts
 import androidx.appcompat.app.ActionBar
-import androidx.appcompat.app.ActionBarDrawerToggle
 import androidx.appcompat.app.AppCompatActivity
 import androidx.appcompat.app.AppCompatDelegate
 import androidx.appcompat.content.res.AppCompatResources
@@ -349,7 +348,6 @@ class MainWebViewActivity : AppCompatActivity(), CreateBookmarkDialog.CreateBook
     private lateinit var userAgentNamesArrayAdapter: ArrayAdapter<CharSequence>
 
     // Define the class variables.
-    private var actionBarDrawerToggle: ActionBarDrawerToggle? = null
     private var appBarHeight = 0
     private var bookmarksCursor: Cursor? = null
     private var bookmarksDatabaseHelper: BookmarksDatabaseHelper? = null
@@ -639,9 +637,6 @@ class MainWebViewActivity : AppCompatActivity(), CreateBookmarkDialog.CreateBook
             urlRelativeLayout = findViewById(R.id.url_relativelayout)
             urlEditText = findViewById(R.id.url_edittext)
 
-            // Create the hamburger icon at the start of the AppBar.
-            actionBarDrawerToggle = ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.open_navigation_drawer, R.string.close_navigation_drawer)
-
             // Initially disable the sliding drawers.  They will be enabled once the filter lists are loaded.
             drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED)
 
@@ -738,15 +733,6 @@ class MainWebViewActivity : AppCompatActivity(), CreateBookmarkDialog.CreateBook
         }
     }
 
-    public override fun onPostCreate(savedInstanceState: Bundle?) {
-        // Run the default commands.
-        super.onPostCreate(savedInstanceState)
-
-        // Sync the state of the DrawerToggle after the default `onRestoreInstanceState()` has finished.  This creates the navigation drawer icon.
-        // If the app is restarting to change the app theme the action bar drawer toggle will not yet be populated.
-        actionBarDrawerToggle?.syncState()
-    }
-
     override fun onNewIntent(intent: Intent) {
         // Run the default commands.
         super.onNewIntent(intent)
@@ -4690,10 +4676,7 @@ class MainWebViewActivity : AppCompatActivity(), CreateBookmarkDialog.CreateBook
 
             override fun onDrawerOpened(drawerView: View) {}
 
-            override fun onDrawerClosed(drawerView: View) {
-                // Reset the drawer icon when the drawer is closed.  Otherwise, it remains an arrow if the drawer is open when the app is restarted.
-                actionBarDrawerToggle!!.syncState()
-            }
+            override fun onDrawerClosed(drawerView: View) {}
 
             override fun onDrawerStateChanged(newState: Int) {
                 if (newState == DrawerLayout.STATE_SETTLING || newState == DrawerLayout.STATE_DRAGGING) {  // A drawer is opening or closing.
@@ -6166,6 +6149,11 @@ class MainWebViewActivity : AppCompatActivity(), CreateBookmarkDialog.CreateBook
             currentWebView!!.loadUrl(openFilePath)
         }
     }
+    // The view parameter cannot be removed because it is called from the layout onClick.
+    fun openNavigationDrawer(@Suppress("UNUSED_PARAMETER")view: View) {
+        // Open the navigation drawer.
+        drawerLayout.openDrawer(GravityCompat.START)
+    }
 
     private fun openWithApp(url: String) {
         // Create an open with app intent with `ACTION_VIEW`.
index 1d4d07c87ac5b9cce359268ba4efe3e7836685f9..8acda0eae08824576126302112ce3af62a9fb2c7 100644 (file)
@@ -11,4 +11,4 @@
     <path
         android:fillColor="@color/black"
         android:pathData="M3,13h2v-2L3,11v2zM3,17h2v-2L3,15v2zM3,9h2L5,7L3,7v2zM7,13h14v-2L7,11v2zM7,17h14v-2L7,15v2zM7,7v2h14L21,7L7,7z" />
-</vector>
\ No newline at end of file
+</vector>
diff --git a/app/src/main/res/drawable/menu.xml b/app/src/main/res/drawable/menu.xml
new file mode 100644 (file)
index 0000000..67d9f2b
--- /dev/null
@@ -0,0 +1,13 @@
+<!-- This file comes from the Android Material icon set, where it is called `menu_rounded_weight400_grade0_24px`.  It is released under the Apache License 2.0. -->
+
+<vector
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:height="24dp"
+    android:width="24dp"
+    android:viewportHeight="960"
+    android:viewportWidth="960" >
+
+    <path
+        android:fillColor="@color/icon"
+        android:pathData="M160,720Q143,720 131.5,708.5Q120,697 120,680Q120,663 131.5,651.5Q143,640 160,640L800,640Q817,640 828.5,651.5Q840,663 840,680Q840,697 828.5,708.5Q817,720 800,720L160,720ZM160,520Q143,520 131.5,508.5Q120,497 120,480Q120,463 131.5,451.5Q143,440 160,440L800,440Q817,440 828.5,451.5Q840,463 840,480Q840,497 828.5,508.5Q817,520 800,520L160,520ZM160,320Q143,320 131.5,308.5Q120,297 120,280Q120,263 131.5,251.5Q143,240 160,240L800,240Q817,240 828.5,251.5Q840,263 840,280Q840,297 828.5,308.5Q817,320 800,320L160,320Z" />
+</vector>
index a9d6a24ee4628ab0143be239e79cd8db07241b24..84886efb892985f1e11c2c0b69216bb9479b8e92 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 
 <!--
-  Copyright © 2015-2019,2022 Soren Stoutner <soren@stoutner.com>.
+  Copyright 2015-2019,2022-2023 Soren Stoutner <soren@stoutner.com>.
 
   This file is part of Privacy Browser Android <https://www.stoutner.com/privacy-browser-android>.
 
   You should have received a copy of the GNU General Public License
   along with Privacy Browser Android.  If not, see <http://www.gnu.org/licenses/>. -->
 
-<!-- A relative layout is used instead of a linear layout because the app bar does not let `android:layout_weight="1"` cause the URL text bar to fill all the available space.
-    Placing the edit text inside a relative layout also draws a line under the edit text. -->
-<RelativeLayout
+
+<LinearLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools"
+    android:layout_height="wrap_content"
+    android:layout_width="match_parent"
+    android:orientation="horizontal" >
+
+    <ImageView
+        android:layout_height="24dp"
+        android:layout_width="24dp"
+        android:layout_gravity="center_vertical"
+        android:layout_marginEnd="8dp"
+        android:src="@drawable/menu"
+        android:contentDescription="@string/navigation_drawer"
+        android:onClick="openNavigationDrawer" />
+
+    <!-- A relative layout is used instead of a linear layout because the app bar does not let `android:layout_weight="1"` cause the URL text bar to fill all the available space.
+    Placing the edit text inside a relative layout also draws a line under the edit text. -->
+    <RelativeLayout
     android:id="@+id/url_relativelayout"
     android:layout_height="wrap_content"
     android:layout_width="match_parent"
@@ -40,4 +55,5 @@
         android:selectAllOnFocus="true"
         android:autofillHints=""
         tools:ignore="UnusedAttribute" />
-</RelativeLayout>
\ No newline at end of file
+    </RelativeLayout>
+</LinearLayout>