X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyBrowserAndroid.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Ffragments%2FSettingsFragment.java;h=bac86c1e1eb3dda46e0346bce93c2d97fba8f1c6;hp=306f1e2c57a0c3465e718f21f62a5432e152a48f;hb=ab11ca2de00c56982e46627c8e7fc670462b0b3c;hpb=1d656c562831f535aa33903d44198dd890393f4f 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 306f1e2c..bac86c1e 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/fragments/SettingsFragment.java +++ b/app/src/main/java/com/stoutner/privacybrowser/fragments/SettingsFragment.java @@ -143,7 +143,7 @@ public class SettingsFragment extends PreferenceFragmentCompat { searchPreference = findPreference("search"); searchCustomURLPreference = findPreference("search_custom_url"); proxyPreference = findPreference("proxy"); - proxyCustomUrlPreference = findPreference("proxy_custom_url"); + proxyCustomUrlPreference = findPreference(getString(R.string.proxy_custom_url_key)); fullScreenBrowsingModePreference = findPreference("full_screen_browsing_mode"); hideAppBarPreference = findPreference("hide_app_bar"); clearEverythingPreference = findPreference("clear_everything"); @@ -157,7 +157,7 @@ public class SettingsFragment extends PreferenceFragmentCompat { openIntentsInNewTabPreference = findPreference("open_intents_in_new_tab"); swipeToRefreshPreference = findPreference("swipe_to_refresh"); downloadWithExternalAppPreference = findPreference(getString(R.string.download_with_external_app_key)); - scrollAppBarPreference = findPreference("scroll_app_bar"); + scrollAppBarPreference = findPreference(getString(R.string.scroll_app_bar_key)); bottomAppBarPreference = findPreference(getString(R.string.bottom_app_bar_key)); displayAdditionalAppBarIconsPreference = findPreference(getString(R.string.display_additional_app_bar_icons_key)); appThemePreference = findPreference("app_theme"); @@ -316,11 +316,7 @@ public class SettingsFragment extends PreferenceFragmentCompat { break; case ProxyHelper.TOR: - if (Build.VERSION.SDK_INT == 19) { // Proxying through SOCKS doesn't work on Android KitKat. - proxyPreference.setSummary(getString(R.string.tor_enabled_kitkat)); - } else { - proxyPreference.setSummary(getString(R.string.tor_enabled)); - } + proxyPreference.setSummary(getString(R.string.tor_enabled)); break; case ProxyHelper.I2P: @@ -333,10 +329,10 @@ public class SettingsFragment extends PreferenceFragmentCompat { } // Set the summary text for the custom proxy URL. - proxyCustomUrlPreference.setSummary(sharedPreferences.getString("proxy_custom_url", getString(R.string.proxy_custom_url_default_value))); + proxyCustomUrlPreference.setSummary(sharedPreferences.getString(getString(R.string.proxy_custom_url_key), getString(R.string.proxy_custom_url_default_value))); // Only enable the custom proxy URL if a custom proxy is selected. - proxyCustomUrlPreference.setEnabled(proxyString.equals("Custom")); + proxyCustomUrlPreference.setEnabled(proxyString.equals(ProxyHelper.CUSTOM)); // Set the status of the clear and exit preferences. @@ -403,20 +399,8 @@ public class SettingsFragment extends PreferenceFragmentCompat { webViewThemeEntryNumber = 0; } - // Set the visibility of the WebView theme preference. - 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 - // Set the current theme as the summary text for the preference. - webViewThemePreference.setSummary(webViewThemeEntriesStringArray[webViewThemeEntryNumber]); - } + // Set the current theme as the summary text for the preference. + webViewThemePreference.setSummary(webViewThemeEntriesStringArray[webViewThemeEntryNumber]); // Set the JavaScript icon. @@ -689,7 +673,7 @@ public class SettingsFragment extends PreferenceFragmentCompat { } // Set the Proxy icons according to the theme and status. - if (proxyString.equals("None")) { // Proxying is disabled. + if (proxyString.equals(ProxyHelper.NONE)) { // Proxying is disabled. if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) { // Dark theme. // Set the main proxy icon to be disabled. proxyPreference.setIcon(R.drawable.proxy_disabled_night); @@ -877,7 +861,7 @@ public class SettingsFragment extends PreferenceFragmentCompat { } // Set the scroll app bar preference icon. - if (sharedPreferences.getBoolean("scroll_app_bar", true)) { + if (sharedPreferences.getBoolean(getString(R.string.scroll_app_bar_key), true)) { if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) { scrollAppBarPreference.setIcon(R.drawable.app_bar_enabled_day); } else { @@ -1441,11 +1425,7 @@ public class SettingsFragment extends PreferenceFragmentCompat { break; case ProxyHelper.TOR: - if (Build.VERSION.SDK_INT == 19) { // Proxying through SOCKS doesn't work on Android KitKat. - proxyPreference.setSummary(context.getString(R.string.tor_enabled_kitkat)); - } else { - proxyPreference.setSummary(context.getString(R.string.tor_enabled)); - } + proxyPreference.setSummary(context.getString(R.string.tor_enabled)); break; case ProxyHelper.I2P: @@ -1458,10 +1438,10 @@ public class SettingsFragment extends PreferenceFragmentCompat { } // Update the status of the custom URL preference. - proxyCustomUrlPreference.setEnabled(currentProxyString.equals("Custom")); + proxyCustomUrlPreference.setEnabled(currentProxyString.equals(ProxyHelper.CUSTOM)); // Update the icons. - if (currentProxyString.equals("None")) { // Proxying is disabled. + if (currentProxyString.equals(ProxyHelper.NONE)) { // Proxying is disabled. if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) { // Dark theme. // Set the main proxy icon to be disabled proxyPreference.setIcon(R.drawable.proxy_disabled_night); @@ -1502,7 +1482,7 @@ public class SettingsFragment extends PreferenceFragmentCompat { case "proxy_custom_url": // Set the summary text for the proxy custom URL. - proxyCustomUrlPreference.setSummary(sharedPreferences.getString("proxy_custom_url", context.getString(R.string.proxy_custom_url_default_value))); + proxyCustomUrlPreference.setSummary(sharedPreferences.getString(context.getString(R.string.proxy_custom_url_key), context.getString(R.string.proxy_custom_url_default_value))); break; case "full_screen_browsing_mode": @@ -1770,7 +1750,7 @@ public class SettingsFragment extends PreferenceFragmentCompat { case "scroll_app_bar": // Update the icon. - if (sharedPreferences.getBoolean("scroll_app_bar", true)) { + if (sharedPreferences.getBoolean(context.getString(R.string.scroll_app_bar_key), true)) { if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) { scrollAppBarPreference.setIcon(R.drawable.app_bar_enabled_day); } else {