+ fontSizePreference.setSummary(savedPreferences.getString("font_size", getString(R.string.font_size_default_value)) + "%");
+
+
+ // 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 app theme.
+ String currentAppTheme = savedPreferences.getString("app_theme", getString(R.string.app_theme_default_value));
+
+ // Define an app theme entry number.
+ int appThemeEntryNumber;
+
+ // 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;
+ }
+
+ // Set the current theme as the summary text for the preference.
+ appThemePreference.setSummary(appThemeEntriesStringArray[appThemeEntryNumber]);
+
+
+ // 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]);
+ }