From: Soren Stoutner Date: Wed, 7 Jun 2023 22:01:17 +0000 (-0700) Subject: Enable WebView algorithmic darkening on API 24-28. https://redmine.stoutner.com... X-Git-Tag: v3.15~1 X-Git-Url: https://gitweb.stoutner.com/?a=commitdiff_plain;h=fb1d23a702622f51fde491f8b868062603f4ccad;p=PrivacyBrowserAndroid.git Enable WebView algorithmic darkening on API 24-28. https://redmine.stoutner.com/issues/1012 --- diff --git a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.kt b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.kt index 96cd882b..ffa89265 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.kt +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.kt @@ -1075,9 +1075,6 @@ class MainWebViewActivity : AppCompatActivity(), CreateBookmarkDialog.CreateBook // Disable the clear form data menu item if the API >= 26 so that the status of the main Clear Data is calculated correctly. optionsClearFormDataMenuItem.isEnabled = Build.VERSION.SDK_INT < 26 - // Only display the dark WebView menu item if the API >= 29. - optionsDarkWebViewMenuItem.isVisible = Build.VERSION.SDK_INT >= 29 - // Set the status of the additional app bar icons. Setting the refresh menu item to `SHOW_AS_ACTION_ALWAYS` makes it appear even on small devices like phones. if (displayAdditionalAppBarIcons) { // Display the additional icons. optionsRefreshMenuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS) @@ -1159,8 +1156,8 @@ class MainWebViewActivity : AppCompatActivity(), CreateBookmarkDialog.CreateBook // Enable dark WebView if night mode is enabled. optionsDarkWebViewMenuItem.isEnabled = (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) - // Set the checkbox status for dark WebView if the device is running API >= 29 and algorithmic darkening is supported. - if ((Build.VERSION.SDK_INT >= 29) && WebViewFeature.isFeatureSupported(WebViewFeature.ALGORITHMIC_DARKENING)) + // Set the checkbox status for dark WebView if algorithmic darkening is supported. + if (WebViewFeature.isFeatureSupported(WebViewFeature.ALGORITHMIC_DARKENING)) optionsDarkWebViewMenuItem.isChecked = WebSettingsCompat.isAlgorithmicDarkeningAllowed(currentWebView!!.settings) } @@ -1918,7 +1915,7 @@ class MainWebViewActivity : AppCompatActivity(), CreateBookmarkDialog.CreateBook R.id.dark_webview -> { // Dark WebView. // Toggle dark WebView if supported. - if ((Build.VERSION.SDK_INT >= 29) && WebViewFeature.isFeatureSupported(WebViewFeature.ALGORITHMIC_DARKENING)) + if (WebViewFeature.isFeatureSupported(WebViewFeature.ALGORITHMIC_DARKENING)) WebSettingsCompat.setAlgorithmicDarkeningAllowed(currentWebView!!.settings, !WebSettingsCompat.isAlgorithmicDarkeningAllowed(currentWebView!!.settings) ) @@ -3238,8 +3235,8 @@ class MainWebViewActivity : AppCompatActivity(), CreateBookmarkDialog.CreateBook } } - // Set the WebView theme if device is running API >= 29 and algorithmic darkening is supported. - if ((Build.VERSION.SDK_INT >= 29) && WebViewFeature.isFeatureSupported(WebViewFeature.ALGORITHMIC_DARKENING)) { + // Set the WebView theme if algorithmic darkening is supported. + if (WebViewFeature.isFeatureSupported(WebViewFeature.ALGORITHMIC_DARKENING)) { // Set the WebView theme. when (webViewThemeInt) { // Set the WebView theme. @@ -3358,8 +3355,8 @@ class MainWebViewActivity : AppCompatActivity(), CreateBookmarkDialog.CreateBook else -> nestedScrollWebView.settings.userAgentString = userAgentDataArray[userAgentArrayPosition] } - // Set the WebView theme if the device is running API >= 29 and algorithmic darkening is supported. - if ((Build.VERSION.SDK_INT >= 29) && WebViewFeature.isFeatureSupported(WebViewFeature.ALGORITHMIC_DARKENING)) { + // Set the WebView theme if algorithmic darkening is supported. + if (WebViewFeature.isFeatureSupported(WebViewFeature.ALGORITHMIC_DARKENING)) { // Set the WebView theme. when (defaultWebViewTheme) { // The light theme is selected. Turn off algorithmic darkening. @@ -4443,8 +4440,8 @@ class MainWebViewActivity : AppCompatActivity(), CreateBookmarkDialog.CreateBook // Get the WebView theme entry values string array. val webViewThemeEntryValuesStringArray = resources.getStringArray(R.array.webview_theme_entry_values) - // Set the WebView theme if device is running API >= 29 and algorithmic darkening is supported. - if (Build.VERSION.SDK_INT >= 29 && WebViewFeature.isFeatureSupported(WebViewFeature.ALGORITHMIC_DARKENING)) { + // Set the WebView theme if algorithmic darkening is supported. + if (WebViewFeature.isFeatureSupported(WebViewFeature.ALGORITHMIC_DARKENING)) { // Set the WebView them. A switch statement cannot be used because the WebView theme entry values string array is not a compile time constant. if (webViewTheme == webViewThemeEntryValuesStringArray[1]) { // The light theme is selected. // Turn off algorithmic darkening. diff --git a/app/src/main/java/com/stoutner/privacybrowser/fragments/DomainSettingsFragment.kt b/app/src/main/java/com/stoutner/privacybrowser/fragments/DomainSettingsFragment.kt index ee7bc883..2687adc7 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/fragments/DomainSettingsFragment.kt +++ b/app/src/main/java/com/stoutner/privacybrowser/fragments/DomainSettingsFragment.kt @@ -269,10 +269,6 @@ class DomainSettingsFragment : Fragment() { if (Build.VERSION.SDK_INT >= 26) formDataLinearLayout.visibility = View.GONE - // Hide the WebView theme linear layout if the API < 29. - if (Build.VERSION.SDK_INT < 29) - webViewThemeLinearLayout.visibility = View.GONE - // Initialize the database handler. val domainsDatabaseHelper = DomainsDatabaseHelper(requireContext()) diff --git a/app/src/main/java/com/stoutner/privacybrowser/fragments/SettingsFragment.kt b/app/src/main/java/com/stoutner/privacybrowser/fragments/SettingsFragment.kt index 7935a8a1..397dad08 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/fragments/SettingsFragment.kt +++ b/app/src/main/java/com/stoutner/privacybrowser/fragments/SettingsFragment.kt @@ -191,15 +191,6 @@ class SettingsFragment : PreferenceFragmentCompat() { clearAndExitCategory.removePreference(clearFormDataPreference) } - // Remove the WebView theme preference if the API < 29. - if (Build.VERSION.SDK_INT < 29) { - // Get a handle for the general category. - val generalCategory = findPreference(getString(R.string.general_category_key))!! - - // Remove the WebView theme preference. - generalCategory.removePreference(webViewThemePreference) - } - // Only enable Fanboy's social blocking list preference if Fanboy's annoyance list is disabled. fanboySocialBlockingListPreference.isEnabled = !fanboyAnnoyanceListEnabled diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 8799d33a..16087e37 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -273,6 +273,8 @@ Nach Datenbank-ID sortiert. Nach Anzeige-Reihenfolge sortiert. Databank-ID: + Verzeichnis-ID: + \u0020 – %1$d Ordner: Übergeordneter Ordner: Sortierung: diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index e313dfef..076d8109 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -269,6 +269,7 @@ Ordina per database ID. Ordina come visualizzato. ID Database: + \u0020 – %1$d Cartella: Cartella superiore: Ordine di visualizzazione: diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index f3b94816..477751d6 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -266,6 +266,8 @@ Сортировать по ID базы данных. Сортировать по порядку отображения. ID базы данных: + ID папки: + \u0020 – %1$d Папка: Родительская папка: Порядок отображения: