+ // Apply the new theme.
+ AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
+ break;
+
+ case 2:
+ // Update the theme preference summary text.
+ appThemePreference.setSummary(appThemeEntriesStringArray[2]);
+
+ // Apply the new theme.
+ AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
+ break;
+ }
+
+ // Disable the WebView theme preference if the API >= 33 and the app theme is set to light.
+ webViewThemePreference.setEnabled((Build.VERSION.SDK_INT < 33) || (appThemeEntryNumber != 1));
+
+ // Get the WebView theme.
+ String webViewTheme = sharedPreferences.getString(context.getString(R.string.webview_theme_key), context.getString(R.string.webview_theme_default_value));
+
+ // Declare a WebView theme entry number.
+ int webViewThemeEntryNumber;
+
+ // 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 (webViewTheme.equals(webViewThemeEntriesStringArray[1])) { // The light theme is selected.
+ // Store the WebView theme entry number.
+ webViewThemeEntryNumber = 1;
+ } else if (webViewTheme.equals(webViewThemeEntryValuesStringArray[2])) { // The dark theme is selected.
+ // Store the WebView theme entry number.
+ webViewThemeEntryNumber = 2;