diff options
author | Alex Ning <chineseperson5@gmail.com> | 2020-04-19 05:03:33 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2020-04-19 05:03:33 +0000 |
commit | 499f507f88283c060ed5538474123b6d5f84bda2 (patch) | |
tree | 67c0e4c29c18b947582ab41dc907762486d8cdd0 /app/src/main/java | |
parent | 2d60b732a97141ebe2a434c9c6b2ccfe5886a8da (diff) | |
download | infinity-for-reddit-499f507f88283c060ed5538474123b6d5f84bda2.tar infinity-for-reddit-499f507f88283c060ed5538474123b6d5f84bda2.tar.gz infinity-for-reddit-499f507f88283c060ed5538474123b6d5f84bda2.tar.bz2 infinity-for-reddit-499f507f88283c060ed5538474123b6d5f84bda2.tar.lz infinity-for-reddit-499f507f88283c060ed5538474123b6d5f84bda2.tar.xz infinity-for-reddit-499f507f88283c060ed5538474123b6d5f84bda2.tar.zst infinity-for-reddit-499f507f88283c060ed5538474123b6d5f84bda2.zip |
Add an option to ignore navigation bar height.
Diffstat (limited to 'app/src/main/java')
3 files changed, 24 insertions, 1 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/BaseActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/BaseActivity.java index c5b7f36f..bbbdf950 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/BaseActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/BaseActivity.java @@ -207,6 +207,10 @@ public abstract class BaseActivity extends AppCompatActivity { } public int getNavBarHeight() { + if (getSharedPreferences().getBoolean(SharedPreferencesUtils.IMMERSIVE_INTERFACE_IGNORE_NAV_BAR_KEY, false)) { + return 0; + } + Resources resources = getResources(); int navBarResourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android"); if (navBarResourceId > 0) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/InterfacePreferenceFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/InterfacePreferenceFragment.java index 56c65426..c3c21c1c 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/InterfacePreferenceFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/InterfacePreferenceFragment.java @@ -30,6 +30,7 @@ public class InterfacePreferenceFragment extends PreferenceFragmentCompat { setPreferencesFromResource(R.xml.interface_preference, rootKey); SwitchPreference immersiveInterfaceSwitch = findPreference(SharedPreferencesUtils.IMMERSIVE_INTERFACE_KEY); + SwitchPreference immersiveInterfaceIgnoreNavBarSwitch = findPreference(SharedPreferencesUtils.IMMERSIVE_INTERFACE_IGNORE_NAV_BAR_KEY); SwitchPreference bottomAppBarSwitch = findPreference(SharedPreferencesUtils.BOTTOM_APP_BAR_KEY); SwitchPreference voteButtonsOnTheRightSwitch = findPreference(SharedPreferencesUtils.VOTE_BUTTONS_ON_THE_RIGHT_KEY); SwitchPreference showElapsedTimeSwitch = findPreference(SharedPreferencesUtils.SHOW_ELAPSED_TIME_KEY); @@ -37,15 +38,32 @@ public class InterfacePreferenceFragment extends PreferenceFragmentCompat { SwitchPreference showDividerInCompactLayout = findPreference(SharedPreferencesUtils.SHOW_DIVIDER_IN_COMPACT_LAYOUT); SwitchPreference showAbsoluteNumberOfVotes = findPreference(SharedPreferencesUtils.SHOW_ABSOLUTE_NUMBER_OF_VOTES); - if (immersiveInterfaceSwitch != null) { + if (immersiveInterfaceSwitch != null && immersiveInterfaceIgnoreNavBarSwitch != null) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { immersiveInterfaceSwitch.setVisible(true); immersiveInterfaceSwitch.setOnPreferenceChangeListener((preference, newValue) -> { + if ((Boolean) newValue) { + immersiveInterfaceIgnoreNavBarSwitch.setVisible(true); + } else { + immersiveInterfaceIgnoreNavBarSwitch.setVisible(false); + } + EventBus.getDefault().post(new RecreateActivityEvent()); + return true; + }); + + if (immersiveInterfaceSwitch.isChecked()) { + immersiveInterfaceIgnoreNavBarSwitch.setVisible(true); + } else { + immersiveInterfaceIgnoreNavBarSwitch.setVisible(false); + } + + immersiveInterfaceIgnoreNavBarSwitch.setOnPreferenceChangeListener((preference, newValue) -> { EventBus.getDefault().post(new RecreateActivityEvent()); return true; }); } else { immersiveInterfaceSwitch.setVisible(false); + immersiveInterfaceIgnoreNavBarSwitch.setVisible(false); } } 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 374a814a..ec523487 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java @@ -31,6 +31,7 @@ public class SharedPreferencesUtils { public static final String CONTENT_FONT_SIZE_KEY = "content_font_size"; public static final String AMOLED_DARK_KEY = "amoled_dark"; 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 BOTTOM_APP_BAR_KEY = "bottom_app_bar"; public static final String VOTE_BUTTONS_ON_THE_RIGHT_KEY = "vote_buttons_on_the_right"; |