javaScriptEnabledSearchCustomURLPreference.setEnabled(javaScriptEnabledSearchString.equals("Custom URL"));
- // Set the homepage URL as the summary text for the Homepage preference when the preference screen is loaded. The default is "https://www.duckduckgo.com".
+ // Set the homepage URL as the summary text for the `Homepage` preference when the preference screen is loaded. The default is `https://www.duckduckgo.com`.
final Preference homepagePreference = findPreference("homepage");
homepagePreference.setSummary(savedPreferences.getString("homepage", "https://www.duckduckgo.com"));
+ // Set the default font size as the summary text for the `Default Font Size` preference when the preference screen is loaded. The default is `100`.
+ final Preference defaultFontSizePreference = findPreference("default_font_size");
+ String defaultFontSizeString = savedPreferences.getString("default_font_size", "100");
+ defaultFontSizePreference.setSummary(defaultFontSizeString + "%%");
+
// Listen for preference changes.
preferencesListener = new SharedPreferences.OnSharedPreferenceChangeListener() {
MainWebViewActivity.mainWebView.getSettings().setJavaScriptEnabled(MainWebViewActivity.javaScriptEnabled);
MainWebViewActivity.mainWebView.reload();
- // Update the privacy icon.
- updatePrivacyIcon();
+ // Update the privacy icons.
+ MainWebViewActivity.updatePrivacyIcons(MainWebViewActivity.privacyBrowserActivity);
break;
case "first_party_cookies_enabled":
MenuItem firstPartyCookiesMenuItem = MainWebViewActivity.mainMenu.findItem(R.id.toggleFirstPartyCookies);
firstPartyCookiesMenuItem.setChecked(MainWebViewActivity.firstPartyCookiesEnabled);
- // Update the privacy icon.
- updatePrivacyIcon();
+ // Update the privacy icons.
+ MainWebViewActivity.updatePrivacyIcons(MainWebViewActivity.privacyBrowserActivity);
break;
case "third_party_cookies_enabled":
MainWebViewActivity.cookieManager.setAcceptThirdPartyCookies(MainWebViewActivity.mainWebView, MainWebViewActivity.thirdPartyCookiesEnabled);
MainWebViewActivity.mainWebView.reload();
}
+
+ // Update the privacy icons.
+ MainWebViewActivity.updatePrivacyIcons(MainWebViewActivity.privacyBrowserActivity);
break;
case "dom_storage_enabled":
MainWebViewActivity.mainWebView.getSettings().setDomStorageEnabled(MainWebViewActivity.domStorageEnabled);
MainWebViewActivity.mainWebView.reload();
- // Update the privacy icon.
- updatePrivacyIcon();
+ // Update the privacy icons.
+ MainWebViewActivity.updatePrivacyIcons(MainWebViewActivity.privacyBrowserActivity);
break;
case "save_form_data_enabled":
// Update mainWebView and reload the website.
MainWebViewActivity.mainWebView.getSettings().setSaveFormData(MainWebViewActivity.saveFormDataEnabled);
MainWebViewActivity.mainWebView.reload();
+
+ // Update the privacy icons.
+ MainWebViewActivity.updatePrivacyIcons(MainWebViewActivity.privacyBrowserActivity);
break;
case "user_agent":
customUserAgent.setSummary(sharedPreferences.getString("custom_user_agent", "PrivacyBrowser/1.0"));
// Update mainWebView's user agent. The default is "PrivacyBrowser/1.0".
- MainWebViewActivity.mainWebView.getSettings().setUserAgentString(sharedPreferences.getString("user_agent", "PrivacyBrowser/1.0"));
+ MainWebViewActivity.mainWebView.getSettings().setUserAgentString(sharedPreferences.getString("custom_user_agent", "PrivacyBrowser/1.0"));
break;
case "javascript_disabled_search":
MainWebViewActivity.homepage = sharedPreferences.getString("homepage", "https://www.duckduckgo.com");
break;
+ case "default_font_size":
+ // Get the default font size as a string. The default is `100`.
+ String newDefaultFontSizeString = sharedPreferences.getString("default_font_size", "100");
+
+ // Update the font size on `mainWebView`. The default is `100`.
+ MainWebViewActivity.mainWebView.getSettings().setTextZoom(Integer.valueOf(newDefaultFontSizeString));
+
+ // Update the summary text of `default_font_size`.
+ defaultFontSizePreference.setSummary(newDefaultFontSizeString + "%%");
+
case "swipe_to_refresh_enabled":
- // Set swipeToRefreshEnabled to the new state. The default is true.
+ // Set `swipeToRefreshEnabled` to the new state. The default is `true`.
MainWebViewActivity.swipeToRefreshEnabled = sharedPreferences.getBoolean("swipe_to_refresh_enabled", true);
- // Update swipeRefreshLayout to match the new state.
+ // Update `swipeRefreshLayout` to match the new state.
MainWebViewActivity.swipeToRefresh.setEnabled(MainWebViewActivity.swipeToRefreshEnabled);
break;
super.onResume();
savedPreferences.registerOnSharedPreferenceChangeListener(preferencesListener);
}
-
- private void updatePrivacyIcon() {
- // Define a reference to the toggleJavaScript icon.
- MenuItem toggleJavaScript = MainWebViewActivity.mainMenu.findItem(R.id.toggleJavaScript);
-
- if (MainWebViewActivity.javaScriptEnabled) {
- toggleJavaScript.setIcon(R.drawable.javascript_enabled);
- } else {
- if (MainWebViewActivity.firstPartyCookiesEnabled) {
- toggleJavaScript.setIcon(R.drawable.warning);
- } else {
- toggleJavaScript.setIcon(R.drawable.privacy_mode);
- }
- }
- }
}