]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/commitdiff
Use WebView's new built-in dark theme. https://redmine.stoutner.com/issues/366
authorSoren Stoutner <soren@stoutner.com>
Thu, 25 Jun 2020 20:40:58 +0000 (13:40 -0700)
committerSoren Stoutner <soren@stoutner.com>
Thu, 25 Jun 2020 20:40:58 +0000 (13:40 -0700)
35 files changed:
.idea/dictionaries/soren.xml
app/src/main/java/com/stoutner/privacybrowser/activities/DomainsActivity.java
app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java
app/src/main/java/com/stoutner/privacybrowser/adapters/WebViewPagerAdapter.java
app/src/main/java/com/stoutner/privacybrowser/fragments/DomainSettingsFragment.java
app/src/main/java/com/stoutner/privacybrowser/fragments/SettingsFragment.java
app/src/main/java/com/stoutner/privacybrowser/helpers/DomainsDatabaseHelper.java
app/src/main/java/com/stoutner/privacybrowser/helpers/ImportExportDatabaseHelper.java
app/src/main/java/com/stoutner/privacybrowser/views/NestedScrollWebView.java
app/src/main/res/drawable/webview_dark_theme_day.xml [new file with mode: 0644]
app/src/main/res/drawable/webview_dark_theme_night.xml [new file with mode: 0644]
app/src/main/res/drawable/webview_light_theme_day.xml [new file with mode: 0644]
app/src/main/res/drawable/webview_light_theme_night.xml [new file with mode: 0644]
app/src/main/res/drawable/webview_theme_disabled_day.xml [deleted file]
app/src/main/res/drawable/webview_theme_disabled_night.xml [deleted file]
app/src/main/res/drawable/webview_theme_enabled_day.xml [deleted file]
app/src/main/res/drawable/webview_theme_enabled_night.xml [deleted file]
app/src/main/res/layout/domain_settings_fragment.xml
app/src/main/res/layout/webview_framelayout.xml
app/src/main/res/menu/webview_options_menu.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 1cefe92843f92b3437b60aadb6717135975b4501..db5337400691a98dd42c401651120ea8f93d39ee 100644 (file)
       <w>materialdesignicons</w>
       <w>mimetype</w>
       <w>mitm</w>
+      <w>mojeek</w>
       <w>mozilla</w>
       <w>navigationview</w>
       <w>nestedscroll</w>
index 6c07a121cd5762c8df94fefcf1993a7d18cd944b..6baf5f6e534df8c4cf7ac969753abeb500c25b0e 100644 (file)
@@ -707,7 +707,7 @@ public class DomainsActivity extends AppCompatActivity implements AddDomainDialo
         Spinner fontSizeSpinner = view.findViewById(R.id.font_size_spinner);
         EditText customFontSizeEditText = view.findViewById(R.id.custom_font_size_edittext);
         Spinner swipeToRefreshSpinner = view.findViewById(R.id.swipe_to_refresh_spinner);
-        Spinner nightModeSpinner = view.findViewById(R.id.night_mode_spinner);
+        Spinner webViewThemeSpinner = view.findViewById(R.id.webview_theme_spinner);
         Spinner wideViewportSpinner = view.findViewById(R.id.wide_viewport_spinner);
         Spinner displayWebpageImagesSpinner = view.findViewById(R.id.display_webpage_images_spinner);
         Switch pinnedSslCertificateSwitch = view.findViewById(R.id.pinned_ssl_certificate_switch);
@@ -732,7 +732,7 @@ public class DomainsActivity extends AppCompatActivity implements AddDomainDialo
         int userAgentSwitchPosition = userAgentSpinner.getSelectedItemPosition();
         int fontSizeSwitchPosition = fontSizeSpinner.getSelectedItemPosition();
         int swipeToRefreshInt = swipeToRefreshSpinner.getSelectedItemPosition();
-        int nightModeInt = nightModeSpinner.getSelectedItemPosition();
+        int webViewThemeInt = webViewThemeSpinner.getSelectedItemPosition();
         int wideViewportInt = wideViewportSpinner.getSelectedItemPosition();
         int displayWebpageImagesInt = displayWebpageImagesSpinner.getSelectedItemPosition();
         boolean pinnedSslCertificate = pinnedSslCertificateSwitch.isChecked();
@@ -772,7 +772,7 @@ public class DomainsActivity extends AppCompatActivity implements AddDomainDialo
 
         // Save the domain settings.
         domainsDatabaseHelper.updateDomain(DomainsActivity.currentDomainDatabaseId, domainNameString, javaScript, firstPartyCookies, thirdPartyCookies, domStorage, formData, easyList, easyPrivacy,
-                fanboysAnnoyance, fanboysSocialBlocking, ultraList, ultraPrivacy, blockAllThirdPartyRequests, userAgentName, fontSizeInt, swipeToRefreshInt, nightModeInt, wideViewportInt,
+                fanboysAnnoyance, fanboysSocialBlocking, ultraList, ultraPrivacy, blockAllThirdPartyRequests, userAgentName, fontSizeInt, swipeToRefreshInt, webViewThemeInt, wideViewportInt,
                 displayWebpageImagesInt, pinnedSslCertificate, pinnedIpAddress);
 
         // Update the pinned SSL certificate if a new one is checked.
index be28dd88489c516c2d48549f37f7db1b7d07b011..c130a2671dd550e4b62943a0ac66d1029b5818f4 100644 (file)
@@ -668,6 +668,7 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
         MenuItem toggleSaveFormDataMenuItem = menu.findItem(R.id.toggle_save_form_data);  // Form data can be removed once the minimum API >= 26.
         MenuItem clearFormDataMenuItem = menu.findItem(R.id.clear_form_data);  // Form data can be removed once the minimum API >= 26.
         MenuItem refreshMenuItem = menu.findItem(R.id.refresh);
+        MenuItem darkWebViewMenuItem = menu.findItem(R.id.dark_webview);
         MenuItem adConsentMenuItem = menu.findItem(R.id.ad_consent);
 
         // Only display third-party cookies if API >= 21
@@ -680,6 +681,9 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
         // Disable the clear form data menu item if the API >= 26 so that the status of the main Clear Data is calculated correctly.
         clearFormDataMenuItem.setEnabled(Build.VERSION.SDK_INT < 26);
 
+        // Only display the dark WebView menu item if API >= 21.
+        darkWebViewMenuItem.setVisible(Build.VERSION.SDK_INT >= 21);
+
         // Only show Ad Consent if this is the free flavor.
         adConsentMenuItem.setVisible(BuildConfig.FLAVOR.contentEquals("free"));
 
@@ -751,7 +755,7 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
         MenuItem swipeToRefreshMenuItem = menu.findItem(R.id.swipe_to_refresh);
         MenuItem wideViewportMenuItem = menu.findItem(R.id.wide_viewport);
         MenuItem displayImagesMenuItem = menu.findItem(R.id.display_images);
-        MenuItem nightModeMenuItem = menu.findItem(R.id.night_mode);
+        MenuItem darkWebViewMenuItem = menu.findItem(R.id.dark_webview);
 
         // Get a handle for the cookie manager.
         CookieManager cookieManager = CookieManager.getInstance();
@@ -788,7 +792,6 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
             swipeToRefreshMenuItem.setChecked(currentWebView.getSwipeToRefresh());
             wideViewportMenuItem.setChecked(currentWebView.getSettings().getUseWideViewPort());
             displayImagesMenuItem.setChecked(currentWebView.getSettings().getLoadsImagesAutomatically());
-            nightModeMenuItem.setChecked(currentWebView.getNightMode());
 
             // Initialize the display names for the blocklists with the number of blocked requests.
             blocklistsMenuItem.setTitle(getString(R.string.blocklists) + " - " + currentWebView.getRequestsCount(NestedScrollWebView.BLOCKED_REQUESTS));
@@ -811,6 +814,11 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
 
             // Enable DOM Storage if JavaScript is enabled.
             domStorageMenuItem.setEnabled(currentWebView.getSettings().getJavaScriptEnabled());
+
+            // Set the checkbox status for dark WebView if the WebView supports it.
+            if (WebViewFeature.isFeatureSupported(WebViewFeature.FORCE_DARK)) {
+                darkWebViewMenuItem.setChecked(WebSettingsCompat.getForceDark(currentWebView.getSettings()) == WebSettingsCompat.FORCE_DARK_ON);
+            }
         }
 
         // Set the checked status of the first party cookies menu item.
@@ -1557,28 +1565,19 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
                 // Consume the event.
                 return true;
 
-            case R.id.night_mode:
-                // Toggle night mode.
-                currentWebView.setNightMode(!currentWebView.getNightMode());
-
-                // Enable or disable JavaScript according to night mode, the global preference, and any domain settings.
-                if (currentWebView.getNightMode()) {  // Night mode is enabled, which requires JavaScript.
-                    // Enable JavaScript.
-                    currentWebView.getSettings().setJavaScriptEnabled(true);
-                } else if (currentWebView.getDomainSettingsApplied()) {  // Night mode is disabled and domain settings are applied.  Set JavaScript according to the domain settings.
-                    // Apply the JavaScript preference that was stored the last time domain settings were loaded.
-                    currentWebView.getSettings().setJavaScriptEnabled(currentWebView.getDomainSettingsJavaScriptEnabled());
-                } else {  // Night mode is disabled and domain settings are not applied.  Set JavaScript according to the global preference.
-                    // Apply the JavaScript preference.
-                    currentWebView.getSettings().setJavaScriptEnabled(sharedPreferences.getBoolean("javascript", false));
+            case R.id.dark_webview:
+                // Check to see if dark WebView is supported by this WebView.
+                if (WebViewFeature.isFeatureSupported(WebViewFeature.FORCE_DARK)) {
+                    // Toggle the dark WebView setting.
+                    if (WebSettingsCompat.getForceDark(currentWebView.getSettings()) == WebSettingsCompat.FORCE_DARK_ON) {  // Dark WebView is currently enabled.
+                        // Turn off dark WebView.
+                        WebSettingsCompat.setForceDark(currentWebView.getSettings(), WebSettingsCompat.FORCE_DARK_OFF);
+                    } else {  // Dark WebView is currently disabled.
+                        // turn on dark WebView.
+                        WebSettingsCompat.setForceDark(currentWebView.getSettings(), WebSettingsCompat.FORCE_DARK_ON);
+                    }
                 }
 
-                // Update the privacy icons.
-                updatePrivacyIcons(false);
-
-                // Reload the website.
-                currentWebView.reload();
-
                 // Consume the event.
                 return true;
 
@@ -3877,7 +3876,7 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
 
                 // Get the settings from the cursor.
                 nestedScrollWebView.setDomainSettingsDatabaseId(currentDomainSettingsCursor.getInt(currentDomainSettingsCursor.getColumnIndex(DomainsDatabaseHelper._ID)));
-                nestedScrollWebView.setDomainSettingsJavaScriptEnabled(currentDomainSettingsCursor.getInt(currentDomainSettingsCursor.getColumnIndex(DomainsDatabaseHelper.ENABLE_JAVASCRIPT)) == 1);
+                nestedScrollWebView.getSettings().setJavaScriptEnabled(currentDomainSettingsCursor.getInt(currentDomainSettingsCursor.getColumnIndex(DomainsDatabaseHelper.ENABLE_JAVASCRIPT)) == 1);
                 nestedScrollWebView.setAcceptFirstPartyCookies(currentDomainSettingsCursor.getInt(currentDomainSettingsCursor.getColumnIndex(DomainsDatabaseHelper.ENABLE_FIRST_PARTY_COOKIES)) == 1);
                 boolean domainThirdPartyCookiesEnabled = (currentDomainSettingsCursor.getInt(currentDomainSettingsCursor.getColumnIndex(DomainsDatabaseHelper.ENABLE_THIRD_PARTY_COOKIES)) == 1);
                 nestedScrollWebView.getSettings().setDomStorageEnabled(currentDomainSettingsCursor.getInt(currentDomainSettingsCursor.getColumnIndex(DomainsDatabaseHelper.ENABLE_DOM_STORAGE)) == 1);
@@ -3899,7 +3898,7 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
                 String userAgentName = currentDomainSettingsCursor.getString(currentDomainSettingsCursor.getColumnIndex(DomainsDatabaseHelper.USER_AGENT));
                 int fontSize = currentDomainSettingsCursor.getInt(currentDomainSettingsCursor.getColumnIndex(DomainsDatabaseHelper.FONT_SIZE));
                 int swipeToRefreshInt = currentDomainSettingsCursor.getInt(currentDomainSettingsCursor.getColumnIndex(DomainsDatabaseHelper.SWIPE_TO_REFRESH));
-                int nightModeInt = currentDomainSettingsCursor.getInt(currentDomainSettingsCursor.getColumnIndex(DomainsDatabaseHelper.NIGHT_MODE));
+                int webViewThemeInt = currentDomainSettingsCursor.getInt(currentDomainSettingsCursor.getColumnIndex(DomainsDatabaseHelper.WEBVIEW_THEME));
                 int wideViewportInt = currentDomainSettingsCursor.getInt(currentDomainSettingsCursor.getColumnIndex(DomainsDatabaseHelper.WIDE_VIEWPORT));
                 int displayWebpageImagesInt = currentDomainSettingsCursor.getInt(currentDomainSettingsCursor.getColumnIndex(DomainsDatabaseHelper.DISPLAY_IMAGES));
                 boolean pinnedSslCertificate = (currentDomainSettingsCursor.getInt(currentDomainSettingsCursor.getColumnIndex(DomainsDatabaseHelper.PINNED_SSL_CERTIFICATE)) == 1);
@@ -3930,6 +3929,9 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
                     pinnedSslEndDate = new Date(currentDomainSettingsCursor.getLong(currentDomainSettingsCursor.getColumnIndex(DomainsDatabaseHelper.SSL_END_DATE)));
                 }
 
+                // Close the current host domain settings cursor.
+                currentDomainSettingsCursor.close();
+
                 // If there is a pinned SSL certificate, store it in the WebView.
                 if (pinnedSslCertificate) {
                     nestedScrollWebView.setPinnedSslCertificate(pinnedSslIssuedToCName, pinnedSslIssuedToOName, pinnedSslIssuedToUName, pinnedSslIssuedByCName, pinnedSslIssuedByOName, pinnedSslIssuedByUName,
@@ -3941,37 +3943,7 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
                     nestedScrollWebView.setPinnedIpAddresses(pinnedHostIpAddresses);
                 }
 
-                // Set night mode according to the night mode int.
-                switch (nightModeInt) {
-                    case DomainsDatabaseHelper.SYSTEM_DEFAULT:
-                        // Set night mode according to the current default.
-                        nestedScrollWebView.setNightMode(sharedPreferences.getBoolean("night_mode", false));
-                        break;
-
-                    case DomainsDatabaseHelper.ENABLED:
-                        // Enable night mode.
-                        nestedScrollWebView.setNightMode(true);
-                        break;
-
-                    case DomainsDatabaseHelper.DISABLED:
-                        // Disable night mode.
-                        nestedScrollWebView.setNightMode(false);
-                        break;
-                }
-
-                // Enable JavaScript if night mode is enabled.
-                if (nestedScrollWebView.getNightMode()) {
-                    // Enable JavaScript.
-                    nestedScrollWebView.getSettings().setJavaScriptEnabled(true);
-                } else {
-                    // Set JavaScript according to the domain settings.
-                    nestedScrollWebView.getSettings().setJavaScriptEnabled(nestedScrollWebView.getDomainSettingsJavaScriptEnabled());
-                }
-
-                // Close the current host domain settings cursor.
-                currentDomainSettingsCursor.close();
-
-                // Apply the domain settings.
+                // Apply the cookie domain settings.
                 cookieManager.setAcceptCookie(nestedScrollWebView.getAcceptFirstPartyCookies());
 
                 // Set third-party cookies status if API >= 21.
@@ -4075,6 +4047,36 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
                         swipeRefreshLayout.setEnabled(false);
                 }
 
+                // Check to see if WebView themes are supported.
+                if (WebViewFeature.isFeatureSupported(WebViewFeature.FORCE_DARK)) {
+                    // Set the WebView theme.
+                    switch (webViewThemeInt) {
+                        case DomainsDatabaseHelper.SYSTEM_DEFAULT:
+                            // // Ge the current system theme status.
+                            int currentThemeStatus = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
+
+                            // Set the WebView theme according to the current system theme status.
+                            if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {  // The system is in night mode.
+                                // Turn on the WebView dark mode.
+                                WebSettingsCompat.setForceDark(nestedScrollWebView.getSettings(), WebSettingsCompat.FORCE_DARK_ON);
+                            } else {  // The system is in day mode.
+                                // Turn off the WebView dark mode.
+                                WebSettingsCompat.setForceDark(nestedScrollWebView.getSettings(), WebSettingsCompat.FORCE_DARK_OFF);
+                            }
+                            break;
+
+                        case DomainsDatabaseHelper.LIGHT_THEME:
+                            // Turn off the WebView dark mode.
+                            WebSettingsCompat.setForceDark(nestedScrollWebView.getSettings(), WebSettingsCompat.FORCE_DARK_OFF);
+                            break;
+
+                        case DomainsDatabaseHelper.DARK_THEME:
+                            // Turn on the WebView dark mode.
+                            WebSettingsCompat.setForceDark(nestedScrollWebView.getSettings(), WebSettingsCompat.FORCE_DARK_ON);
+                            break;
+                    }
+                }
+
                 // Set the viewport.
                 switch (wideViewportInt) {
                     case DomainsDatabaseHelper.SYSTEM_DEFAULT:
@@ -4116,7 +4118,7 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
                 }
             } else {  // The new URL does not have custom domain settings.  Load the defaults.
                 // Store the values from the shared preferences.
-                boolean defaultJavaScriptEnabled = sharedPreferences.getBoolean("javascript", false);
+                nestedScrollWebView.getSettings().setJavaScriptEnabled(sharedPreferences.getBoolean("javascript", false));
                 nestedScrollWebView.setAcceptFirstPartyCookies(sharedPreferences.getBoolean("first_party_cookies", false));
                 boolean defaultThirdPartyCookiesEnabled = sharedPreferences.getBoolean("third_party_cookies", false);
                 nestedScrollWebView.getSettings().setDomStorageEnabled(sharedPreferences.getBoolean("dom_storage", false));
@@ -4128,16 +4130,7 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
                 nestedScrollWebView.enableBlocklist(NestedScrollWebView.ULTRALIST, sharedPreferences.getBoolean("ultralist", true));
                 nestedScrollWebView.enableBlocklist(NestedScrollWebView.ULTRAPRIVACY, sharedPreferences.getBoolean("ultraprivacy", true));
                 nestedScrollWebView.enableBlocklist(NestedScrollWebView.THIRD_PARTY_REQUESTS, sharedPreferences.getBoolean("block_all_third_party_requests", false));
-                nestedScrollWebView.setNightMode(sharedPreferences.getBoolean("night_mode", false));
-
-                // Enable JavaScript if night mode is enabled.
-                if (nestedScrollWebView.getNightMode()) {
-                    // Enable JavaScript.
-                    nestedScrollWebView.getSettings().setJavaScriptEnabled(true);
-                } else {
-                    // Set JavaScript according to the domain settings.
-                    nestedScrollWebView.getSettings().setJavaScriptEnabled(defaultJavaScriptEnabled);
-                }
+                String webViewTheme = sharedPreferences.getString("webview_theme", getString(R.string.webview_theme_default_value));
 
                 // Apply the default first-party cookie setting.
                 cookieManager.setAcceptCookie(nestedScrollWebView.getAcceptFirstPartyCookies());
@@ -4201,6 +4194,33 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
                         nestedScrollWebView.getSettings().setUserAgentString(userAgentDataArray[userAgentArrayPosition]);
                 }
 
+                // Get the WebView theme entry values string array.
+                String[] webViewThemeEntryValuesStringArray = getResources().getStringArray(R.array.webview_theme_entry_values);
+
+                // Apply the WebView theme if supported by the installed WebView.
+                if (WebViewFeature.isFeatureSupported(WebViewFeature.FORCE_DARK)) {
+                    // Set the WebView theme.  A switch statement cannot be used because the WebView theme entry values string array is not a compile time constant.
+                    if (webViewTheme.equals(webViewThemeEntryValuesStringArray[1])) {  // The light theme is selected.
+                        // Turn off the WebView dark mode.
+                        WebSettingsCompat.setForceDark(nestedScrollWebView.getSettings(), WebSettingsCompat.FORCE_DARK_OFF);
+                    } else if (webViewTheme.equals(webViewThemeEntryValuesStringArray[2])) {  // The dark theme is selected.
+                        // Turn on the WebView dark mode.
+                        WebSettingsCompat.setForceDark(nestedScrollWebView.getSettings(), WebSettingsCompat.FORCE_DARK_ON);
+                    } else {  // The system default theme is selected.
+                        // Get the current system theme status.
+                        int currentThemeStatus = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
+
+                        // Set the WebView theme according to the current system theme status.
+                        if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {  // The system is in night mode.
+                            // Turn on the WebView dark mode.
+                            WebSettingsCompat.setForceDark(nestedScrollWebView.getSettings(), WebSettingsCompat.FORCE_DARK_ON);
+                        } else {  // The system is in day mode.
+                            // Turn off the WebView dark mode.
+                            WebSettingsCompat.setForceDark(nestedScrollWebView.getSettings(), WebSettingsCompat.FORCE_DARK_OFF);
+                        }
+                    }
+                }
+
                 // Set the viewport.
                 nestedScrollWebView.getSettings().setUseWideViewPort(wideViewport);
 
@@ -4987,6 +5007,39 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
 
     @Override
     public void initializeWebView(NestedScrollWebView nestedScrollWebView, int pageNumber, ProgressBar progressBar, String url) {
+        // Get a handle for the shared preferences.
+        SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
+
+        // Get the WebView theme.
+        String webViewTheme = sharedPreferences.getString("webview_theme", getString(R.string.webview_theme_default_value));
+
+        // Get the WebView theme entry values string array.
+        String[] webViewThemeEntryValuesStringArray = getResources().getStringArray(R.array.webview_theme_entry_values);
+
+        // Apply the WebView theme if supported by the installed WebView.
+        if (WebViewFeature.isFeatureSupported(WebViewFeature.FORCE_DARK)) {
+            // Set the WebView theme.  A switch statement cannot be used because the WebView theme entry values string array is not a compile time constant.
+            if (webViewTheme.equals(webViewThemeEntryValuesStringArray[1])) {  // The light theme is selected.
+                // Turn off the WebView dark mode.
+                WebSettingsCompat.setForceDark(nestedScrollWebView.getSettings(), WebSettingsCompat.FORCE_DARK_OFF);
+            } else if (webViewTheme.equals(webViewThemeEntryValuesStringArray[2])) {  // The dark theme is selected.
+                // Turn on the WebView dark mode.
+                WebSettingsCompat.setForceDark(nestedScrollWebView.getSettings(), WebSettingsCompat.FORCE_DARK_ON);
+            } else {  // The system default theme is selected.
+                // Get the current system theme status.
+                int currentThemeStatus = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
+
+                // Set the WebView theme according to the current system theme status.
+                if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {  // The system is in night mode.
+                    // Turn on the WebView dark mode.
+                    WebSettingsCompat.setForceDark(nestedScrollWebView.getSettings(), WebSettingsCompat.FORCE_DARK_ON);
+                } else {  // The system is in day mode.
+                    // Turn off the WebView dark mode.
+                    WebSettingsCompat.setForceDark(nestedScrollWebView.getSettings(), WebSettingsCompat.FORCE_DARK_OFF);
+                }
+            }
+        }
+
         // Get a handle for the app compat delegate.
         AppCompatDelegate appCompatDelegate = getDelegate();
 
@@ -5015,9 +5068,6 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
         // Remove the lint warning below that the input method manager might be null.
         assert inputMethodManager != null;
 
-        // Get a handle for the shared preferences.
-        SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
-
         // Initialize the favorite icon.
         nestedScrollWebView.initializeFavoriteIcon();
 
@@ -5234,46 +5284,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.
             @Override
             public void onProgressChanged(WebView view, int progress) {
-                // Inject the night mode CSS if night mode is enabled.
-                if (nestedScrollWebView.getNightMode()) {  // Night mode is enabled.
-                    // `background-color: #212121` sets the background to be dark gray.  `color: #BDBDBD` sets the text color to be light gray.  `box-shadow: none` removes a lower underline on links
-                    // used by WordPress.  `text-decoration: none` removes all text underlines.  `text-shadow: none` removes text shadows, which usually have a hard coded color.
-                    // `border: none` removes all borders, which can also be used to underline text.  `a {color: #1565C0}` sets links to be a dark blue.
-                    // `::selection {background: #0D47A1}' sets the text selection highlight color to be a dark blue. `!important` takes precedent over any existing sub-settings.
-                    nestedScrollWebView.evaluateJavascript("(function() {var parent = document.getElementsByTagName('head').item(0); var style = document.createElement('style'); style.type = 'text/css'; " +
-                            "style.innerHTML = '* {background-color: #212121 !important; color: #BDBDBD !important; box-shadow: none !important; text-decoration: none !important;" +
-                            "text-shadow: none !important; border: none !important;} a {color: #1565C0 !important;} ::selection {background: #0D47A1 !important;}'; parent.appendChild(style)})()", value -> {
-                        // Initialize a handler to display `mainWebView`.
-                        Handler displayWebViewHandler = new Handler();
-
-                        // Setup a runnable to display `mainWebView` after a delay to allow the CSS to be applied.
-                        Runnable displayWebViewRunnable = () -> {
-                            // Only display `mainWebView` if the progress bar is gone.  This prevents the display of the `WebView` while it is still loading.
-                            if (progressBar.getVisibility() == View.GONE) {
-                                nestedScrollWebView.setVisibility(View.VISIBLE);
-                            }
-                        };
-
-                        // Display the WebView after 500 milliseconds.
-                        displayWebViewHandler.postDelayed(displayWebViewRunnable, 500);
-                    });
-                } else {  // Night mode is disabled.
-                    // Display the nested scroll WebView if night mode is disabled.
-                    // Because of a race condition between `applyDomainSettings` and `onPageStarted`,
-                    // when night mode is set by domain settings the WebView may be hidden even if night mode is not currently enabled.
-                    nestedScrollWebView.setVisibility(View.VISIBLE);
-                }
-
                 // Update the progress bar.
                 progressBar.setProgress(progress);
 
@@ -5288,6 +5303,12 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
                     //Stop the swipe to refresh indicator if it is running
                     swipeRefreshLayout.setRefreshing(false);
                 }
+
+                // If this is a new tab, the current WebView would have been created invisible in `webview_framelayout` to prevent a white background splash in night mode.
+                if (progress >= 50) {
+                    // Make the current WebView visible.
+                    currentWebView.setVisibility(View.VISIBLE);
+                }
             }
 
             // Set the favorite icon when it changes.
@@ -5504,7 +5525,7 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
                     // Apply the domain settings for the new URL.  This doesn't do anything if the domain has not changed.
                     applyDomainSettings(nestedScrollWebView, url, true, false);
 
-                    // Manually load the URL.  The changing of the user agent will cause WebView to reload the previous URL.
+                    // Load the URL.  By using `loadUrl()`, instead of `loadUrlFromBase()`, the Referer header will never be sent.
                     nestedScrollWebView.loadUrl(url, customHeaders);
 
                     // Returning true indicates that Privacy Browser is manually handling the loading of the URL.
@@ -5966,14 +5987,6 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
                 // Reset the requests counters.
                 nestedScrollWebView.resetRequestsCounters();
 
-                // TODO.  Make the background of a new tab match the theme.
-                // If night mode is enabled, hide `mainWebView` until after the night mode CSS is applied.
-                if (nestedScrollWebView.getNightMode()) {
-                    nestedScrollWebView.setVisibility(View.INVISIBLE);
-                } else {
-                    nestedScrollWebView.setVisibility(View.VISIBLE);
-                }
-
                 // Hide the keyboard.
                 inputMethodManager.hideSoftInputFromWindow(nestedScrollWebView.getWindowToken(), 0);
 
index 5947df4466ec147802ec0762f8b66ec9eba52bcc..535512a5ebb4fd40cc427f2cdfdafa43816438a0 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2019 Soren Stoutner <soren@stoutner.com>.
+ * Copyright © 2019-2020 Soren Stoutner <soren@stoutner.com>.
  *
  * This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
  *
@@ -59,6 +59,7 @@ public class WebViewPagerAdapter extends FragmentPagerAdapter {
     }
 
     @Override
+    @NonNull
     public Fragment getItem(int pageNumber) {
         // Get the fragment for a particular page.  Page numbers are 0 indexed.
         return webViewFragmentsList.get(pageNumber);
index 10fb6637197cffb8c3821db0ddf575f32a2db622..1588ad3c2d5bedc6a31365486bcd68f411816e35 100644 (file)
@@ -104,7 +104,7 @@ public class DomainSettingsFragment extends Fragment {
         String defaultCustomUserAgentString = sharedPreferences.getString("custom_user_agent", getString(R.string.custom_user_agent_default_value));
         String defaultFontSizeString = sharedPreferences.getString("font_size", getString(R.string.font_size_default_value));
         boolean defaultSwipeToRefresh = sharedPreferences.getBoolean("swipe_to_refresh", true);
-        boolean defaultNightMode = sharedPreferences.getBoolean("night_mode", false);
+        String defaultWebViewTheme = sharedPreferences.getString("webview_theme", getString(R.string.webview_theme_default_value));
         boolean defaultWideViewport = sharedPreferences.getBoolean("wide_viewport", true);
         boolean defaultDisplayWebpageImages = sharedPreferences.getBoolean("display_webpage_images", true);
 
@@ -144,9 +144,9 @@ public class DomainSettingsFragment extends Fragment {
         ImageView swipeToRefreshImageView = domainSettingsView.findViewById(R.id.swipe_to_refresh_imageview);
         Spinner swipeToRefreshSpinner = domainSettingsView.findViewById(R.id.swipe_to_refresh_spinner);
         TextView swipeToRefreshTextView = domainSettingsView.findViewById(R.id.swipe_to_refresh_textview);
-        ImageView nightModeImageView = domainSettingsView.findViewById(R.id.night_mode_imageview);
-        Spinner nightModeSpinner = domainSettingsView.findViewById(R.id.night_mode_spinner);
-        TextView nightModeTextView = domainSettingsView.findViewById(R.id.night_mode_textview);
+        ImageView webViewThemeImageView = domainSettingsView.findViewById(R.id.webview_theme_imageview);
+        Spinner webViewThemeSpinner = domainSettingsView.findViewById(R.id.webview_theme_spinner);
+        TextView webViewThemeTextView = domainSettingsView.findViewById(R.id.webview_theme_textview);
         ImageView wideViewportImageView = domainSettingsView.findViewById(R.id.wide_viewport_imageview);
         Spinner wideViewportSpinner = domainSettingsView.findViewById(R.id.wide_viewport_spinner);
         TextView wideViewportTextView = domainSettingsView.findViewById(R.id.wide_viewport_textview);
@@ -220,7 +220,7 @@ public class DomainSettingsFragment extends Fragment {
         String currentUserAgentName = domainCursor.getString(domainCursor.getColumnIndex(DomainsDatabaseHelper.USER_AGENT));
         int fontSizeInt = domainCursor.getInt(domainCursor.getColumnIndex(DomainsDatabaseHelper.FONT_SIZE));
         int swipeToRefreshInt = domainCursor.getInt(domainCursor.getColumnIndex(DomainsDatabaseHelper.SWIPE_TO_REFRESH));
-        int nightModeInt = domainCursor.getInt(domainCursor.getColumnIndex(DomainsDatabaseHelper.NIGHT_MODE));
+        int webViewThemeInt = domainCursor.getInt(domainCursor.getColumnIndex(DomainsDatabaseHelper.WEBVIEW_THEME));
         int wideViewportInt = domainCursor.getInt(domainCursor.getColumnIndex(DomainsDatabaseHelper.WIDE_VIEWPORT));
         int displayImagesInt = domainCursor.getInt(domainCursor.getColumnIndex(DomainsDatabaseHelper.DISPLAY_IMAGES));
         int pinnedSslCertificateInt = domainCursor.getInt(domainCursor.getColumnIndex(DomainsDatabaseHelper.PINNED_SSL_CERTIFICATE));
@@ -250,7 +250,7 @@ public class DomainSettingsFragment extends Fragment {
         ArrayAdapter<CharSequence> translatedUserAgentArrayAdapter = ArrayAdapter.createFromResource(context, R.array.translated_domain_settings_user_agent_names, R.layout.spinner_item);
         ArrayAdapter<CharSequence> fontSizeArrayAdapter = ArrayAdapter.createFromResource(context, R.array.font_size_array, R.layout.spinner_item);
         ArrayAdapter<CharSequence> swipeToRefreshArrayAdapter = ArrayAdapter.createFromResource(context, R.array.swipe_to_refresh_array, R.layout.spinner_item);
-        ArrayAdapter<CharSequence> nightModeArrayAdapter = ArrayAdapter.createFromResource(context, R.array.night_mode_array, R.layout.spinner_item);
+        ArrayAdapter<CharSequence> webViewThemeArrayAdapter = ArrayAdapter.createFromResource(context, R.array.webview_theme_array, R.layout.spinner_item);
         ArrayAdapter<CharSequence> wideViewportArrayAdapter = ArrayAdapter.createFromResource(context, R.array.wide_viewport_array, R.layout.spinner_item);
         ArrayAdapter<CharSequence> displayImagesArrayAdapter = ArrayAdapter.createFromResource(context, R.array.display_webpage_images_array, R.layout.spinner_item);
 
@@ -258,7 +258,7 @@ public class DomainSettingsFragment extends Fragment {
         translatedUserAgentArrayAdapter.setDropDownViewResource(R.layout.domain_settings_spinner_dropdown_items);
         fontSizeArrayAdapter.setDropDownViewResource(R.layout.domain_settings_spinner_dropdown_items);
         swipeToRefreshArrayAdapter.setDropDownViewResource(R.layout.domain_settings_spinner_dropdown_items);
-        nightModeArrayAdapter.setDropDownViewResource(R.layout.domain_settings_spinner_dropdown_items);
+        webViewThemeArrayAdapter.setDropDownViewResource(R.layout.domain_settings_spinner_dropdown_items);
         wideViewportArrayAdapter.setDropDownViewResource(R.layout.domain_settings_spinner_dropdown_items);
         displayImagesArrayAdapter.setDropDownViewResource(R.layout.domain_settings_spinner_dropdown_items);
 
@@ -266,7 +266,7 @@ public class DomainSettingsFragment extends Fragment {
         userAgentSpinner.setAdapter(translatedUserAgentArrayAdapter);
         fontSizeSpinner.setAdapter(fontSizeArrayAdapter);
         swipeToRefreshSpinner.setAdapter(swipeToRefreshArrayAdapter);
-        nightModeSpinner.setAdapter(nightModeArrayAdapter);
+        webViewThemeSpinner.setAdapter(webViewThemeArrayAdapter);
         wideViewportSpinner.setAdapter(wideViewportArrayAdapter);
         displayWebpageImagesSpinner.setAdapter(displayImagesArrayAdapter);
 
@@ -365,28 +365,13 @@ public class DomainSettingsFragment extends Fragment {
             }
         });
 
-        // Create a boolean to track if night mode is enabled.
-        boolean nightModeEnabled = (nightModeInt == DomainsDatabaseHelper.ENABLED) || ((nightModeInt == DomainsDatabaseHelper.SYSTEM_DEFAULT) && defaultNightMode);
-
-        // Disable the JavaScript switch if night mode is enabled.
-        if (nightModeEnabled) {
-            javaScriptSwitch.setEnabled(false);
-        } else {
-            javaScriptSwitch.setEnabled(true);
-        }
-
-        // Set the JavaScript icon.
-        if ((javaScriptInt == 1) || nightModeEnabled) {
-            javaScriptImageView.setImageDrawable(resources.getDrawable(R.drawable.javascript_enabled));
-        } else {
-            javaScriptImageView.setImageDrawable(resources.getDrawable(R.drawable.privacy_mode));
-        }
-
         // Set the JavaScript switch status.
         if (javaScriptInt == 1) {  // JavaScript is enabled.
             javaScriptSwitch.setChecked(true);
+            javaScriptImageView.setImageDrawable(resources.getDrawable(R.drawable.javascript_enabled));
         } else {  // JavaScript is disabled.
             javaScriptSwitch.setChecked(false);
+            javaScriptImageView.setImageDrawable(resources.getDrawable(R.drawable.privacy_mode));
         }
 
         // Set the first-party cookies status.  Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons.
@@ -450,7 +435,7 @@ public class DomainSettingsFragment extends Fragment {
         }
 
         // Only enable DOM storage if JavaScript is enabled.
-        if ((javaScriptInt == 1) || nightModeEnabled) {  // JavaScript is enabled.
+        if (javaScriptInt == 1) {  // JavaScript is enabled.
             // Enable the DOM storage `Switch`.
             domStorageSwitch.setEnabled(true);
 
@@ -488,19 +473,23 @@ public class DomainSettingsFragment extends Fragment {
             }
         }
 
-        // Set the form data status.  Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons.  Form data can be removed once the minimum API >= 26.
+        // Set the form data visibility.  Form data can be removed once the minimum API >= 26.
         if (Build.VERSION.SDK_INT >= 26) {  // Form data no longer applies to newer versions of Android.
-            // Hide the form data switch.
+            // Hide the form data image view and switch.
+            formDataImageView.setVisibility(View.GONE);
             formDataSwitch.setVisibility(View.GONE);
         } else {  // Form data should be displayed because this is an older version of Android.
             if (formDataInt == 1) {  // Form data is on.
+                // Turn the form data switch on.
                 formDataSwitch.setChecked(true);
+
+                // Set the form data icon.
                 formDataImageView.setImageDrawable(resources.getDrawable(R.drawable.form_data_enabled));
             } else {  // Form data is off.
                 // Turn the form data switch to off.
                 formDataSwitch.setChecked(false);
 
-                // Set the icon according to the theme.
+                // Set the icon according to the theme.  Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons.
                 if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
                     formDataImageView.setImageDrawable(resources.getDrawable(R.drawable.form_data_disabled_night));
                 } else {
@@ -809,7 +798,7 @@ public class DomainSettingsFragment extends Fragment {
             fontSizeSpinner.performClick();
         });
 
-        // Display the swipe to refresh selection in the spinner.
+        // Select the swipe to refresh selection in the spinner.
         swipeToRefreshSpinner.setSelection(swipeToRefreshInt);
 
         // Set the swipe to refresh text.
@@ -872,71 +861,121 @@ public class DomainSettingsFragment extends Fragment {
             swipeToRefreshSpinner.performClick();
         });
 
-        // Display the night mode in the spinner.
-        nightModeSpinner.setSelection(nightModeInt);
-
-        // Set the default night mode text.
-        if (defaultNightMode) {
-            nightModeTextView.setText(nightModeArrayAdapter.getItem(DomainsDatabaseHelper.ENABLED));
-        } else {
-            nightModeTextView.setText(nightModeArrayAdapter.getItem(DomainsDatabaseHelper.DISABLED));
+        // Get the WebView theme string arrays.
+        String[] webViewThemeStringArray = resources.getStringArray(R.array.webview_theme_array);
+        String[] webViewThemeEntryValuesStringArray = resources.getStringArray(R.array.webview_theme_entry_values);
+
+        // Define an app WebView theme entry number.
+        int appWebViewThemeEntryNumber;
+
+        // Get the WebView theme entry number that matches the current WebView theme.  A switch statement cannot be used because the WebView theme entry values string array is not a compile time constant.
+        if (defaultWebViewTheme.equals(webViewThemeEntryValuesStringArray[1])) {  // The light theme is selected.
+            // Store the default WebView theme entry number.
+            appWebViewThemeEntryNumber = 1;
+        } else if (defaultWebViewTheme.equals(webViewThemeEntryValuesStringArray[2])) {  // The dark theme is selected.
+            // Store the default WebView theme entry number.
+            appWebViewThemeEntryNumber = 2;
+        } else {  // The system default theme is selected.
+            // Store the default WebView theme entry number.
+            appWebViewThemeEntryNumber = 0;
         }
 
-        // Set the night mode icon and TextView settings.  Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons.
-        switch (nightModeInt) {
-            case DomainsDatabaseHelper.SYSTEM_DEFAULT:
-                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.webview_theme_enabled_night));
-                    } else {
-                        nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_theme_enabled_day));
+        // Set the WebView theme visibility.
+        if (Build.VERSION.SDK_INT < 21) {  // The WebView theme cannot be set on API 19.
+            // Get a handle for the webView theme linear layout.
+            LinearLayout webViewThemeLinearLayout = domainSettingsView.findViewById(R.id.webview_theme_linearlayout);
+
+            // Hide the WebView theme linear layout.
+            webViewThemeLinearLayout.setVisibility(View.GONE);
+        } else {  // The WebView theme can be set on API >= 21.
+            // Select the WebView theme in the spinner.
+            webViewThemeSpinner.setSelection(webViewThemeInt);
+
+            // Set the WebView theme text.
+            if (appWebViewThemeEntryNumber == DomainsDatabaseHelper.SYSTEM_DEFAULT) {  // The app WebView theme is system default.
+                // Set the text according to the current UI theme.
+                if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
+                    webViewThemeTextView.setText(webViewThemeStringArray[DomainsDatabaseHelper.LIGHT_THEME]);
+                } else {
+                    webViewThemeTextView.setText(webViewThemeStringArray[DomainsDatabaseHelper.DARK_THEME]);
+                }
+            } else {  // The app WebView theme is not system default.
+                // Set the text according to the app WebView theme.
+                webViewThemeTextView.setText(webViewThemeStringArray[appWebViewThemeEntryNumber]);
+            }
+
+            // Set the WebView theme icon and text visibility.  Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons.
+            switch (webViewThemeInt) {
+                case DomainsDatabaseHelper.SYSTEM_DEFAULT:  // The domain WebView theme is system default.
+                    // Set the icon according to the app WebView theme.
+                    switch (appWebViewThemeEntryNumber) {
+                        case DomainsDatabaseHelper.SYSTEM_DEFAULT:  // The default WebView theme is system default.
+                            // Set the icon according to the app theme.
+                            if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
+                                // Set the light mode icon.
+                                webViewThemeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_light_theme_day));
+                            } else {
+                                // Set the dark theme icon.
+                                webViewThemeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_dark_theme_night));
+                            }
+                            break;
+
+                        case DomainsDatabaseHelper.LIGHT_THEME:  // the default WebView theme is light.
+                            // Set the icon according to the app theme.
+                            if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
+                                webViewThemeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_light_theme_day));
+                            } else {
+                                webViewThemeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_light_theme_night));
+                            }
+                            break;
+
+                        case DomainsDatabaseHelper.DARK_THEME:  // the default WebView theme is dark.
+                            // Set the icon according to the app theme.
+                            if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
+                                webViewThemeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_dark_theme_day));
+                            } else {
+                                webViewThemeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_dark_theme_night));
+                            }
+                            break;
                     }
-                } 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.webview_theme_disabled_night));
+
+                    // Show the WebView theme text view.
+                    webViewThemeTextView.setVisibility(View.VISIBLE);
+                    break;
+
+                case DomainsDatabaseHelper.LIGHT_THEME:  // The domain WebView theme is light.
+                    // Set the icon according to the app theme.
+                    if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
+                        webViewThemeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_light_theme_day));
                     } else {
-                        nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_theme_disabled_day));
+                        webViewThemeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_light_theme_night));
                     }
-                }
 
-                // Show night mode TextView.
-                nightModeTextView.setVisibility(View.VISIBLE);
-                break;
-
-            case DomainsDatabaseHelper.ENABLED:
-                // Set the icon according to the theme.
-                if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                    nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_theme_enabled_night));
-                } else {
-                    nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_theme_enabled_day));
-                }
+                    // Hide the WebView theme text view.
+                    webViewThemeTextView.setVisibility(View.GONE);
+                    break;
 
-                // Hide the night mode TextView.
-                nightModeTextView.setVisibility(View.GONE);
-                break;
+                case DomainsDatabaseHelper.DARK_THEME:  // The domain WebView theme is dark.
+                    // Set the icon according to the app theme.
+                    if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
+                        webViewThemeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_dark_theme_day));
+                    } else {
+                        webViewThemeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_dark_theme_night));
+                    }
 
-            case DomainsDatabaseHelper.DISABLED:
-                // Set the icon according to the theme.
-                if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                    nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_theme_disabled_night));
-                } else {
-                    nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_theme_disabled_day));
-                }
+                    // Hide the WebView theme text view.
+                    webViewThemeTextView.setVisibility(View.GONE);
+                    break;
+            }
 
-                // Hide the night mode TextView.
-                nightModeTextView.setVisibility(View.GONE);
-                break;
+            // Open the WebView theme spinner when the text view is clicked.
+            webViewThemeTextView.setOnClickListener((View v) -> {
+                // Open the WebView theme spinner.
+                webViewThemeSpinner.performClick();
+            });
         }
 
-        // Open the night mode spinner when the TextView is clicked.
-        nightModeTextView.setOnClickListener((View v) -> {
-            // Open the night mode spinner.
-            nightModeSpinner.performClick();
-        });
-
-        // Display the wide viewport in the spinner.
+        // Select the wide viewport in the spinner.
         wideViewportSpinner.setSelection(wideViewportInt);
 
         // Set the default wide viewport text.
@@ -1771,112 +1810,72 @@ public class DomainSettingsFragment extends Fragment {
             }
         });
 
-        // Set the night mode spinner listener.
-        nightModeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
+        // Set the WebView theme spinner listener.
+        webViewThemeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
             @Override
             public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
-                // Update the icon and the visibility of `nightModeTextView`.  Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons.
+                // Update the icon and the visibility of the WebView theme text view.  Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons.
                 switch (position) {
-                    case DomainsDatabaseHelper.SYSTEM_DEFAULT:
-                        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.webview_theme_enabled_night));
-                            } else {
-                                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.webview_theme_disabled_night));
-                            } else {
-                                nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_theme_disabled_day));
-                            }
-                        }
+                    case DomainsDatabaseHelper.SYSTEM_DEFAULT:  // the domain WebView theme is system default.
+                        // Set the icon according to the app WebView theme.
+                        switch (appWebViewThemeEntryNumber) {
+                            case DomainsDatabaseHelper.SYSTEM_DEFAULT:  // The default WebView theme is system default.
+                                // Set the icon according to the app theme.
+                                if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
+                                    // Set the light mode icon.
+                                    webViewThemeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_light_theme_day));
+                                } else {
+                                    // Set the dark theme icon.
+                                    webViewThemeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_dark_theme_night));
+                                }
+                                break;
 
-                        // Show the night mode TextView.
-                        nightModeTextView.setVisibility(View.VISIBLE);
-                        break;
+                            case DomainsDatabaseHelper.LIGHT_THEME:  // The default WebView theme is light.
+                                // Set the icon according to the app theme.
+                                if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
+                                    webViewThemeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_light_theme_day));
+                                } else {
+                                    webViewThemeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_light_theme_night));
+                                }
+                                break;
 
-                    case DomainsDatabaseHelper.ENABLED:
-                        // Set the icon according to the theme.
-                        if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                            nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_theme_enabled_night));
-                        } else {
-                            nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_theme_enabled_day));
+                            case DomainsDatabaseHelper.DARK_THEME:  // The default WebView theme is dark.
+                                // Set the icon according to the app theme.
+                                if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
+                                    webViewThemeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_dark_theme_day));
+                                } else {
+                                    webViewThemeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_dark_theme_night));
+                                }
+                                break;
                         }
 
-                        // Hide `nightModeTextView`.
-                        nightModeTextView.setVisibility(View.GONE);
+                        // Show the WebView theme text view.
+                        webViewThemeTextView.setVisibility(View.VISIBLE);
                         break;
 
-                    case DomainsDatabaseHelper.DISABLED:
-                        // Set the icon according to the theme.
-                        if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                            nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_theme_disabled_night));
+                    case DomainsDatabaseHelper.LIGHT_THEME:  // The domain WebView theme is light.
+                        // Set the icon according to the app theme.
+                        if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
+                            webViewThemeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_light_theme_day));
                         } else {
-                            nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_theme_disabled_day));
+                            webViewThemeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_light_theme_night));
                         }
 
-                        // Hide `nightModeTextView`.
-                        nightModeTextView.setVisibility(View.GONE);
+                        // Hide the WebView theme text view.
+                        webViewThemeTextView.setVisibility(View.GONE);
                         break;
-                }
-
-                // Create a boolean to store the current night mode setting.
-                boolean currentNightModeEnabled = (position == DomainsDatabaseHelper.ENABLED) || ((position == DomainsDatabaseHelper.SYSTEM_DEFAULT) && defaultNightMode);
-
-                // Disable the JavaScript switch if night mode is enabled.
-                if (currentNightModeEnabled) {
-                    javaScriptSwitch.setEnabled(false);
-                } else {
-                    javaScriptSwitch.setEnabled(true);
-                }
-
-                // Update the JavaScript icon.
-                if ((javaScriptInt == 1) || currentNightModeEnabled) {
-                    javaScriptImageView.setImageDrawable(resources.getDrawable(R.drawable.javascript_enabled));
-                } else {
-                    javaScriptImageView.setImageDrawable(resources.getDrawable(R.drawable.privacy_mode));
-                }
-
-                // Update the DOM storage status.
-                if ((javaScriptInt == 1) || currentNightModeEnabled) {  // JavaScript is enabled.
-                    // Enable the DOM storage `Switch`.
-                    domStorageSwitch.setEnabled(true);
-
-                    // Set the DOM storage status.  Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons.
-                    if (domStorageInt == 1) {  // Both JavaScript and DOM storage are enabled.
-                        domStorageSwitch.setChecked(true);
-                        domStorageImageView.setImageDrawable(resources.getDrawable(R.drawable.dom_storage_enabled));
-                    } else {  // JavaScript is enabled but DOM storage is disabled.
-                        // Set the DOM storage switch to off.
-                        domStorageSwitch.setChecked(false);
 
-                        // Set the icon according to the theme.
-                        if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                            domStorageImageView.setImageDrawable(resources.getDrawable(R.drawable.dom_storage_disabled_night));
+                    case DomainsDatabaseHelper.DARK_THEME:  // The domain WebView theme is dark.
+                        // Set the icon according to the app theme.
+                        if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
+                            webViewThemeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_dark_theme_day));
                         } else {
-                            domStorageImageView.setImageDrawable(resources.getDrawable(R.drawable.dom_storage_disabled_day));
+                            webViewThemeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_dark_theme_night));
                         }
-                    }
-                } else {  // JavaScript is disabled.
-                    // Disable the DOM storage `Switch`.
-                    domStorageSwitch.setEnabled(false);
-
-                    // Set the checked status of DOM storage.
-                    if (domStorageInt == 1) {  // DOM storage is enabled but JavaScript is disabled.
-                        domStorageSwitch.setChecked(true);
-                    } else {  // Both JavaScript and DOM storage are disabled.
-                        domStorageSwitch.setChecked(false);
-                    }
 
-                    // Set the icon according to the theme.
-                    if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
-                        domStorageImageView.setImageDrawable(resources.getDrawable(R.drawable.dom_storage_ghosted_night));
-                    } else {
-                        domStorageImageView.setImageDrawable(resources.getDrawable(R.drawable.dom_storage_ghosted_day));
-                    }
+                        // Hide the WebView theme text view.
+                        webViewThemeTextView.setVisibility(View.GONE);
+                        break;
                 }
             }
 
index 6130ece8584ff3f44ab1571354058c55df0c302a..eb70ef25fdf17ce6651778bb34de7d50cb76b253 100644 (file)
@@ -361,7 +361,25 @@ public class SettingsFragment extends PreferenceFragmentCompat {
         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.
+        // 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 WebView 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 visibility of the WebView theme preference.
         if (Build.VERSION.SDK_INT < 21) {  // The device is running API 19.
             // Get a handle for the general category.
             PreferenceCategory generalCategory = findPreference("general");
@@ -372,24 +390,6 @@ public class SettingsFragment extends PreferenceFragmentCompat {
             // 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]);
         }
@@ -905,6 +905,35 @@ public class SettingsFragment extends PreferenceFragmentCompat {
             }
         }
 
+        // Set the WebView theme preference icon.
+        switch (webViewThemeEntryNumber) {
+            case 0:  // The system default WebView theme is selected.
+                // Set the icon according to the app theme.
+                if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
+                    webViewThemePreference.setIcon(R.drawable.webview_light_theme_day);
+                } else {
+                    webViewThemePreference.setIcon(R.drawable.webview_dark_theme_night);
+                }
+                break;
+
+            case 1:  // The light WebView theme is selected.
+                // Set the icon according to the app theme.
+                if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
+                    webViewThemePreference.setIcon(R.drawable.webview_light_theme_day);
+                } else {
+                    webViewThemePreference.setIcon(R.drawable.webview_light_theme_night);
+                }
+                break;
+
+            case 2:  // The dark WebView theme is selected.
+                if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
+                    webViewThemePreference.setIcon(R.drawable.webview_dark_theme_day);
+                } else {
+                    webViewThemePreference.setIcon(R.drawable.webview_dark_theme_night);
+                }
+                break;
+        }
+
         // Set the wide viewport preference icon.
         if (savedPreferences.getBoolean("wide_viewport", true)) {
             if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
@@ -1860,6 +1889,34 @@ public class SettingsFragment extends PreferenceFragmentCompat {
                         newWebViewThemeEntryNumber = 0;
                     }
 
+                    // Update the icon.
+                    switch (newWebViewThemeEntryNumber) {
+                        case 0:  // The system default WebView theme is selected.
+                            // Set the icon according to the app theme.
+                            if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
+                                webViewThemePreference.setIcon(R.drawable.webview_light_theme_day);
+                            } else {
+                                webViewThemePreference.setIcon(R.drawable.webview_dark_theme_night);
+                            }
+                            break;
+
+                        case 1:  // The system default WebView theme is selected.
+                            if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
+                                webViewThemePreference.setIcon(R.drawable.webview_light_theme_day);
+                            } else {
+                                webViewThemePreference.setIcon(R.drawable.webview_light_theme_night);
+                            }
+                            break;
+
+                        case 2:  // The system default WebView theme is selected.
+                            if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
+                                webViewThemePreference.setIcon(R.drawable.webview_dark_theme_day);
+                            } else {
+                                webViewThemePreference.setIcon(R.drawable.webview_dark_theme_night);
+                            }
+                            break;
+                    }
+
                     // Set the current theme as the summary text for the preference.
                     webViewThemePreference.setSummary(webViewThemeEntriesStringArray[newWebViewThemeEntryNumber]);
                     break;
index 1e40f9705244d454e82a8d4145e7788222f5de56..e58997c3d3c5ebab9b3d4644b11b18c9f3021b33 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2017-2019 Soren Stoutner <soren@stoutner.com>.
+ * Copyright © 2017-2020 Soren Stoutner <soren@stoutner.com>.
  *
  * This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
  *
@@ -28,7 +28,7 @@ import android.database.sqlite.SQLiteOpenHelper;
 import android.preference.PreferenceManager;
 
 public class DomainsDatabaseHelper extends SQLiteOpenHelper {
-    private static final int SCHEMA_VERSION = 11;
+    private static final int SCHEMA_VERSION = 12;
     static final String DOMAINS_DATABASE = "domains.db";
     static final String DOMAINS_TABLE = "domains";
 
@@ -49,7 +49,7 @@ public class DomainsDatabaseHelper extends SQLiteOpenHelper {
     public static final String USER_AGENT = "useragent";
     public static final String FONT_SIZE = "fontsize";
     public static final String SWIPE_TO_REFRESH = "swipetorefresh";
-    public static final String NIGHT_MODE = "nightmode";
+    public static final String WEBVIEW_THEME = "webview_theme";
     public static final String WIDE_VIEWPORT = "wide_viewport";
     public static final String DISPLAY_IMAGES = "displayimages";
     public static final String PINNED_SSL_CERTIFICATE = "pinnedsslcertificate";
@@ -68,6 +68,8 @@ public class DomainsDatabaseHelper extends SQLiteOpenHelper {
     public static final int SYSTEM_DEFAULT = 0;
     public static final int ENABLED = 1;
     public static final int DISABLED = 2;
+    public static final int LIGHT_THEME = 1;
+    public static final int DARK_THEME = 2;
 
     static final String CREATE_DOMAINS_TABLE = "CREATE TABLE " + DOMAINS_TABLE + " (" +
             _ID + " INTEGER PRIMARY KEY, " +
@@ -87,7 +89,7 @@ public class DomainsDatabaseHelper extends SQLiteOpenHelper {
             USER_AGENT + " TEXT, " +
             FONT_SIZE + " INTEGER, " +
             SWIPE_TO_REFRESH + " INTEGER, " +
-            NIGHT_MODE + " INTEGER, " +
+            WEBVIEW_THEME + " INTEGER, " +
             WIDE_VIEWPORT + " INTEGER, " +
             DISPLAY_IMAGES + " INTEGER, " +
             PINNED_SSL_CERTIFICATE + " BOOLEAN, " +
@@ -142,8 +144,8 @@ public class DomainsDatabaseHelper extends SQLiteOpenHelper {
 
             // Upgrade from schema version 3.
             case 3:
-                // Add the Night Mode column.
-                domainsDatabase.execSQL("ALTER TABLE " + DOMAINS_TABLE + " ADD COLUMN " + NIGHT_MODE + " INTEGER");
+                // Add the night mode column.
+                domainsDatabase.execSQL("ALTER TABLE " + DOMAINS_TABLE + " ADD COLUMN nightmode INTEGER");
 
             // Upgrade from schema version 4.
             case 4:
@@ -192,12 +194,12 @@ public class DomainsDatabaseHelper extends SQLiteOpenHelper {
 
             // Upgrade from schema version 5.
             case 5:
-                // Add the swipe to refresh column.
+                // Add the swipe to refresh column.  This defaults to `0`, which is `System default`, so a separate step isn't needed to populate the column.
                 domainsDatabase.execSQL("ALTER TABLE " + DOMAINS_TABLE + " ADD COLUMN " + SWIPE_TO_REFRESH + " INTEGER");
 
             // Upgrade from schema version 6.
             case 6:
-                // Add the block all third-party requests column.
+                // Add the block all third-party requests column.  This defaults to `0`, which is off, so a separate step isn't needed to populate the column.
                 domainsDatabase.execSQL("ALTER TABLE " + DOMAINS_TABLE + " ADD COLUMN " + BLOCK_ALL_THIRD_PARTY_REQUESTS + " BOOLEAN");
 
             // Upgrade from schema version 7.
@@ -210,13 +212,13 @@ public class DomainsDatabaseHelper extends SQLiteOpenHelper {
 
             // Upgrade from schema version 8.
             case 8:
-                // Add the Pinned IP Addresses columns.
+                // Add the pinned IP addresses columns.  These default to `0` and `""`, so a separate step isn't needed to populate the columns.
                 domainsDatabase.execSQL("ALTER TABLE " + DOMAINS_TABLE + " ADD COLUMN " + PINNED_IP_ADDRESSES + " BOOLEAN");
                 domainsDatabase.execSQL("ALTER TABLE " + DOMAINS_TABLE + " ADD COLUMN " + IP_ADDRESSES + " TEXT");
 
             // Upgrade from schema version 9.
             case 9:
-                // Add the Wide Viewport column.
+                // Add the wide viewport column.  This defaults to `0`, which is `System default`, so a separate step isn't needed to populate the column.
                 domainsDatabase.execSQL("ALTER TABLE " + DOMAINS_TABLE + " ADD COLUMN " + WIDE_VIEWPORT + " INTEGER");
 
             // Upgrade from schema version 10.
@@ -226,6 +228,14 @@ public class DomainsDatabaseHelper extends SQLiteOpenHelper {
 
                 // Enable it for all existing rows.
                 domainsDatabase.execSQL("UPDATE " + DOMAINS_TABLE + " SET " + ULTRALIST + " = " + 1);
+
+            // Upgrade from schema version 11.
+            case 11:
+                // Add the WebView theme column.  This defaults to `0`, which is `System default`, so a separate step isn't needed to populate the column.
+                domainsDatabase.execSQL("ALTER TABLE " + DOMAINS_TABLE + " ADD COLUMN " + WEBVIEW_THEME + " INTEGER");
+
+                // SQLite amazingly doesn't include an easy command to delete a column.  <https://www.sqlite.org/lang_altertable.html>
+                // Although a new table could be created and all the data copied to it, I think I will just leave the old night mode column.  It will be wiped out the next time an import is run.
         }
     }
 
@@ -323,7 +333,7 @@ public class DomainsDatabaseHelper extends SQLiteOpenHelper {
         domainContentValues.put(USER_AGENT, "System default user agent");
         domainContentValues.put(FONT_SIZE, 0);
         domainContentValues.put(SWIPE_TO_REFRESH, 0);
-        domainContentValues.put(NIGHT_MODE, 0);
+        domainContentValues.put(WEBVIEW_THEME, 0);
         domainContentValues.put(WIDE_VIEWPORT, 0);
         domainContentValues.put(DISPLAY_IMAGES, 0);
 
@@ -353,7 +363,7 @@ public class DomainsDatabaseHelper extends SQLiteOpenHelper {
 
     public void updateDomain(int databaseId, String domainName, boolean javaScript, boolean firstPartyCookies, boolean thirdPartyCookies, boolean domStorage, boolean formData, boolean easyList,
                              boolean easyPrivacy, boolean fanboysAnnoyance, boolean fanboysSocialBlocking, boolean ultraList, boolean ultraPrivacy, boolean blockAllThirdPartyRequests, String userAgent,
-                             int fontSize, int swipeToRefresh, int nightMode, int wideViewport, int displayImages, boolean pinnedSslCertificate, boolean pinnedIpAddresses) {
+                             int fontSize, int swipeToRefresh, int webViewTheme, int wideViewport, int displayImages, boolean pinnedSslCertificate, boolean pinnedIpAddresses) {
 
         // Store the domain data in a `ContentValues`.
         ContentValues domainContentValues = new ContentValues();
@@ -375,7 +385,7 @@ public class DomainsDatabaseHelper extends SQLiteOpenHelper {
         domainContentValues.put(USER_AGENT, userAgent);
         domainContentValues.put(FONT_SIZE, fontSize);
         domainContentValues.put(SWIPE_TO_REFRESH, swipeToRefresh);
-        domainContentValues.put(NIGHT_MODE, nightMode);
+        domainContentValues.put(WEBVIEW_THEME, webViewTheme);
         domainContentValues.put(WIDE_VIEWPORT, wideViewport);
         domainContentValues.put(DISPLAY_IMAGES, displayImages);
         domainContentValues.put(PINNED_SSL_CERTIFICATE, pinnedSslCertificate);
index 6815258aab86091f851cc48d09c304da621b5ae8..8ad6e15adf6b555d56497cfdfc7a2d281b0577bd 100644 (file)
@@ -84,7 +84,7 @@ public class ImportExportDatabaseHelper {
     private static final String SCROLL_APP_BAR = "scroll_app_bar";
     private static final String DISPLAY_ADDITIONAL_APP_BAR_ICONS = "display_additional_app_bar_icons";
     private static final String APP_THEME = "app_theme";
-    private static final String NIGHT_MODE = "night_mode";
+    private static final String WEBVIEW_THEME = "webview_theme";
     private static final String WIDE_VIEWPORT = "wide_viewport";
     private static final String DISPLAY_WEBPAGE_IMAGES = "display_webpage_images";
 
@@ -105,6 +105,42 @@ public class ImportExportDatabaseHelper {
             // Create the export database domains table.
             exportDatabase.execSQL(DomainsDatabaseHelper.CREATE_DOMAINS_TABLE);
 
+
+            // Create the export database bookmarks table.
+            exportDatabase.execSQL(BookmarksDatabaseHelper.CREATE_BOOKMARKS_TABLE);
+
+            // Open the bookmarks database.  The `0` specifies the database version, but that is ignored and set instead using a constant in `BookmarksDatabaseHelper`.
+            BookmarksDatabaseHelper bookmarksDatabaseHelper = new BookmarksDatabaseHelper(context, null, null, 0);
+
+            // Get a full bookmarks cursor.
+            Cursor bookmarksCursor = bookmarksDatabaseHelper.getAllBookmarks();
+
+            // Move to the first bookmark.
+            bookmarksCursor.moveToFirst();
+
+            // Copy the data from the bookmarks cursor into the export database.
+            for (int i = 0; i < bookmarksCursor.getCount(); i++) {
+                // Extract the record from the cursor and store the data in a ContentValues.
+                ContentValues bookmarksContentValues = new ContentValues();
+                bookmarksContentValues.put(BookmarksDatabaseHelper.BOOKMARK_NAME, bookmarksCursor.getString(bookmarksCursor.getColumnIndex(BookmarksDatabaseHelper.BOOKMARK_NAME)));
+                bookmarksContentValues.put(BookmarksDatabaseHelper.BOOKMARK_URL, bookmarksCursor.getString(bookmarksCursor.getColumnIndex(BookmarksDatabaseHelper.BOOKMARK_URL)));
+                bookmarksContentValues.put(BookmarksDatabaseHelper.PARENT_FOLDER, bookmarksCursor.getString(bookmarksCursor.getColumnIndex(BookmarksDatabaseHelper.PARENT_FOLDER)));
+                bookmarksContentValues.put(BookmarksDatabaseHelper.DISPLAY_ORDER, bookmarksCursor.getInt(bookmarksCursor.getColumnIndex(BookmarksDatabaseHelper.DISPLAY_ORDER)));
+                bookmarksContentValues.put(BookmarksDatabaseHelper.IS_FOLDER, bookmarksCursor.getInt(bookmarksCursor.getColumnIndex(BookmarksDatabaseHelper.IS_FOLDER)));
+                bookmarksContentValues.put(BookmarksDatabaseHelper.FAVORITE_ICON, bookmarksCursor.getBlob(bookmarksCursor.getColumnIndex(BookmarksDatabaseHelper.FAVORITE_ICON)));
+
+                // Insert the record into the export database.
+                exportDatabase.insert(BookmarksDatabaseHelper.BOOKMARKS_TABLE, null, bookmarksContentValues);
+
+                // Advance to the next record.
+                bookmarksCursor.moveToNext();
+            }
+
+            // Close the bookmarks database.
+            bookmarksCursor.close();
+            bookmarksDatabaseHelper.close();
+
+
             // Open the domains database.  The `0` specifies the database version, but that is ignored and set instead using a constant in `DomainsDatabaseHelper`.
             DomainsDatabaseHelper domainsDatabaseHelper = new DomainsDatabaseHelper(context, null, null, 0);
 
@@ -134,7 +170,7 @@ public class ImportExportDatabaseHelper {
                 domainsContentValues.put(DomainsDatabaseHelper.USER_AGENT, domainsCursor.getString(domainsCursor.getColumnIndex(DomainsDatabaseHelper.USER_AGENT)));
                 domainsContentValues.put(DomainsDatabaseHelper.FONT_SIZE, domainsCursor.getInt(domainsCursor.getColumnIndex(DomainsDatabaseHelper.FONT_SIZE)));
                 domainsContentValues.put(DomainsDatabaseHelper.SWIPE_TO_REFRESH, domainsCursor.getInt(domainsCursor.getColumnIndex(DomainsDatabaseHelper.SWIPE_TO_REFRESH)));
-                domainsContentValues.put(DomainsDatabaseHelper.NIGHT_MODE, domainsCursor.getInt(domainsCursor.getColumnIndex(DomainsDatabaseHelper.NIGHT_MODE)));
+                domainsContentValues.put(DomainsDatabaseHelper.WEBVIEW_THEME, domainsCursor.getInt(domainsCursor.getColumnIndex(DomainsDatabaseHelper.WEBVIEW_THEME)));
                 domainsContentValues.put(DomainsDatabaseHelper.WIDE_VIEWPORT, domainsCursor.getInt(domainsCursor.getColumnIndex(DomainsDatabaseHelper.WIDE_VIEWPORT)));
                 domainsContentValues.put(DomainsDatabaseHelper.DISPLAY_IMAGES, domainsCursor.getInt(domainsCursor.getColumnIndex(DomainsDatabaseHelper.DISPLAY_IMAGES)));
                 domainsContentValues.put(DomainsDatabaseHelper.PINNED_SSL_CERTIFICATE, domainsCursor.getInt(domainsCursor.getColumnIndex(DomainsDatabaseHelper.PINNED_SSL_CERTIFICATE)));
@@ -161,41 +197,6 @@ public class ImportExportDatabaseHelper {
             domainsDatabaseHelper.close();
 
 
-            // Create the export database bookmarks table.
-            exportDatabase.execSQL(BookmarksDatabaseHelper.CREATE_BOOKMARKS_TABLE);
-
-            // Open the bookmarks database.  The `0` specifies the database version, but that is ignored and set instead using a constant in `BookmarksDatabaseHelper`.
-            BookmarksDatabaseHelper bookmarksDatabaseHelper = new BookmarksDatabaseHelper(context, null, null, 0);
-
-            // Get a full bookmarks cursor.
-            Cursor bookmarksCursor = bookmarksDatabaseHelper.getAllBookmarks();
-
-            // Move to the first bookmark.
-            bookmarksCursor.moveToFirst();
-
-            // Copy the data from the bookmarks cursor into the export database.
-            for (int i = 0; i < bookmarksCursor.getCount(); i++) {
-                // Extract the record from the cursor and store the data in a ContentValues.
-                ContentValues bookmarksContentValues = new ContentValues();
-                bookmarksContentValues.put(BookmarksDatabaseHelper.BOOKMARK_NAME, bookmarksCursor.getString(bookmarksCursor.getColumnIndex(BookmarksDatabaseHelper.BOOKMARK_NAME)));
-                bookmarksContentValues.put(BookmarksDatabaseHelper.BOOKMARK_URL, bookmarksCursor.getString(bookmarksCursor.getColumnIndex(BookmarksDatabaseHelper.BOOKMARK_URL)));
-                bookmarksContentValues.put(BookmarksDatabaseHelper.PARENT_FOLDER, bookmarksCursor.getString(bookmarksCursor.getColumnIndex(BookmarksDatabaseHelper.PARENT_FOLDER)));
-                bookmarksContentValues.put(BookmarksDatabaseHelper.DISPLAY_ORDER, bookmarksCursor.getInt(bookmarksCursor.getColumnIndex(BookmarksDatabaseHelper.DISPLAY_ORDER)));
-                bookmarksContentValues.put(BookmarksDatabaseHelper.IS_FOLDER, bookmarksCursor.getInt(bookmarksCursor.getColumnIndex(BookmarksDatabaseHelper.IS_FOLDER)));
-                bookmarksContentValues.put(BookmarksDatabaseHelper.FAVORITE_ICON, bookmarksCursor.getBlob(bookmarksCursor.getColumnIndex(BookmarksDatabaseHelper.FAVORITE_ICON)));
-
-                // Insert the record into the export database.
-                exportDatabase.insert(BookmarksDatabaseHelper.BOOKMARKS_TABLE, null, bookmarksContentValues);
-
-                // Advance to the next record.
-                bookmarksCursor.moveToNext();
-            }
-
-            // Close the bookmarks database.
-            bookmarksCursor.close();
-            bookmarksDatabaseHelper.close();
-
-
             // Prepare the preferences table SQL creation string.
             String CREATE_PREFERENCES_TABLE = "CREATE TABLE " + PREFERENCES_TABLE + " (" +
                     _ID + " INTEGER PRIMARY KEY, " +
@@ -239,7 +240,7 @@ public class ImportExportDatabaseHelper {
                     SCROLL_APP_BAR + " BOOLEAN, " +
                     DISPLAY_ADDITIONAL_APP_BAR_ICONS + " BOOLEAN, " +
                     APP_THEME + " TEXT, " +
-                    NIGHT_MODE + " BOOLEAN, " +
+                    WEBVIEW_THEME + " TEXT, " +
                     WIDE_VIEWPORT + " BOOLEAN, " +
                     DISPLAY_WEBPAGE_IMAGES + " BOOLEAN)";
 
@@ -291,7 +292,7 @@ public class ImportExportDatabaseHelper {
             preferencesContentValues.put(SCROLL_APP_BAR, sharedPreferences.getBoolean(SCROLL_APP_BAR, true));
             preferencesContentValues.put(DISPLAY_ADDITIONAL_APP_BAR_ICONS, sharedPreferences.getBoolean(DISPLAY_ADDITIONAL_APP_BAR_ICONS, false));
             preferencesContentValues.put(APP_THEME, sharedPreferences.getString(APP_THEME, context.getString(R.string.app_theme_default_value)));
-            preferencesContentValues.put(NIGHT_MODE, sharedPreferences.getBoolean(NIGHT_MODE, false));
+            preferencesContentValues.put(WEBVIEW_THEME, sharedPreferences.getString(WEBVIEW_THEME, context.getString(R.string.webview_theme_default_value)));
             preferencesContentValues.put(WIDE_VIEWPORT, sharedPreferences.getBoolean(WIDE_VIEWPORT, true));
             preferencesContentValues.put(DISPLAY_WEBPAGE_IMAGES, sharedPreferences.getBoolean(DISPLAY_WEBPAGE_IMAGES, true));
 
@@ -566,9 +567,59 @@ public class ImportExportDatabaseHelper {
                             // Set the app theme to be dark.
                             importDatabase.execSQL("UPDATE " + PREFERENCES_TABLE + " SET " + APP_THEME + " = 'Dark'");
                         }
+
+                        // Add the WebView theme to the domains table.  This defaults to 0, which is `System default`, so a separate step isn't needed to populate the database.
+                        importDatabase.execSQL("ALTER TABLE " + DomainsDatabaseHelper.DOMAINS_TABLE + " ADD COLUMN " + DomainsDatabaseHelper.WEBVIEW_THEME + " INTEGER");
+
+                        // Add the WebView theme to the preferences table.
+                        importDatabase.execSQL("ALTER TABLE " + PREFERENCES_TABLE + " ADD COLUMN " + WEBVIEW_THEME + " TEXT");
+
+                        // Get the WebView theme default value string.
+                        String webViewThemeDefaultValue = context.getString(R.string.webview_theme_default_value);
+
+                        // Set the WebView theme in the preferences table to be the default.
+                        importDatabase.execSQL("UPDATE " + PREFERENCES_TABLE + " SET " + WEBVIEW_THEME + " = " + "'" + webViewThemeDefaultValue + "'");
                 }
             }
 
+
+            // Get a cursor for the bookmarks table.
+            Cursor importBookmarksCursor = importDatabase.rawQuery("SELECT * FROM " + BookmarksDatabaseHelper.BOOKMARKS_TABLE, null);
+
+            // Delete the current bookmarks database.
+            context.deleteDatabase(BookmarksDatabaseHelper.BOOKMARKS_DATABASE);
+
+            // Create a new bookmarks database.  The `0` specifies the database version, but that is ignored and set instead using a constant in `BookmarksDatabaseHelper`.
+            BookmarksDatabaseHelper bookmarksDatabaseHelper = new BookmarksDatabaseHelper(context, null, null, 0);
+
+            // Move to the first bookmark.
+            importBookmarksCursor.moveToFirst();
+
+            // Copy the data from the import bookmarks cursor into the bookmarks database.
+            for (int i = 0; i < importBookmarksCursor.getCount(); i++) {
+                // Extract the record from the cursor and store the data in a ContentValues.
+                ContentValues bookmarksContentValues = new ContentValues();
+                bookmarksContentValues.put(BookmarksDatabaseHelper.BOOKMARK_NAME, importBookmarksCursor.getString(importBookmarksCursor.getColumnIndex(BookmarksDatabaseHelper.BOOKMARK_NAME)));
+                bookmarksContentValues.put(BookmarksDatabaseHelper.BOOKMARK_URL, importBookmarksCursor.getString(importBookmarksCursor.getColumnIndex(BookmarksDatabaseHelper.BOOKMARK_URL)));
+                bookmarksContentValues.put(BookmarksDatabaseHelper.PARENT_FOLDER, importBookmarksCursor.getString(importBookmarksCursor.getColumnIndex(BookmarksDatabaseHelper.PARENT_FOLDER)));
+                bookmarksContentValues.put(BookmarksDatabaseHelper.DISPLAY_ORDER, importBookmarksCursor.getInt(importBookmarksCursor.getColumnIndex(BookmarksDatabaseHelper.DISPLAY_ORDER)));
+                bookmarksContentValues.put(BookmarksDatabaseHelper.IS_FOLDER, importBookmarksCursor.getInt(importBookmarksCursor.getColumnIndex(BookmarksDatabaseHelper.IS_FOLDER)));
+                bookmarksContentValues.put(BookmarksDatabaseHelper.FAVORITE_ICON, importBookmarksCursor.getBlob(importBookmarksCursor.getColumnIndex(BookmarksDatabaseHelper.FAVORITE_ICON)));
+
+                // Insert the record into the export database.
+                bookmarksDatabaseHelper.createBookmark(bookmarksContentValues);
+
+                // Advance to the next record.
+                importBookmarksCursor.moveToNext();
+            }
+
+            // Close the bookmarks cursor.
+            importBookmarksCursor.close();
+
+            // Close the bookmarks database.
+            bookmarksDatabaseHelper.close();
+
+
             // Get a cursor for the domains table.
             Cursor importDomainsCursor = importDatabase.rawQuery("SELECT * FROM " + DomainsDatabaseHelper.DOMAINS_TABLE + " ORDER BY " + DomainsDatabaseHelper.DOMAIN_NAME + " ASC", null);
 
@@ -604,7 +655,7 @@ public class ImportExportDatabaseHelper {
                 domainsContentValues.put(DomainsDatabaseHelper.USER_AGENT, importDomainsCursor.getString(importDomainsCursor.getColumnIndex(DomainsDatabaseHelper.USER_AGENT)));
                 domainsContentValues.put(DomainsDatabaseHelper.FONT_SIZE, importDomainsCursor.getInt(importDomainsCursor.getColumnIndex(DomainsDatabaseHelper.FONT_SIZE)));
                 domainsContentValues.put(DomainsDatabaseHelper.SWIPE_TO_REFRESH, importDomainsCursor.getInt(importDomainsCursor.getColumnIndex(DomainsDatabaseHelper.SWIPE_TO_REFRESH)));
-                domainsContentValues.put(DomainsDatabaseHelper.NIGHT_MODE, importDomainsCursor.getInt(importDomainsCursor.getColumnIndex(DomainsDatabaseHelper.NIGHT_MODE)));
+                domainsContentValues.put(DomainsDatabaseHelper.WEBVIEW_THEME, importDomainsCursor.getInt(importDomainsCursor.getColumnIndex(DomainsDatabaseHelper.WEBVIEW_THEME)));
                 domainsContentValues.put(DomainsDatabaseHelper.WIDE_VIEWPORT, importDomainsCursor.getInt(importDomainsCursor.getColumnIndex(DomainsDatabaseHelper.WIDE_VIEWPORT)));
                 domainsContentValues.put(DomainsDatabaseHelper.DISPLAY_IMAGES, importDomainsCursor.getInt(importDomainsCursor.getColumnIndex(DomainsDatabaseHelper.DISPLAY_IMAGES)));
                 domainsContentValues.put(DomainsDatabaseHelper.PINNED_SSL_CERTIFICATE, importDomainsCursor.getInt(importDomainsCursor.getColumnIndex(DomainsDatabaseHelper.PINNED_SSL_CERTIFICATE)));
@@ -635,43 +686,6 @@ public class ImportExportDatabaseHelper {
             domainsDatabaseHelper.close();
 
 
-            // Get a cursor for the bookmarks table.
-            Cursor importBookmarksCursor = importDatabase.rawQuery("SELECT * FROM " + BookmarksDatabaseHelper.BOOKMARKS_TABLE, null);
-
-            // Delete the current bookmarks database.
-            context.deleteDatabase(BookmarksDatabaseHelper.BOOKMARKS_DATABASE);
-
-            // Create a new bookmarks database.  The `0` specifies the database version, but that is ignored and set instead using a constant in `BookmarksDatabaseHelper`.
-            BookmarksDatabaseHelper bookmarksDatabaseHelper = new BookmarksDatabaseHelper(context, null, null, 0);
-
-            // Move to the first bookmark.
-            importBookmarksCursor.moveToFirst();
-
-            // Copy the data from the import bookmarks cursor into the bookmarks database.
-            for (int i = 0; i < importBookmarksCursor.getCount(); i++) {
-                // Extract the record from the cursor and store the data in a ContentValues.
-                ContentValues bookmarksContentValues = new ContentValues();
-                bookmarksContentValues.put(BookmarksDatabaseHelper.BOOKMARK_NAME, importBookmarksCursor.getString(importBookmarksCursor.getColumnIndex(BookmarksDatabaseHelper.BOOKMARK_NAME)));
-                bookmarksContentValues.put(BookmarksDatabaseHelper.BOOKMARK_URL, importBookmarksCursor.getString(importBookmarksCursor.getColumnIndex(BookmarksDatabaseHelper.BOOKMARK_URL)));
-                bookmarksContentValues.put(BookmarksDatabaseHelper.PARENT_FOLDER, importBookmarksCursor.getString(importBookmarksCursor.getColumnIndex(BookmarksDatabaseHelper.PARENT_FOLDER)));
-                bookmarksContentValues.put(BookmarksDatabaseHelper.DISPLAY_ORDER, importBookmarksCursor.getInt(importBookmarksCursor.getColumnIndex(BookmarksDatabaseHelper.DISPLAY_ORDER)));
-                bookmarksContentValues.put(BookmarksDatabaseHelper.IS_FOLDER, importBookmarksCursor.getInt(importBookmarksCursor.getColumnIndex(BookmarksDatabaseHelper.IS_FOLDER)));
-                bookmarksContentValues.put(BookmarksDatabaseHelper.FAVORITE_ICON, importBookmarksCursor.getBlob(importBookmarksCursor.getColumnIndex(BookmarksDatabaseHelper.FAVORITE_ICON)));
-
-                // Insert the record into the export database.
-                bookmarksDatabaseHelper.createBookmark(bookmarksContentValues);
-
-                // Advance to the next record.
-                importBookmarksCursor.moveToNext();
-            }
-
-            // Close the bookmarks cursor.
-            importBookmarksCursor.close();
-
-            // Close the bookmarks database.
-            bookmarksDatabaseHelper.close();
-
-
             // Get a cursor for the preferences table.
             Cursor importPreferencesCursor = importDatabase.rawQuery("SELECT * FROM " + PREFERENCES_TABLE, null);
 
@@ -722,7 +736,7 @@ public class ImportExportDatabaseHelper {
                     .putBoolean(SCROLL_APP_BAR, importPreferencesCursor.getInt(importPreferencesCursor.getColumnIndex(SCROLL_APP_BAR)) == 1)
                     .putBoolean(DISPLAY_ADDITIONAL_APP_BAR_ICONS, importPreferencesCursor.getInt(importPreferencesCursor.getColumnIndex(DISPLAY_ADDITIONAL_APP_BAR_ICONS)) == 1)
                     .putString(APP_THEME, importPreferencesCursor.getString(importPreferencesCursor.getColumnIndex(APP_THEME)))
-                    .putBoolean(NIGHT_MODE, importPreferencesCursor.getInt(importPreferencesCursor.getColumnIndex(NIGHT_MODE)) == 1)
+                    .putString(WEBVIEW_THEME, importPreferencesCursor.getString(importPreferencesCursor.getColumnIndex(WEBVIEW_THEME)))
                     .putBoolean(WIDE_VIEWPORT, importPreferencesCursor.getInt(importPreferencesCursor.getColumnIndex(WIDE_VIEWPORT)) == 1)
                     .putBoolean(DISPLAY_WEBPAGE_IMAGES, importPreferencesCursor.getInt(importPreferencesCursor.getColumnIndex(DISPLAY_WEBPAGE_IMAGES)) == 1)
                     .apply();
index 21ab2c64b19504f4169e4358b5bdebe73b0c7db2..c3f2fc51e2ee8e341b6cdf7667fffb877d71c186 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2019 Soren Stoutner <soren@stoutner.com>.
+ * Copyright © 2019-2020 Soren Stoutner <soren@stoutner.com>.
  *
  * This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
  *
@@ -74,9 +74,6 @@ public class NestedScrollWebView extends WebView implements NestedScrollingChild
     // Track the status of first-party cookies.
     private boolean acceptFirstPartyCookies;
 
-    // Track the domain settings JavaScript status.  This can be removed once night mode does not require JavaScript.
-    private boolean domainSettingsJavaScriptEnabled;
-
     // Track the resource requests.
     private List<String[]> resourceRequests = Collections.synchronizedList(new ArrayList<>());  // Using a synchronized list makes adding resource requests thread safe.
     private boolean easyListEnabled;
@@ -120,9 +117,6 @@ public class NestedScrollWebView extends WebView implements NestedScrollingChild
     // The default or favorite icon.
     private Bitmap favoriteOrDefaultIcon;
 
-    // Track night mode.
-    private boolean nightMode;
-
     // Track swipe to refresh.
     private boolean swipeToRefresh;
 
@@ -274,18 +268,6 @@ public class NestedScrollWebView extends WebView implements NestedScrollingChild
     }
 
 
-    // Domain settings JavaScript enabled.  This can be removed once night mode does not require JavaScript.
-    public void setDomainSettingsJavaScriptEnabled(boolean status) {
-        // Store the domain settings JavaScript status.
-        domainSettingsJavaScriptEnabled = status;
-    }
-
-    public boolean getDomainSettingsJavaScriptEnabled() {
-        // Return the domain settings JavaScript status.
-        return domainSettingsJavaScriptEnabled;
-    }
-
-
     // Resource requests.
     public void addResourceRequest(String[] resourceRequest) {
         // Add the resource request to the list.
@@ -638,18 +620,6 @@ public class NestedScrollWebView extends WebView implements NestedScrollingChild
     }
 
 
-    // Night mode.
-    public void setNightMode(boolean status) {
-        // Store the night mode status.
-        nightMode = status;
-    }
-
-    public boolean getNightMode() {
-        // Return the night mode status.
-        return nightMode;
-    }
-
-
     // Swipe to refresh.
     public void setSwipeToRefresh(boolean status) {
         // Store the swipe to refresh status.
diff --git a/app/src/main/res/drawable/webview_dark_theme_day.xml b/app/src/main/res/drawable/webview_dark_theme_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_dark_theme_night.xml b/app/src/main/res/drawable/webview_dark_theme_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_light_theme_day.xml b/app/src/main/res/drawable/webview_light_theme_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_light_theme_night.xml b/app/src/main/res/drawable/webview_light_theme_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>
diff --git a/app/src/main/res/drawable/webview_theme_disabled_day.xml b/app/src/main/res/drawable/webview_theme_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/webview_theme_disabled_night.xml b/app/src/main/res/drawable/webview_theme_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/webview_theme_enabled_day.xml b/app/src/main/res/drawable/webview_theme_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/webview_theme_enabled_night.xml b/app/src/main/res/drawable/webview_theme_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>
index 710c0c09a1e1f4ec7f26ccff0ed7febd586700b2..0c570ee42d303ba6a1bedae37070a6a5c6db0864 100644 (file)
                 android:textSize="13sp" />
         </LinearLayout>
 
-        <!-- Night Mode. -->
+        <!-- WebView Theme. -->
         <LinearLayout
+            android:id="@+id/webview_theme_linearlayout"
             android:layout_height="wrap_content"
             android:layout_width="match_parent"
             android:orientation="vertical"
                 android:orientation="horizontal" >
 
                 <ImageView
-                    android:id="@+id/night_mode_imageview"
+                    android:id="@+id/webview_theme_imageview"
                     android:layout_height="wrap_content"
                     android:layout_width="wrap_content"
                     android:layout_marginTop="1dp"
                     android:contentDescription="@string/webview_theme" />
 
                 <Spinner
-                    android:id="@+id/night_mode_spinner"
+                    android:id="@+id/webview_theme_spinner"
                     android:layout_height="wrap_content"
                     android:layout_width="match_parent" />
             </LinearLayout>
 
             <TextView
-                android:id="@+id/night_mode_textview"
+                android:id="@+id/webview_theme_textview"
                 android:layout_height="match_parent"
                 android:layout_width="match_parent"
                 android:layout_marginStart="45dp"
index 1a9418d1e90f14d6c57b950db605a24820291554..6f3e530c9f4c40c28337515f6d884bfcb6d8ae9b 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 
 <!--
-  Copyright © 2019 Soren Stoutner <soren@stoutner.com>.
+  Copyright © 2019-2020 Soren Stoutner <soren@stoutner.com>.
 
   This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>>.
 
     xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:background="?android:attr/colorBackground" >
+    android:layout_height="match_parent" >
 
-    <!-- TODO.  The background and the visibility might not be necessary. -->
-    <!-- The WebView is initially `visibility="invisible"` so that the background color matches the theme. -->
+    <!-- The nested scroll WebView is created with `visibility="invisible"` to prevent a white background splash in night mode.  It is set visible in `onProgressChanged()` in `MainWebViewActivity`. -->
     <com.stoutner.privacybrowser.views.NestedScrollWebView
         android:id="@+id/nestedscroll_webview"
         android:layout_height="match_parent"
index d298b13411ba03e13ea2b7efe115da0cfe45a263..6208ad1580a1f0ad476f4895706202e38aa0cf98 100644 (file)
                 app:showAsAction="never" />
 
             <item
-                android:id="@+id/night_mode"
-                android:title="@string/options_night_mode"
+                android:id="@+id/dark_webview"
+                android:title="@string/dark_webview"
                 android:orderInCategory="1160"
                 android:checkable="true"
                 app:showAsAction="never" />
index 3e03b2aeca6e696afa831962faeabbd64eaa1c3a..4a94aff87991a65157e39ddb9f90fd8d0962e723 100644 (file)
         <string name="swipe_to_refresh_options_menu">Herunterziehen zum aktualisieren</string>
         <string name="wide_viewport">Breiter Anzeigebereich</string>
         <string name="display_images">Bilder anzeigen</string>
-        <string name="options_night_mode">Nacht-Modus</string>
         <string name="font_size">Schriftgröße</string>
         <string name="find_on_page">Auf Seite finden</string>
         <string name="print">Drucken</string>
         <item>Herunterziehen zum aktualisieren aktiviert</item>
         <item>Herunterziehen zum aktualisieren deaktiviert</item>
     </string-array>
-    <string-array name="night_mode_array">
-        <item>Standardeinstellung</item>
-        <item>Nachtmodus aktiviert</item>
-        <item>Nachtmodus deaktiviert</item>
-    </string-array>
     <string-array name="wide_viewport_array">
         <item>Standardeinstellung</item>
         <item>Breiter Anzeigebereich aktiviert</item>
index e2014c4f3eb8c2450378e7b86ea8ba0a9ff11f78..c7f4950df2ae847fc7683119a25e7a33909d9d59 100644 (file)
         <string name="swipe_to_refresh_options_menu">Deslizar para actualizar</string>
         <string name="wide_viewport">Vista amplia</string>
         <string name="display_images">Mostrar imágenes</string>
-        <string name="options_night_mode">Modo noche</string>
         <string name="font_size">Tamaño de fuente</string>
         <string name="find_on_page">Buscar en página</string>
         <string name="print">Imprimir</string>
         <item>Deslizar para actualizar habilitado</item>
         <item>Deslizar para actualizar deshabilitado</item>
     </string-array>
-    <string-array name="night_mode_array">
-        <item>Por defecto del sistema</item>
-        <item>Modo noche habilitado</item>
-        <item>Modo noche deshabilitado</item>
-    </string-array>
     <string-array name="wide_viewport_array">
         <item>Por defecto del sistema</item>
         <item>Vista amplia habilitada</item>
index d3c3216503acb80aef97c99010b11efc98298dd5..861c4457cd4477c9706cd6aab1919c09eb6ccb7c 100644 (file)
         <string name="swipe_to_refresh_options_menu">Glisser pour actualiser</string>
         <string name="wide_viewport">Fenêtre large</string>
         <string name="display_images">Afficher les images</string>
-        <string name="options_night_mode">Mode nuit</string>
         <string name="font_size">Police</string>
         <string name="find_on_page">Chercher sur la page</string>
         <string name="print">Imprimer</string>
         <item>Glisser pour actualiser activé</item>
         <item>Glisser pour actualiser déactivé</item>
     </string-array>
-    <string-array name="night_mode_array">
-        <item>Réglages systèmes</item>
-        <item>Mode nuit activé</item>
-        <item>Mode nuit désactivé</item>
-    </string-array>
     <string-array name="wide_viewport_array">
         <item>Réglages systèmes</item>
         <item>Mode fenêtre large activé</item>
index 8208d547b015a874cff0764169d05cc7792a0bdf..a87b07c3b8326cea44fc71b9ceec8fa0f94ad42f 100644 (file)
         <string name="swipe_to_refresh_options_menu">Swipe per aggiornare</string>
         <string name="wide_viewport">Finestra grande</string>
         <string name="display_images">Mostra immagini</string>
-        <string name="options_night_mode">Modalità Notte</string>
         <string name="font_size">Dimensione font</string>
         <string name="find_on_page">Cerca nella pagina</string>
         <string name="print">Stampa</string>
         <item>Swipe per aggiornare abilitato</item>
         <item>Swipe per aggiornare disabilitato</item>
     </string-array>
-    <string-array name="night_mode_array">
-        <item>Impostazioni di default</item>
-        <item>Modalità Notte abilitata</item>
-        <item>Modalità Notte disabilitata</item>
-    </string-array>
     <string-array name="wide_viewport_array">
         <item>Impostazioni di default</item>
         <item>Finestra grande abilitata</item>
index e9035a5aad03d16b1294530e1f269fe8aee20a24..12616d422342f5927bbc966349db46adae11bb19 100644 (file)
@@ -75,7 +75,6 @@
         <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 1ddfc47fb9f877aecd023635a95232cc731c3ce4..4a72b943d6a0a742f4f64049c9e52ca3ce3c57da 100644 (file)
@@ -79,7 +79,6 @@
         <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 e8eed110fa6dd50d3c2f41c1ed68588f4b702e28..499bd779d7c311310623a58b83d27cb97a245135 100644 (file)
@@ -69,7 +69,6 @@
         <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 a24e78dba9beaeead1f632d2109be0a3d5157037..61649bbc38a1694aedf901c226a114c009d4a24a 100644 (file)
         <string name="swipe_to_refresh_options_menu">Потянуть для обновления</string>
         <string name="wide_viewport">Широкий вид просмотра</string>
         <string name="display_images">Показывать изображения</string>
-        <string name="options_night_mode">Ночной режим</string>
         <string name="font_size">Размер шрифта</string>
         <string name="find_on_page">Найти на странице</string>
         <string name="print">Печать</string>
         <item>Потянуть для обновления - включено</item>
         <item>Потянуть для обновления - выключено</item>
     </string-array>
-    <string-array name="night_mode_array">
-        <item>Настройки по умолчанию</item>
-        <item>Ночной режим включен</item>
-        <item>Ночной режим выключен</item>
-    </string-array>
     <string-array name="wide_viewport_array">
         <item>Настройки по умолчанию</item>
         <item>Широкий вид просмотра включен</item>
index 4e475fd12f67111a818c098985354d3d0933ecbd..729068f3fa809bbbfc263e5d282dd1f917c51016 100644 (file)
         <string name="swipe_to_refresh_options_menu">Yenilemek için kaydır</string>
         <string name="wide_viewport">Geniş ekran</string>
         <string name="display_images">Resimleri göster</string>
-        <string name="options_night_mode">Gece modu</string>
         <string name="font_size">Yazı Tipi Boyutu</string>
         <string name="find_on_page">Sayfada bul</string>
         <string name="print">Yazdır</string>
         <item>Yenilemek için kaydır etkin</item>
         <item>Yenilemek için kaydır devre dışı</item>
     </string-array>
-    <string-array name="night_mode_array">
-        <item>Sistem varsayılanı</item>
-        <item>Gece modu etkin</item>
-        <item>Gece modu devre dışı</item>
-    </string-array>
     <string-array name="wide_viewport_array">
         <item>Sistem varsayılanı</item>
         <item>Geniş ekran etkin</item>
index 69e1173314561d874a2c6d2ba1071f1311f990e7..7a9e08c6cb678c80398807ffbcffdfd04208c0c6 100644 (file)
@@ -75,7 +75,6 @@
         <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 9acd4a362f7f95693978cc1e1d60614265addbae..efe68c8c79a7ab7fcd8779cb5937e149cc5fca14 100644 (file)
@@ -79,7 +79,6 @@
         <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 f935542997fdfd0ebf7897a86c91144839cf035e..dd911345b6cb086f468382eed65ae3fa05930f97 100644 (file)
@@ -57,5 +57,4 @@
     <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 77f6e766a115649eb4b9e7c00a1dd2570c61e745..8626d48229c7273d3b8d0f1dfc0a4392e08f7960 100644 (file)
         <string name="swipe_to_refresh_options_menu">Swipe to Refresh</string>
         <string name="wide_viewport">Wide Viewport</string>
         <string name="display_images">Display Images</string>
-        <string name="options_night_mode">Night Mode</string>
+        <string name="dark_webview">Dark WebView</string>
         <string name="font_size">Font Size</string>
         <string name="find_on_page">Find on Page</string>
         <string name="print">Print</string>
         <item>Swipe to refresh enabled</item>
         <item>Swipe to refresh disabled</item>
     </string-array>
-    <string-array name="night_mode_array">
+    <string-array name="webview_theme_array">
         <item>System default</item>
-        <item>Night mode enabled</item>
-        <item>Night mode disabled</item>
+        <item>Light WebView theme</item>
+        <item>Dark WebView theme</item>
     </string-array>
     <string-array name="wide_viewport_array">
         <item>System default</item>
index ca0f2145a5ee782382c6669cc18b5548132ea081..08fcb8a4229c2f109e613483ef3fe15b0d82c35c 100644 (file)
@@ -69,7 +69,6 @@
         <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 f5f3eb3fe9d45e151669d86c75deac2def2b5556..0b0142bde3eca71a9f2b29cd165fa64b17d0230f 100644 (file)
             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" />
+            android:defaultValue="@string/webview_theme_default_value" />
 
         <SwitchPreference
             android:key="wide_viewport"