diff options
5 files changed, 19 insertions, 2 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/BaseActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/BaseActivity.java index e2f02bdd..12e565c4 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/BaseActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/BaseActivity.java @@ -89,6 +89,9 @@ public abstract class BaseActivity extends AppCompatActivity { int systemThemeType = Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.THEME_KEY, "2")); immersiveInterface = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && mSharedPreferences.getBoolean(SharedPreferencesUtils.IMMERSIVE_INTERFACE_KEY, true); + if (immersiveInterface && config.orientation == Configuration.ORIENTATION_LANDSCAPE) { + immersiveInterface = !mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_IMMERSIVE_INTERFACE_IN_LANDSCAPE_MODE, false); + } switch (systemThemeType) { case 0: AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_NO); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/ImmersiveInterfacePreferenceFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/ImmersiveInterfacePreferenceFragment.java index 785721cb..73d5d305 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/ImmersiveInterfacePreferenceFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/ImmersiveInterfacePreferenceFragment.java @@ -7,8 +7,8 @@ import androidx.preference.SwitchPreference; import org.greenrobot.eventbus.EventBus; -import ml.docilealligator.infinityforreddit.events.RecreateActivityEvent; import ml.docilealligator.infinityforreddit.R; +import ml.docilealligator.infinityforreddit.events.RecreateActivityEvent; import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils; public class ImmersiveInterfacePreferenceFragment extends PreferenceFragmentCompat { @@ -19,8 +19,10 @@ public class ImmersiveInterfacePreferenceFragment extends PreferenceFragmentComp SwitchPreference immersiveInterfaceSwitch = findPreference(SharedPreferencesUtils.IMMERSIVE_INTERFACE_KEY); SwitchPreference immersiveInterfaceIgnoreNavBarSwitch = findPreference(SharedPreferencesUtils.IMMERSIVE_INTERFACE_IGNORE_NAV_BAR_KEY); + SwitchPreference disableImmersiveInterfaceInLandscapeModeSwitch = findPreference(SharedPreferencesUtils.DISABLE_IMMERSIVE_INTERFACE_IN_LANDSCAPE_MODE); - if (immersiveInterfaceSwitch != null && immersiveInterfaceIgnoreNavBarSwitch != null) { + if (immersiveInterfaceSwitch != null && immersiveInterfaceIgnoreNavBarSwitch != null + && disableImmersiveInterfaceInLandscapeModeSwitch != null) { immersiveInterfaceSwitch.setOnPreferenceChangeListener((preference, newValue) -> { if ((Boolean) newValue) { immersiveInterfaceIgnoreNavBarSwitch.setVisible(true); @@ -41,6 +43,11 @@ public class ImmersiveInterfacePreferenceFragment extends PreferenceFragmentComp EventBus.getDefault().post(new RecreateActivityEvent()); return true; }); + + disableImmersiveInterfaceInLandscapeModeSwitch.setOnPreferenceChangeListener((preference, newValue) -> { + EventBus.getDefault().post(new RecreateActivityEvent()); + return true; + }); } } }
\ No newline at end of file diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java index 45878da5..0d6c9ffe 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java @@ -35,6 +35,7 @@ public class SharedPreferencesUtils { public static final String IMMERSIVE_INTERFACE_ENTRY_KEY = "immersive_interface_entry"; public static final String IMMERSIVE_INTERFACE_KEY = "immersive_interface"; public static final String IMMERSIVE_INTERFACE_IGNORE_NAV_BAR_KEY = "immersive_interface_ignore_nav_bar"; + public static final String DISABLE_IMMERSIVE_INTERFACE_IN_LANDSCAPE_MODE = "disable_immersive_interface_in_landscape_mode"; public static final String BOTTOM_APP_BAR_KEY = "bottom_app_bar"; public static final String VOTE_BUTTONS_ON_THE_RIGHT_KEY = "vote_buttons_on_the_right"; diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index e096984a..f5410e92 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -359,6 +359,7 @@ <string name="settings_immersive_interface_summary">Does Not Apply to All Pages</string> <string name="settings_immersive_interface_ignore_nav_bar_title">Ignore Navigation Bar in Immersive Interface</string> <string name="settings_immersive_interface_ignore_nav_bar_summary">Prevent the Bottom Navigation Bar Having Extra Padding</string> + <string name="settings_disable_immersive_interface_in_landscape_mode">Disable Immersive Interface in Landscape Mode</string> <string name="settings_customize_tabs_in_main_page_title">Customize Tabs in Main Page</string> <string name="only_for_logged_in_user">Only for Logged-in User</string> <string name="settings_enable_bottom_app_bar_title">Enable Bottom Navigation</string> diff --git a/app/src/main/res/xml/immersive_interface_preferences.xml b/app/src/main/res/xml/immersive_interface_preferences.xml index 6cd31d84..5897108a 100644 --- a/app/src/main/res/xml/immersive_interface_preferences.xml +++ b/app/src/main/res/xml/immersive_interface_preferences.xml @@ -13,4 +13,9 @@ app:title="@string/settings_immersive_interface_ignore_nav_bar_title" app:summary="@string/settings_immersive_interface_ignore_nav_bar_summary" /> + <SwitchPreference + app:defaultValue="false" + app:key="disable_immersive_interface_in_landscape_mode" + app:title="@string/settings_disable_immersive_interface_in_landscape_mode"/> + </PreferenceScreen>
\ No newline at end of file |