mirror of
https://git.mihon.tech/mihonapp/mihon
synced 2024-11-26 23:28:58 +03: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:
parent
fa872f6cf7
commit
7fb4cbb8a0
5 changed files with 42 additions and 6 deletions
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -149,6 +149,7 @@
|
|||
<!-- General section -->
|
||||
<string name="pref_category_theme">Theme</string>
|
||||
<string name="pref_category_locale">Locale</string>
|
||||
<string name="pref_category_navigation">Navigation</string>
|
||||
<string name="pref_theme_mode">Dark mode</string>
|
||||
<string name="theme_system">Follow system</string>
|
||||
<string name="theme_light">Off</string>
|
||||
|
@ -166,6 +167,8 @@
|
|||
<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_hide_updates_button">Hide Updates button</string>
|
||||
<string name="pref_hide_history_button">Hide History button</string>
|
||||
<string name="pref_manage_notifications">Manage notifications</string>
|
||||
|
||||
<string name="pref_category_security">Security</string>
|
||||
|
|
Loading…
Reference in a new issue