]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/blobdiff - app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java
Fix the app bar and the find on page bar both being displayed on resume. Fixes https...
[PrivacyBrowserAndroid.git] / app / src / main / java / com / stoutner / privacybrowser / activities / MainWebViewActivity.java
index 70f8581d98879d80b760b0eb4ee78f7e020381d8..1a77420d89b673938509a1a75335c53a492498cd 100644 (file)
@@ -221,9 +221,6 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation
     // `translucentNavigationBarOnFullscreen` is used in `onCreate()` and `applyAppSettings()`.
     private boolean translucentNavigationBarOnFullscreen;
 
-    // `proxyThroughOrbot` is used in `onCreate()` and `applyAppSettings()`.
-    private boolean proxyThroughOrbot;
-
     // `currentDomainName` is used in `onCreate(), `onNavigationItemSelected()`, and `applyDomainSettings()`.
     private String currentDomainName;
 
@@ -676,7 +673,7 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation
                 }
 
                 // Update `urlTextBox` and apply domain settings if not waiting on Orbot.
-                if (!waitingForOrbot && !url.startsWith("data:text/html,<html><body><br/><center><h1>")) {  // Sometimes `waitingForOrbot` is reset while the Orbot message `onPageFinished()` is running, causing a race condition.  For this reason we check both.
+                if (!waitingForOrbot) {
                     // Check to see if `WebView` has set `url` to be `about:blank`.
                     if (url.equals("about:blank")) {  // `WebView` is blank, so `formattedUrlString` should be `""` and `urlTextBox` should display a hint.
                         // Set `formattedUrlString` to `""`.
@@ -870,9 +867,6 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation
         // Initialize `webViewTitle`.
         webViewTitle = getString(R.string.no_title);
 
-        // Apply the app settings from the shared preferences.
-        applyAppSettings();
-
         // Initialize `favoriteIconBitmap`.  We have to use `ContextCompat` until API >= 21.
         Drawable favoriteIconDrawable = ContextCompat.getDrawable(getApplicationContext(), R.drawable.world);
         BitmapDrawable favoriteIconBitmapDrawable = (BitmapDrawable) favoriteIconDrawable;
@@ -883,6 +877,9 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation
             favoriteIconBitmap = favoriteIconDefaultBitmap;
         }
 
+        // Apply the app settings from the shared preferences.
+        applyAppSettings();
+
         // Load `formattedUrlString` if we are not waiting for Orbot to connect.
         if (!waitingForOrbot) {
             loadUrl(formattedUrlString);
@@ -990,6 +987,11 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation
 
         // Prepare the font size title and current size menu item.
         switch (fontSize) {
+            case 25:
+                fontSizeTitle = getResources().getString(R.string.font_size) + " - " + getResources().getString(R.string.twenty_five_percent);
+                selectedFontSizeMenuItem = menu.findItem(R.id.fontSizeTwentyFivePercent);
+                break;
+
             case 50:
                 fontSizeTitle = getResources().getString(R.string.font_size) + " - " + getResources().getString(R.string.fifty_percent);
                 selectedFontSizeMenuItem = menu.findItem(R.id.fontSizeFiftyPercent);
@@ -1194,6 +1196,10 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation
                 Snackbar.make(findViewById(R.id.main_webview), R.string.form_data_deleted, Snackbar.LENGTH_SHORT).show();
                 return true;
 
+            case R.id.fontSizeTwentyFivePercent:
+                mainWebView.getSettings().setTextZoom(25);
+                return true;
+
             case R.id.fontSizeFiftyPercent:
                 mainWebView.getSettings().setTextZoom(50);
                 return true;
@@ -1825,7 +1831,7 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation
     }
 
     @Override
-    public void onResume() {
+    public void onResume() {  // `onResume()` also runs every time the app starts after `onCreate()` and `onStart()`.
         super.onResume();
 
         // Resume JavaScript (if enabled).
@@ -2137,7 +2143,7 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation
         adBlockerEnabled = sharedPreferences.getBoolean("block_ads", true);
         incognitoModeEnabled = sharedPreferences.getBoolean("incognito_mode", false);
         boolean doNotTrackEnabled = sharedPreferences.getBoolean("do_not_track", false);
-        proxyThroughOrbot = sharedPreferences.getBoolean("proxy_through_orbot", false);
+        boolean proxyThroughOrbot = sharedPreferences.getBoolean("proxy_through_orbot", false);
         fullScreenBrowsingModeEnabled = sharedPreferences.getBoolean("enable_full_screen_browsing_mode", false);
         hideSystemBarsOnFullscreen = sharedPreferences.getBoolean("hide_system_bars", false);
         translucentNavigationBarOnFullscreen = sharedPreferences.getBoolean("translucent_navigation_bar", true);
@@ -2251,8 +2257,10 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation
             // Reset `inFullScreenBrowsingMode` to `false`.
             inFullScreenBrowsingMode = false;
 
-            // Show the `appBar`.
-            appBar.show();
+            // Show the `appBar` if `findOnPageLinearLayout` is not visible.
+            if (findOnPageLinearLayout.getVisibility() == View.GONE) {
+                appBar.show();
+            }
 
             // Show the `BannerAd` in the free flavor.
             if (BuildConfig.FLAVOR.contentEquals("free")) {