mirror of
https://git.mihon.tech/mihonapp/mihon
synced 2024-11-26 23:28:58 +03:00
Move all pager/webtoon reader setting to Compose sheet
This commit is contained in:
parent
12e7ee9d0c
commit
e40b8d537c
10 changed files with 121 additions and 272 deletions
|
@ -1,6 +1,7 @@
|
||||||
package eu.kanade.domain.base
|
package eu.kanade.domain.base
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import androidx.annotation.StringRes
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.util.system.isPreviewBuildType
|
import eu.kanade.tachiyomi.util.system.isPreviewBuildType
|
||||||
import eu.kanade.tachiyomi.util.system.isReleaseBuildType
|
import eu.kanade.tachiyomi.util.system.isReleaseBuildType
|
||||||
|
@ -19,7 +20,7 @@ class BasePreferences(
|
||||||
|
|
||||||
fun acraEnabled() = preferenceStore.getBoolean("acra.enable", isPreviewBuildType || isReleaseBuildType)
|
fun acraEnabled() = preferenceStore.getBoolean("acra.enable", isPreviewBuildType || isReleaseBuildType)
|
||||||
|
|
||||||
enum class ExtensionInstaller(val titleResId: Int) {
|
enum class ExtensionInstaller(@StringRes val titleResId: Int) {
|
||||||
LEGACY(R.string.ext_installer_legacy),
|
LEGACY(R.string.ext_installer_legacy),
|
||||||
PACKAGEINSTALLER(R.string.ext_installer_packageinstaller),
|
PACKAGEINSTALLER(R.string.ext_installer_packageinstaller),
|
||||||
SHIZUKU(R.string.ext_installer_shizuku),
|
SHIZUKU(R.string.ext_installer_shizuku),
|
||||||
|
|
|
@ -7,7 +7,6 @@ import androidx.compose.runtime.ReadOnlyComposable
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.ui.platform.LocalView
|
import androidx.compose.ui.platform.LocalView
|
||||||
import androidx.compose.ui.res.stringArrayResource
|
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import eu.kanade.presentation.more.settings.Preference
|
import eu.kanade.presentation.more.settings.Preference
|
||||||
import eu.kanade.presentation.util.collectAsState
|
import eu.kanade.presentation.util.collectAsState
|
||||||
|
@ -164,9 +163,9 @@ object SettingsReaderScreen : SearchableSettings {
|
||||||
Preference.PreferenceItem.ListPreference(
|
Preference.PreferenceItem.ListPreference(
|
||||||
pref = navModePref,
|
pref = navModePref,
|
||||||
title = stringResource(R.string.pref_viewer_nav),
|
title = stringResource(R.string.pref_viewer_nav),
|
||||||
entries = stringArrayResource(id = R.array.pager_nav).let {
|
entries = ReaderPreferences.TapZones
|
||||||
it.indices.zip(it).toMap()
|
.mapIndexed { index, it -> index to stringResource(it) }
|
||||||
},
|
.toMap(),
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.ListPreference(
|
Preference.PreferenceItem.ListPreference(
|
||||||
pref = readerPreferences.pagerNavInverted(),
|
pref = readerPreferences.pagerNavInverted(),
|
||||||
|
@ -182,25 +181,16 @@ object SettingsReaderScreen : SearchableSettings {
|
||||||
Preference.PreferenceItem.ListPreference(
|
Preference.PreferenceItem.ListPreference(
|
||||||
pref = imageScaleTypePref,
|
pref = imageScaleTypePref,
|
||||||
title = stringResource(R.string.pref_image_scale_type),
|
title = stringResource(R.string.pref_image_scale_type),
|
||||||
entries = mapOf(
|
entries = ReaderPreferences.ImageScaleType
|
||||||
1 to stringResource(R.string.scale_type_fit_screen),
|
.mapIndexed { index, it -> index + 1 to stringResource(it) }
|
||||||
2 to stringResource(R.string.scale_type_stretch),
|
.toMap(),
|
||||||
3 to stringResource(R.string.scale_type_fit_width),
|
|
||||||
4 to stringResource(R.string.scale_type_fit_height),
|
|
||||||
5 to stringResource(R.string.scale_type_original_size),
|
|
||||||
6 to stringResource(R.string.scale_type_smart_fit),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.ListPreference(
|
Preference.PreferenceItem.ListPreference(
|
||||||
pref = readerPreferences.zoomStart(),
|
pref = readerPreferences.zoomStart(),
|
||||||
title = stringResource(R.string.pref_zoom_start),
|
title = stringResource(R.string.pref_zoom_start),
|
||||||
entries = mapOf(
|
entries = ReaderPreferences.ZoomStart
|
||||||
1 to stringResource(R.string.zoom_start_automatic),
|
.mapIndexed { index, it -> index + 1 to stringResource(it) }
|
||||||
2 to stringResource(R.string.zoom_start_left),
|
.toMap(),
|
||||||
3 to stringResource(R.string.zoom_start_right),
|
|
||||||
4 to stringResource(R.string.zoom_start_center),
|
|
||||||
),
|
|
||||||
|
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
pref = readerPreferences.cropBorders(),
|
pref = readerPreferences.cropBorders(),
|
||||||
|
@ -265,9 +255,9 @@ object SettingsReaderScreen : SearchableSettings {
|
||||||
Preference.PreferenceItem.ListPreference(
|
Preference.PreferenceItem.ListPreference(
|
||||||
pref = navModePref,
|
pref = navModePref,
|
||||||
title = stringResource(R.string.pref_viewer_nav),
|
title = stringResource(R.string.pref_viewer_nav),
|
||||||
entries = stringArrayResource(id = R.array.webtoon_nav).let {
|
entries = ReaderPreferences.TapZones
|
||||||
it.indices.zip(it).toMap()
|
.mapIndexed { index, it -> index to stringResource(it) }
|
||||||
},
|
.toMap(),
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.ListPreference(
|
Preference.PreferenceItem.ListPreference(
|
||||||
pref = readerPreferences.webtoonNavInverted(),
|
pref = readerPreferences.webtoonNavInverted(),
|
||||||
|
|
|
@ -12,17 +12,23 @@ import eu.kanade.tachiyomi.ui.reader.setting.ReaderSettingsScreenModel
|
||||||
import eu.kanade.tachiyomi.util.system.isReleaseBuildType
|
import eu.kanade.tachiyomi.util.system.isReleaseBuildType
|
||||||
import tachiyomi.presentation.core.components.CheckboxItem
|
import tachiyomi.presentation.core.components.CheckboxItem
|
||||||
import tachiyomi.presentation.core.components.HeadingItem
|
import tachiyomi.presentation.core.components.HeadingItem
|
||||||
|
import tachiyomi.presentation.core.components.RadioItem
|
||||||
import tachiyomi.presentation.core.components.SliderItem
|
import tachiyomi.presentation.core.components.SliderItem
|
||||||
import java.text.NumberFormat
|
import java.text.NumberFormat
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
internal fun ColumnScope.ReadingModePage(screenModel: ReaderSettingsScreenModel) {
|
internal fun ColumnScope.ReadingModePage(screenModel: ReaderSettingsScreenModel) {
|
||||||
|
HeadingItem("This is still a WIP, the UI will be improved soon")
|
||||||
|
|
||||||
HeadingItem(R.string.pref_category_for_this_series)
|
HeadingItem(R.string.pref_category_for_this_series)
|
||||||
|
|
||||||
// Reading mode
|
// TODO: Reading mode
|
||||||
// Rotation type
|
HeadingItem(R.string.pref_category_reading_mode)
|
||||||
|
|
||||||
// if (pager)
|
// TODO: Rotation type
|
||||||
|
HeadingItem(R.string.rotation_type)
|
||||||
|
|
||||||
|
// TODO: if (pager)
|
||||||
PagerViewerSettings(screenModel)
|
PagerViewerSettings(screenModel)
|
||||||
|
|
||||||
WebtoonViewerSettings(screenModel)
|
WebtoonViewerSettings(screenModel)
|
||||||
|
@ -32,10 +38,47 @@ internal fun ColumnScope.ReadingModePage(screenModel: ReaderSettingsScreenModel)
|
||||||
private fun ColumnScope.PagerViewerSettings(screenModel: ReaderSettingsScreenModel) {
|
private fun ColumnScope.PagerViewerSettings(screenModel: ReaderSettingsScreenModel) {
|
||||||
HeadingItem(R.string.pager_viewer)
|
HeadingItem(R.string.pager_viewer)
|
||||||
|
|
||||||
// Tap zones
|
val navigationModePager by screenModel.preferences.navigationModePager().collectAsState()
|
||||||
// Invert tap zones
|
HeadingItem(R.string.pref_viewer_nav)
|
||||||
// Scale type
|
ReaderPreferences.TapZones.mapIndexed { index, titleResId ->
|
||||||
// Zoom start position
|
RadioItem(
|
||||||
|
label = stringResource(titleResId),
|
||||||
|
selected = navigationModePager == index,
|
||||||
|
onClick = { screenModel.preferences.navigationModePager().set(index) },
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (navigationModePager != 5) {
|
||||||
|
val pagerNavInverted by screenModel.preferences.pagerNavInverted().collectAsState()
|
||||||
|
HeadingItem(R.string.pref_read_with_tapping_inverted)
|
||||||
|
ReaderPreferences.TappingInvertMode.values().map {
|
||||||
|
RadioItem(
|
||||||
|
label = stringResource(it.titleResId),
|
||||||
|
selected = pagerNavInverted == it,
|
||||||
|
onClick = { screenModel.preferences.pagerNavInverted().set(it) },
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val imageScaleType by screenModel.preferences.imageScaleType().collectAsState()
|
||||||
|
HeadingItem(R.string.pref_image_scale_type)
|
||||||
|
ReaderPreferences.ImageScaleType.mapIndexed { index, it ->
|
||||||
|
RadioItem(
|
||||||
|
label = stringResource(it),
|
||||||
|
selected = imageScaleType == index + 1,
|
||||||
|
onClick = { screenModel.preferences.imageScaleType().set(index + 1) },
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
val zoomStart by screenModel.preferences.zoomStart().collectAsState()
|
||||||
|
HeadingItem(R.string.pref_zoom_start)
|
||||||
|
ReaderPreferences.ZoomStart.mapIndexed { index, it ->
|
||||||
|
RadioItem(
|
||||||
|
label = stringResource(it),
|
||||||
|
selected = zoomStart == index + 1,
|
||||||
|
onClick = { screenModel.preferences.zoomStart().set(index + 1) },
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
val cropBorders by screenModel.preferences.cropBorders().collectAsState()
|
val cropBorders by screenModel.preferences.cropBorders().collectAsState()
|
||||||
CheckboxItem(
|
CheckboxItem(
|
||||||
|
@ -111,8 +154,27 @@ private fun ColumnScope.WebtoonViewerSettings(screenModel: ReaderSettingsScreenM
|
||||||
|
|
||||||
HeadingItem(R.string.webtoon_viewer)
|
HeadingItem(R.string.webtoon_viewer)
|
||||||
|
|
||||||
// TODO: Tap zones
|
val navigationModeWebtoon by screenModel.preferences.navigationModeWebtoon().collectAsState()
|
||||||
// TODO: Invert tap zones
|
HeadingItem(R.string.pref_viewer_nav)
|
||||||
|
ReaderPreferences.TapZones.mapIndexed { index, titleResId ->
|
||||||
|
RadioItem(
|
||||||
|
label = stringResource(titleResId),
|
||||||
|
selected = navigationModeWebtoon == index,
|
||||||
|
onClick = { screenModel.preferences.navigationModeWebtoon().set(index) },
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (navigationModeWebtoon != 5) {
|
||||||
|
val webtoonNavInverted by screenModel.preferences.webtoonNavInverted().collectAsState()
|
||||||
|
HeadingItem(R.string.pref_read_with_tapping_inverted)
|
||||||
|
ReaderPreferences.TappingInvertMode.values().map {
|
||||||
|
RadioItem(
|
||||||
|
label = stringResource(it.titleResId),
|
||||||
|
selected = webtoonNavInverted == it,
|
||||||
|
onClick = { screenModel.preferences.webtoonNavInverted().set(it) },
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val webtoonSidePadding by screenModel.preferences.webtoonSidePadding().collectAsState()
|
val webtoonSidePadding by screenModel.preferences.webtoonSidePadding().collectAsState()
|
||||||
SliderItem(
|
SliderItem(
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package eu.kanade.tachiyomi.ui.reader.setting
|
package eu.kanade.tachiyomi.ui.reader.setting
|
||||||
|
|
||||||
|
import androidx.annotation.StringRes
|
||||||
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.util.system.isReleaseBuildType
|
import eu.kanade.tachiyomi.util.system.isReleaseBuildType
|
||||||
import tachiyomi.core.preference.PreferenceStore
|
import tachiyomi.core.preference.PreferenceStore
|
||||||
import tachiyomi.core.preference.getEnum
|
import tachiyomi.core.preference.getEnum
|
||||||
|
@ -122,11 +124,15 @@ class ReaderPreferences(
|
||||||
|
|
||||||
// endregion
|
// endregion
|
||||||
|
|
||||||
enum class TappingInvertMode(val shouldInvertHorizontal: Boolean = false, val shouldInvertVertical: Boolean = false) {
|
enum class TappingInvertMode(
|
||||||
NONE,
|
@StringRes val titleResId: Int,
|
||||||
HORIZONTAL(shouldInvertHorizontal = true),
|
val shouldInvertHorizontal: Boolean = false,
|
||||||
VERTICAL(shouldInvertVertical = true),
|
val shouldInvertVertical: Boolean = false,
|
||||||
BOTH(shouldInvertHorizontal = true, shouldInvertVertical = true),
|
) {
|
||||||
|
NONE(R.string.tapping_inverted_none),
|
||||||
|
HORIZONTAL(R.string.tapping_inverted_horizontal, shouldInvertHorizontal = true),
|
||||||
|
VERTICAL(R.string.tapping_inverted_vertical, shouldInvertVertical = true),
|
||||||
|
BOTH(R.string.tapping_inverted_both, shouldInvertHorizontal = true, shouldInvertVertical = true),
|
||||||
}
|
}
|
||||||
|
|
||||||
enum class ReaderHideThreshold(val threshold: Int) {
|
enum class ReaderHideThreshold(val threshold: Int) {
|
||||||
|
@ -139,5 +145,30 @@ class ReaderPreferences(
|
||||||
companion object {
|
companion object {
|
||||||
const val WEBTOON_PADDING_MIN = 0
|
const val WEBTOON_PADDING_MIN = 0
|
||||||
const val WEBTOON_PADDING_MAX = 25
|
const val WEBTOON_PADDING_MAX = 25
|
||||||
|
|
||||||
|
val TapZones = listOf(
|
||||||
|
R.string.label_default,
|
||||||
|
R.string.l_nav,
|
||||||
|
R.string.kindlish_nav,
|
||||||
|
R.string.edge_nav,
|
||||||
|
R.string.right_and_left_nav,
|
||||||
|
R.string.disabled_nav,
|
||||||
|
)
|
||||||
|
|
||||||
|
val ImageScaleType = listOf(
|
||||||
|
R.string.scale_type_fit_screen,
|
||||||
|
R.string.scale_type_stretch,
|
||||||
|
R.string.scale_type_fit_width,
|
||||||
|
R.string.scale_type_fit_height,
|
||||||
|
R.string.scale_type_original_size,
|
||||||
|
R.string.scale_type_smart_fit,
|
||||||
|
)
|
||||||
|
|
||||||
|
val ZoomStart = listOf(
|
||||||
|
R.string.zoom_start_automatic,
|
||||||
|
R.string.zoom_start_left,
|
||||||
|
R.string.zoom_start_right,
|
||||||
|
R.string.zoom_start_center,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,26 +1,16 @@
|
||||||
package eu.kanade.tachiyomi.ui.reader.setting
|
package eu.kanade.tachiyomi.ui.reader.setting
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.core.view.isVisible
|
|
||||||
import androidx.lifecycle.lifecycleScope
|
|
||||||
import com.google.android.material.bottomsheet.BottomSheetDialog
|
import com.google.android.material.bottomsheet.BottomSheetDialog
|
||||||
import eu.kanade.domain.manga.model.orientationType
|
import eu.kanade.domain.manga.model.orientationType
|
||||||
import eu.kanade.domain.manga.model.readingModeType
|
import eu.kanade.domain.manga.model.readingModeType
|
||||||
import eu.kanade.tachiyomi.databinding.ReaderReadingModeSettingsBinding
|
import eu.kanade.tachiyomi.databinding.ReaderReadingModeSettingsBinding
|
||||||
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
|
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
|
||||||
import eu.kanade.tachiyomi.ui.reader.viewer.pager.PagerViewer
|
|
||||||
import eu.kanade.tachiyomi.ui.reader.viewer.webtoon.WebtoonViewer
|
|
||||||
import eu.kanade.tachiyomi.util.preference.bindToPreference
|
|
||||||
import kotlinx.coroutines.flow.launchIn
|
|
||||||
import kotlinx.coroutines.flow.onEach
|
|
||||||
import uy.kohesive.injekt.injectLazy
|
|
||||||
|
|
||||||
class ReaderSettingsSheet(
|
class ReaderSettingsSheet(
|
||||||
private val activity: ReaderActivity,
|
private val activity: ReaderActivity,
|
||||||
) : BottomSheetDialog(activity) {
|
) : BottomSheetDialog(activity) {
|
||||||
|
|
||||||
private val readerPreferences: ReaderPreferences by injectLazy()
|
|
||||||
|
|
||||||
private lateinit var binding: ReaderReadingModeSettingsBinding
|
private lateinit var binding: ReaderReadingModeSettingsBinding
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
@ -30,24 +20,12 @@ class ReaderSettingsSheet(
|
||||||
setContentView(binding.root)
|
setContentView(binding.root)
|
||||||
|
|
||||||
initGeneralPreferences()
|
initGeneralPreferences()
|
||||||
|
|
||||||
when (activity.viewModel.state.value.viewer) {
|
|
||||||
is PagerViewer -> initPagerPreferences()
|
|
||||||
is WebtoonViewer -> initWebtoonPreferences()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initGeneralPreferences() {
|
private fun initGeneralPreferences() {
|
||||||
binding.viewer.onItemSelectedListener = { position ->
|
binding.viewer.onItemSelectedListener = { position ->
|
||||||
val readingModeType = ReadingModeType.fromSpinner(position)
|
val readingModeType = ReadingModeType.fromSpinner(position)
|
||||||
activity.viewModel.setMangaReadingMode(readingModeType.flagValue)
|
activity.viewModel.setMangaReadingMode(readingModeType.flagValue)
|
||||||
|
|
||||||
val mangaViewer = activity.viewModel.getMangaReadingMode()
|
|
||||||
if (mangaViewer == ReadingModeType.WEBTOON.flagValue || mangaViewer == ReadingModeType.CONTINUOUS_VERTICAL.flagValue) {
|
|
||||||
initWebtoonPreferences()
|
|
||||||
} else {
|
|
||||||
initPagerPreferences()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
binding.viewer.setSelection(activity.viewModel.manga?.readingModeType?.let { ReadingModeType.fromPreference(it.toInt()).prefValue } ?: ReadingModeType.DEFAULT.prefValue)
|
binding.viewer.setSelection(activity.viewModel.manga?.readingModeType?.let { ReadingModeType.fromPreference(it.toInt()).prefValue } ?: ReadingModeType.DEFAULT.prefValue)
|
||||||
|
|
||||||
|
@ -57,34 +35,4 @@ class ReaderSettingsSheet(
|
||||||
}
|
}
|
||||||
binding.rotationMode.setSelection(activity.viewModel.manga?.orientationType?.let { OrientationType.fromPreference(it.toInt()).prefValue } ?: OrientationType.DEFAULT.prefValue)
|
binding.rotationMode.setSelection(activity.viewModel.manga?.orientationType?.let { OrientationType.fromPreference(it.toInt()).prefValue } ?: OrientationType.DEFAULT.prefValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initPagerPreferences() {
|
|
||||||
binding.webtoonPrefsGroup.root.isVisible = false
|
|
||||||
binding.pagerPrefsGroup.root.isVisible = true
|
|
||||||
|
|
||||||
binding.pagerPrefsGroup.tappingInverted.bindToPreference(readerPreferences.pagerNavInverted(), ReaderPreferences.TappingInvertMode::class.java)
|
|
||||||
|
|
||||||
binding.pagerPrefsGroup.pagerNav.bindToPreference(readerPreferences.navigationModePager())
|
|
||||||
readerPreferences.navigationModePager().changes()
|
|
||||||
.onEach {
|
|
||||||
val isTappingEnabled = it != 5
|
|
||||||
binding.pagerPrefsGroup.tappingInverted.isVisible = isTappingEnabled
|
|
||||||
}
|
|
||||||
.launchIn(activity.lifecycleScope)
|
|
||||||
binding.pagerPrefsGroup.scaleType.bindToPreference(readerPreferences.imageScaleType(), 1)
|
|
||||||
|
|
||||||
binding.pagerPrefsGroup.zoomStart.bindToPreference(readerPreferences.zoomStart(), 1)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun initWebtoonPreferences() {
|
|
||||||
binding.pagerPrefsGroup.root.isVisible = false
|
|
||||||
binding.webtoonPrefsGroup.root.isVisible = true
|
|
||||||
|
|
||||||
binding.webtoonPrefsGroup.tappingInverted.bindToPreference(readerPreferences.webtoonNavInverted(), ReaderPreferences.TappingInvertMode::class.java)
|
|
||||||
|
|
||||||
binding.webtoonPrefsGroup.webtoonNav.bindToPreference(readerPreferences.navigationModeWebtoon())
|
|
||||||
readerPreferences.navigationModeWebtoon().changes()
|
|
||||||
.onEach { binding.webtoonPrefsGroup.tappingInverted.isVisible = it != 5 }
|
|
||||||
.launchIn(activity.lifecycleScope)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,43 +77,6 @@ class MaterialSpinnerView @JvmOverloads constructor(context: Context, attrs: Att
|
||||||
binding.details.text = entries.getOrNull(selection).orEmpty()
|
binding.details.text = entries.getOrNull(selection).orEmpty()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun bindToPreference(pref: Preference<Int>, offset: Int = 0, block: ((Int) -> Unit)? = null) {
|
|
||||||
setSelection(pref.get() - offset)
|
|
||||||
|
|
||||||
popup = makeSettingsPopup(pref, offset, block)
|
|
||||||
setOnTouchListener(popup?.dragToOpenListener)
|
|
||||||
setOnClickListener {
|
|
||||||
popup?.show()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun <T : Enum<T>> bindToPreference(pref: Preference<T>, clazz: Class<T>) {
|
|
||||||
val enumConstants = clazz.enumConstants
|
|
||||||
enumConstants?.indexOf(pref.get())?.let { setSelection(it) }
|
|
||||||
|
|
||||||
popup = makeSettingsPopup(pref, clazz)
|
|
||||||
setOnTouchListener(popup?.dragToOpenListener)
|
|
||||||
setOnClickListener {
|
|
||||||
popup?.show()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun <T : Enum<T>> makeSettingsPopup(preference: Preference<T>, clazz: Class<T>): PopupMenu {
|
|
||||||
return createPopupMenu { pos ->
|
|
||||||
onItemSelectedListener?.invoke(pos)
|
|
||||||
|
|
||||||
val enumConstants = clazz.enumConstants
|
|
||||||
enumConstants?.get(pos)?.let { enumValue -> preference.set(enumValue) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun makeSettingsPopup(preference: Preference<Int>, intValues: List<Int?>, block: ((Int) -> Unit)? = null): PopupMenu {
|
|
||||||
return createPopupMenu { pos ->
|
|
||||||
preference.set(intValues[pos] ?: 0)
|
|
||||||
block?.invoke(pos)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun makeSettingsPopup(preference: Preference<Int>, offset: Int = 0, block: ((Int) -> Unit)? = null): PopupMenu {
|
private fun makeSettingsPopup(preference: Preference<Int>, offset: Int = 0, block: ((Int) -> Unit)? = null): PopupMenu {
|
||||||
return createPopupMenu { pos ->
|
return createPopupMenu { pos ->
|
||||||
preference.set(pos + offset)
|
preference.set(pos + offset)
|
||||||
|
|
|
@ -1,46 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/pager_prefs"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginBottom="8dp"
|
|
||||||
android:paddingStart="16dp"
|
|
||||||
android:paddingEnd="16dp"
|
|
||||||
android:text="@string/pager_viewer"
|
|
||||||
android:textAppearance="@style/TextAppearance.Tachiyomi.SectionHeader" />
|
|
||||||
|
|
||||||
<eu.kanade.tachiyomi.widget.MaterialSpinnerView
|
|
||||||
android:id="@+id/pager_nav"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:entries="@array/pager_nav"
|
|
||||||
app:title="@string/pref_viewer_nav" />
|
|
||||||
|
|
||||||
<eu.kanade.tachiyomi.widget.MaterialSpinnerView
|
|
||||||
android:id="@+id/tapping_inverted"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:entries="@array/invert_tapping_mode"
|
|
||||||
app:title="@string/pref_read_with_tapping_inverted" />
|
|
||||||
|
|
||||||
<eu.kanade.tachiyomi.widget.MaterialSpinnerView
|
|
||||||
android:id="@+id/scale_type"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:entries="@array/image_scale_type"
|
|
||||||
app:title="@string/pref_image_scale_type" />
|
|
||||||
|
|
||||||
<eu.kanade.tachiyomi.widget.MaterialSpinnerView
|
|
||||||
android:id="@+id/zoom_start"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:entries="@array/zoom_start"
|
|
||||||
app:title="@string/pref_zoom_start" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
|
@ -1,7 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
@ -10,17 +9,6 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/for_this_series_prefs"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="16dp"
|
|
||||||
android:layout_marginBottom="8dp"
|
|
||||||
android:paddingStart="16dp"
|
|
||||||
android:paddingEnd="16dp"
|
|
||||||
android:text="@string/pref_category_for_this_series"
|
|
||||||
android:textAppearance="@style/TextAppearance.Tachiyomi.SectionHeader" />
|
|
||||||
|
|
||||||
<eu.kanade.tachiyomi.widget.MaterialSpinnerView
|
<eu.kanade.tachiyomi.widget.MaterialSpinnerView
|
||||||
android:id="@+id/viewer"
|
android:id="@+id/viewer"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -36,21 +24,6 @@
|
||||||
android:entries="@array/rotation_type"
|
android:entries="@array/rotation_type"
|
||||||
app:title="@string/rotation_type" />
|
app:title="@string/rotation_type" />
|
||||||
|
|
||||||
<include
|
|
||||||
android:id="@+id/pager_prefs_group"
|
|
||||||
layout="@layout/reader_pager_settings"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:visibility="gone"
|
|
||||||
tools:visibility="visible" />
|
|
||||||
|
|
||||||
<include
|
|
||||||
android:id="@+id/webtoon_prefs_group"
|
|
||||||
layout="@layout/reader_webtoon_settings"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:visibility="gone" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</androidx.core.widget.NestedScrollView>
|
</androidx.core.widget.NestedScrollView>
|
||||||
|
|
|
@ -1,32 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/webtoon_prefs"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:paddingStart="16dp"
|
|
||||||
android:paddingEnd="16dp"
|
|
||||||
android:layout_marginBottom="8dp"
|
|
||||||
android:text="@string/webtoon_viewer"
|
|
||||||
android:textAppearance="@style/TextAppearance.Tachiyomi.SectionHeader" />
|
|
||||||
|
|
||||||
<eu.kanade.tachiyomi.widget.MaterialSpinnerView
|
|
||||||
android:id="@+id/webtoon_nav"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:entries="@array/webtoon_nav"
|
|
||||||
app:title="@string/pref_viewer_nav" />
|
|
||||||
|
|
||||||
<eu.kanade.tachiyomi.widget.MaterialSpinnerView
|
|
||||||
android:id="@+id/tapping_inverted"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:entries="@array/invert_tapping_mode"
|
|
||||||
app:title="@string/pref_read_with_tapping_inverted" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
|
@ -9,22 +9,6 @@
|
||||||
<item>@string/vertical_plus_viewer</item>
|
<item>@string/vertical_plus_viewer</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<string-array name="image_scale_type">
|
|
||||||
<item>@string/scale_type_fit_screen</item>
|
|
||||||
<item>@string/scale_type_stretch</item>
|
|
||||||
<item>@string/scale_type_fit_width</item>
|
|
||||||
<item>@string/scale_type_fit_height</item>
|
|
||||||
<item>@string/scale_type_original_size</item>
|
|
||||||
<item>@string/scale_type_smart_fit</item>
|
|
||||||
</string-array>
|
|
||||||
|
|
||||||
<string-array name="zoom_start">
|
|
||||||
<item>@string/zoom_start_automatic</item>
|
|
||||||
<item>@string/zoom_start_left</item>
|
|
||||||
<item>@string/zoom_start_right</item>
|
|
||||||
<item>@string/zoom_start_center</item>
|
|
||||||
</string-array>
|
|
||||||
|
|
||||||
<string-array name="rotation_type">
|
<string-array name="rotation_type">
|
||||||
<item>@string/label_default</item>
|
<item>@string/label_default</item>
|
||||||
<item>@string/rotation_free</item>
|
<item>@string/rotation_free</item>
|
||||||
|
@ -34,29 +18,4 @@
|
||||||
<item>@string/rotation_force_landscape</item>
|
<item>@string/rotation_force_landscape</item>
|
||||||
<item>@string/rotation_reverse_portrait</item>
|
<item>@string/rotation_reverse_portrait</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<string-array name="invert_tapping_mode">
|
|
||||||
<item>@string/tapping_inverted_none</item>
|
|
||||||
<item>@string/tapping_inverted_horizontal</item>
|
|
||||||
<item>@string/tapping_inverted_vertical</item>
|
|
||||||
<item>@string/tapping_inverted_both</item>
|
|
||||||
</string-array>
|
|
||||||
|
|
||||||
<string-array name="pager_nav">
|
|
||||||
<item>@string/label_default</item>
|
|
||||||
<item>@string/l_nav</item>
|
|
||||||
<item>@string/kindlish_nav</item>
|
|
||||||
<item>@string/edge_nav</item>
|
|
||||||
<item>@string/right_and_left_nav</item>
|
|
||||||
<item>@string/disabled_nav</item>
|
|
||||||
</string-array>
|
|
||||||
|
|
||||||
<string-array name="webtoon_nav">
|
|
||||||
<item>@string/label_default</item>
|
|
||||||
<item>@string/l_nav</item>
|
|
||||||
<item>@string/kindlish_nav</item>
|
|
||||||
<item>@string/edge_nav</item>
|
|
||||||
<item>@string/right_and_left_nav</item>
|
|
||||||
<item>@string/disabled_nav</item>
|
|
||||||
</string-array>
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in a new issue