From 5af263278d6c5388aaaf4ece6f16bc05cd90225f Mon Sep 17 00:00:00 2001 From: Soren Stoutner Date: Thu, 26 Nov 2020 23:00:22 -0700 Subject: [PATCH] Fix a rare crash on resource requests. https://redmine.stoutner.com/issues/645 --- app/src/main/assets/de/about_changelog.html | 4 +-- app/src/main/assets/en/about_changelog.html | 4 +-- app/src/main/assets/es/about_changelog.html | 4 +-- app/src/main/assets/fr/about_changelog.html | 4 +-- app/src/main/assets/it/about_changelog.html | 4 +-- .../main/assets/pt-rBR/about_changelog.html | 4 +-- app/src/main/assets/ru/about_changelog.html | 4 +-- app/src/main/assets/tr/about_changelog.html | 4 +-- .../activities/MainWebViewActivity.java | 29 ++++++++++--------- 9 files changed, 31 insertions(+), 30 deletions(-) diff --git a/app/src/main/assets/de/about_changelog.html b/app/src/main/assets/de/about_changelog.html index d69dadf6..8202e0db 100644 --- a/app/src/main/assets/de/about_changelog.html +++ b/app/src/main/assets/de/about_changelog.html @@ -33,8 +33,8 @@ -

3.6.1 (version code 53)

-

26. November 2020 - Mindest-API 19, Ziel-API 29

+

3.6.1 (version code 53)

+

26. November 2020 - Mindest-API 19, Ziel-API 29

diff --git a/app/src/main/assets/en/about_changelog.html b/app/src/main/assets/en/about_changelog.html index 8437b690..b4c00294 100644 --- a/app/src/main/assets/en/about_changelog.html +++ b/app/src/main/assets/en/about_changelog.html @@ -27,8 +27,8 @@ -

3.6.1 (version code 53)

-

26 November 2020 - minimum API 19, target API 29

+

3.6.1 (version code 53)

+

26 November 2020 - minimum API 19, target API 29

diff --git a/app/src/main/assets/es/about_changelog.html b/app/src/main/assets/es/about_changelog.html index 4713b1df..3a89f0f9 100644 --- a/app/src/main/assets/es/about_changelog.html +++ b/app/src/main/assets/es/about_changelog.html @@ -29,8 +29,8 @@ -

3.6.1 (código de versión 53)

-

26 de noviembre de 2020 - API mínimo 19, API dirigido 29

+

3.6.1 (código de versión 53)

+

26 de noviembre de 2020 - API mínimo 19, API dirigido 29

diff --git a/app/src/main/assets/fr/about_changelog.html b/app/src/main/assets/fr/about_changelog.html index 497fc4b3..079df41d 100644 --- a/app/src/main/assets/fr/about_changelog.html +++ b/app/src/main/assets/fr/about_changelog.html @@ -29,8 +29,8 @@ -

3.6.1 (version code 53)

-

26 Novembre 2020 - API minimale : 19, API optimale : 29

+

3.6.1 (version code 53)

+

26 Novembre 2020 - API minimale : 19, API optimale : 29

diff --git a/app/src/main/assets/it/about_changelog.html b/app/src/main/assets/it/about_changelog.html index dd342f79..8cb5a9c7 100644 --- a/app/src/main/assets/it/about_changelog.html +++ b/app/src/main/assets/it/about_changelog.html @@ -29,8 +29,8 @@ -

3.6.1 (versione codice 53)

-

26 Novembre 2020 - minima API 19, target API 29

+

3.6.1 (versione codice 53)

+

26 Novembre 2020 - minima API 19, target API 29

diff --git a/app/src/main/assets/pt-rBR/about_changelog.html b/app/src/main/assets/pt-rBR/about_changelog.html index 55cfd33e..445b49f2 100644 --- a/app/src/main/assets/pt-rBR/about_changelog.html +++ b/app/src/main/assets/pt-rBR/about_changelog.html @@ -29,8 +29,8 @@ -

3.6.1 (código da versão 53)

-

26 November 2020 - minimum API 19, target API 29

+

3.6.1 (código da versão 53)

+

26 November 2020 - minimum API 19, target API 29

diff --git a/app/src/main/assets/ru/about_changelog.html b/app/src/main/assets/ru/about_changelog.html index 12988601..37a171f7 100644 --- a/app/src/main/assets/ru/about_changelog.html +++ b/app/src/main/assets/ru/about_changelog.html @@ -27,8 +27,8 @@ -

3.6.1 (код версии 53)

-

26 Ноябрь 2020 года - минимальный API 19, целевой API 29

+

3.6.1 (код версии 53)

+

26 Ноябрь 2020 года - минимальный API 19, целевой API 29

diff --git a/app/src/main/assets/tr/about_changelog.html b/app/src/main/assets/tr/about_changelog.html index 4c47728b..b7eab553 100644 --- a/app/src/main/assets/tr/about_changelog.html +++ b/app/src/main/assets/tr/about_changelog.html @@ -27,8 +27,8 @@ -

3.6.1 (version code 53)

-

26 November 2020 - minimum API 19, target API 29

+

3.6.1 (version code 53)

+

26 November 2020 - minimum API 19, target API 29

diff --git a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java index 1595f4a3..9d001fe0 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java @@ -332,6 +332,13 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook private TabLayout tabLayout; private SwipeRefreshLayout swipeRefreshLayout; private ViewPager webViewPager; + private NavigationView navigationView; + + // Declare the class menus. + private Menu navigationMenu; + + // Declare the class menu items. + private MenuItem navigationRequestsMenuItem; @Override // Remove the warning about needing to override `performClick()` when using an `OnTouchListener` with `WebView`. @@ -404,6 +411,13 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook tabLayout = findViewById(R.id.tablayout); swipeRefreshLayout = findViewById(R.id.swiperefreshlayout); webViewPager = findViewById(R.id.webviewpager); + navigationView = findViewById(R.id.navigationview); + + // Get handles for the class menus. + navigationMenu = navigationView.getMenu(); + + // Get a handle for the navigation requests menu item. + navigationRequestsMenuItem = navigationMenu.findItem(R.id.requests); // Get a handle for the app compat delegate. AppCompatDelegate appCompatDelegate = getDelegate(); @@ -3250,8 +3264,6 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook this.registerReceiver(orbotStatusBroadcastReceiver, new IntentFilter("org.torproject.android.intent.action.STATUS")); // Get handles for views that need to be modified. - NavigationView navigationView = findViewById(R.id.navigationview); - SwipeRefreshLayout swipeRefreshLayout = findViewById(R.id.swiperefreshlayout); ListView bookmarksListView = findViewById(R.id.bookmarks_drawer_listview); FloatingActionButton launchBookmarksActivityFab = findViewById(R.id.launch_bookmarks_activity_fab); FloatingActionButton createBookmarkFolderFab = findViewById(R.id.create_bookmark_folder_fab); @@ -3261,12 +3273,10 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook // Listen for touches on the navigation menu. navigationView.setNavigationItemSelectedListener(this); - // Get handles for the navigation menu and the back and forward menu items. - Menu navigationMenu = navigationView.getMenu(); + // Get handles for the navigation menu items. MenuItem navigationBackMenuItem = navigationMenu.findItem(R.id.back); MenuItem navigationForwardMenuItem = navigationMenu.findItem(R.id.forward); MenuItem navigationHistoryMenuItem = navigationMenu.findItem(R.id.history); - MenuItem navigationRequestsMenuItem = navigationMenu.findItem(R.id.requests); // Update the web view pager every time a tab is modified. webViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { @@ -5789,15 +5799,6 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook // Sanitize the URL. url = sanitizeUrl(url); - // Get a handle for the navigation view. - NavigationView navigationView = findViewById(R.id.navigationview); - - // Get a handle for the navigation menu. - Menu navigationMenu = navigationView.getMenu(); - - // Get a handle for the navigation requests menu item. - MenuItem navigationRequestsMenuItem = navigationMenu.findItem(R.id.requests); - // Create an empty web resource response to be used if the resource request is blocked. WebResourceResponse emptyWebResourceResponse = new WebResourceResponse("text/plain", "utf8", new ByteArrayInputStream("".getBytes())); -- 2.45.2