Selaa lähdekoodia

Allow center aligned side nav icons (closes #5177)

arkon 3 vuotta sitten
vanhempi
commit
6c53bb4d51

+ 1 - 1
app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt

@@ -15,7 +15,7 @@ object PreferenceKeys {
 
     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 enableTransitions = "pref_enable_transitions_key"
 

+ 1 - 1
app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt

@@ -66,7 +66,7 @@ class PreferencesHelper(val context: Context) {
 
     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)
 

+ 6 - 2
app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt

@@ -142,9 +142,13 @@ class MainActivity : BaseViewBindingActivity<MainActivityBinding>() {
         }
 
         if (binding.sideNav != null) {
-            preferences.showSideNavOnBottom()
+            preferences.sideNavIconAlignment()
                 .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)
         }

+ 0 - 1
app/src/main/java/eu/kanade/tachiyomi/ui/more/AboutController.kt

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

+ 11 - 4
app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsGeneralController.kt

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

+ 4 - 1
app/src/main/res/values/strings.xml

@@ -161,7 +161,10 @@
     <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_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_category_security">Security</string>