mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-11-04 08:08:55 +01:00 
			
		
		
		
	Add option to hide "Updates" and "History" buttons (#5077)
* Add otion to hide "Updates" abd "History" buttons * Add otion to hide "Updates" abd "History" buttons * explicit imports * New category Navigation * Add functionality for SideNav
This commit is contained in:
		@@ -15,6 +15,10 @@ object PreferenceKeys {
 | 
			
		||||
 | 
			
		||||
    const val hideBottomBar = "pref_hide_bottom_bar_on_scroll"
 | 
			
		||||
 | 
			
		||||
    const val hideUpdatesButton = "pref_hide_updates_button"
 | 
			
		||||
 | 
			
		||||
    const val hideHistoryButton = "pref_hide_history_button"
 | 
			
		||||
 | 
			
		||||
    const val enableTransitions = "pref_enable_transitions_key"
 | 
			
		||||
 | 
			
		||||
    const val doubleTapAnimationSpeed = "pref_double_tap_anim_speed"
 | 
			
		||||
 
 | 
			
		||||
@@ -65,6 +65,10 @@ class PreferencesHelper(val context: Context) {
 | 
			
		||||
 | 
			
		||||
    fun hideBottomBar() = flowPrefs.getBoolean(Keys.hideBottomBar, true)
 | 
			
		||||
 | 
			
		||||
    fun hideUpdatesButton() = flowPrefs.getBoolean(Keys.hideUpdatesButton, true)
 | 
			
		||||
 | 
			
		||||
    fun hideHistoryButton() = flowPrefs.getBoolean(Keys.hideHistoryButton, true)
 | 
			
		||||
 | 
			
		||||
    fun useBiometricLock() = flowPrefs.getBoolean(Keys.useBiometricLock, false)
 | 
			
		||||
 | 
			
		||||
    fun lockAppAfter() = flowPrefs.getInt(Keys.lockAppAfter, 0)
 | 
			
		||||
 
 | 
			
		||||
@@ -5,6 +5,7 @@ import android.content.Intent
 | 
			
		||||
import android.graphics.Color
 | 
			
		||||
import android.os.Build
 | 
			
		||||
import android.os.Bundle
 | 
			
		||||
import android.view.Menu
 | 
			
		||||
import android.view.View
 | 
			
		||||
import android.view.ViewGroup
 | 
			
		||||
import android.widget.Toast
 | 
			
		||||
@@ -465,8 +466,8 @@ class MainActivity : BaseViewBindingActivity<MainActivityBinding>() {
 | 
			
		||||
            if (visible) {
 | 
			
		||||
                if (collapse) {
 | 
			
		||||
                    bottomNavAnimator?.expand()
 | 
			
		||||
                    updateNavMenu(it.menu)
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                bottomViewNavigationBehavior?.slideUp(it)
 | 
			
		||||
            } else {
 | 
			
		||||
                if (collapse) {
 | 
			
		||||
@@ -481,9 +482,17 @@ class MainActivity : BaseViewBindingActivity<MainActivityBinding>() {
 | 
			
		||||
    private fun showSideNav(visible: Boolean) {
 | 
			
		||||
        binding.sideNav?.let {
 | 
			
		||||
            it.isVisible = visible
 | 
			
		||||
            updateNavMenu(it.menu)
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private fun updateNavMenu(menu: Menu) {
 | 
			
		||||
        val navUpdates = menu.findItem(R.id.nav_updates)
 | 
			
		||||
        navUpdates.isVisible = !preferences.hideUpdatesButton().get()
 | 
			
		||||
        val navHistory = menu.findItem(R.id.nav_history)
 | 
			
		||||
        navHistory.isVisible = !preferences.hideHistoryButton().get()
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Used to manually offset a view within the activity's child views that might be cut off due to
 | 
			
		||||
     * the collapsing AppBarLayout.
 | 
			
		||||
 
 | 
			
		||||
@@ -45,11 +45,7 @@ class SettingsGeneralController : SettingsController() {
 | 
			
		||||
            titleRes = R.string.pref_confirm_exit
 | 
			
		||||
            defaultValue = false
 | 
			
		||||
        }
 | 
			
		||||
        switchPreference {
 | 
			
		||||
            key = Keys.hideBottomBar
 | 
			
		||||
            titleRes = R.string.pref_hide_bottom_bar_on_scroll
 | 
			
		||||
            defaultValue = true
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
 | 
			
		||||
            preference {
 | 
			
		||||
                key = "pref_manage_notifications"
 | 
			
		||||
@@ -265,5 +261,25 @@ class SettingsGeneralController : SettingsController() {
 | 
			
		||||
                summary = "%s"
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        preferenceCategory {
 | 
			
		||||
            titleRes = R.string.pref_category_navigation
 | 
			
		||||
 | 
			
		||||
            switchPreference {
 | 
			
		||||
                key = Keys.hideBottomBar
 | 
			
		||||
                titleRes = R.string.pref_hide_bottom_bar_on_scroll
 | 
			
		||||
                defaultValue = true
 | 
			
		||||
            }
 | 
			
		||||
            switchPreference {
 | 
			
		||||
                key = Keys.hideUpdatesButton
 | 
			
		||||
                titleRes = R.string.pref_hide_updates_button
 | 
			
		||||
                defaultValue = false
 | 
			
		||||
            }
 | 
			
		||||
            switchPreference {
 | 
			
		||||
                key = Keys.hideHistoryButton
 | 
			
		||||
                titleRes = R.string.pref_hide_history_button
 | 
			
		||||
                defaultValue = false
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user