Ad a preference to disable full screen browsing mode. Fixes https://redmine.stoutner...
[PrivacyBrowser.git] / app / src / main / java / com / stoutner / privacybrowser / fragments / SettingsFragment.java
index 535b647a8d8e93aae123c2067156cb4a8772ec8b..95ca66b720e9b73a8ab75f503cdff0ca748185c5 100644 (file)
@@ -119,6 +119,20 @@ public class SettingsFragment extends PreferenceFragment {
         javaScriptEnabledSearchCustomURLPreference.setEnabled(javaScriptEnabledSearchString.equals("Custom URL"));
 
 
+        // Enable the full screen options if full screen browsing mode is enabled.
+        final Preference hideSystemBarsPreference = findPreference("hide_system_bars");
+        final Preference translucentNavigationBarPreference = findPreference("translucent_navigation_bar");
+        final boolean fullScreenBrowsingModeEnabled = savedPreferences.getBoolean("enable_full_screen_browsing_mode", false);
+        if (!fullScreenBrowsingModeEnabled) {
+            // Disable the full screen options.
+            hideSystemBarsPreference.setEnabled(false);
+            translucentNavigationBarPreference.setEnabled(false);
+        } else {
+            // Disable `transparent_navigation_bar` if `hide_system_bars` is `true`.
+            translucentNavigationBarPreference.setEnabled(!savedPreferences.getBoolean("hide_system_bars", false));
+        }
+
+
         // 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"));
@@ -128,10 +142,6 @@ public class SettingsFragment extends PreferenceFragment {
         String defaultFontSizeString = savedPreferences.getString("default_font_size", "100");
         defaultFontSizePreference.setSummary(defaultFontSizeString + "%%");
 
-        // Disable `transparent_navigation_bar` if `hide_system_bars` is enabled.
-        final Preference translucentNavigationBarPreference = findPreference("translucent_navigation_bar");
-        translucentNavigationBarPreference.setEnabled(!savedPreferences.getBoolean("hide_system_bars", false));
-
 
         // Listen for preference changes.
         preferencesListener = new SharedPreferences.OnSharedPreferenceChangeListener() {
@@ -216,6 +226,21 @@ public class SettingsFragment extends PreferenceFragment {
                         javaScriptEnabledSearchCustomURLPreference.setSummary(sharedPreferences.getString("javascript_enabled_search_custom_url", ""));
                         break;
 
+                    case "enable_full_screen_browsing_mode":
+                        boolean newFullScreenBrowsingModeEnabled = sharedPreferences.getBoolean("enable_full_screen_browsing_mode", false);
+                        if (newFullScreenBrowsingModeEnabled) {
+                            // Enable `hideSystemBarsPreference`.
+                            hideSystemBarsPreference.setEnabled(true);
+
+                            // Only enable `transparent_navigation_bar` if `hide_system_bars` is `false`.
+                            translucentNavigationBarPreference.setEnabled(!sharedPreferences.getBoolean("hide_system_bars", false));
+                        } else {
+                            // Disable the full screen options.
+                            hideSystemBarsPreference.setEnabled(false);
+                            translucentNavigationBarPreference.setEnabled(false);
+                        }
+                        break;
+
                     case "homepage":
                         // Set the new homepage URL as the summary text for the Homepage preference.  The default is `https://www.duckduckgo.com`.
                         homepagePreference.setSummary(sharedPreferences.getString("homepage", "https://www.duckduckgo.com"));