Fix invert tapping dropdown not updating checked state in reader
Fixes #8566 Should ideally just Compose-ify it all some day.
This commit is contained in:
parent
f1b85ff39d
commit
2c850d0e33
2 changed files with 10 additions and 9 deletions
|
@ -7,6 +7,7 @@ import androidx.core.view.isVisible
|
|||
import androidx.core.widget.NestedScrollView
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.preference.PreferenceValues
|
||||
import eu.kanade.tachiyomi.databinding.ReaderReadingModeSettingsBinding
|
||||
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
|
||||
import eu.kanade.tachiyomi.ui.reader.viewer.pager.PagerViewer
|
||||
|
@ -68,7 +69,7 @@ class ReaderReadingModeSettings @JvmOverloads constructor(context: Context, attr
|
|||
binding.webtoonPrefsGroup.root.isVisible = false
|
||||
binding.pagerPrefsGroup.root.isVisible = true
|
||||
|
||||
binding.pagerPrefsGroup.tappingInverted.bindToPreference(readerPreferences.pagerNavInverted())
|
||||
binding.pagerPrefsGroup.tappingInverted.bindToPreference(readerPreferences.pagerNavInverted(), PreferenceValues.TappingInvertMode::class.java)
|
||||
binding.pagerPrefsGroup.navigatePan.bindToPreference(readerPreferences.navigateToPan())
|
||||
|
||||
binding.pagerPrefsGroup.pagerNav.bindToPreference(readerPreferences.navigationModePager())
|
||||
|
@ -104,7 +105,7 @@ class ReaderReadingModeSettings @JvmOverloads constructor(context: Context, attr
|
|||
binding.pagerPrefsGroup.root.isVisible = false
|
||||
binding.webtoonPrefsGroup.root.isVisible = true
|
||||
|
||||
binding.webtoonPrefsGroup.tappingInverted.bindToPreference(readerPreferences.webtoonNavInverted())
|
||||
binding.webtoonPrefsGroup.tappingInverted.bindToPreference(readerPreferences.webtoonNavInverted(), PreferenceValues.TappingInvertMode::class.java)
|
||||
|
||||
binding.webtoonPrefsGroup.webtoonNav.bindToPreference(readerPreferences.navigationModeWebtoon())
|
||||
readerPreferences.navigationModeWebtoon()
|
||||
|
|
|
@ -89,14 +89,14 @@ class MaterialSpinnerView @JvmOverloads constructor(context: Context, attrs: Att
|
|||
}
|
||||
}
|
||||
|
||||
inline fun <reified T : Enum<T>> bindToPreference(pref: Preference<T>) {
|
||||
val enumConstants = T::class.java.enumConstants
|
||||
fun <T : Enum<T>> bindToPreference(pref: Preference<T>, clazz: Class<T>) {
|
||||
val enumConstants = clazz.enumConstants
|
||||
enumConstants?.indexOf(pref.get())?.let { setSelection(it) }
|
||||
|
||||
val popup = makeSettingsPopup(pref)
|
||||
setOnTouchListener(popup.dragToOpenListener)
|
||||
popup = makeSettingsPopup(pref, clazz)
|
||||
setOnTouchListener(popup?.dragToOpenListener)
|
||||
setOnClickListener {
|
||||
popup.show()
|
||||
popup?.show()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -111,11 +111,11 @@ class MaterialSpinnerView @JvmOverloads constructor(context: Context, attrs: Att
|
|||
}
|
||||
}
|
||||
|
||||
inline fun <reified T : Enum<T>> makeSettingsPopup(preference: Preference<T>): PopupMenu {
|
||||
private fun <T : Enum<T>> makeSettingsPopup(preference: Preference<T>, clazz: Class<T>): PopupMenu {
|
||||
return createPopupMenu { pos ->
|
||||
onItemSelectedListener?.invoke(pos)
|
||||
|
||||
val enumConstants = T::class.java.enumConstants
|
||||
val enumConstants = clazz.enumConstants
|
||||
enumConstants?.get(pos)?.let { enumValue -> preference.set(enumValue) }
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue