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

Based on 90be3e3494

Co-authored-by: Jays2Kings <Jays2Kings@users.noreply.github.com>
(cherry picked from commit a462ce3626720ba770b6d1e991be9490a551e83c)

# Conflicts:
#	app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt
#	app/src/main/res/values/strings.xml
This commit is contained in:
arkon 2021-05-23 14:27:44 -04:00 committed by Jobobby04
parent ec9967d2d6
commit 9adbb1b115
6 changed files with 29 additions and 9 deletions

View File

@ -13,7 +13,9 @@ object PreferenceKeys {
const val confirmExit = "pref_confirm_exit" 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 enableTransitionsPager = "pref_enable_transitions_pager_key" const val enableTransitionsPager = "pref_enable_transitions_pager_key"

View File

@ -65,7 +65,9 @@ class PreferencesHelper(val context: Context) {
fun confirmExit() = prefs.getBoolean(Keys.confirmExit, false) 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) fun useAuthenticator() = flowPrefs.getBoolean(Keys.useAuthenticator, false)

View File

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

View File

@ -47,9 +47,15 @@ class SettingsGeneralController : SettingsController() {
titleRes = R.string.pref_confirm_exit titleRes = R.string.pref_confirm_exit
defaultValue = false defaultValue = false
} }
if (!context.isTablet()) { if (context.isTablet()) {
switchPreference { 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 titleRes = R.string.pref_hide_bottom_bar_on_scroll
defaultValue = true defaultValue = true
} }

View File

@ -166,9 +166,7 @@
<string name="pref_date_format">Date format</string> <string name="pref_date_format">Date format</string>
<string name="pref_confirm_exit">Confirm exit</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_hide_bottom_bar_on_scroll">Hide bottom bar on scroll</string>
<string name="pref_hide_updates_button">Move Update button to the More tab</string> <string name="pref_move_side_nav_to_bottom">Move side navigation buttons to bottom</string>
<string name="pref_hide_history_button">Move History button to the More tab</string>
<string name="pref_show_bottom_bar_labels">Always show bottom bar labels</string>
<string name="pref_manage_notifications">Manage notifications</string> <string name="pref_manage_notifications">Manage notifications</string>
<string name="pref_category_security">Security</string> <string name="pref_category_security">Security</string>

View File

@ -179,6 +179,9 @@
<string name="auto_solve_captchas_summary">Use HIGHLY EXPERIMENTAL automatic ReCAPTCHA solver. Will be grayed out if unsupported by your device.</string> <string name="auto_solve_captchas_summary">Use HIGHLY EXPERIMENTAL automatic ReCAPTCHA solver. Will be grayed out if unsupported by your device.</string>
<string name="put_recommends_in_overflow">Recommendations in overflow</string> <string name="put_recommends_in_overflow">Recommendations in overflow</string>
<string name="put_recommends_in_overflow_summary">Put the recommendations button in the overflow menu instead of on the manga page</string> <string name="put_recommends_in_overflow_summary">Put the recommendations button in the overflow menu instead of on the manga page</string>
<string name="pref_hide_updates_button">Move Update button to the More tab</string>
<string name="pref_hide_history_button">Move History button to the More tab</string>
<string name="pref_show_bottom_bar_labels">Always show bottom bar labels</string>
<!-- Library settings --> <!-- Library settings -->
<string name="pref_sorting_settings">Sorting Settings</string> <string name="pref_sorting_settings">Sorting Settings</string>