Add controls for displaying webpage images. Implements https://redmine.stoutner...
[PrivacyBrowser.git] / app / src / main / java / com / stoutner / privacybrowser / fragments / SettingsFragment.java
index dcc548939e58c356020cf3a0baba24b67161950a..2ca684613699fcc570273af45773c09c2fca5014 100644 (file)
@@ -67,6 +67,7 @@ public class SettingsFragment extends PreferenceFragment {
         final Preference defaultFontSizePreference = findPreference("default_font_size");
         final Preference swipeToRefreshPreference = findPreference("swipe_to_refresh");
         final Preference displayAdditionalAppBarIconsPreference = findPreference("display_additional_app_bar_icons");
+        final Preference displayWebpageImagesPreference = findPreference("display_webpage_images");
 
         // Set dependencies.
         domStoragePreference.setDependency("javascript_enabled");
@@ -288,7 +289,7 @@ public class SettingsFragment extends PreferenceFragment {
                     translucentNavigationBarPreference.setIcon(R.drawable.translucent_bar_disabled);
                 }
             }
-        } else {  // `fullScreenBrwosingModeBoolean` is false.
+        } else {  // `fullScreenBrowsingModeBoolean` is false.
             fullScreenBrowsingModePreference.setIcon(R.drawable.full_screen_disabled);
             hideSystemBarsPreference.setIcon(R.drawable.hide_system_bars_ghosted);
             translucentNavigationBarPreference.setIcon(R.drawable.translucent_bar_ghosted);
@@ -308,6 +309,14 @@ public class SettingsFragment extends PreferenceFragment {
             displayAdditionalAppBarIconsPreference.setIcon(R.drawable.more_disabled);
         }
 
+        // Set the `displayWebpageImagesPreference` icon.
+        if (savedPreferences.getBoolean("display_webpage_images", true)) {
+            displayWebpageImagesPreference.setIcon(R.drawable.images_enabled);
+        } else {
+            displayWebpageImagesPreference.setIcon(R.drawable.images_disabled);
+        }
+
+
         // Listen for preference changes.
         preferencesListener = new SharedPreferences.OnSharedPreferenceChangeListener() {
             @Override
@@ -639,6 +648,15 @@ public class SettingsFragment extends PreferenceFragment {
                         }
                         break;
 
+                    case "display_webpage_images":
+                        // Update the icon.
+                        if (sharedPreferences.getBoolean("display_webpage_images", true)) {
+                            displayWebpageImagesPreference.setIcon(R.drawable.images_enabled);
+                        } else {
+                            displayWebpageImagesPreference.setIcon(R.drawable.images_disabled);
+                        }
+                        break;
+
                     default:
                         // If no match, do nothing.
                         break;