Allow center aligned side nav icons (closes #5177)

(cherry picked from commit 6c53bb4d515d15c39bb4ba8e0eae46341fd58c45)
This commit is contained in:
arkon 2021-06-03 09:30:50 -04:00 committed by Jobobby04
parent 84330af417
commit 330b7990fe
6 changed files with 23 additions and 10 deletions

View File

@ -15,7 +15,7 @@ object PreferenceKeys {
const val hideBottomBarOnScroll = "pref_hide_bottom_bar_on_scroll" const val hideBottomBarOnScroll = "pref_hide_bottom_bar_on_scroll"
const val showSideNavOnBottom = "pref_show_side_nav_on_bottom" const val sideNavIconAlignment = "pref_side_nav_icon_alignment"
const val enableTransitionsPager = "pref_enable_transitions_pager_key" const val enableTransitionsPager = "pref_enable_transitions_pager_key"

View File

@ -68,7 +68,7 @@ class PreferencesHelper(val context: Context) {
fun hideBottomBarOnScroll() = flowPrefs.getBoolean(Keys.hideBottomBarOnScroll, true) fun hideBottomBarOnScroll() = flowPrefs.getBoolean(Keys.hideBottomBarOnScroll, true)
fun showSideNavOnBottom() = flowPrefs.getBoolean(Keys.showSideNavOnBottom, false) fun sideNavIconAlignment() = flowPrefs.getInt(Keys.sideNavIconAlignment, 0)
fun useAuthenticator() = flowPrefs.getBoolean(Keys.useAuthenticator, false) fun useAuthenticator() = flowPrefs.getBoolean(Keys.useAuthenticator, false)

View File

@ -168,9 +168,13 @@ class MainActivity : BaseViewBindingActivity<MainActivityBinding>() {
} }
if (binding.sideNav != null) { if (binding.sideNav != null) {
preferences.showSideNavOnBottom() preferences.sideNavIconAlignment()
.asImmediateFlow { .asImmediateFlow {
binding.sideNav?.menuGravity = if (!it) Gravity.TOP else Gravity.BOTTOM binding.sideNav?.menuGravity = when (it) {
1 -> Gravity.CENTER
2 -> Gravity.BOTTOM
else -> Gravity.TOP
}
} }
.launchIn(lifecycleScope) .launchIn(lifecycleScope)
} }

View File

@ -27,7 +27,6 @@ import eu.kanade.tachiyomi.util.system.toast
import exh.syDebugVersion import exh.syDebugVersion
import timber.log.Timber import timber.log.Timber
import java.text.DateFormat import java.text.DateFormat
import java.text.ParseException
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
import java.util.Locale import java.util.Locale
import java.util.TimeZone import java.util.TimeZone

View File

@ -48,10 +48,17 @@ class SettingsGeneralController : SettingsController() {
defaultValue = false defaultValue = false
} }
if (context.isTablet()) { if (context.isTablet()) {
switchPreference { intListPreference {
key = Keys.showSideNavOnBottom key = Keys.sideNavIconAlignment
titleRes = R.string.pref_move_side_nav_to_bottom titleRes = R.string.pref_side_nav_icon_alignment
defaultValue = false entriesRes = arrayOf(
R.string.alignment_top,
R.string.alignment_center,
R.string.alignment_bottom,
)
entryValues = arrayOf("0", "1", "2")
defaultValue = "0"
summary = "%s"
} }
} else { } else {
switchPreference { switchPreference {

View File

@ -161,7 +161,10 @@
<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_move_side_nav_to_bottom">Move side navigation buttons to bottom</string> <string name="pref_side_nav_icon_alignment">Side navigation icon alignment</string>
<string name="alignment_top">Top</string>
<string name="alignment_center">Center</string>
<string name="alignment_bottom">Bottom</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>