mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-11-04 08:08:55 +01:00 
			
		
		
		
	Move all pager/webtoon reader setting to Compose sheet
This commit is contained in:
		@@ -1,6 +1,7 @@
 | 
			
		||||
package eu.kanade.domain.base
 | 
			
		||||
 | 
			
		||||
import android.content.Context
 | 
			
		||||
import androidx.annotation.StringRes
 | 
			
		||||
import eu.kanade.tachiyomi.R
 | 
			
		||||
import eu.kanade.tachiyomi.util.system.isPreviewBuildType
 | 
			
		||||
import eu.kanade.tachiyomi.util.system.isReleaseBuildType
 | 
			
		||||
@@ -19,7 +20,7 @@ class BasePreferences(
 | 
			
		||||
 | 
			
		||||
    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),
 | 
			
		||||
        PACKAGEINSTALLER(R.string.ext_installer_packageinstaller),
 | 
			
		||||
        SHIZUKU(R.string.ext_installer_shizuku),
 | 
			
		||||
 
 | 
			
		||||
@@ -7,7 +7,6 @@ import androidx.compose.runtime.ReadOnlyComposable
 | 
			
		||||
import androidx.compose.runtime.getValue
 | 
			
		||||
import androidx.compose.runtime.remember
 | 
			
		||||
import androidx.compose.ui.platform.LocalView
 | 
			
		||||
import androidx.compose.ui.res.stringArrayResource
 | 
			
		||||
import androidx.compose.ui.res.stringResource
 | 
			
		||||
import eu.kanade.presentation.more.settings.Preference
 | 
			
		||||
import eu.kanade.presentation.util.collectAsState
 | 
			
		||||
@@ -164,9 +163,9 @@ object SettingsReaderScreen : SearchableSettings {
 | 
			
		||||
                Preference.PreferenceItem.ListPreference(
 | 
			
		||||
                    pref = navModePref,
 | 
			
		||||
                    title = stringResource(R.string.pref_viewer_nav),
 | 
			
		||||
                    entries = stringArrayResource(id = R.array.pager_nav).let {
 | 
			
		||||
                        it.indices.zip(it).toMap()
 | 
			
		||||
                    },
 | 
			
		||||
                    entries = ReaderPreferences.TapZones
 | 
			
		||||
                        .mapIndexed { index, it -> index to stringResource(it) }
 | 
			
		||||
                        .toMap(),
 | 
			
		||||
                ),
 | 
			
		||||
                Preference.PreferenceItem.ListPreference(
 | 
			
		||||
                    pref = readerPreferences.pagerNavInverted(),
 | 
			
		||||
@@ -182,25 +181,16 @@ object SettingsReaderScreen : SearchableSettings {
 | 
			
		||||
                Preference.PreferenceItem.ListPreference(
 | 
			
		||||
                    pref = imageScaleTypePref,
 | 
			
		||||
                    title = stringResource(R.string.pref_image_scale_type),
 | 
			
		||||
                    entries = mapOf(
 | 
			
		||||
                        1 to stringResource(R.string.scale_type_fit_screen),
 | 
			
		||||
                        2 to stringResource(R.string.scale_type_stretch),
 | 
			
		||||
                        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),
 | 
			
		||||
                    ),
 | 
			
		||||
                    entries = ReaderPreferences.ImageScaleType
 | 
			
		||||
                        .mapIndexed { index, it -> index + 1 to stringResource(it) }
 | 
			
		||||
                        .toMap(),
 | 
			
		||||
                ),
 | 
			
		||||
                Preference.PreferenceItem.ListPreference(
 | 
			
		||||
                    pref = readerPreferences.zoomStart(),
 | 
			
		||||
                    title = stringResource(R.string.pref_zoom_start),
 | 
			
		||||
                    entries = mapOf(
 | 
			
		||||
                        1 to stringResource(R.string.zoom_start_automatic),
 | 
			
		||||
                        2 to stringResource(R.string.zoom_start_left),
 | 
			
		||||
                        3 to stringResource(R.string.zoom_start_right),
 | 
			
		||||
                        4 to stringResource(R.string.zoom_start_center),
 | 
			
		||||
                    ),
 | 
			
		||||
 | 
			
		||||
                    entries = ReaderPreferences.ZoomStart
 | 
			
		||||
                        .mapIndexed { index, it -> index + 1 to stringResource(it) }
 | 
			
		||||
                        .toMap(),
 | 
			
		||||
                ),
 | 
			
		||||
                Preference.PreferenceItem.SwitchPreference(
 | 
			
		||||
                    pref = readerPreferences.cropBorders(),
 | 
			
		||||
@@ -265,9 +255,9 @@ object SettingsReaderScreen : SearchableSettings {
 | 
			
		||||
                Preference.PreferenceItem.ListPreference(
 | 
			
		||||
                    pref = navModePref,
 | 
			
		||||
                    title = stringResource(R.string.pref_viewer_nav),
 | 
			
		||||
                    entries = stringArrayResource(id = R.array.webtoon_nav).let {
 | 
			
		||||
                        it.indices.zip(it).toMap()
 | 
			
		||||
                    },
 | 
			
		||||
                    entries = ReaderPreferences.TapZones
 | 
			
		||||
                        .mapIndexed { index, it -> index to stringResource(it) }
 | 
			
		||||
                        .toMap(),
 | 
			
		||||
                ),
 | 
			
		||||
                Preference.PreferenceItem.ListPreference(
 | 
			
		||||
                    pref = readerPreferences.webtoonNavInverted(),
 | 
			
		||||
 
 | 
			
		||||
@@ -12,17 +12,23 @@ import eu.kanade.tachiyomi.ui.reader.setting.ReaderSettingsScreenModel
 | 
			
		||||
import eu.kanade.tachiyomi.util.system.isReleaseBuildType
 | 
			
		||||
import tachiyomi.presentation.core.components.CheckboxItem
 | 
			
		||||
import tachiyomi.presentation.core.components.HeadingItem
 | 
			
		||||
import tachiyomi.presentation.core.components.RadioItem
 | 
			
		||||
import tachiyomi.presentation.core.components.SliderItem
 | 
			
		||||
import java.text.NumberFormat
 | 
			
		||||
 | 
			
		||||
@Composable
 | 
			
		||||
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)
 | 
			
		||||
 | 
			
		||||
    // Reading mode
 | 
			
		||||
    // Rotation type
 | 
			
		||||
    // TODO: Reading mode
 | 
			
		||||
    HeadingItem(R.string.pref_category_reading_mode)
 | 
			
		||||
 | 
			
		||||
    // if (pager)
 | 
			
		||||
    // TODO: Rotation type
 | 
			
		||||
    HeadingItem(R.string.rotation_type)
 | 
			
		||||
 | 
			
		||||
    // TODO: if (pager)
 | 
			
		||||
    PagerViewerSettings(screenModel)
 | 
			
		||||
 | 
			
		||||
    WebtoonViewerSettings(screenModel)
 | 
			
		||||
@@ -32,10 +38,47 @@ internal fun ColumnScope.ReadingModePage(screenModel: ReaderSettingsScreenModel)
 | 
			
		||||
private fun ColumnScope.PagerViewerSettings(screenModel: ReaderSettingsScreenModel) {
 | 
			
		||||
    HeadingItem(R.string.pager_viewer)
 | 
			
		||||
 | 
			
		||||
    // Tap zones
 | 
			
		||||
    // Invert tap zones
 | 
			
		||||
    // Scale type
 | 
			
		||||
    // Zoom start position
 | 
			
		||||
    val navigationModePager by screenModel.preferences.navigationModePager().collectAsState()
 | 
			
		||||
    HeadingItem(R.string.pref_viewer_nav)
 | 
			
		||||
    ReaderPreferences.TapZones.mapIndexed { index, titleResId ->
 | 
			
		||||
        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()
 | 
			
		||||
    CheckboxItem(
 | 
			
		||||
@@ -111,8 +154,27 @@ private fun ColumnScope.WebtoonViewerSettings(screenModel: ReaderSettingsScreenM
 | 
			
		||||
 | 
			
		||||
    HeadingItem(R.string.webtoon_viewer)
 | 
			
		||||
 | 
			
		||||
    // TODO: Tap zones
 | 
			
		||||
    // TODO: Invert tap zones
 | 
			
		||||
    val navigationModeWebtoon by screenModel.preferences.navigationModeWebtoon().collectAsState()
 | 
			
		||||
    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()
 | 
			
		||||
    SliderItem(
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,7 @@
 | 
			
		||||
package eu.kanade.tachiyomi.ui.reader.setting
 | 
			
		||||
 | 
			
		||||
import androidx.annotation.StringRes
 | 
			
		||||
import eu.kanade.tachiyomi.R
 | 
			
		||||
import eu.kanade.tachiyomi.util.system.isReleaseBuildType
 | 
			
		||||
import tachiyomi.core.preference.PreferenceStore
 | 
			
		||||
import tachiyomi.core.preference.getEnum
 | 
			
		||||
@@ -122,11 +124,15 @@ class ReaderPreferences(
 | 
			
		||||
 | 
			
		||||
    // endregion
 | 
			
		||||
 | 
			
		||||
    enum class TappingInvertMode(val shouldInvertHorizontal: Boolean = false, val shouldInvertVertical: Boolean = false) {
 | 
			
		||||
        NONE,
 | 
			
		||||
        HORIZONTAL(shouldInvertHorizontal = true),
 | 
			
		||||
        VERTICAL(shouldInvertVertical = true),
 | 
			
		||||
        BOTH(shouldInvertHorizontal = true, shouldInvertVertical = true),
 | 
			
		||||
    enum class TappingInvertMode(
 | 
			
		||||
        @StringRes val titleResId: Int,
 | 
			
		||||
        val shouldInvertHorizontal: Boolean = false,
 | 
			
		||||
        val shouldInvertVertical: Boolean = false,
 | 
			
		||||
    ) {
 | 
			
		||||
        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) {
 | 
			
		||||
@@ -139,5 +145,30 @@ class ReaderPreferences(
 | 
			
		||||
    companion object {
 | 
			
		||||
        const val WEBTOON_PADDING_MIN = 0
 | 
			
		||||
        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
 | 
			
		||||
 | 
			
		||||
import android.os.Bundle
 | 
			
		||||
import androidx.core.view.isVisible
 | 
			
		||||
import androidx.lifecycle.lifecycleScope
 | 
			
		||||
import com.google.android.material.bottomsheet.BottomSheetDialog
 | 
			
		||||
import eu.kanade.domain.manga.model.orientationType
 | 
			
		||||
import eu.kanade.domain.manga.model.readingModeType
 | 
			
		||||
import eu.kanade.tachiyomi.databinding.ReaderReadingModeSettingsBinding
 | 
			
		||||
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(
 | 
			
		||||
    private val activity: ReaderActivity,
 | 
			
		||||
) : BottomSheetDialog(activity) {
 | 
			
		||||
 | 
			
		||||
    private val readerPreferences: ReaderPreferences by injectLazy()
 | 
			
		||||
 | 
			
		||||
    private lateinit var binding: ReaderReadingModeSettingsBinding
 | 
			
		||||
 | 
			
		||||
    override fun onCreate(savedInstanceState: Bundle?) {
 | 
			
		||||
@@ -30,24 +20,12 @@ class ReaderSettingsSheet(
 | 
			
		||||
        setContentView(binding.root)
 | 
			
		||||
 | 
			
		||||
        initGeneralPreferences()
 | 
			
		||||
 | 
			
		||||
        when (activity.viewModel.state.value.viewer) {
 | 
			
		||||
            is PagerViewer -> initPagerPreferences()
 | 
			
		||||
            is WebtoonViewer -> initWebtoonPreferences()
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private fun initGeneralPreferences() {
 | 
			
		||||
        binding.viewer.onItemSelectedListener = { position ->
 | 
			
		||||
            val readingModeType = ReadingModeType.fromSpinner(position)
 | 
			
		||||
            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)
 | 
			
		||||
 | 
			
		||||
@@ -57,34 +35,4 @@ class ReaderSettingsSheet(
 | 
			
		||||
        }
 | 
			
		||||
        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()
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    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 {
 | 
			
		||||
        return createPopupMenu { pos ->
 | 
			
		||||
            preference.set(pos + offset)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user