From 6b662fcb3e0c8dfbdc212e55d10ad291ec569280 Mon Sep 17 00:00:00 2001 From: Soren Stoutner Date: Thu, 28 Dec 2023 17:02:20 -0700 Subject: [PATCH] Reimplement ActionBarDrawerToggle to get rid of the wasted padding. https://redmine.stoutner.com/issues/1074 --- app/src/main/assets/de/about_licenses.html | 1 + app/src/main/assets/en/about_licenses.html | 1 + app/src/main/assets/es/about_licenses.html | 1 + app/src/main/assets/fr/about_licenses.html | 1 + app/src/main/assets/it/about_licenses.html | 1 + .../main/assets/pt-rBR/about_licenses.html | 1 + app/src/main/assets/ru/about_licenses.html | 1 + .../menu_rounded_weight400_grade0_24px.svg | 30 +++++++++++++++++++ app/src/main/assets/tr/about_licenses.html | 1 + .../main/assets/zh-rCN/about_licenses.html | 1 + .../activities/MainWebViewActivity.kt | 24 ++++----------- app/src/main/res/drawable/history.xml | 2 +- app/src/main/res/drawable/menu.xml | 13 ++++++++ app/src/main/res/layout/url_app_bar.xml | 26 ++++++++++++---- 14 files changed, 80 insertions(+), 24 deletions(-) create mode 100644 app/src/main/assets/shared_images/menu_rounded_weight400_grade0_24px.svg create mode 100644 app/src/main/res/drawable/menu.xml diff --git a/app/src/main/assets/de/about_licenses.html b/app/src/main/assets/de/about_licenses.html index 933dce14..3af3b7d8 100644 --- a/app/src/main/assets/de/about_licenses.html +++ b/app/src/main/assets/de/about_licenses.html @@ -146,6 +146,7 @@

location_off.

lock.

map.

+

menu_rounded_weight400_grade0_24px.

more.

new_releases.

open_in_browser.

diff --git a/app/src/main/assets/en/about_licenses.html b/app/src/main/assets/en/about_licenses.html index a21861d1..437ae6b4 100644 --- a/app/src/main/assets/en/about_licenses.html +++ b/app/src/main/assets/en/about_licenses.html @@ -142,6 +142,7 @@

location_off.

lock.

map.

+

menu_rounded_weight400_grade0_24px.

more.

new_releases.

open_in_browser.

diff --git a/app/src/main/assets/es/about_licenses.html b/app/src/main/assets/es/about_licenses.html index caf64bb9..a88798fe 100644 --- a/app/src/main/assets/es/about_licenses.html +++ b/app/src/main/assets/es/about_licenses.html @@ -146,6 +146,7 @@

location_off.

lock.

map.

+

menu_rounded_weight400_grade0_24px.

more.

new_releases.

open_in_browser.

diff --git a/app/src/main/assets/fr/about_licenses.html b/app/src/main/assets/fr/about_licenses.html index ec49f4fe..fc2d04cf 100644 --- a/app/src/main/assets/fr/about_licenses.html +++ b/app/src/main/assets/fr/about_licenses.html @@ -148,6 +148,7 @@

location_off.

lock.

map.

+

menu_rounded_weight400_grade0_24px.

more.

new_releases.

open_in_browser.

diff --git a/app/src/main/assets/it/about_licenses.html b/app/src/main/assets/it/about_licenses.html index 11ba61b6..466a4f66 100644 --- a/app/src/main/assets/it/about_licenses.html +++ b/app/src/main/assets/it/about_licenses.html @@ -150,6 +150,7 @@

location_off.

lock.

map.

+

menu_rounded_weight400_grade0_24px.

more.

new_releases.

open_in_browser.

diff --git a/app/src/main/assets/pt-rBR/about_licenses.html b/app/src/main/assets/pt-rBR/about_licenses.html index b1e10d51..bbc93151 100644 --- a/app/src/main/assets/pt-rBR/about_licenses.html +++ b/app/src/main/assets/pt-rBR/about_licenses.html @@ -144,6 +144,7 @@

location_off.

lock.

map.

+

menu_rounded_weight400_grade0_24px.

more.

new_releases.

open_in_browser.

diff --git a/app/src/main/assets/ru/about_licenses.html b/app/src/main/assets/ru/about_licenses.html index a536b0d0..b2d58794 100644 --- a/app/src/main/assets/ru/about_licenses.html +++ b/app/src/main/assets/ru/about_licenses.html @@ -142,6 +142,7 @@

location_off.

lock.

map.

+

menu_rounded_weight400_grade0_24px.

more.

new_releases.

open_in_browser.

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 index 00000000..044514eb --- /dev/null +++ b/app/src/main/assets/shared_images/menu_rounded_weight400_grade0_24px.svg @@ -0,0 +1,30 @@ + + + + + + + + diff --git a/app/src/main/assets/tr/about_licenses.html b/app/src/main/assets/tr/about_licenses.html index 25f12863..509e3567 100644 --- a/app/src/main/assets/tr/about_licenses.html +++ b/app/src/main/assets/tr/about_licenses.html @@ -143,6 +143,7 @@

location_off.

lock.

map.

+

menu_rounded_weight400_grade0_24px.

more.

new_releases.

open_in_browser.

diff --git a/app/src/main/assets/zh-rCN/about_licenses.html b/app/src/main/assets/zh-rCN/about_licenses.html index 8137f332..99ca707f 100644 --- a/app/src/main/assets/zh-rCN/about_licenses.html +++ b/app/src/main/assets/zh-rCN/about_licenses.html @@ -143,6 +143,7 @@

location_off.

lock.

map.

+

menu_rounded_weight400_grade0_24px.

more.

new_releases.

open_in_browser.

diff --git a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.kt b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.kt index 50e08d0d..3e6acce2 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.kt +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.kt @@ -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 // 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`. diff --git a/app/src/main/res/drawable/history.xml b/app/src/main/res/drawable/history.xml index 1d4d07c8..8acda0ea 100644 --- a/app/src/main/res/drawable/history.xml +++ b/app/src/main/res/drawable/history.xml @@ -11,4 +11,4 @@ - \ No newline at end of file + diff --git a/app/src/main/res/drawable/menu.xml b/app/src/main/res/drawable/menu.xml new file mode 100644 index 00000000..67d9f2b8 --- /dev/null +++ b/app/src/main/res/drawable/menu.xml @@ -0,0 +1,13 @@ + + + + + + diff --git a/app/src/main/res/layout/url_app_bar.xml b/app/src/main/res/layout/url_app_bar.xml index a9d6a24e..84886efb 100644 --- a/app/src/main/res/layout/url_app_bar.xml +++ b/app/src/main/res/layout/url_app_bar.xml @@ -1,7 +1,7 @@ - - + + + + + - \ No newline at end of file + + -- 2.45.2