]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/commitdiff
Fix custom headers not being loaded for links initialed from the WebView. https...
authorSoren Stoutner <soren@stoutner.com>
Sat, 20 Jun 2020 19:24:47 +0000 (12:24 -0700)
committerSoren Stoutner <soren@stoutner.com>
Sat, 20 Jun 2020 19:24:47 +0000 (12:24 -0700)
27 files changed:
app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java
app/src/main/java/com/stoutner/privacybrowser/fragments/DomainSettingsFragment.java
app/src/main/java/com/stoutner/privacybrowser/fragments/SettingsFragment.java
app/src/main/res/drawable/night_mode_disabled_day.xml [deleted file]
app/src/main/res/drawable/night_mode_disabled_night.xml [deleted file]
app/src/main/res/drawable/night_mode_enabled_day.xml [deleted file]
app/src/main/res/drawable/night_mode_enabled_night.xml [deleted file]
app/src/main/res/drawable/webview_theme_disabled_day.xml [new file with mode: 0644]
app/src/main/res/drawable/webview_theme_disabled_night.xml [new file with mode: 0644]
app/src/main/res/drawable/webview_theme_enabled_day.xml [new file with mode: 0644]
app/src/main/res/drawable/webview_theme_enabled_night.xml [new file with mode: 0644]
app/src/main/res/layout/domain_settings_fragment.xml
app/src/main/res/values-de/strings.xml
app/src/main/res/values-es/strings.xml
app/src/main/res/values-fr/strings.xml
app/src/main/res/values-it/strings.xml
app/src/main/res/values-night-v23/styles.xml
app/src/main/res/values-night-v27/styles.xml
app/src/main/res/values-night/styles.xml
app/src/main/res/values-ru/strings.xml
app/src/main/res/values-tr/strings.xml
app/src/main/res/values-v23/styles.xml
app/src/main/res/values-v27/styles.xml
app/src/main/res/values/attrs.xml
app/src/main/res/values/strings.xml
app/src/main/res/values/styles.xml
app/src/main/res/xml/preferences.xml

index 89a73f25608c99c1254ccc32cff939477fe40e8e..be28dd88489c516c2d48549f37f7db1b7d07b011 100644 (file)
@@ -107,6 +107,8 @@ import androidx.drawerlayout.widget.DrawerLayout;
 import androidx.fragment.app.DialogFragment;
 import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
 import androidx.viewpager.widget.ViewPager;
+import androidx.webkit.WebSettingsCompat;
+import androidx.webkit.WebViewFeature;
 
 import com.google.android.material.appbar.AppBarLayout;
 import com.google.android.material.floatingactionbutton.FloatingActionButton;
@@ -3732,10 +3734,7 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
 
     // `reloadWebsite` is used if returning from the Domains activity.  Otherwise JavaScript might not function correctly if it is newly enabled.
     @SuppressLint("SetJavaScriptEnabled")
-    private boolean applyDomainSettings(NestedScrollWebView nestedScrollWebView, String url, boolean resetTab, boolean reloadWebsite) {
-        // Store a copy of the current user agent to track changes for the return boolean.
-        String initialUserAgent = nestedScrollWebView.getSettings().getUserAgentString();
-
+    private void applyDomainSettings(NestedScrollWebView nestedScrollWebView, String url, boolean resetTab, boolean reloadWebsite) {
         // Store the current URL.
         nestedScrollWebView.setCurrentUrl(url);
 
@@ -4223,9 +4222,6 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
         if (reloadWebsite) {
             nestedScrollWebView.reload();
         }
-
-        // Return the user agent changed status.
-        return !nestedScrollWebView.getSettings().getUserAgentString().equals(initialUserAgent);
     }
 
     private void applyProxy(boolean reloadWebViews) {
@@ -5238,6 +5234,11 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
             });
         }
 
+        // TODO.
+        if (WebViewFeature.isFeatureSupported(WebViewFeature.FORCE_DARK)) {
+            WebSettingsCompat.setForceDark(nestedScrollWebView.getSettings(), WebSettingsCompat.FORCE_DARK_AUTO);
+        }
+
         // Set the web chrome client.
         nestedScrollWebView.setWebChromeClient(new WebChromeClient() {
             // Update the progress bar when a page is loading.
@@ -5491,28 +5492,24 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
         });
 
         nestedScrollWebView.setWebViewClient(new WebViewClient() {
-            // `shouldOverrideUrlLoading` makes this `WebView` the default handler for URLs inside the app, so that links are not kicked out to other apps.
+            // `shouldOverrideUrlLoading` makes this WebView the default handler for URLs inside the app, so that links are not kicked out to other apps.
             // The deprecated `shouldOverrideUrlLoading` must be used until API >= 24.
             @Override
             public boolean shouldOverrideUrlLoading(WebView view, String url) {
                 // Sanitize the url.
                 url = sanitizeUrl(url);
 
+                // Handle the URL according to the type.
                 if (url.startsWith("http")) {  // Load the URL in Privacy Browser.
                     // Apply the domain settings for the new URL.  This doesn't do anything if the domain has not changed.
-                    boolean userAgentChanged = applyDomainSettings(nestedScrollWebView, url, true, false);
+                    applyDomainSettings(nestedScrollWebView, url, true, false);
 
-                    // Check if the user agent has changed.
-                    if (userAgentChanged) {
-                        // Manually load the URL.  The changing of the user agent will cause WebView to reload the previous URL.
-                        nestedScrollWebView.loadUrl(url, customHeaders);
+                    // Manually load the URL.  The changing of the user agent will cause WebView to reload the previous URL.
+                    nestedScrollWebView.loadUrl(url, customHeaders);
 
-                        // Returning true indicates that Privacy Browser is manually handling the loading of the URL.
-                        return true;
-                    } else {
-                        // Returning false causes the current WebView to handle the URL and prevents it from adding redirects to the history list.
-                        return false;
-                    }
+                    // Returning true indicates that Privacy Browser is manually handling the loading of the URL.
+                    // Custom headers cannot be added if false is returned and the WebView handles the loading of the URL.
+                    return true;
                 } else if (url.startsWith("mailto:")) {  // Load the email address in an external email program.
                     // Use `ACTION_SENDTO` instead of `ACTION_SEND` so that only email programs are launched.
                     Intent emailIntent = new Intent(Intent.ACTION_SENDTO);
index 006fa2163c1dbbd719f69f38afe47a2a87ceccdc..10fb6637197cffb8c3821db0ddf575f32a2db622 100644 (file)
@@ -580,10 +580,12 @@ public class DomainSettingsFragment extends Fragment {
 
         // Only enable Fanboy's Social Blocking List if Fanboy's Annoyance List is off.
         if (fanboysAnnoyanceListInt == 0) {  // Fanboy's Annoyance List is on.
+            // Enable Fanboy's Social Blocking List switch.
+            fanboysSocialBlockingListSwitch.setEnabled(true);
+
             // Enable Fanboy's Social Blocking List.  Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons.
             if (fanboysSocialBlockingListInt == 1) {  // Fanboy's Social Blocking List is on.
-                // Enable the switch and turn it on.
-                fanboysSocialBlockingListSwitch.setEnabled(true);
+                // Turn on Fanboy's Social Blocking List switch.
                 fanboysSocialBlockingListSwitch.setChecked(true);
 
                 // Set the icon according to the theme.
@@ -593,8 +595,7 @@ public class DomainSettingsFragment extends Fragment {
                     fanboysSocialBlockingListImageView.setImageDrawable(resources.getDrawable(R.drawable.social_media_enabled_day));
                 }
             } else {  // Fanboy's Social Blocking List is off.
-                // Enable the switch but turn it off.
-                fanboysSocialBlockingListSwitch.setEnabled(true);
+                // Turn off Fanboy's Social Blocking List switch.
                 fanboysSocialBlockingListSwitch.setChecked(false);
 
                 // Set the icon according to the theme.
@@ -605,14 +606,15 @@ public class DomainSettingsFragment extends Fragment {
                 }
             }
         } else {  // Fanboy's Annoyance List is on.
-            // Disable Fanboy's Social Blocking List.  Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons.
+            // Disable Fanboy's Social Blocking List switch.
+            fanboysSocialBlockingListSwitch.setEnabled(false);
+
+            // Handle the status of Fanboy's Social Blocking List.  Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons.
             if (fanboysSocialBlockingListInt == 1) {  // Fanboy's Social Blocking List is on.
-                // Disable the switch but turn it on.
-                fanboysSocialBlockingListSwitch.setEnabled(false);
+                // Turn on Fanboy's Social Blocking List switch.
                 fanboysSocialBlockingListSwitch.setChecked(true);
             } else {  // Fanboy's Social Blocking List is off.
-                // Disable the switch and turn it off.
-                fanboysSocialBlockingListSwitch.setEnabled(false);
+                // Turn off Fanboy's Social Blocking List switch.
                 fanboysSocialBlockingListSwitch.setChecked(false);
             }
 
@@ -886,16 +888,16 @@ public class DomainSettingsFragment extends Fragment {
                 if (defaultNightMode) {  // Night mode enabled by default.
                     // Set the icon according to the theme.
                     if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                        nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.night_mode_enabled_night));
+                        nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_theme_enabled_night));
                     } else {
-                        nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.night_mode_enabled_day));
+                        nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_theme_enabled_day));
                     }
                 } else {  // Night mode disabled by default.
                     // Set the icon according to the theme.
                     if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                        nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.night_mode_disabled_night));
+                        nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_theme_disabled_night));
                     } else {
-                        nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.night_mode_disabled_day));
+                        nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_theme_disabled_day));
                     }
                 }
 
@@ -906,9 +908,9 @@ public class DomainSettingsFragment extends Fragment {
             case DomainsDatabaseHelper.ENABLED:
                 // Set the icon according to the theme.
                 if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                    nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.night_mode_enabled_night));
+                    nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_theme_enabled_night));
                 } else {
-                    nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.night_mode_enabled_day));
+                    nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_theme_enabled_day));
                 }
 
                 // Hide the night mode TextView.
@@ -918,9 +920,9 @@ public class DomainSettingsFragment extends Fragment {
             case DomainsDatabaseHelper.DISABLED:
                 // Set the icon according to the theme.
                 if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                    nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.night_mode_disabled_night));
+                    nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_theme_disabled_night));
                 } else {
-                    nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.night_mode_disabled_day));
+                    nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_theme_disabled_day));
                 }
 
                 // Hide the night mode TextView.
@@ -1779,16 +1781,16 @@ public class DomainSettingsFragment extends Fragment {
                         if (defaultNightMode) {  // Night mode enabled by default.
                             // Set the icon according to the theme.
                             if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                                nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.night_mode_enabled_night));
+                                nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_theme_enabled_night));
                             } else {
-                                nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.night_mode_enabled_day));
+                                nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_theme_enabled_day));
                             }
                         } else {  // Night mode disabled by default.
                             // Set the icon according to the theme.
                             if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                                nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.night_mode_disabled_night));
+                                nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_theme_disabled_night));
                             } else {
-                                nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.night_mode_disabled_day));
+                                nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_theme_disabled_day));
                             }
                         }
 
@@ -1799,9 +1801,9 @@ public class DomainSettingsFragment extends Fragment {
                     case DomainsDatabaseHelper.ENABLED:
                         // Set the icon according to the theme.
                         if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                            nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.night_mode_enabled_night));
+                            nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_theme_enabled_night));
                         } else {
-                            nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.night_mode_enabled_day));
+                            nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_theme_enabled_day));
                         }
 
                         // Hide `nightModeTextView`.
@@ -1811,9 +1813,9 @@ public class DomainSettingsFragment extends Fragment {
                     case DomainsDatabaseHelper.DISABLED:
                         // Set the icon according to the theme.
                         if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                            nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.night_mode_disabled_night));
+                            nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_theme_disabled_night));
                         } else {
-                            nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.night_mode_disabled_day));
+                            nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_theme_disabled_day));
                         }
 
                         // Hide `nightModeTextView`.
index 75f9b31d903b0f0058dbd539f91d0d4796150bb4..6130ece8584ff3f44ab1571354058c55df0c302a 100644 (file)
@@ -112,7 +112,7 @@ public class SettingsFragment extends PreferenceFragmentCompat {
         Preference scrollAppBarPreference = findPreference("scroll_app_bar");
         Preference displayAdditionalAppBarIconsPreference = findPreference("display_additional_app_bar_icons");
         Preference appThemePreference = findPreference("app_theme");
-        Preference nightModePreference = findPreference("night_mode");
+        Preference webViewThemePreference = findPreference("webview_theme");
         Preference wideViewportPreference = findPreference("wide_viewport");
         Preference displayWebpageImagesPreference = findPreference("display_webpage_images");
 
@@ -157,12 +157,13 @@ public class SettingsFragment extends PreferenceFragmentCompat {
         assert scrollAppBarPreference != null;
         assert displayAdditionalAppBarIconsPreference != null;
         assert appThemePreference != null;
-        assert nightModePreference != null;
+        assert webViewThemePreference != null;
         assert wideViewportPreference != null;
         assert displayWebpageImagesPreference != null;
 
-        // Set the hide app bar preference dependency.
+        // Set the preference dependencies.
         hideAppBarPreference.setDependency("full_screen_browsing_mode");
+        domStoragePreference.setDependency("javascript");
 
         // Get strings from the preferences.
         String userAgentName = savedPreferences.getString("user_agent", getString(R.string.user_agent_default_value));
@@ -173,26 +174,21 @@ public class SettingsFragment extends PreferenceFragmentCompat {
         // Get booleans that are used in multiple places from the preferences.
         boolean javaScriptEnabled = savedPreferences.getBoolean("javascript", false);
         boolean firstPartyCookiesEnabled = savedPreferences.getBoolean("first_party_cookies", false);
-        boolean thirdPartyCookiesEnabled = savedPreferences.getBoolean("third_party_cookies", false);
         boolean fanboyAnnoyanceListEnabled = savedPreferences.getBoolean("fanboys_annoyance_list", true);
         boolean fanboySocialBlockingEnabled = savedPreferences.getBoolean("fanboys_social_blocking_list", true);
         boolean fullScreenBrowsingMode = savedPreferences.getBoolean("full_screen_browsing_mode", false);
         boolean clearEverything = savedPreferences.getBoolean("clear_everything", true);
-        boolean nightMode = savedPreferences.getBoolean("night_mode", false);
 
         // Only enable the third-party cookies preference if first-party cookies are enabled and API >= 21.
         thirdPartyCookiesPreference.setEnabled(firstPartyCookiesEnabled && (Build.VERSION.SDK_INT >= 21));
 
-        // Only enable the DOM storage preference if either JavaScript or Night Mode is enabled.
-        domStoragePreference.setEnabled(javaScriptEnabled || nightMode);
-
         // Remove the form data preferences if the API is >= 26 as they no longer do anything.
         if (Build.VERSION.SDK_INT >= 26) {
-            // Get the categories.
+            // Get handles for the categories.
             PreferenceCategory privacyCategory = findPreference("privacy");
             PreferenceCategory clearAndExitCategory = findPreference("clear_and_exit");
 
-            // Remove the lint warnings below that the preference categories might be null.
+            // Remove the incorrect lint warnings below that the preference categories might be null.
             assert privacyCategory != null;
             assert clearAndExitCategory != null;
 
@@ -335,22 +331,25 @@ public class SettingsFragment extends PreferenceFragmentCompat {
         fontSizePreference.setSummary(savedPreferences.getString("font_size", getString(R.string.font_size_default_value)) + "%");
 
 
-        // Get the theme string arrays.
+        // Get the app theme string arrays.
         String[] appThemeEntriesStringArray = resources.getStringArray(R.array.app_theme_entries);
         String[] appThemeEntryValuesStringArray = resources.getStringArray(R.array.app_theme_entry_values);
 
-        // Get the current theme.
+        // Get the current app theme.
         String currentAppTheme = savedPreferences.getString("app_theme", getString(R.string.app_theme_default_value));
 
-        // Define a theme entry number.
+        // Define an app theme entry number.
         int appThemeEntryNumber;
 
-        // Get the theme entry number that matches the current theme.  A switch statement cannot be used because the theme entry values string array is not a compile time constant.
+        // Get the app theme entry number that matches the current app theme.  A switch statement cannot be used because the theme entry values string array is not a compile time constant.
         if (currentAppTheme.equals(appThemeEntryValuesStringArray[1])) {  // The light theme is selected.
+            // Store the app theme entry number.
             appThemeEntryNumber = 1;
         } else if (currentAppTheme.equals(appThemeEntryValuesStringArray[2])) {  // The dark theme is selected.
+            // Store the app theme entry number.
             appThemeEntryNumber = 2;
         } else {  // The system default theme is selected.
+            // Store the app theme entry number.
             appThemeEntryNumber = 0;
         }
 
@@ -358,11 +357,46 @@ public class SettingsFragment extends PreferenceFragmentCompat {
         appThemePreference.setSummary(appThemeEntriesStringArray[appThemeEntryNumber]);
 
 
-        // Disable the JavaScript preference if Night Mode is enabled.  JavaScript will be enabled for all web pages.
-        javaScriptPreference.setEnabled(!nightMode);
+        // Get the WebView theme string arrays.
+        String[] webViewThemeEntriesStringArray = resources.getStringArray(R.array.webview_theme_entries);
+        String[] webViewThemeEntryValuesStringArray = resources.getStringArray(R.array.webview_theme_entry_values);
+
+        // Hide the WebView theme preference if the API < 21.
+        if (Build.VERSION.SDK_INT < 21) {  // The device is running API 19.
+            // Get a handle for the general category.
+            PreferenceCategory generalCategory = findPreference("general");
+
+            // Remove the incorrect lint warning below that the general preference category might be null.
+            assert generalCategory != null;
+
+            // Remove the WebView theme preference.
+            generalCategory.removePreference(webViewThemePreference);
+        } else {  // The device is running API >= 21
+            // Get the current WebView theme.
+            String currentWebViewTheme = savedPreferences.getString("webview_theme", getString(R.string.webview_theme_default_value));
+
+            // Define a WebView theme entry number.
+            int webViewThemeEntryNumber;
+
+            // Get the WebView theme entry number that matches the current WebView theme.  A switch statement cannot be used because the theme entry values string array is not a compile time constant.
+            if (currentWebViewTheme.equals(webViewThemeEntryValuesStringArray[1])) {  // The light theme is selected.
+                // Store the WebView theme entry number.
+                webViewThemeEntryNumber = 1;
+            } else if (currentWebViewTheme.equals(webViewThemeEntryValuesStringArray[2])) {  // The dark theme is selected.
+                // Store the WebView theme entry number.
+                webViewThemeEntryNumber = 2;
+            } else {  // The system default theme is selected.
+                // Store the WebView theme entry number.
+                webViewThemeEntryNumber = 0;
+            }
+
+            // Set the current theme as the summary text for the preference.
+            webViewThemePreference.setSummary(webViewThemeEntriesStringArray[webViewThemeEntryNumber]);
+        }
+
 
         // Set the JavaScript icon.
-        if (javaScriptEnabled || nightMode) {
+        if (javaScriptEnabled) {
             javaScriptPreference.setIcon(R.drawable.javascript_enabled);
         } else {
             javaScriptPreference.setIcon(R.drawable.privacy_mode);
@@ -381,7 +415,7 @@ public class SettingsFragment extends PreferenceFragmentCompat {
 
         // Set the third party cookies icon.
         if (firstPartyCookiesEnabled && Build.VERSION.SDK_INT >= 21) {
-            if (thirdPartyCookiesEnabled) {
+            if (savedPreferences.getBoolean("third_party_cookies", false)) {
                 thirdPartyCookiesPreference.setIcon(R.drawable.cookies_warning);
             } else {
                 if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
@@ -399,7 +433,7 @@ public class SettingsFragment extends PreferenceFragmentCompat {
         }
 
         // Set the DOM storage icon.
-        if (javaScriptEnabled || nightMode) {  // The preference is enabled.
+        if (javaScriptEnabled) {  // The preference is enabled.
             if (savedPreferences.getBoolean("dom_storage", false)) {  // DOM storage is enabled.
                 domStoragePreference.setIcon(R.drawable.dom_storage_enabled);
             } else {  // DOM storage is disabled.
@@ -871,21 +905,6 @@ public class SettingsFragment extends PreferenceFragmentCompat {
             }
         }
 
-        // Set the night mode preference icon.
-        if (nightMode) {
-            if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                nightModePreference.setIcon(R.drawable.night_mode_enabled_night);
-            } else {
-                nightModePreference.setIcon(R.drawable.night_mode_enabled_day);
-            }
-        } else {
-            if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                nightModePreference.setIcon(R.drawable.night_mode_disabled_night);
-            } else {
-                nightModePreference.setIcon(R.drawable.night_mode_disabled_day);
-            }
-        }
-
         // Set the wide viewport preference icon.
         if (savedPreferences.getBoolean("wide_viewport", true)) {
             if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
@@ -1822,55 +1841,27 @@ public class SettingsFragment extends PreferenceFragmentCompat {
                     currentThemeStatus = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
                     break;
 
-                case "night_mode":
-                    // Store the current night mode status.
-                    boolean currentNightModeBoolean = sharedPreferences.getBoolean("night_mode", false);
-                    boolean currentJavaScriptBoolean = sharedPreferences.getBoolean("javascript", false);
+                case "webview_theme":
+                    // Get the new WebView theme.
+                    String newWebViewTheme = sharedPreferences.getString("webview_theme", getString(R.string.webview_theme_default_value));
 
-                    // Update the icon.
-                    if (currentNightModeBoolean) {
-                        if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                            nightModePreference.setIcon(R.drawable.night_mode_enabled_night);
-                        } else {
-                            nightModePreference.setIcon(R.drawable.night_mode_enabled_day);
-                        }
-                    } else {
-                        if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                            nightModePreference.setIcon(R.drawable.night_mode_disabled_night);
-                        } else {
-                            nightModePreference.setIcon(R.drawable.night_mode_disabled_day);
-                        }
-                    }
-
-                    // Update the status of `javaScriptPreference` and `domStoragePreference`.
-                    javaScriptPreference.setEnabled(!currentNightModeBoolean);
-                    domStoragePreference.setEnabled(currentNightModeBoolean || currentJavaScriptBoolean);
+                    // Define a new WebView theme entry number.
+                    int newWebViewThemeEntryNumber;
 
-                    // Update the `javaScriptPreference` icon.
-                    if (currentNightModeBoolean || currentJavaScriptBoolean) {
-                        javaScriptPreference.setIcon(R.drawable.javascript_enabled);
-                    } else {
-                        javaScriptPreference.setIcon(R.drawable.privacy_mode);
+                    // Get the webView theme entry number that matches the new WebView theme.  A switch statement cannot be used because the theme entry values string array is not a compile time constant.
+                    if (newWebViewTheme.equals(webViewThemeEntriesStringArray[1])) {  // The light theme is selected.
+                        // Store the new WebView theme entry number.
+                        newWebViewThemeEntryNumber = 1;
+                    } else if (newWebViewTheme.equals(webViewThemeEntryValuesStringArray[2])) {  // The dark theme is selected.
+                        // Store the WebView theme entry number.
+                        newWebViewThemeEntryNumber = 2;
+                    } else {  // The system default theme is selected.
+                        // Store the WebView theme entry number.
+                        newWebViewThemeEntryNumber = 0;
                     }
 
-                    // Update the DOM storage preference icon.
-                    if (currentNightModeBoolean || currentJavaScriptBoolean) {  // The preference is enabled.
-                        if (sharedPreferences.getBoolean("dom_storage", false)) {  // DOM storage is enabled.
-                            domStoragePreference.setIcon(R.drawable.dom_storage_enabled);
-                        } else {  // DOM storage is disabled.
-                            if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                                domStoragePreference.setIcon(R.drawable.dom_storage_disabled_night);
-                            } else {
-                                domStoragePreference.setIcon(R.drawable.dom_storage_disabled_day);
-                            }
-                        }
-                    } else {  // The preference is disabled.  The icon should be ghosted.
-                        if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                            domStoragePreference.setIcon(R.drawable.dom_storage_ghosted_night);
-                        } else {
-                            domStoragePreference.setIcon(R.drawable.dom_storage_ghosted_day);
-                        }
-                    }
+                    // Set the current theme as the summary text for the preference.
+                    webViewThemePreference.setSummary(webViewThemeEntriesStringArray[newWebViewThemeEntryNumber]);
                     break;
 
                 case "wide_viewport":
diff --git a/app/src/main/res/drawable/night_mode_disabled_day.xml b/app/src/main/res/drawable/night_mode_disabled_day.xml
deleted file mode 100644 (file)
index 64b69b3..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-<!-- This file is derived from `compare`, which is part of the Android Material icon set.  It is released under the Apache License 2.0.
-    Modifications copyright © 2017 Soren Stoutner <soren@stoutner.com>.  The resulting image is released under the GPLv3+ license. -->
-
-<!-- `tools:ignore="VectorRaster"` removes the lint warning about `android:autoMirrored="true"` not applying to API < 21. -->
-<vector
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:tools="http://schemas.android.com/tools"
-    android:height="24dp"
-    android:width="24dp"
-    android:viewportHeight="24"
-    android:viewportWidth="24"
-    android:autoMirrored="true"
-    tools:ignore="VectorRaster" >
-
-    <!-- A hard coded color must be used until API >= 21.  Then `@color` or `?attr/colorControlNormal` may be used instead. -->
-    <path
-        android:fillColor="#FF757575"
-        android:pathData="m14,3h5c1.1,0 2,0.9 2,2v14c0,1.1 -0.9,2 -2,2h-5v2L12,23L12,1h2zM14,18h5L14,12ZM5,3h5L10,5L5,5v13l5,-6v9L5,21C3.9,21 3,20.1 3,19L3,5C3,3.9 3.9,3 5,3Z"/>
-</vector>
diff --git a/app/src/main/res/drawable/night_mode_disabled_night.xml b/app/src/main/res/drawable/night_mode_disabled_night.xml
deleted file mode 100644 (file)
index 0ee9acc..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-<!-- This file is derived from `compare`, which is part of the Android Material icon set.  It is released under the Apache License 2.0.
-    Modifications copyright © 2017 Soren Stoutner <soren@stoutner.com>.  The resulting image is released under the GPLv3+ license. -->
-
-<!-- `tools:ignore="VectorRaster"` removes the lint warning about `android:autoMirrored="true"` not applying to API < 21. -->
-<vector
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:tools="http://schemas.android.com/tools"
-    android:height="24dp"
-    android:width="24dp"
-    android:viewportHeight="24"
-    android:viewportWidth="24"
-    android:autoMirrored="true"
-    tools:ignore="VectorRaster" >
-
-    <!-- A hard coded color must be used until API >= 21.  Then `@color` or `?attr/colorControlNormal` may be used instead. -->
-    <path
-        android:fillColor="#FF9E9E9E"
-        android:pathData="m14,3h5c1.1,0 2,0.9 2,2v14c0,1.1 -0.9,2 -2,2h-5v2L12,23L12,1h2zM14,18h5L14,12ZM5,3h5L10,5L5,5v13l5,-6v9L5,21C3.9,21 3,20.1 3,19L3,5C3,3.9 3.9,3 5,3Z"/>
-</vector>
diff --git a/app/src/main/res/drawable/night_mode_enabled_day.xml b/app/src/main/res/drawable/night_mode_enabled_day.xml
deleted file mode 100644 (file)
index ffbec3f..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-<!-- This file is derived from `compare`, which is part of the Android Material icon set.  It is released under the Apache License 2.0.
-    Modifications copyright © 2017 Soren Stoutner <soren@stoutner.com>.  The resulting image is released under the GPLv3+ license. -->
-
-<!-- `tools:ignore="VectorRaster"` removes the lint warning about `android:autoMirrored="true"` not applying to API < 21. -->
-<vector
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:tools="http://schemas.android.com/tools"
-    android:height="24dp"
-    android:width="24dp"
-    android:viewportHeight="24"
-    android:viewportWidth="24"
-    android:autoMirrored="true"
-    tools:ignore="VectorRaster" >
-
-    <!-- A hard coded color must be used until API >= 21.  Then `@color` or `?attr/colorControlNormal` may be used instead. -->
-    <path
-        android:fillColor="#FF1565C0"
-        android:pathData="m14,3h5c1.1,0 2,0.9 2,2v14c0,1.1 -0.9,2 -2,2h-5v2L12,23L12,1h2zM14,18h5L14,12ZM5,3h5L10,5L5,5v13l5,-6v9L5,21C3.9,21 3,20.1 3,19L3,5C3,3.9 3.9,3 5,3Z"/>
-</vector>
diff --git a/app/src/main/res/drawable/night_mode_enabled_night.xml b/app/src/main/res/drawable/night_mode_enabled_night.xml
deleted file mode 100644 (file)
index 55d6313..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-<!-- This file is derived from `compare`, which is part of the Android Material icon set.  It is released under the Apache License 2.0.
-    Modifications copyright © 2017 Soren Stoutner <soren@stoutner.com>.  The resulting image is released under the GPLv3+ license. -->
-
-<!-- `tools:ignore="VectorRaster"` removes the lint warning about `android:autoMirrored="true"` not applying to API < 21. -->
-<vector
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:tools="http://schemas.android.com/tools"
-    android:height="24dp"
-    android:width="24dp"
-    android:viewportHeight="24.0"
-    android:viewportWidth="24.0"
-    android:autoMirrored="true"
-    tools:ignore="VectorRaster" >
-
-    <!-- A hard coded color must be used until API >= 21.  Then `@color` or `?attr/colorControlNormal` may be used instead. -->
-    <path
-        android:fillColor="#FF8AB4F8"
-        android:pathData="m14,3h5c1.1,0 2,0.9 2,2v14c0,1.1 -0.9,2 -2,2h-5v2L12,23L12,1h2zM14,18h5L14,12ZM5,3h5L10,5L5,5v13l5,-6v9L5,21C3.9,21 3,20.1 3,19L3,5C3,3.9 3.9,3 5,3Z"/>
-</vector>
diff --git a/app/src/main/res/drawable/webview_theme_disabled_day.xml b/app/src/main/res/drawable/webview_theme_disabled_day.xml
new file mode 100644 (file)
index 0000000..64b69b3
--- /dev/null
@@ -0,0 +1,19 @@
+<!-- This file is derived from `compare`, which is part of the Android Material icon set.  It is released under the Apache License 2.0.
+    Modifications copyright © 2017 Soren Stoutner <soren@stoutner.com>.  The resulting image is released under the GPLv3+ license. -->
+
+<!-- `tools:ignore="VectorRaster"` removes the lint warning about `android:autoMirrored="true"` not applying to API < 21. -->
+<vector
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:height="24dp"
+    android:width="24dp"
+    android:viewportHeight="24"
+    android:viewportWidth="24"
+    android:autoMirrored="true"
+    tools:ignore="VectorRaster" >
+
+    <!-- A hard coded color must be used until API >= 21.  Then `@color` or `?attr/colorControlNormal` may be used instead. -->
+    <path
+        android:fillColor="#FF757575"
+        android:pathData="m14,3h5c1.1,0 2,0.9 2,2v14c0,1.1 -0.9,2 -2,2h-5v2L12,23L12,1h2zM14,18h5L14,12ZM5,3h5L10,5L5,5v13l5,-6v9L5,21C3.9,21 3,20.1 3,19L3,5C3,3.9 3.9,3 5,3Z"/>
+</vector>
diff --git a/app/src/main/res/drawable/webview_theme_disabled_night.xml b/app/src/main/res/drawable/webview_theme_disabled_night.xml
new file mode 100644 (file)
index 0000000..0ee9acc
--- /dev/null
@@ -0,0 +1,19 @@
+<!-- This file is derived from `compare`, which is part of the Android Material icon set.  It is released under the Apache License 2.0.
+    Modifications copyright © 2017 Soren Stoutner <soren@stoutner.com>.  The resulting image is released under the GPLv3+ license. -->
+
+<!-- `tools:ignore="VectorRaster"` removes the lint warning about `android:autoMirrored="true"` not applying to API < 21. -->
+<vector
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:height="24dp"
+    android:width="24dp"
+    android:viewportHeight="24"
+    android:viewportWidth="24"
+    android:autoMirrored="true"
+    tools:ignore="VectorRaster" >
+
+    <!-- A hard coded color must be used until API >= 21.  Then `@color` or `?attr/colorControlNormal` may be used instead. -->
+    <path
+        android:fillColor="#FF9E9E9E"
+        android:pathData="m14,3h5c1.1,0 2,0.9 2,2v14c0,1.1 -0.9,2 -2,2h-5v2L12,23L12,1h2zM14,18h5L14,12ZM5,3h5L10,5L5,5v13l5,-6v9L5,21C3.9,21 3,20.1 3,19L3,5C3,3.9 3.9,3 5,3Z"/>
+</vector>
diff --git a/app/src/main/res/drawable/webview_theme_enabled_day.xml b/app/src/main/res/drawable/webview_theme_enabled_day.xml
new file mode 100644 (file)
index 0000000..ffbec3f
--- /dev/null
@@ -0,0 +1,19 @@
+<!-- This file is derived from `compare`, which is part of the Android Material icon set.  It is released under the Apache License 2.0.
+    Modifications copyright © 2017 Soren Stoutner <soren@stoutner.com>.  The resulting image is released under the GPLv3+ license. -->
+
+<!-- `tools:ignore="VectorRaster"` removes the lint warning about `android:autoMirrored="true"` not applying to API < 21. -->
+<vector
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:height="24dp"
+    android:width="24dp"
+    android:viewportHeight="24"
+    android:viewportWidth="24"
+    android:autoMirrored="true"
+    tools:ignore="VectorRaster" >
+
+    <!-- A hard coded color must be used until API >= 21.  Then `@color` or `?attr/colorControlNormal` may be used instead. -->
+    <path
+        android:fillColor="#FF1565C0"
+        android:pathData="m14,3h5c1.1,0 2,0.9 2,2v14c0,1.1 -0.9,2 -2,2h-5v2L12,23L12,1h2zM14,18h5L14,12ZM5,3h5L10,5L5,5v13l5,-6v9L5,21C3.9,21 3,20.1 3,19L3,5C3,3.9 3.9,3 5,3Z"/>
+</vector>
diff --git a/app/src/main/res/drawable/webview_theme_enabled_night.xml b/app/src/main/res/drawable/webview_theme_enabled_night.xml
new file mode 100644 (file)
index 0000000..55d6313
--- /dev/null
@@ -0,0 +1,19 @@
+<!-- This file is derived from `compare`, which is part of the Android Material icon set.  It is released under the Apache License 2.0.
+    Modifications copyright © 2017 Soren Stoutner <soren@stoutner.com>.  The resulting image is released under the GPLv3+ license. -->
+
+<!-- `tools:ignore="VectorRaster"` removes the lint warning about `android:autoMirrored="true"` not applying to API < 21. -->
+<vector
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:height="24dp"
+    android:width="24dp"
+    android:viewportHeight="24.0"
+    android:viewportWidth="24.0"
+    android:autoMirrored="true"
+    tools:ignore="VectorRaster" >
+
+    <!-- A hard coded color must be used until API >= 21.  Then `@color` or `?attr/colorControlNormal` may be used instead. -->
+    <path
+        android:fillColor="#FF8AB4F8"
+        android:pathData="m14,3h5c1.1,0 2,0.9 2,2v14c0,1.1 -0.9,2 -2,2h-5v2L12,23L12,1h2zM14,18h5L14,12ZM5,3h5L10,5L5,5v13l5,-6v9L5,21C3.9,21 3,20.1 3,19L3,5C3,3.9 3.9,3 5,3Z"/>
+</vector>
index dd2e8c524cb121432679d7333207a8b7841bec6b..710c0c09a1e1f4ec7f26ccff0ed7febd586700b2 100644 (file)
                     android:layout_marginTop="1dp"
                     android:layout_marginEnd="10dp"
                     android:layout_gravity="center_vertical"
-                    android:contentDescription="@string/night_mode" />
+                    android:contentDescription="@string/webview_theme" />
 
                 <Spinner
                     android:id="@+id/night_mode_spinner"
index 2179f82acd7bc9a74b8aff5954bd84c3c3b4f38c..3e03b2aeca6e696afa831962faeabbd64eaa1c3a 100644 (file)
             <item>Hell</item>
             <item>Dunkel</item>
         </string-array>
-        <string name="night_mode">Nacht-Modus</string>
-        <string name="night_mode_summary">Aktivieren des Nacht-Modus aktiviert JavaScript für alle Webseiten.</string>
         <string name="wide_viewport_preference">Breiter Anzeigebereich</string>
         <string name="wide_viewport_summary">Wird der breite Anzeigebereich verwendet, werden manche Webseiten eher wie am Desktop (Standrechner, Laptop) angezeigt.</string>
         <string name="display_webpage_images">Webseiten-Bilder anzeigen</string>
index 1152e50ca201ac970eb8f7174c0d8aa21126e449..e2014c4f3eb8c2450378e7b86ea8ba0a9ff11f78 100644 (file)
             <item>Claro</item>
             <item>Oscuro</item>
         </string-array>
-        <string name="night_mode">Modo noche</string>
-        <string name="night_mode_summary">Activar el modo noche también activará javascript para todas las páginas web.</string>
         <string name="wide_viewport_preference">Vista amplia</string>
         <string name="wide_viewport_summary">El uso de una vista amplia hace que el diseño de algunas páginas web se parezca más al sitio de escritorio.</string>
         <string name="display_webpage_images">Mostrar imágenes de la página web</string>
index 7eae34c7299cb89deca63e37a2fe7a5c2be77d04..d3c3216503acb80aef97c99010b11efc98298dd5 100644 (file)
             <item>Clair</item>
             <item>Sombre</item>
         </string-array>
-        <string name="night_mode">Mode nuit</string>
-        <string name="night_mode_summary">L\'activation du mode nuit activera également JavaScript pour toutes les pages Web.</string>
         <string name="wide_viewport_preference">Large fenêtre</string>
         <string name="wide_viewport_summary">L\'utilisation d\'une fenêtre d\'affichage large fait que la mise en page de certaines pages Web ressemble davantage au site de bureau.</string>
         <string name="display_webpage_images">Afficher images Web</string>
index 874c6972f2ce5b3b53c06d6c6b25220876c1e197..8208d547b015a874cff0764169d05cc7792a0bdf 100644 (file)
             <item>Chiaro</item>
             <item>Scuro</item>
         </string-array>
-        <string name="night_mode">Modalità Notte</string>
-        <string name="night_mode_summary">L\'abilitazione della modalità notte attiva anche JavaScript per tutte le pagine web.</string>
         <string name="wide_viewport_preference">Finestra grande</string>
         <string name="wide_viewport_summary">L\'utilizzo di una finestra grande permette la visualizzazione di alcune pagine web come in modalità desktop.</string>
         <string name="display_webpage_images">Mostra immagini delle pagine web</string>
index 12616d422342f5927bbc966349db46adae11bb19..e9035a5aad03d16b1294530e1f269fe8aee20a24 100644 (file)
@@ -75,6 +75,7 @@
         <item name="homepageIcon">@drawable/home_enabled_night</item>
         <item name="searchIcon">@drawable/search_enabled_night</item>
         <item name="userAgentIcon">@drawable/user_agent_night</item>
+        <item name="webViewThemeIcon">@drawable/webview_theme_enabled_night</item>
     </style>
 
     <style name="PrivacyBrowserAlertDialog" parent="Theme.AppCompat.DayNight.Dialog.Alert" >
index 4a72b943d6a0a742f4f64049c9e52ca3ce3c57da..1ddfc47fb9f877aecd023635a95232cc731c3ce4 100644 (file)
@@ -79,6 +79,7 @@
         <item name="homepageIcon">@drawable/home_enabled_night</item>
         <item name="searchIcon">@drawable/search_enabled_night</item>
         <item name="userAgentIcon">@drawable/user_agent_night</item>
+        <item name="webViewThemeIcon">@drawable/webview_theme_enabled_night</item>
     </style>
 
     <style name="PrivacyBrowserAlertDialog" parent="Theme.AppCompat.DayNight.Dialog.Alert" >
index 499bd779d7c311310623a58b83d27cb97a245135..e8eed110fa6dd50d3c2f41c1ed68588f4b702e28 100644 (file)
@@ -69,6 +69,7 @@
         <item name="homepageIcon">@drawable/home_enabled_night</item>
         <item name="searchIcon">@drawable/search_enabled_night</item>
         <item name="userAgentIcon">@drawable/user_agent_night</item>
+        <item name="webViewThemeIcon">@drawable/webview_theme_enabled_night</item>
     </style>
 
     <style name="PrivacyBrowserAlertDialog" parent="Theme.AppCompat.DayNight.Dialog.Alert" >
index 4e32aa5cd21d4b230fbca9a1dced4bc78de489a8..a24e78dba9beaeead1f632d2109be0a3d5157037 100644 (file)
             <item>Светлая</item>
             <item>Темная</item>
         </string-array>
-        <string name="night_mode">Ночной режим</string>
-        <string name="night_mode_summary">Включение ночного режима также включает JavaScript для всех веб-страниц.</string>
         <string name="wide_viewport_preference">Широкий вид просмотра</string>
         <string name="wide_viewport_summary">Использование широкого вида просмотра делает стиль некоторых веб-страниц более похожим на сайт для компьютера.</string>
         <string name="display_webpage_images">Показывать изображения веб-страницы</string>
index 5f0b590cf9059a18d12a0d8b6cf8842cda5c2528..4e475fd12f67111a818c098985354d3d0933ecbd 100644 (file)
         <string name="scroll_app_bar_summary">WebView aşağı kaydırıldığında, ekranın üst kısmından uygulama çubuğunu kaydırır.</string>
         <string name="display_additional_app_bar_icons">Ek uygulama çubuğu simgelerini göster</string>
         <string name="display_additional_app_bar_icons_summary">WebView\'ı yenilemek, yer varsa çerezleri ve DOM depolamayı değiştirmek için simgeleri uygulama çubuğunda gösterir.</string>
-        <string name="night_mode">Gece modu</string>
-        <string name="night_mode_summary">Gece modunu etkinleştirmek, aynı zamanda tüm sitelerde JavaScript\'i etkinleştirir.</string>
         <string name="wide_viewport_preference">Geniş ekran</string>
         <string name="wide_viewport_summary">Geniş ekran kullanmak, bazı web sayfalarının düzenini masaüstü versiyonları gibi yapar.</string>
         <string name="display_webpage_images">Web sayfasının görsellerini göster</string>
index 7a9e08c6cb678c80398807ffbcffdfd04208c0c6..69e1173314561d874a2c6d2ba1071f1311f990e7 100644 (file)
@@ -75,6 +75,7 @@
         <item name="homepageIcon">@drawable/home_enabled_day</item>
         <item name="searchIcon">@drawable/search_enabled_day</item>
         <item name="userAgentIcon">@drawable/user_agent_day</item>
+        <item name="webViewThemeIcon">@drawable/webview_theme_enabled_day</item>
     </style>
 
     <style name="PrivacyBrowserAlertDialog" parent="Theme.AppCompat.DayNight.Dialog.Alert" >
index efe68c8c79a7ab7fcd8779cb5937e149cc5fca14..9acd4a362f7f95693978cc1e1d60614265addbae 100644 (file)
@@ -79,6 +79,7 @@
         <item name="homepageIcon">@drawable/home_enabled_day</item>
         <item name="searchIcon">@drawable/search_enabled_day</item>
         <item name="userAgentIcon">@drawable/user_agent_day</item>
+        <item name="webViewThemeIcon">@drawable/webview_theme_enabled_day</item>
     </style>
 
     <style name="PrivacyBrowserAlertDialog" parent="Theme.AppCompat.DayNight.Dialog.Alert" >
index dd911345b6cb086f468382eed65ae3fa05930f97..f935542997fdfd0ebf7897a86c91144839cf035e 100644 (file)
@@ -57,4 +57,5 @@
     <attr name="selectAllIcon" format="reference" />
     <attr name="sortIcon" format="reference" />
     <attr name="userAgentIcon" format="reference" />
+    <attr name="webViewThemeIcon" format="reference" />
 </resources>
\ No newline at end of file
index 91df074d01aabc4982bce5519cbfe4f7d330b8c1..77f6e766a115649eb4b9e7c00a1dd2570c61e745 100644 (file)
             <item>Light</item>
             <item>Dark</item>
         </string-array>
-        <string name="night_mode">Night mode</string>
-        <string name="night_mode_summary">Enabling night mode will also enable JavaScript for all web pages.</string>
+        <string name="webview_theme">WebView theme</string>
+        <string-array name="webview_theme_entries">
+            <item>System default</item>
+            <item>Light</item>
+            <item>Dark</item>
+        </string-array>
+        <string-array name="webview_theme_entry_values" translatable="false">  <!-- None of the items in this string array should be translated. -->
+            <item>System default</item>
+            <item>Light</item>
+            <item>Dark</item>
+        </string-array>
         <string name="wide_viewport_preference">Wide viewport</string>
         <string name="wide_viewport_summary">Using a wide viewport makes some webpages layout more like the desktop site.</string>
         <string name="display_webpage_images">Display webpage images</string>
     <string name="download_custom_location_default_value" translatable="false" />
     <string name="font_size_default_value" translatable="false">100</string>
     <string name="app_theme_default_value" translatable="false">System default</string>
+    <string name="webview_theme_default_value" translatable="false">System default</string>
 
     <!-- Ad Control. There are no ads in the standard flavor, but these strings must exist because they are referenced in the code. -->
     <string name="google_app_id" translatable="false">Null</string>
index 08fcb8a4229c2f109e613483ef3fe15b0d82c35c..ca0f2145a5ee782382c6669cc18b5548132ea081 100644 (file)
@@ -69,6 +69,7 @@
         <item name="homepageIcon">@drawable/home_enabled_day</item>
         <item name="searchIcon">@drawable/search_enabled_day</item>
         <item name="userAgentIcon">@drawable/user_agent_day</item>
+        <item name="webViewThemeIcon">@drawable/webview_theme_enabled_day</item>
     </style>
 
     <style name="PrivacyBrowserAlertDialog" parent="Theme.AppCompat.DayNight.Dialog.Alert" >
index a60edb01ee354fd012049341186a3cc1a3e367a5..f5f3eb3fe9d45e151669d86c75deac2def2b5556 100644 (file)
             android:defaultValue="@string/app_theme_default_value"
             android:icon="?attr/appThemeIcon" />
 
-        <SwitchPreference
-            android:key="night_mode"
-            android:title="@string/night_mode"
-            android:summary="@string/night_mode_summary"
-            android:defaultValue="false" />
+        <ListPreference
+            android:key="webview_theme"
+            android:title="@string/webview_theme"
+            android:entries="@array/webview_theme_entries"
+            android:entryValues="@array/webview_theme_entry_values"
+            android:defaultValue="@string/webview_theme_default_value"
+            android:icon="?attr/webViewThemeIcon" />
 
         <SwitchPreference
             android:key="wide_viewport"