]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/blobdiff - app/src/main/java/com/stoutner/privacybrowser/SettingsFragment.java
Create controls for font size.
[PrivacyBrowserAndroid.git] / app / src / main / java / com / stoutner / privacybrowser / SettingsFragment.java
index cd6a81e1e4dfae4ce34720711df7e350f0b783f4..38463427425875c55dbeb7f8c4c36a62a03d2e99 100644 (file)
@@ -109,10 +109,15 @@ public class SettingsFragment extends PreferenceFragment {
         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() {
@@ -302,11 +307,21 @@ public class SettingsFragment extends PreferenceFragment {
                         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;