+ } else {
+ clearFormDataPreference.setIcon(R.drawable.form_data_warning);
+ }
+ break;
+
+ case "clear_logcat":
+ // Update the icon.
+ if (sharedPreferences.getBoolean(getString(R.string.clear_logcat_key), true)) {
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
+ clearLogcatPreference.setIcon(R.drawable.bug_cleared_day);
+ } else {
+ clearLogcatPreference.setIcon(R.drawable.bug_cleared_night);
+ }
+ } else {
+ clearLogcatPreference.setIcon(R.drawable.bug_warning);
+ }
+ break;
+
+ case "clear_cache":
+ // Update the icon.
+ if (sharedPreferences.getBoolean("clear_cache", true)) {
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+ clearCachePreference.setIcon(R.drawable.cache_cleared_night);
+ } else {
+ clearCachePreference.setIcon(R.drawable.cache_cleared_day);
+ }
+ } else {
+ clearCachePreference.setIcon(R.drawable.cache_warning);
+ }
+ break;
+
+ case "homepage":
+ // Set the new homepage URL as the summary text for the Homepage preference.
+ homepagePreference.setSummary(sharedPreferences.getString("homepage", getString(R.string.homepage_default_value)));
+ break;
+
+ case "download_location":
+ // Get the new download location.
+ String newDownloadLocationString = sharedPreferences.getString("download_location", getString(R.string.download_location_default_value));
+
+ // Check to see if a download custom location is selected.
+ if (newDownloadLocationString.equals(downloadLocationEntryValuesStringArray[3])) { // A download custom location is selected.
+ // Set the download location summary text to be `Custom`.
+ downloadLocationPreference.setSummary(downloadLocationEntriesStringArray[3]);
+
+ // Enable the download custom location preference.
+ downloadCustomLocationPreference.setEnabled(true);
+ } else { // A download custom location is not selected.
+ // Set the download location summary text to be the download location.
+ downloadLocationPreference.setSummary(downloadLocationHelper.getDownloadLocation(context));
+
+ // Disable the download custom location.
+ downloadCustomLocationPreference.setEnabled(newDownloadLocationString.equals(downloadLocationEntryValuesStringArray[3]));
+ }
+
+ // Update the download custom location icon.
+ if (downloadCustomLocationPreference.isEnabled()) {
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+ downloadCustomLocationPreference.setIcon(R.drawable.downloads_enabled_night);
+ } else {
+ downloadCustomLocationPreference.setIcon(R.drawable.downloads_enabled_day);
+ }
+ } else {
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+ downloadCustomLocationPreference.setIcon(R.drawable.downloads_ghosted_night);
+ } else {
+ downloadCustomLocationPreference.setIcon(R.drawable.downloads_ghosted_day);
+ }
+ }
+ break;
+
+ case "download_custom_location":
+ // Set the new download custom location as the summary text for the preference.
+ downloadCustomLocationPreference.setSummary(sharedPreferences.getString("download_custom_location", getString(R.string.download_custom_location_default_value)));
+ break;
+
+ case "font_size":
+ // Update the font size summary text.
+ fontSizePreference.setSummary(sharedPreferences.getString("font_size", getString(R.string.font_size_default_value)) + "%");
+ break;
+
+ case "open_intents_in_new_tab":
+ // Update the icon.
+ if (sharedPreferences.getBoolean("open_intents_in_new_tab", true)) {
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+ openIntentsInNewTabPreference.setIcon(R.drawable.tab_enabled_night);
+ } else {
+ openIntentsInNewTabPreference.setIcon(R.drawable.tab_enabled_day);
+ }
+ } else {
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+ openIntentsInNewTabPreference.setIcon(R.drawable.tab_disabled_night);
+ } else {
+ openIntentsInNewTabPreference.setIcon(R.drawable.tab_disabled_day);
+ }
+ }
+ break;
+
+ case "swipe_to_refresh":
+ // Update the icon.
+ if (sharedPreferences.getBoolean("swipe_to_refresh", true)) {
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+ swipeToRefreshPreference.setIcon(R.drawable.refresh_enabled_night);
+ } else {
+ swipeToRefreshPreference.setIcon(R.drawable.refresh_enabled_day);
+ }
+ } else {
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+ swipeToRefreshPreference.setIcon(R.drawable.refresh_disabled_night);
+ } else {
+ swipeToRefreshPreference.setIcon(R.drawable.refresh_disabled_day);
+ }
+ }
+ break;
+
+ case "scroll_app_bar":
+ // Update the icon.
+ if (sharedPreferences.getBoolean("scroll_app_bar", true)) {
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+ scrollAppBarPreference.setIcon(R.drawable.app_bar_enabled_night);
+ } else {
+ scrollAppBarPreference.setIcon(R.drawable.app_bar_enabled_day);
+ }
+ } else {
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+ scrollAppBarPreference.setIcon(R.drawable.app_bar_disabled_night);
+ } else {
+ scrollAppBarPreference.setIcon(R.drawable.app_bar_disabled_day);
+ }
+ }
+ break;
+
+ case "display_additional_app_bar_icons":
+ // Update the icon.
+ if (sharedPreferences.getBoolean("display_additional_app_bar_icons", false)) {
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+ displayAdditionalAppBarIconsPreference.setIcon(R.drawable.more_enabled_night);
+ } else {
+ displayAdditionalAppBarIconsPreference.setIcon(R.drawable.more_enabled_day);
+ }
+ } else {
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+ displayAdditionalAppBarIconsPreference.setIcon(R.drawable.more_disabled_night);
+ } else {
+ displayAdditionalAppBarIconsPreference.setIcon(R.drawable.more_disabled_day);
+ }
+ }
+ break;
+
+ case "app_theme":
+ // Get the new theme.
+ String newAppTheme = sharedPreferences.getString("app_theme", getString(R.string.app_theme_default_value));
+
+ // Update the system according to the new theme. A switch statement cannot be used because the theme entry values string array is not a compile time constant.
+ if (newAppTheme.equals(appThemeEntryValuesStringArray[1])) { // The light theme is selected.
+ // Update the theme preference summary text.
+ appThemePreference.setSummary(appThemeEntriesStringArray[1]);
+
+ // Apply the new theme.
+ AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
+ } else if (newAppTheme.equals(appThemeEntryValuesStringArray[2])) { // The dark theme is selected.
+ // Update the theme preference summary text.
+ appThemePreference.setSummary(appThemeEntriesStringArray[2]);
+
+ // Apply the new theme.
+ AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
+ } else { // The system default theme is selected.
+ // Update the theme preference summary text.
+ appThemePreference.setSummary(appThemeEntriesStringArray[0]);
+
+ // Apply the new theme.
+ if (Build.VERSION.SDK_INT >= 28) { // The system default theme is supported.
+ // Follow the system default theme.
+ AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM);
+ } else {// The system default theme is not supported.
+ // Follow the battery saver mode.
+ AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY);
+ }
+ }
+
+ // Update the current theme status.
+ currentThemeStatus = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
+ break;
+
+ case "webview_theme":
+ // Get the new WebView theme.
+ String newWebViewTheme = sharedPreferences.getString("webview_theme", getString(R.string.webview_theme_default_value));
+
+ // Define a new WebView theme entry number.
+ int newWebViewThemeEntryNumber;
+
+ // 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 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;