From 3ebf39bd55cffbf5dc4bfe1c39e91aa22fa93777 Mon Sep 17 00:00:00 2001 From: arkon Date: Sun, 6 Aug 2023 22:27:45 -0400 Subject: [PATCH] Minor reader cleanup --- .../tachiyomi/ui/reader/ReaderActivity.kt | 33 +++++-------------- .../ui/reader/setting/OrientationType.kt | 16 ++++----- .../ui/reader/setting/ReadingModeType.kt | 14 ++++---- app/src/main/res/values/arrays.xml | 21 ------------ 4 files changed, 23 insertions(+), 61 deletions(-) delete mode 100644 app/src/main/res/values/arrays.xml diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt index 1e8971057..4d09abb55 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt @@ -382,11 +382,14 @@ class ReaderActivity : BaseActivity() { binding.pageNumber.setComposeContent { val state by viewModel.state.collectAsState() + val showPageNumber by viewModel.readerPreferences.showPageNumber().collectAsState() - PageIndicatorText( - currentPage = state.currentPage, - totalPages = state.totalPages, - ) + if (!state.menuVisible && showPageNumber) { + PageIndicatorText( + currentPage = state.currentPage, + totalPages = state.totalPages, + ) + } } binding.dialogRoot.setComposeContent { @@ -554,10 +557,6 @@ class ReaderActivity : BaseActivity() { bottomAnimation.applySystemAnimatorScale(this) binding.readerMenuBottom.startAnimation(bottomAnimation) } - - if (readerPreferences.showPageNumber().get()) { - config?.setPageNumberVisibility(false) - } } else { if (readerPreferences.fullscreen().get()) { windowInsetsController.hide(WindowInsetsCompat.Type.systemBars()) @@ -580,10 +579,6 @@ class ReaderActivity : BaseActivity() { bottomAnimation.applySystemAnimatorScale(this) binding.readerMenuBottom.startAnimation(bottomAnimation) } - - if (readerPreferences.showPageNumber().get()) { - config?.setPageNumberVisibility(true) - } } } @@ -636,9 +631,8 @@ class ReaderActivity : BaseActivity() { private fun showReadingModeToast(mode: Int) { try { - val strings = resources.getStringArray(R.array.viewers_selector) readingModeToast?.cancel() - readingModeToast = toast(strings[mode]) + readingModeToast = toast(ReadingModeType.fromPreference(mode).stringRes) } catch (e: ArrayIndexOutOfBoundsException) { logcat(LogPriority.ERROR) { "Unknown reading mode: $mode" } } @@ -892,10 +886,6 @@ class ReaderActivity : BaseActivity() { } .launchIn(lifecycleScope) - readerPreferences.showPageNumber().changes() - .onEach(::setPageNumberVisibility) - .launchIn(lifecycleScope) - readerPreferences.trueColor().changes() .onEach(::setTrueColor) .launchIn(lifecycleScope) @@ -945,13 +935,6 @@ class ReaderActivity : BaseActivity() { } } - /** - * Sets the visibility of the bottom page indicator according to [visible]. - */ - fun setPageNumberVisibility(visible: Boolean) { - binding.pageNumber.isVisible = visible - } - /** * Sets the 32-bit color mode according to [enabled]. */ diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/OrientationType.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/OrientationType.kt index bf5135153..3650038f5 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/OrientationType.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/OrientationType.kt @@ -5,14 +5,14 @@ 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.label_default, R.drawable.ic_screen_rotation_24dp, 0x00000000), - FREE(1, ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED, R.string.rotation_free, R.drawable.ic_screen_rotation_24dp, 0x00000008), - PORTRAIT(2, ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT, R.string.rotation_portrait, R.drawable.ic_stay_current_portrait_24dp, 0x00000010), - LANDSCAPE(3, ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE, R.string.rotation_landscape, R.drawable.ic_stay_current_landscape_24dp, 0x00000018), - LOCKED_PORTRAIT(4, ActivityInfo.SCREEN_ORIENTATION_PORTRAIT, R.string.rotation_force_portrait, R.drawable.ic_screen_lock_portrait_24dp, 0x00000020), - LOCKED_LANDSCAPE(5, ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE, R.string.rotation_force_landscape, R.drawable.ic_screen_lock_landscape_24dp, 0x00000028), - REVERSE_PORTRAIT(6, ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT, R.string.rotation_reverse_portrait, R.drawable.ic_stay_current_portrait_24dp, 0x00000030), +enum class OrientationType(val flag: Int, @StringRes val stringRes: Int, @DrawableRes val iconRes: Int, val flagValue: Int) { + DEFAULT(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED, R.string.label_default, R.drawable.ic_screen_rotation_24dp, 0x00000000), + FREE(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED, R.string.rotation_free, R.drawable.ic_screen_rotation_24dp, 0x00000008), + PORTRAIT(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT, R.string.rotation_portrait, R.drawable.ic_stay_current_portrait_24dp, 0x00000010), + LANDSCAPE(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE, R.string.rotation_landscape, R.drawable.ic_stay_current_landscape_24dp, 0x00000018), + LOCKED_PORTRAIT(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT, R.string.rotation_force_portrait, R.drawable.ic_screen_lock_portrait_24dp, 0x00000020), + LOCKED_LANDSCAPE(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE, R.string.rotation_force_landscape, R.drawable.ic_screen_lock_landscape_24dp, 0x00000028), + REVERSE_PORTRAIT(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT, R.string.rotation_reverse_portrait, R.drawable.ic_stay_current_portrait_24dp, 0x00000030), ; companion object { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/ReadingModeType.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/ReadingModeType.kt index e3f3b38b7..2bce0735b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/ReadingModeType.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/ReadingModeType.kt @@ -10,13 +10,13 @@ import eu.kanade.tachiyomi.ui.reader.viewer.pager.R2LPagerViewer import eu.kanade.tachiyomi.ui.reader.viewer.pager.VerticalPagerViewer import eu.kanade.tachiyomi.ui.reader.viewer.webtoon.WebtoonViewer -enum class ReadingModeType(val prefValue: Int, @StringRes val stringRes: Int, @DrawableRes val iconRes: Int, val flagValue: Int) { - DEFAULT(0, R.string.label_default, 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_viewer, R.drawable.ic_reader_webtoon_24dp, 0x00000004), - CONTINUOUS_VERTICAL(5, R.string.vertical_plus_viewer, R.drawable.ic_reader_continuous_vertical_24dp, 0x00000005), +enum class ReadingModeType(@StringRes val stringRes: Int, @DrawableRes val iconRes: Int, val flagValue: Int) { + DEFAULT(R.string.label_default, R.drawable.ic_reader_default_24dp, 0x00000000), + LEFT_TO_RIGHT(R.string.left_to_right_viewer, R.drawable.ic_reader_ltr_24dp, 0x00000001), + RIGHT_TO_LEFT(R.string.right_to_left_viewer, R.drawable.ic_reader_rtl_24dp, 0x00000002), + VERTICAL(R.string.vertical_viewer, R.drawable.ic_reader_vertical_24dp, 0x00000003), + WEBTOON(R.string.webtoon_viewer, R.drawable.ic_reader_webtoon_24dp, 0x00000004), + CONTINUOUS_VERTICAL(R.string.vertical_plus_viewer, R.drawable.ic_reader_continuous_vertical_24dp, 0x00000005), ; companion object { diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml deleted file mode 100644 index 11d827db9..000000000 --- a/app/src/main/res/values/arrays.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - @string/label_default - @string/left_to_right_viewer - @string/right_to_left_viewer - @string/vertical_viewer - @string/webtoon_viewer - @string/vertical_plus_viewer - - - - @string/label_default - @string/rotation_free - @string/rotation_portrait - @string/rotation_landscape - @string/rotation_force_portrait - @string/rotation_force_landscape - @string/rotation_reverse_portrait - -