diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/settings/OrientationType.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/settings/OrientationType.kt index be9834ea3c..37d389f7a6 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/settings/OrientationType.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/settings/OrientationType.kt @@ -5,17 +5,21 @@ import androidx.annotation.DrawableRes import androidx.annotation.StringRes import eu.kanade.tachiyomi.R -enum class OrientationType(val prefValue: Int, val flag: Int, @StringRes val stringRes: Int, @DrawableRes val iconRes: Int, val flagValue: Int) { - DEFAULT(0, ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED, R.string.default_value, R.drawable.ic_screen_rotation_24dp, 0x00000000), - FREE(1, ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED, R.string.free, R.drawable.ic_screen_rotation_24dp, 0x00000008), - PORTRAIT(2, ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT, R.string.portrait, R.drawable.ic_stay_current_portrait_24dp, 0x00000010), - LANDSCAPE(3, ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE, R.string.landscape, R.drawable.ic_stay_current_landscape_24dp, 0x00000018), - LOCKED_PORTRAIT(4, ActivityInfo.SCREEN_ORIENTATION_PORTRAIT, R.string.locked_portrait, R.drawable.ic_screen_lock_portrait_24dp, 0x00000020), - LOCKED_LANDSCAPE(5, ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE, R.string.locked_landscape, R.drawable.ic_screen_lock_landscape_24dp, 0x00000028), +enum class OrientationType(val prefValue: Int, val flag: Int, @StringRes val stringRes: Int, @DrawableRes val iconRes: Int) { + DEFAULT(0, ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED, R.string.default_value, R.drawable.ic_screen_rotation_24dp), + FREE(1, ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED, R.string.free, R.drawable.ic_screen_rotation_24dp), + PORTRAIT(2, ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT, R.string.portrait, R.drawable.ic_stay_current_portrait_24dp), + LANDSCAPE(3, ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE, R.string.landscape, R.drawable.ic_stay_current_landscape_24dp), + LOCKED_PORTRAIT(4, ActivityInfo.SCREEN_ORIENTATION_PORTRAIT, R.string.locked_portrait, R.drawable.ic_screen_lock_portrait_24dp), + LOCKED_LANDSCAPE(5, ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE, R.string.locked_landscape, R.drawable.ic_screen_lock_landscape_24dp), ; + @Suppress("RemoveRedundantQualifierName") + val flagValue = prefValue shl OrientationType.SHIFT + companion object { - const val MASK = 0x00000038 + private const val SHIFT = 0x00000003 + const val MASK = 7 shl SHIFT fun fromPreference(preference: Int): OrientationType = values().find { it.flagValue == preference } ?: FREE diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/settings/ReadingModeType.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/settings/ReadingModeType.kt index 1601114859..57d3de5650 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/settings/ReadingModeType.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/settings/ReadingModeType.kt @@ -5,18 +5,22 @@ import androidx.annotation.StringRes import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.util.lang.next -enum class ReadingModeType(val prefValue: Int, @StringRes val stringRes: Int, @DrawableRes val iconRes: Int, val flagValue: Int) { - DEFAULT(0, R.string.default_value, R.drawable.ic_reader_default_24dp, 0x00000000), - LEFT_TO_RIGHT(1, R.string.left_to_right_viewer, R.drawable.ic_reader_ltr_24dp, 0x00000001), - RIGHT_TO_LEFT(2, R.string.right_to_left_viewer, R.drawable.ic_reader_rtl_24dp, 0x00000002), - VERTICAL(3, R.string.vertical_viewer, R.drawable.ic_reader_vertical_24dp, 0x00000003), - WEBTOON(4, R.string.webtoon, R.drawable.ic_reader_webtoon_24dp, 0x00000004), - CONTINUOUS_VERTICAL(5, R.string.continuous_vertical, R.drawable.ic_reader_continuous_vertical_24dp, 0x00000005), +enum class ReadingModeType(val prefValue: Int, @StringRes val stringRes: Int, @DrawableRes val iconRes: Int) { + DEFAULT(0, R.string.default_value, R.drawable.ic_reader_default_24dp), + LEFT_TO_RIGHT(1, R.string.left_to_right_viewer, R.drawable.ic_reader_ltr_24dp), + RIGHT_TO_LEFT(2, R.string.right_to_left_viewer, R.drawable.ic_reader_rtl_24dp), + VERTICAL(3, R.string.vertical_viewer, R.drawable.ic_reader_vertical_24dp), + WEBTOON(4, R.string.webtoon, R.drawable.ic_reader_webtoon_24dp), + CONTINUOUS_VERTICAL(5, R.string.continuous_vertical, R.drawable.ic_reader_continuous_vertical_24dp), ; + @Suppress("RemoveRedundantQualifierName") + val flagValue = prefValue shl ReadingModeType.SHIFT + companion object { fun fromPreference(preference: Int): ReadingModeType = values().find { it.flagValue == preference } ?: DEFAULT - const val MASK = 0x00000007 + private const val SHIFT = 0x00000000 + const val MASK = 7 shl SHIFT fun getNextReadingMode(preference: Int): ReadingModeType { val current = fromPreference(preference)