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:
simakover 2021-05-16 00:01:05 +05:00 committed by GitHub
parent fa872f6cf7
commit 7fb4cbb8a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 42 additions and 6 deletions

View File

@ -15,6 +15,10 @@ object PreferenceKeys {
const val hideBottomBar = "pref_hide_bottom_bar_on_scroll" 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 enableTransitions = "pref_enable_transitions_key"
const val doubleTapAnimationSpeed = "pref_double_tap_anim_speed" const val doubleTapAnimationSpeed = "pref_double_tap_anim_speed"

View File

@ -65,6 +65,10 @@ class PreferencesHelper(val context: Context) {
fun hideBottomBar() = flowPrefs.getBoolean(Keys.hideBottomBar, true) 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 useBiometricLock() = flowPrefs.getBoolean(Keys.useBiometricLock, false)
fun lockAppAfter() = flowPrefs.getInt(Keys.lockAppAfter, 0) fun lockAppAfter() = flowPrefs.getInt(Keys.lockAppAfter, 0)

View File

@ -5,6 +5,7 @@ import android.content.Intent
import android.graphics.Color import android.graphics.Color
import android.os.Build import android.os.Build
import android.os.Bundle import android.os.Bundle
import android.view.Menu
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.Toast import android.widget.Toast
@ -465,8 +466,8 @@ class MainActivity : BaseViewBindingActivity<MainActivityBinding>() {
if (visible) { if (visible) {
if (collapse) { if (collapse) {
bottomNavAnimator?.expand() bottomNavAnimator?.expand()
updateNavMenu(it.menu)
} }
bottomViewNavigationBehavior?.slideUp(it) bottomViewNavigationBehavior?.slideUp(it)
} else { } else {
if (collapse) { if (collapse) {
@ -481,9 +482,17 @@ class MainActivity : BaseViewBindingActivity<MainActivityBinding>() {
private fun showSideNav(visible: Boolean) { private fun showSideNav(visible: Boolean) {
binding.sideNav?.let { binding.sideNav?.let {
it.isVisible = visible 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 * Used to manually offset a view within the activity's child views that might be cut off due to
* the collapsing AppBarLayout. * the collapsing AppBarLayout.

View File

@ -45,11 +45,7 @@ class SettingsGeneralController : SettingsController() {
titleRes = R.string.pref_confirm_exit titleRes = R.string.pref_confirm_exit
defaultValue = false 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) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
preference { preference {
key = "pref_manage_notifications" key = "pref_manage_notifications"
@ -265,5 +261,25 @@ class SettingsGeneralController : SettingsController() {
summary = "%s" 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
}
}
} }
} }

View File

@ -149,6 +149,7 @@
<!-- General section --> <!-- General section -->
<string name="pref_category_theme">Theme</string> <string name="pref_category_theme">Theme</string>
<string name="pref_category_locale">Locale</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="pref_theme_mode">Dark mode</string>
<string name="theme_system">Follow system</string> <string name="theme_system">Follow system</string>
<string name="theme_light">Off</string> <string name="theme_light">Off</string>
@ -166,6 +167,8 @@
<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">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_manage_notifications">Manage notifications</string>
<string name="pref_category_security">Security</string> <string name="pref_category_security">Security</string>