mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-11-04 08:08:55 +01:00 
			
		
		
		
	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:
		@@ -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"
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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)
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
            }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user