From 7fb4cbb8a002c857be96d0d0fda8c76d08444a0b Mon Sep 17 00:00:00 2001 From: simakover Date: Sun, 16 May 2021 00:01:05 +0500 Subject: [PATCH] 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 --- .../data/preference/PreferenceKeys.kt | 4 +++ .../data/preference/PreferencesHelper.kt | 4 +++ .../kanade/tachiyomi/ui/main/MainActivity.kt | 11 +++++++- .../ui/setting/SettingsGeneralController.kt | 26 +++++++++++++++---- app/src/main/res/values/strings.xml | 3 +++ 5 files changed, 42 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt index c30c4da48..6fad83404 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt @@ -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" diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt index 5340ae67c..db157250c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt @@ -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) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt index 8e92225c0..5c3be4bf5 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt @@ -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() { if (visible) { if (collapse) { bottomNavAnimator?.expand() + updateNavMenu(it.menu) } - bottomViewNavigationBehavior?.slideUp(it) } else { if (collapse) { @@ -481,9 +482,17 @@ class MainActivity : BaseViewBindingActivity() { 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. diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsGeneralController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsGeneralController.kt index ffcd95b5c..e814f5cac 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsGeneralController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsGeneralController.kt @@ -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 + } + } } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 2a1939c99..ee8f0f1cb 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -149,6 +149,7 @@ Theme Locale + Navigation Dark mode Follow system Off @@ -166,6 +167,8 @@ Date format Confirm exit Hide bottom bar on scroll + Hide Updates button + Hide History button Manage notifications Security