From: Soren Stoutner Date: Sat, 20 Jun 2020 19:24:47 +0000 (-0700) Subject: Fix custom headers not being loaded for links initialed from the WebView. https... X-Git-Tag: v3.5~3 X-Git-Url: https://gitweb.stoutner.com/?a=commitdiff_plain;ds=sidebyside;h=9d621a09cdc72a3ad434084b3aab297f3a7a9d44;p=PrivacyBrowserAndroid.git Fix custom headers not being loaded for links initialed from the WebView. https://redmine.stoutner.com/issues/584 --- diff --git a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java index 89a73f25..be28dd88 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java @@ -107,6 +107,8 @@ import androidx.drawerlayout.widget.DrawerLayout; import androidx.fragment.app.DialogFragment; import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; import androidx.viewpager.widget.ViewPager; +import androidx.webkit.WebSettingsCompat; +import androidx.webkit.WebViewFeature; import com.google.android.material.appbar.AppBarLayout; import com.google.android.material.floatingactionbutton.FloatingActionButton; @@ -3732,10 +3734,7 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook // `reloadWebsite` is used if returning from the Domains activity. Otherwise JavaScript might not function correctly if it is newly enabled. @SuppressLint("SetJavaScriptEnabled") - private boolean applyDomainSettings(NestedScrollWebView nestedScrollWebView, String url, boolean resetTab, boolean reloadWebsite) { - // Store a copy of the current user agent to track changes for the return boolean. - String initialUserAgent = nestedScrollWebView.getSettings().getUserAgentString(); - + private void applyDomainSettings(NestedScrollWebView nestedScrollWebView, String url, boolean resetTab, boolean reloadWebsite) { // Store the current URL. nestedScrollWebView.setCurrentUrl(url); @@ -4223,9 +4222,6 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook if (reloadWebsite) { nestedScrollWebView.reload(); } - - // Return the user agent changed status. - return !nestedScrollWebView.getSettings().getUserAgentString().equals(initialUserAgent); } private void applyProxy(boolean reloadWebViews) { @@ -5238,6 +5234,11 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook }); } + // TODO. + if (WebViewFeature.isFeatureSupported(WebViewFeature.FORCE_DARK)) { + WebSettingsCompat.setForceDark(nestedScrollWebView.getSettings(), WebSettingsCompat.FORCE_DARK_AUTO); + } + // Set the web chrome client. nestedScrollWebView.setWebChromeClient(new WebChromeClient() { // Update the progress bar when a page is loading. @@ -5491,28 +5492,24 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook }); nestedScrollWebView.setWebViewClient(new WebViewClient() { - // `shouldOverrideUrlLoading` makes this `WebView` the default handler for URLs inside the app, so that links are not kicked out to other apps. + // `shouldOverrideUrlLoading` makes this WebView the default handler for URLs inside the app, so that links are not kicked out to other apps. // The deprecated `shouldOverrideUrlLoading` must be used until API >= 24. @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { // Sanitize the url. url = sanitizeUrl(url); + // Handle the URL according to the type. if (url.startsWith("http")) { // Load the URL in Privacy Browser. // Apply the domain settings for the new URL. This doesn't do anything if the domain has not changed. - boolean userAgentChanged = applyDomainSettings(nestedScrollWebView, url, true, false); + applyDomainSettings(nestedScrollWebView, url, true, false); - // Check if the user agent has changed. - if (userAgentChanged) { - // Manually load the URL. The changing of the user agent will cause WebView to reload the previous URL. - nestedScrollWebView.loadUrl(url, customHeaders); + // Manually load the URL. The changing of the user agent will cause WebView to reload the previous URL. + nestedScrollWebView.loadUrl(url, customHeaders); - // Returning true indicates that Privacy Browser is manually handling the loading of the URL. - return true; - } else { - // Returning false causes the current WebView to handle the URL and prevents it from adding redirects to the history list. - return false; - } + // Returning true indicates that Privacy Browser is manually handling the loading of the URL. + // Custom headers cannot be added if false is returned and the WebView handles the loading of the URL. + return true; } else if (url.startsWith("mailto:")) { // Load the email address in an external email program. // Use `ACTION_SENDTO` instead of `ACTION_SEND` so that only email programs are launched. Intent emailIntent = new Intent(Intent.ACTION_SENDTO); diff --git a/app/src/main/java/com/stoutner/privacybrowser/fragments/DomainSettingsFragment.java b/app/src/main/java/com/stoutner/privacybrowser/fragments/DomainSettingsFragment.java index 006fa216..10fb6637 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/fragments/DomainSettingsFragment.java +++ b/app/src/main/java/com/stoutner/privacybrowser/fragments/DomainSettingsFragment.java @@ -580,10 +580,12 @@ public class DomainSettingsFragment extends Fragment { // Only enable Fanboy's Social Blocking List if Fanboy's Annoyance List is off. if (fanboysAnnoyanceListInt == 0) { // Fanboy's Annoyance List is on. + // Enable Fanboy's Social Blocking List switch. + fanboysSocialBlockingListSwitch.setEnabled(true); + // Enable Fanboy's Social Blocking List. Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons. if (fanboysSocialBlockingListInt == 1) { // Fanboy's Social Blocking List is on. - // Enable the switch and turn it on. - fanboysSocialBlockingListSwitch.setEnabled(true); + // Turn on Fanboy's Social Blocking List switch. fanboysSocialBlockingListSwitch.setChecked(true); // Set the icon according to the theme. @@ -593,8 +595,7 @@ public class DomainSettingsFragment extends Fragment { fanboysSocialBlockingListImageView.setImageDrawable(resources.getDrawable(R.drawable.social_media_enabled_day)); } } else { // Fanboy's Social Blocking List is off. - // Enable the switch but turn it off. - fanboysSocialBlockingListSwitch.setEnabled(true); + // Turn off Fanboy's Social Blocking List switch. fanboysSocialBlockingListSwitch.setChecked(false); // Set the icon according to the theme. @@ -605,14 +606,15 @@ public class DomainSettingsFragment extends Fragment { } } } else { // Fanboy's Annoyance List is on. - // Disable Fanboy's Social Blocking List. Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons. + // Disable Fanboy's Social Blocking List switch. + fanboysSocialBlockingListSwitch.setEnabled(false); + + // Handle the status of Fanboy's Social Blocking List. Once the minimum API >= 21 a selector can be used as the tint mode instead of specifying different icons. if (fanboysSocialBlockingListInt == 1) { // Fanboy's Social Blocking List is on. - // Disable the switch but turn it on. - fanboysSocialBlockingListSwitch.setEnabled(false); + // Turn on Fanboy's Social Blocking List switch. fanboysSocialBlockingListSwitch.setChecked(true); } else { // Fanboy's Social Blocking List is off. - // Disable the switch and turn it off. - fanboysSocialBlockingListSwitch.setEnabled(false); + // Turn off Fanboy's Social Blocking List switch. fanboysSocialBlockingListSwitch.setChecked(false); } @@ -886,16 +888,16 @@ public class DomainSettingsFragment extends Fragment { if (defaultNightMode) { // Night mode enabled by default. // Set the icon according to the theme. if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) { - nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.night_mode_enabled_night)); + nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_theme_enabled_night)); } else { - nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.night_mode_enabled_day)); + nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_theme_enabled_day)); } } else { // Night mode disabled by default. // Set the icon according to the theme. if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) { - nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.night_mode_disabled_night)); + nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_theme_disabled_night)); } else { - nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.night_mode_disabled_day)); + nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_theme_disabled_day)); } } @@ -906,9 +908,9 @@ public class DomainSettingsFragment extends Fragment { case DomainsDatabaseHelper.ENABLED: // Set the icon according to the theme. if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) { - nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.night_mode_enabled_night)); + nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_theme_enabled_night)); } else { - nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.night_mode_enabled_day)); + nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_theme_enabled_day)); } // Hide the night mode TextView. @@ -918,9 +920,9 @@ public class DomainSettingsFragment extends Fragment { case DomainsDatabaseHelper.DISABLED: // Set the icon according to the theme. if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) { - nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.night_mode_disabled_night)); + nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_theme_disabled_night)); } else { - nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.night_mode_disabled_day)); + nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_theme_disabled_day)); } // Hide the night mode TextView. @@ -1779,16 +1781,16 @@ public class DomainSettingsFragment extends Fragment { if (defaultNightMode) { // Night mode enabled by default. // Set the icon according to the theme. if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) { - nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.night_mode_enabled_night)); + nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_theme_enabled_night)); } else { - nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.night_mode_enabled_day)); + nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_theme_enabled_day)); } } else { // Night mode disabled by default. // Set the icon according to the theme. if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) { - nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.night_mode_disabled_night)); + nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_theme_disabled_night)); } else { - nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.night_mode_disabled_day)); + nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_theme_disabled_day)); } } @@ -1799,9 +1801,9 @@ public class DomainSettingsFragment extends Fragment { case DomainsDatabaseHelper.ENABLED: // Set the icon according to the theme. if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) { - nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.night_mode_enabled_night)); + nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_theme_enabled_night)); } else { - nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.night_mode_enabled_day)); + nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_theme_enabled_day)); } // Hide `nightModeTextView`. @@ -1811,9 +1813,9 @@ public class DomainSettingsFragment extends Fragment { case DomainsDatabaseHelper.DISABLED: // Set the icon according to the theme. if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) { - nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.night_mode_disabled_night)); + nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_theme_disabled_night)); } else { - nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.night_mode_disabled_day)); + nightModeImageView.setImageDrawable(resources.getDrawable(R.drawable.webview_theme_disabled_day)); } // Hide `nightModeTextView`. diff --git a/app/src/main/java/com/stoutner/privacybrowser/fragments/SettingsFragment.java b/app/src/main/java/com/stoutner/privacybrowser/fragments/SettingsFragment.java index 75f9b31d..6130ece8 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/fragments/SettingsFragment.java +++ b/app/src/main/java/com/stoutner/privacybrowser/fragments/SettingsFragment.java @@ -112,7 +112,7 @@ public class SettingsFragment extends PreferenceFragmentCompat { Preference scrollAppBarPreference = findPreference("scroll_app_bar"); Preference displayAdditionalAppBarIconsPreference = findPreference("display_additional_app_bar_icons"); Preference appThemePreference = findPreference("app_theme"); - Preference nightModePreference = findPreference("night_mode"); + Preference webViewThemePreference = findPreference("webview_theme"); Preference wideViewportPreference = findPreference("wide_viewport"); Preference displayWebpageImagesPreference = findPreference("display_webpage_images"); @@ -157,12 +157,13 @@ public class SettingsFragment extends PreferenceFragmentCompat { assert scrollAppBarPreference != null; assert displayAdditionalAppBarIconsPreference != null; assert appThemePreference != null; - assert nightModePreference != null; + assert webViewThemePreference != null; assert wideViewportPreference != null; assert displayWebpageImagesPreference != null; - // Set the hide app bar preference dependency. + // Set the preference dependencies. hideAppBarPreference.setDependency("full_screen_browsing_mode"); + domStoragePreference.setDependency("javascript"); // Get strings from the preferences. String userAgentName = savedPreferences.getString("user_agent", getString(R.string.user_agent_default_value)); @@ -173,26 +174,21 @@ public class SettingsFragment extends PreferenceFragmentCompat { // Get booleans that are used in multiple places from the preferences. boolean javaScriptEnabled = savedPreferences.getBoolean("javascript", false); boolean firstPartyCookiesEnabled = savedPreferences.getBoolean("first_party_cookies", false); - boolean thirdPartyCookiesEnabled = savedPreferences.getBoolean("third_party_cookies", false); boolean fanboyAnnoyanceListEnabled = savedPreferences.getBoolean("fanboys_annoyance_list", true); boolean fanboySocialBlockingEnabled = savedPreferences.getBoolean("fanboys_social_blocking_list", true); boolean fullScreenBrowsingMode = savedPreferences.getBoolean("full_screen_browsing_mode", false); boolean clearEverything = savedPreferences.getBoolean("clear_everything", true); - boolean nightMode = savedPreferences.getBoolean("night_mode", false); // Only enable the third-party cookies preference if first-party cookies are enabled and API >= 21. thirdPartyCookiesPreference.setEnabled(firstPartyCookiesEnabled && (Build.VERSION.SDK_INT >= 21)); - // Only enable the DOM storage preference if either JavaScript or Night Mode is enabled. - domStoragePreference.setEnabled(javaScriptEnabled || nightMode); - // Remove the form data preferences if the API is >= 26 as they no longer do anything. if (Build.VERSION.SDK_INT >= 26) { - // Get the categories. + // Get handles for the categories. PreferenceCategory privacyCategory = findPreference("privacy"); PreferenceCategory clearAndExitCategory = findPreference("clear_and_exit"); - // Remove the lint warnings below that the preference categories might be null. + // Remove the incorrect lint warnings below that the preference categories might be null. assert privacyCategory != null; assert clearAndExitCategory != null; @@ -335,22 +331,25 @@ public class SettingsFragment extends PreferenceFragmentCompat { fontSizePreference.setSummary(savedPreferences.getString("font_size", getString(R.string.font_size_default_value)) + "%"); - // Get the theme string arrays. + // Get the app theme string arrays. String[] appThemeEntriesStringArray = resources.getStringArray(R.array.app_theme_entries); String[] appThemeEntryValuesStringArray = resources.getStringArray(R.array.app_theme_entry_values); - // Get the current theme. + // Get the current app theme. String currentAppTheme = savedPreferences.getString("app_theme", getString(R.string.app_theme_default_value)); - // Define a theme entry number. + // Define an app theme entry number. int appThemeEntryNumber; - // Get the theme entry number that matches the current theme. A switch statement cannot be used because the theme entry values string array is not a compile time constant. + // Get the app theme entry number that matches the current app theme. A switch statement cannot be used because the theme entry values string array is not a compile time constant. if (currentAppTheme.equals(appThemeEntryValuesStringArray[1])) { // The light theme is selected. + // Store the app theme entry number. appThemeEntryNumber = 1; } else if (currentAppTheme.equals(appThemeEntryValuesStringArray[2])) { // The dark theme is selected. + // Store the app theme entry number. appThemeEntryNumber = 2; } else { // The system default theme is selected. + // Store the app theme entry number. appThemeEntryNumber = 0; } @@ -358,11 +357,46 @@ public class SettingsFragment extends PreferenceFragmentCompat { appThemePreference.setSummary(appThemeEntriesStringArray[appThemeEntryNumber]); - // Disable the JavaScript preference if Night Mode is enabled. JavaScript will be enabled for all web pages. - javaScriptPreference.setEnabled(!nightMode); + // Get the WebView theme string arrays. + String[] webViewThemeEntriesStringArray = resources.getStringArray(R.array.webview_theme_entries); + String[] webViewThemeEntryValuesStringArray = resources.getStringArray(R.array.webview_theme_entry_values); + + // Hide the WebView theme preference if the API < 21. + if (Build.VERSION.SDK_INT < 21) { // The device is running API 19. + // Get a handle for the general category. + PreferenceCategory generalCategory = findPreference("general"); + + // Remove the incorrect lint warning below that the general preference category might be null. + assert generalCategory != null; + + // Remove the WebView theme preference. + generalCategory.removePreference(webViewThemePreference); + } else { // The device is running API >= 21 + // Get the current WebView theme. + String currentWebViewTheme = savedPreferences.getString("webview_theme", getString(R.string.webview_theme_default_value)); + + // Define a WebView theme entry number. + int webViewThemeEntryNumber; + + // Get the WebView theme entry number that matches the current WebView theme. A switch statement cannot be used because the theme entry values string array is not a compile time constant. + if (currentWebViewTheme.equals(webViewThemeEntryValuesStringArray[1])) { // The light theme is selected. + // Store the WebView theme entry number. + webViewThemeEntryNumber = 1; + } else if (currentWebViewTheme.equals(webViewThemeEntryValuesStringArray[2])) { // The dark theme is selected. + // Store the WebView theme entry number. + webViewThemeEntryNumber = 2; + } else { // The system default theme is selected. + // Store the WebView theme entry number. + webViewThemeEntryNumber = 0; + } + + // Set the current theme as the summary text for the preference. + webViewThemePreference.setSummary(webViewThemeEntriesStringArray[webViewThemeEntryNumber]); + } + // Set the JavaScript icon. - if (javaScriptEnabled || nightMode) { + if (javaScriptEnabled) { javaScriptPreference.setIcon(R.drawable.javascript_enabled); } else { javaScriptPreference.setIcon(R.drawable.privacy_mode); @@ -381,7 +415,7 @@ public class SettingsFragment extends PreferenceFragmentCompat { // Set the third party cookies icon. if (firstPartyCookiesEnabled && Build.VERSION.SDK_INT >= 21) { - if (thirdPartyCookiesEnabled) { + if (savedPreferences.getBoolean("third_party_cookies", false)) { thirdPartyCookiesPreference.setIcon(R.drawable.cookies_warning); } else { if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) { @@ -399,7 +433,7 @@ public class SettingsFragment extends PreferenceFragmentCompat { } // Set the DOM storage icon. - if (javaScriptEnabled || nightMode) { // The preference is enabled. + if (javaScriptEnabled) { // The preference is enabled. if (savedPreferences.getBoolean("dom_storage", false)) { // DOM storage is enabled. domStoragePreference.setIcon(R.drawable.dom_storage_enabled); } else { // DOM storage is disabled. @@ -871,21 +905,6 @@ public class SettingsFragment extends PreferenceFragmentCompat { } } - // Set the night mode preference icon. - if (nightMode) { - if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) { - nightModePreference.setIcon(R.drawable.night_mode_enabled_night); - } else { - nightModePreference.setIcon(R.drawable.night_mode_enabled_day); - } - } else { - if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) { - nightModePreference.setIcon(R.drawable.night_mode_disabled_night); - } else { - nightModePreference.setIcon(R.drawable.night_mode_disabled_day); - } - } - // Set the wide viewport preference icon. if (savedPreferences.getBoolean("wide_viewport", true)) { if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) { @@ -1822,55 +1841,27 @@ public class SettingsFragment extends PreferenceFragmentCompat { currentThemeStatus = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK; break; - case "night_mode": - // Store the current night mode status. - boolean currentNightModeBoolean = sharedPreferences.getBoolean("night_mode", false); - boolean currentJavaScriptBoolean = sharedPreferences.getBoolean("javascript", false); + case "webview_theme": + // Get the new WebView theme. + String newWebViewTheme = sharedPreferences.getString("webview_theme", getString(R.string.webview_theme_default_value)); - // Update the icon. - if (currentNightModeBoolean) { - if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) { - nightModePreference.setIcon(R.drawable.night_mode_enabled_night); - } else { - nightModePreference.setIcon(R.drawable.night_mode_enabled_day); - } - } else { - if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) { - nightModePreference.setIcon(R.drawable.night_mode_disabled_night); - } else { - nightModePreference.setIcon(R.drawable.night_mode_disabled_day); - } - } - - // Update the status of `javaScriptPreference` and `domStoragePreference`. - javaScriptPreference.setEnabled(!currentNightModeBoolean); - domStoragePreference.setEnabled(currentNightModeBoolean || currentJavaScriptBoolean); + // Define a new WebView theme entry number. + int newWebViewThemeEntryNumber; - // Update the `javaScriptPreference` icon. - if (currentNightModeBoolean || currentJavaScriptBoolean) { - javaScriptPreference.setIcon(R.drawable.javascript_enabled); - } else { - javaScriptPreference.setIcon(R.drawable.privacy_mode); + // Get the webView theme entry number that matches the new WebView theme. A switch statement cannot be used because the theme entry values string array is not a compile time constant. + if (newWebViewTheme.equals(webViewThemeEntriesStringArray[1])) { // The light theme is selected. + // Store the new WebView theme entry number. + newWebViewThemeEntryNumber = 1; + } else if (newWebViewTheme.equals(webViewThemeEntryValuesStringArray[2])) { // The dark theme is selected. + // Store the WebView theme entry number. + newWebViewThemeEntryNumber = 2; + } else { // The system default theme is selected. + // Store the WebView theme entry number. + newWebViewThemeEntryNumber = 0; } - // Update the DOM storage preference icon. - if (currentNightModeBoolean || currentJavaScriptBoolean) { // The preference is enabled. - if (sharedPreferences.getBoolean("dom_storage", false)) { // DOM storage is enabled. - domStoragePreference.setIcon(R.drawable.dom_storage_enabled); - } else { // DOM storage is disabled. - if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) { - domStoragePreference.setIcon(R.drawable.dom_storage_disabled_night); - } else { - domStoragePreference.setIcon(R.drawable.dom_storage_disabled_day); - } - } - } else { // The preference is disabled. The icon should be ghosted. - if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) { - domStoragePreference.setIcon(R.drawable.dom_storage_ghosted_night); - } else { - domStoragePreference.setIcon(R.drawable.dom_storage_ghosted_day); - } - } + // Set the current theme as the summary text for the preference. + webViewThemePreference.setSummary(webViewThemeEntriesStringArray[newWebViewThemeEntryNumber]); break; case "wide_viewport": diff --git a/app/src/main/res/drawable/night_mode_disabled_day.xml b/app/src/main/res/drawable/night_mode_disabled_day.xml deleted file mode 100644 index 64b69b3f..00000000 --- a/app/src/main/res/drawable/night_mode_disabled_day.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - diff --git a/app/src/main/res/drawable/night_mode_disabled_night.xml b/app/src/main/res/drawable/night_mode_disabled_night.xml deleted file mode 100644 index 0ee9accd..00000000 --- a/app/src/main/res/drawable/night_mode_disabled_night.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - diff --git a/app/src/main/res/drawable/night_mode_enabled_day.xml b/app/src/main/res/drawable/night_mode_enabled_day.xml deleted file mode 100644 index ffbec3f7..00000000 --- a/app/src/main/res/drawable/night_mode_enabled_day.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - diff --git a/app/src/main/res/drawable/night_mode_enabled_night.xml b/app/src/main/res/drawable/night_mode_enabled_night.xml deleted file mode 100644 index 55d63136..00000000 --- a/app/src/main/res/drawable/night_mode_enabled_night.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - diff --git a/app/src/main/res/drawable/webview_theme_disabled_day.xml b/app/src/main/res/drawable/webview_theme_disabled_day.xml new file mode 100644 index 00000000..64b69b3f --- /dev/null +++ b/app/src/main/res/drawable/webview_theme_disabled_day.xml @@ -0,0 +1,19 @@ + + + + + + + + diff --git a/app/src/main/res/drawable/webview_theme_disabled_night.xml b/app/src/main/res/drawable/webview_theme_disabled_night.xml new file mode 100644 index 00000000..0ee9accd --- /dev/null +++ b/app/src/main/res/drawable/webview_theme_disabled_night.xml @@ -0,0 +1,19 @@ + + + + + + + + diff --git a/app/src/main/res/drawable/webview_theme_enabled_day.xml b/app/src/main/res/drawable/webview_theme_enabled_day.xml new file mode 100644 index 00000000..ffbec3f7 --- /dev/null +++ b/app/src/main/res/drawable/webview_theme_enabled_day.xml @@ -0,0 +1,19 @@ + + + + + + + + diff --git a/app/src/main/res/drawable/webview_theme_enabled_night.xml b/app/src/main/res/drawable/webview_theme_enabled_night.xml new file mode 100644 index 00000000..55d63136 --- /dev/null +++ b/app/src/main/res/drawable/webview_theme_enabled_night.xml @@ -0,0 +1,19 @@ + + + + + + + + diff --git a/app/src/main/res/layout/domain_settings_fragment.xml b/app/src/main/res/layout/domain_settings_fragment.xml index dd2e8c52..710c0c09 100644 --- a/app/src/main/res/layout/domain_settings_fragment.xml +++ b/app/src/main/res/layout/domain_settings_fragment.xml @@ -560,7 +560,7 @@ android:layout_marginTop="1dp" android:layout_marginEnd="10dp" android:layout_gravity="center_vertical" - android:contentDescription="@string/night_mode" /> + android:contentDescription="@string/webview_theme" /> Hell Dunkel - Nacht-Modus - Aktivieren des Nacht-Modus aktiviert JavaScript für alle Webseiten. Breiter Anzeigebereich Wird der breite Anzeigebereich verwendet, werden manche Webseiten eher wie am Desktop (Standrechner, Laptop) angezeigt. Webseiten-Bilder anzeigen diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 1152e50c..e2014c4f 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -589,8 +589,6 @@ Claro Oscuro - Modo noche - Activar el modo noche también activará javascript para todas las páginas web. Vista amplia El uso de una vista amplia hace que el diseño de algunas páginas web se parezca más al sitio de escritorio. Mostrar imágenes de la página web diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 7eae34c7..d3c32165 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -591,8 +591,6 @@ Clair Sombre - Mode nuit - L\'activation du mode nuit activera également JavaScript pour toutes les pages Web. Large fenêtre L\'utilisation d\'une fenêtre d\'affichage large fait que la mise en page de certaines pages Web ressemble davantage au site de bureau. Afficher images Web diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 874c6972..8208d547 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -589,8 +589,6 @@ Chiaro Scuro - Modalità Notte - L\'abilitazione della modalità notte attiva anche JavaScript per tutte le pagine web. Finestra grande L\'utilizzo di una finestra grande permette la visualizzazione di alcune pagine web come in modalità desktop. Mostra immagini delle pagine web diff --git a/app/src/main/res/values-night-v23/styles.xml b/app/src/main/res/values-night-v23/styles.xml index 12616d42..e9035a5a 100644 --- a/app/src/main/res/values-night-v23/styles.xml +++ b/app/src/main/res/values-night-v23/styles.xml @@ -75,6 +75,7 @@ @drawable/home_enabled_night @drawable/search_enabled_night @drawable/user_agent_night + @drawable/webview_theme_enabled_night