From 1e138ab476d4d2d8fd8d73ef48a32d1606c743a4 Mon Sep 17 00:00:00 2001 From: arkon Date: Thu, 3 Jun 2021 09:30:50 -0400 Subject: [PATCH] Allow center aligned side nav icons --- .../tachiyomi/data/preference/PreferenceKeys.kt | 2 +- .../data/preference/PreferencesHelper.kt | 2 +- .../eu/kanade/tachiyomi/ui/main/MainActivity.kt | 8 ++++++-- .../ui/setting/SettingsGeneralController.kt | 15 ++++++++++----- app/src/main/res/values/strings.xml | 2 +- 5 files changed, 19 insertions(+), 10 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 0f65b4b339..a792db943d 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 @@ -202,7 +202,7 @@ object PreferenceKeys { const val hideBottomNavOnScroll = "hide_bottom_nav_on_scroll" - const val showSideNavOnBottom = "show_side_nav_on_bottom" + const val sideNavIconAlignment = "pref_side_nav_icon_alignment" const val showSeriesInShortcuts = "show_series_shortcuts" const val showSourcesInShortcuts = "show_sources_shortcuts" 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 7e5ba3054f..c503ecbf89 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 @@ -394,7 +394,7 @@ class PreferencesHelper(val context: Context) { fun hideBottomNavOnScroll() = flowPrefs.getBoolean(Keys.hideBottomNavOnScroll, true) - fun showSideNavOnBottom() = flowPrefs.getBoolean(Keys.showSideNavOnBottom, false) + fun sideNavIconAlignment() = flowPrefs.getInt(Keys.sideNavIconAlignment, 0) fun showNsfwSource() = flowPrefs.getBoolean(Keys.showNsfwSource, true) fun showNsfwExtension() = flowPrefs.getBoolean(Keys.showNsfwExtension, true) 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 fb2be954c6..1dc0e3d35a 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 @@ -369,9 +369,13 @@ open class MainActivity : BaseActivity(), DownloadServiceLi binding.toolbar.setIncognitoMode(it) binding.cardToolbar.setIncognitoMode(it) } - preferences.showSideNavOnBottom() + preferences.sideNavIconAlignment() .asImmediateFlowIn(lifecycleScope) { - binding.sideNav?.menuGravity = if (!it) Gravity.TOP else Gravity.BOTTOM + binding.sideNav?.menuGravity = when (it) { + 1 -> Gravity.CENTER + 2 -> Gravity.BOTTOM + else -> Gravity.TOP + } } setExtensionsBadge() setFloatingToolbar(canShowFloatingToolbar(router.backstack.lastOrNull()?.controller), changeBG = false) 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 df109b32db..4db5d83224 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 @@ -13,7 +13,6 @@ import eu.kanade.tachiyomi.util.system.getPrefTheme import eu.kanade.tachiyomi.util.system.isInNightMode import eu.kanade.tachiyomi.util.system.isTablet import kotlinx.coroutines.flow.launchIn -import java.util.Locale import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys class SettingsGeneralController : SettingsController() { @@ -77,10 +76,16 @@ class SettingsGeneralController : SettingsController() { defaultValue = true } - switchPreference { - key = Keys.showSideNavOnBottom - titleRes = R.string.move_side_nav_to_bottom - defaultValue = false + intListPreference(activity) { + key = Keys.sideNavIconAlignment + titleRes = R.string.side_nav_icon_alignment + entriesRes = arrayOf( + R.string.top, + R.string.center, + R.string.bottom, + ) + entryRange = 0..2 + defaultValue = 0 isVisible = activity?.isTablet() == true } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 905dedfb45..1f3d1259d4 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -619,7 +619,7 @@ Updated to v%1$s Secure screen Auto-hide bottom navigation - Move side navigation buttons to bottom + Side navigation icon alignment Follow system theme Hides when scrolling Hide app contents when switching apps and block screenshots