From 85d9d87c19446497e5bf040ccbc7a9db5e4bd191 Mon Sep 17 00:00:00 2001 From: Soren Stoutner <soren@stoutner.com> 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 @@ <body> <h3><a href="https://www.stoutner.com/privacy-browser-android-3-19-2">3.19.2</a> (Code-Version 78)</h3> - <p>10. Januar 2025 - Mindest-API 26, Ziel-API 35</p> + <p><a href="https://gitweb.stoutner.com/?p=PrivacyBrowserAndroid.git;a=commitdiff;h=f8b46833b2246450a0a79067bbb1de044a6f9021;ds=sidebyside">10. Januar 2025</a> - Mindest-API 26, Ziel-API 35</p> <ul> <li><a href="https://redmine.stoutner.com/issues/1257">Layout der Lesezeichen-Leiste</a> unter Android <= 10 (API <= 29) korrigiert.</li> </ul> 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 @@ <body> <h3><a href="https://www.stoutner.com/privacy-browser-android-3-19-2">3.19.2</a> (version code 78)</h3> - <p>10 January 2025 - minimum API 26, target API 35</p> + <p><a href="https://gitweb.stoutner.com/?p=PrivacyBrowserAndroid.git;a=commitdiff;h=f8b46833b2246450a0a79067bbb1de044a6f9021;ds=sidebyside">10 January 2025</a> - minimum API 26, target API 35</p> <ul> <li>Fix the <a href="https://redmine.stoutner.com/issues/1257">layout of the bookmarks drawer</a> on Android <= 10 (API <= 29).</li> </ul> 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 @@ <body> <h3><a href="https://www.stoutner.com/privacy-browser-android-3-19-2">3.19.2</a> (código de versión 78)</h3> - <p>10 de enero de 2025 - API mÃnimo 26, API objetivo 35</p> + <p><a href="https://gitweb.stoutner.com/?p=PrivacyBrowserAndroid.git;a=commitdiff;h=f8b46833b2246450a0a79067bbb1de044a6f9021;ds=sidebyside">10 de enero de 2025</a> - API mÃnimo 26, API objetivo 35</p> <ul> <li>Arreglar el <a href="https://redmine.stoutner.com/issues/1257">diseño del cajón de favoritos</a> en Android <= 10 (API <= 29).</li> </ul> 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 @@ <body> <h3><a href="https://www.stoutner.com/privacy-browser-android-3-19-2">3.19.2</a> (version du code 78)</h3> - <p>10 Janvier 2025 - API minimale : 26, API optimale : 35</p> + <p><a href="https://gitweb.stoutner.com/?p=PrivacyBrowserAndroid.git;a=commitdiff;h=f8b46833b2246450a0a79067bbb1de044a6f9021;ds=sidebyside">10 Janvier 2025</a> - API minimale : 26, API optimale : 35</p> <ul> <li>Fix the <a href="https://redmine.stoutner.com/issues/1257">layout of the bookmarks drawer</a> on Android <= 10 (API <= 29).</li> </ul> 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 @@ <body> <h3><a href="https://www.stoutner.com/privacy-browser-android-3-19-2">3.19.2</a> (versione codice 78)</h3> - <p>10 Gennaio 2025 - minima API 26, target API 35</p> + <p><a href="https://gitweb.stoutner.com/?p=PrivacyBrowserAndroid.git;a=commitdiff;h=f8b46833b2246450a0a79067bbb1de044a6f9021;ds=sidebyside">10 Gennaio 2025</a> - minima API 26, target API 35</p> <ul> <li>Sistemazione del <a href="https://redmine.stoutner.com/issues/1257">layout del cassetto dei segnalibri</a> per Android <= 10 (API <= 29).</li> </ul> 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 @@ <body> <h3><a href="https://www.stoutner.com/privacy-browser-android-3-19-2">3.19.2</a> (código de versão 78)</h3> - <p>10 de janeiro de 2025 - minimum API 26, target API 35</p> + <p><a href="https://gitweb.stoutner.com/?p=PrivacyBrowserAndroid.git;a=commitdiff;h=f8b46833b2246450a0a79067bbb1de044a6f9021;ds=sidebyside">10 de janeiro de 2025</a> - minimum API 26, target API 35</p> <ul> <li>Fix the <a href="https://redmine.stoutner.com/issues/1257">layout of the bookmarks drawer</a> on Android <= 10 (API <= 29).</li> </ul> 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 @@ <body> <h3><a href="https://www.stoutner.com/privacy-browser-android-3-19-2">3.19.2</a> (код веÑÑии 78)</h3> - <p>10 ÑнваÑÑ 2025 года - минималÑнÑй API 26, Ñелевой API 35</p> + <p><a href="https://gitweb.stoutner.com/?p=PrivacyBrowserAndroid.git;a=commitdiff;h=f8b46833b2246450a0a79067bbb1de044a6f9021;ds=sidebyside">10 ÑнваÑÑ 2025 года</a> - минималÑнÑй API 26, Ñелевой API 35</p> <ul> <li>ÐÑпÑавлено <a href="https://redmine.stoutner.com/issues/1257">ÑаÑположение панели закладок</a> на Android <= 10 (API <= 29).</li> </ul> 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 @@ <body> <h3><a href="https://www.stoutner.com/privacy-browser-android-3-19-2">3.19.2</a> (version code 78)</h3> - <p>10 Ocak 2025 - minimum API 26, target API 35</p> + <p><a href="https://gitweb.stoutner.com/?p=PrivacyBrowserAndroid.git;a=commitdiff;h=f8b46833b2246450a0a79067bbb1de044a6f9021;ds=sidebyside">10 Ocak 2025</a> - minimum API 26, target API 35</p> <ul> <li>Fix the <a href="https://redmine.stoutner.com/issues/1257">layout of the bookmarks drawer</a> on Android <= 10 (API <= 29).</li> </ul> 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 @@ <body> <h3><a href="https://www.stoutner.com/privacy-browser-android-3-19-2">3.19.2</a> (version code 78)</h3> - <p>10 January 2025 - æä½æ¯æAPI 26, æé«æ¯æAPI 35</p> + <p><a href="https://gitweb.stoutner.com/?p=PrivacyBrowserAndroid.git;a=commitdiff;h=f8b46833b2246450a0a79067bbb1de044a6f9021;ds=sidebyside">10 January 2025</a> - æä½æ¯æAPI 26, æé«æ¯æAPI 35</p> <ul> <li>Fix the <a href="https://redmine.stoutner.com/issues/1257">layout of the bookmarks drawer</a> on Android <= 10 (API <= 29).</li> </ul> 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