Option to move nav rail buttons to bottom of screen (closes #5158)

Based on 90be3e3494

Co-authored-by: Jays2Kings <Jays2Kings@users.noreply.github.com>
This commit is contained in:
arkon 2021-05-23 14:27:44 -04:00
parent 065cf42aea
commit a462ce3626
5 changed files with 26 additions and 6 deletions

View File

@ -13,7 +13,9 @@ object PreferenceKeys {
const val confirmExit = "pref_confirm_exit"
const val hideBottomBar = "pref_hide_bottom_bar_on_scroll"
const val hideBottomBarOnScroll = "pref_hide_bottom_bar_on_scroll"
const val showSideNavOnBottom = "pref_show_side_nav_on_bottom"
const val enableTransitions = "pref_enable_transitions_key"

View File

@ -63,7 +63,9 @@ class PreferencesHelper(val context: Context) {
fun confirmExit() = prefs.getBoolean(Keys.confirmExit, false)
fun hideBottomBar() = flowPrefs.getBoolean(Keys.hideBottomBar, true)
fun hideBottomBarOnScroll() = flowPrefs.getBoolean(Keys.hideBottomBarOnScroll, true)
fun showSideNavOnBottom() = flowPrefs.getBoolean(Keys.showSideNavOnBottom, false)
fun useAuthenticator() = flowPrefs.getBoolean(Keys.useAuthenticator, false)

View File

@ -5,6 +5,7 @@ import android.content.Intent
import android.graphics.Color
import android.os.Build
import android.os.Bundle
import android.view.Gravity
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
@ -145,11 +146,19 @@ class MainActivity : BaseViewBindingActivity<MainActivityBinding>() {
)
// Set behavior of bottom nav
preferences.hideBottomBar()
preferences.hideBottomBarOnScroll()
.asImmediateFlow { setBottomNavBehaviorOnScroll() }
.launchIn(lifecycleScope)
}
if (binding.sideNav != null) {
preferences.showSideNavOnBottom()
.asImmediateFlow {
binding.sideNav?.menuGravity = if (!it) Gravity.TOP else Gravity.BOTTOM
}
.launchIn(lifecycleScope)
}
nav.setOnItemSelectedListener { item ->
val id = item.itemId
@ -505,7 +514,7 @@ class MainActivity : BaseViewBindingActivity<MainActivityBinding>() {
binding.bottomNav?.updateLayoutParams<CoordinatorLayout.LayoutParams> {
behavior = when {
preferences.hideBottomBar().get() -> HideBottomViewOnScrollBehavior<View>()
preferences.hideBottomBarOnScroll().get() -> HideBottomViewOnScrollBehavior<View>()
else -> null
}
}

View File

@ -46,9 +46,15 @@ class SettingsGeneralController : SettingsController() {
titleRes = R.string.pref_confirm_exit
defaultValue = false
}
if (!context.isTablet()) {
if (context.isTablet()) {
switchPreference {
key = Keys.hideBottomBar
key = Keys.showSideNavOnBottom
titleRes = R.string.pref_move_side_nav_to_bottom
defaultValue = false
}
} else {
switchPreference {
key = Keys.hideBottomBarOnScroll
titleRes = R.string.pref_hide_bottom_bar_on_scroll
defaultValue = true
}

View File

@ -166,6 +166,7 @@
<string name="pref_date_format">Date format</string>
<string name="pref_confirm_exit">Confirm exit</string>
<string name="pref_hide_bottom_bar_on_scroll">Hide bottom bar on scroll</string>
<string name="pref_move_side_nav_to_bottom">Move side navigation buttons to bottom</string>
<string name="pref_manage_notifications">Manage notifications</string>
<string name="pref_category_security">Security</string>