[IDEA] Changing to labels not always visible (#296)

* disable always visible labels

* make it a setting

* remove redundant line

* Fix preference keys

* Update keys again

* Fix import

* Remove extra line

Co-authored-by: jobobby04 <jobobby04@users.noreply.github.com>
This commit is contained in:
OncePunchedMan 2021-05-11 04:02:55 +02:00 committed by GitHub
parent 44ba757ad8
commit 27f2e8ecbc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 27 additions and 1 deletions

View File

@ -374,4 +374,6 @@ object PreferenceKeys {
const val forceHorizontalSeekbar = "pref_force_horz_seekbar"
const val readerBottomButtons = "reader_bottom_buttons"
const val bottomBarLabels = "pref_show_bottom_bar_labels"
}

View File

@ -66,6 +66,8 @@ class PreferencesHelper(val context: Context) {
fun hideBottomBar() = flowPrefs.getBoolean(Keys.hideBottomBar, true)
fun bottomBarLabels() = flowPrefs.getBoolean(Keys.bottomBarLabels, true)
fun useBiometricLock() = flowPrefs.getBoolean(Keys.useBiometricLock, false)
fun lockAppAfter() = flowPrefs.getInt(Keys.lockAppAfter, 0)

View File

@ -25,9 +25,12 @@ import com.bluelinelabs.conductor.Router
import com.bluelinelabs.conductor.RouterTransaction
import com.google.android.material.appbar.AppBarLayout
import com.google.android.material.behavior.HideBottomViewOnScrollBehavior
import com.google.android.material.bottomnavigation.LabelVisibilityMode.LABEL_VISIBILITY_LABELED
import com.google.android.material.bottomnavigation.LabelVisibilityMode.LABEL_VISIBILITY_SELECTED
import dev.chrisbanes.insetter.applyInsetter
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.notification.NotificationReceiver
import eu.kanade.tachiyomi.data.preference.PreferenceKeys.bottomBarLabels
import eu.kanade.tachiyomi.data.preference.asImmediateFlow
import eu.kanade.tachiyomi.databinding.MainActivityBinding
import eu.kanade.tachiyomi.extension.api.ExtensionGithubApi
@ -293,6 +296,12 @@ class MainActivity : BaseViewBindingActivity<MainActivityBinding>() {
}
}
.launchIn(lifecycleScope)
// SY -->
preferences.bottomBarLabels()
.asImmediateFlow { setBottomNavLabelVisibility() }
.launchIn(lifecycleScope)
// SY <--
}
override fun onNewIntent(intent: Intent) {
@ -547,6 +556,14 @@ class MainActivity : BaseViewBindingActivity<MainActivityBinding>() {
}
}
private fun setBottomNavLabelVisibility() {
if (preferences.bottomBarLabels().get()) {
binding.bottomNav.labelVisibilityMode = LABEL_VISIBILITY_LABELED
} else {
binding.bottomNav.labelVisibilityMode = LABEL_VISIBILITY_SELECTED
}
}
companion object {
// Shortcut actions
const val SHORTCUT_LIBRARY = "eu.kanade.tachiyomi.SHOW_LIBRARY"

View File

@ -51,6 +51,11 @@ class SettingsGeneralController : SettingsController() {
titleRes = R.string.pref_hide_bottom_bar_on_scroll
defaultValue = true
}
switchPreference {
key = Keys.bottomBarLabels
titleRes = R.string.pref_show_bottom_bar_labels
defaultValue = true
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
preference {
key = "pref_manage_notifications"

View File

@ -87,7 +87,6 @@
android:layout_gravity="bottom"
app:itemIconTint="@color/bottom_nav_selector"
app:itemTextColor="@color/bottom_nav_selector"
app:labelVisibilityMode="labeled"
app:layout_insetEdge="bottom"
app:menu="@menu/bottom_nav" />

View File

@ -165,6 +165,7 @@
<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_show_bottom_bar_labels">Always show bottom bar labels</string>
<string name="pref_manage_notifications">Manage notifications</string>
<string name="pref_category_security">Security</string>