From 85d9d87c19446497e5bf040ccbc7a9db5e4bd191 Mon Sep 17 00:00:00 2001 From: Soren Stoutner Date: Tue, 21 Jan 2025 09:48:07 -0700 Subject: [PATCH] Fix navigation drawer scroll position on API < 35. https://redmine.stoutner.com/issues/1263 --- app/src/main/assets/de/about_changelog.html | 2 +- app/src/main/assets/en/about_changelog.html | 2 +- app/src/main/assets/es/about_changelog.html | 2 +- app/src/main/assets/fr/about_changelog.html | 2 +- app/src/main/assets/it/about_changelog.html | 2 +- .../main/assets/pt-rBR/about_changelog.html | 2 +- app/src/main/assets/ru/about_changelog.html | 2 +- app/src/main/assets/tr/about_changelog.html | 2 +- .../main/assets/zh-rCN/about_changelog.html | 2 +- .../activities/MainWebViewActivity.kt | 41 ++++++++++++------- 10 files changed, 36 insertions(+), 23 deletions(-) diff --git a/app/src/main/assets/de/about_changelog.html b/app/src/main/assets/de/about_changelog.html index 9bbd3cf5..83488b3f 100644 --- a/app/src/main/assets/de/about_changelog.html +++ b/app/src/main/assets/de/about_changelog.html @@ -34,7 +34,7 @@

3.19.2 (Code-Version 78)

-

10. Januar 2025 - Mindest-API 26, Ziel-API 35

+

10. Januar 2025 - Mindest-API 26, Ziel-API 35

diff --git a/app/src/main/assets/en/about_changelog.html b/app/src/main/assets/en/about_changelog.html index a95e6a93..940d8e08 100644 --- a/app/src/main/assets/en/about_changelog.html +++ b/app/src/main/assets/en/about_changelog.html @@ -30,7 +30,7 @@

3.19.2 (version code 78)

-

10 January 2025 - minimum API 26, target API 35

+

10 January 2025 - minimum API 26, target API 35

diff --git a/app/src/main/assets/es/about_changelog.html b/app/src/main/assets/es/about_changelog.html index eaa88ced..c04eabdb 100644 --- a/app/src/main/assets/es/about_changelog.html +++ b/app/src/main/assets/es/about_changelog.html @@ -32,7 +32,7 @@

3.19.2 (código de versión 78)

-

10 de enero de 2025 - API mínimo 26, API objetivo 35

+

10 de enero de 2025 - API mínimo 26, API objetivo 35

diff --git a/app/src/main/assets/fr/about_changelog.html b/app/src/main/assets/fr/about_changelog.html index b6c30fe3..46ecdbfb 100644 --- a/app/src/main/assets/fr/about_changelog.html +++ b/app/src/main/assets/fr/about_changelog.html @@ -32,7 +32,7 @@

3.19.2 (version du code 78)

-

10 Janvier 2025 - API minimale : 26, API optimale : 35

+

10 Janvier 2025 - API minimale : 26, API optimale : 35

diff --git a/app/src/main/assets/it/about_changelog.html b/app/src/main/assets/it/about_changelog.html index dddc089b..d0f24cf0 100644 --- a/app/src/main/assets/it/about_changelog.html +++ b/app/src/main/assets/it/about_changelog.html @@ -32,7 +32,7 @@

3.19.2 (versione codice 78)

-

10 Gennaio 2025 - minima API 26, target API 35

+

10 Gennaio 2025 - minima API 26, target API 35

diff --git a/app/src/main/assets/pt-rBR/about_changelog.html b/app/src/main/assets/pt-rBR/about_changelog.html index d4417d29..fec05ae1 100644 --- a/app/src/main/assets/pt-rBR/about_changelog.html +++ b/app/src/main/assets/pt-rBR/about_changelog.html @@ -32,7 +32,7 @@

3.19.2 (código de versão 78)

-

10 de janeiro de 2025 - minimum API 26, target API 35

+

10 de janeiro de 2025 - minimum API 26, target API 35

diff --git a/app/src/main/assets/ru/about_changelog.html b/app/src/main/assets/ru/about_changelog.html index 92395a1c..968c1db5 100644 --- a/app/src/main/assets/ru/about_changelog.html +++ b/app/src/main/assets/ru/about_changelog.html @@ -30,7 +30,7 @@

3.19.2 (код версии 78)

-

10 января 2025 года - минимальный API 26, целевой API 35

+

10 января 2025 года - минимальный API 26, целевой API 35

diff --git a/app/src/main/assets/tr/about_changelog.html b/app/src/main/assets/tr/about_changelog.html index d8c8ad7b..cd69fe91 100644 --- a/app/src/main/assets/tr/about_changelog.html +++ b/app/src/main/assets/tr/about_changelog.html @@ -30,7 +30,7 @@

3.19.2 (version code 78)

-

10 Ocak 2025 - minimum API 26, target API 35

+

10 Ocak 2025 - minimum API 26, target API 35

diff --git a/app/src/main/assets/zh-rCN/about_changelog.html b/app/src/main/assets/zh-rCN/about_changelog.html index 45612c88..f993affb 100644 --- a/app/src/main/assets/zh-rCN/about_changelog.html +++ b/app/src/main/assets/zh-rCN/about_changelog.html @@ -32,7 +32,7 @@

3.19.2 (version code 78)

-

10 January 2025 - 最低支持API 26, 最高支持API 35

+

10 January 2025 - 最低支持API 26, 最高支持API 35

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 230d5081..6a725efc 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.kt +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.kt @@ -4676,6 +4676,33 @@ class MainWebViewActivity : AppCompatActivity(), CreateBookmarkDialog.CreateBook override fun onDrawerStateChanged(newState: Int) { if (newState == DrawerLayout.STATE_SETTLING || newState == DrawerLayout.STATE_DRAGGING) { // A drawer is opening or closing. + // Adjust the scroll position of the navigation drawer. + if (bottomAppBar && navigationDrawerFirstView) { // The bottom app bar is in use. + // Reset the navigation drawer first view flag. + navigationDrawerFirstView = false + + // Get a handle for the navigation recycler view. + val navigationRecyclerView = navigationView.getChildAt(0) as RecyclerView + + // Get the navigation linear layout manager. + val navigationLinearLayoutManager = navigationRecyclerView.layoutManager as LinearLayoutManager + + // Scroll the navigation drawer to the bottom. + navigationLinearLayoutManager.scrollToPositionWithOffset(14, 0) + } else if (Build.VERSION.SDK_INT < 35 && navigationDrawerFirstView) { // The top app bar is in use and the API < 35 (which causes the drawer to scroll down for some reason). + // Reset the navigation drawer first view flag. + navigationDrawerFirstView = false + + // Get a handle for the navigation recycler view. + val navigationRecyclerView = navigationView.getChildAt(0) as RecyclerView + + // Get the navigation linear layout manager. + val navigationLinearLayoutManager = navigationRecyclerView.layoutManager as LinearLayoutManager + + // Scroll the navigation drawer to the top. < + navigationLinearLayoutManager.scrollToPositionWithOffset(0, 0) + } + // Update the navigation menu items if the WebView is not null. if (currentWebView != null) { // Set the enabled status of the menu items. @@ -4712,20 +4739,6 @@ class MainWebViewActivity : AppCompatActivity(), CreateBookmarkDialog.CreateBook // Clear the focus from from the WebView if it is not null, which can happen if a user opens a drawer while the browser is being resumed. // Clearing the focus from the WebView removes any text selection markers and context menus, which otherwise draw above the open drawers. currentWebView?.clearFocus() - - if (bottomAppBar && navigationDrawerFirstView) { - // Reset the navigation drawer first view flag. - navigationDrawerFirstView = false - - // Get a handle for the navigation recycler view. - val navigationRecyclerView = navigationView.getChildAt(0) as RecyclerView - - // Get the navigation linear layout manager. - val navigationLinearLayoutManager = navigationRecyclerView.layoutManager as LinearLayoutManager - - // Scroll the navigation drawer to the bottom. - navigationLinearLayoutManager.scrollToPositionWithOffset(13, 0) - } } } }) -- 2.47.2