From 609d8c9685a54734138b39cc25c261794a21ec99 Mon Sep 17 00:00:00 2001 From: arkon Date: Sun, 14 Mar 2021 17:13:20 -0400 Subject: [PATCH] Add icons for reading mode toggle --- .../tachiyomi/ui/reader/ReaderActivity.kt | 10 ++++++--- .../tachiyomi/ui/reader/ReaderPresenter.kt | 4 ++-- .../ui/reader/setting/ReadingModeType.kt | 15 ++++++------- .../ic_reader_continuous_vertical_24dp.xml | 15 +++++++++++++ .../res/drawable/ic_reader_default_24dp.xml | 12 +++++++++++ .../main/res/drawable/ic_reader_ltr_24dp.xml | 21 +++++++++++++++++++ .../main/res/drawable/ic_reader_rtl_24dp.xml | 21 +++++++++++++++++++ .../res/drawable/ic_reader_vertical_24dp.xml | 12 +++++++++++ .../res/drawable/ic_reader_webtoon_24dp.xml | 12 +++++++++++ app/src/main/res/layout/reader_activity.xml | 2 +- 10 files changed, 111 insertions(+), 13 deletions(-) create mode 100644 app/src/main/res/drawable/ic_reader_continuous_vertical_24dp.xml create mode 100644 app/src/main/res/drawable/ic_reader_default_24dp.xml create mode 100644 app/src/main/res/drawable/ic_reader_ltr_24dp.xml create mode 100644 app/src/main/res/drawable/ic_reader_rtl_24dp.xml create mode 100644 app/src/main/res/drawable/ic_reader_vertical_24dp.xml create mode 100644 app/src/main/res/drawable/ic_reader_webtoon_24dp.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 acaeafee01..e78444feae 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 @@ -343,7 +343,7 @@ class ReaderActivity : BaseRxActivity() } binding.actionReaderMode.setOnClickListener { - val newReadingMode = ReadingModeType.getNextReadingMode(presenter.manga?.viewer ?: 0) + val newReadingMode = ReadingModeType.getNextReadingMode(presenter.getMangaViewer(resolveDefault = false)) presenter.setMangaViewer(newReadingMode.prefValue) menuToggleToast?.cancel() @@ -464,12 +464,16 @@ class ReaderActivity : BaseRxActivity() */ fun setManga(manga: Manga) { val prevViewer = viewer + + val viewerMode = ReadingModeType.fromPreference(presenter.getMangaViewer(resolveDefault = false)) + binding.actionReaderMode.setImageResource(viewerMode.iconRes) + val newViewer = when (presenter.getMangaViewer()) { - ReadingModeType.RIGHT_TO_LEFT.prefValue -> R2LPagerViewer(this) + ReadingModeType.LEFT_TO_RIGHT.prefValue -> L2RPagerViewer(this) ReadingModeType.VERTICAL.prefValue -> VerticalPagerViewer(this) ReadingModeType.WEBTOON.prefValue -> WebtoonViewer(this) ReadingModeType.CONTINUOUS_VERTICAL.prefValue -> WebtoonViewer(this, isContinuous = false) - else -> L2RPagerViewer(this) + else -> R2LPagerViewer(this) } // Destroy previous viewer if there was one diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt index f02f17c393..02da5ba901 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt @@ -489,9 +489,9 @@ class ReaderPresenter( /** * Returns the viewer position used by this manga or the default one. */ - fun getMangaViewer(): Int { + fun getMangaViewer(resolveDefault: Boolean = true): Int { val manga = manga ?: return preferences.defaultViewer() - return if (manga.viewer == 0) preferences.defaultViewer() else manga.viewer + return if (resolveDefault && manga.viewer == 0) preferences.defaultViewer() else manga.viewer } /** 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 3fd795fab8..7e54c74c7f 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 @@ -1,16 +1,17 @@ package eu.kanade.tachiyomi.ui.reader.setting +import androidx.annotation.DrawableRes 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) { - DEFAULT(0, R.string.default_viewer), - LEFT_TO_RIGHT(1, R.string.left_to_right_viewer), - RIGHT_TO_LEFT(2, R.string.right_to_left_viewer), - VERTICAL(3, R.string.vertical_viewer), - WEBTOON(4, R.string.webtoon_viewer), - CONTINUOUS_VERTICAL(5, R.string.vertical_plus_viewer), +enum class ReadingModeType(val prefValue: Int, @StringRes val stringRes: Int, @DrawableRes val iconRes: Int) { + DEFAULT(0, R.string.default_viewer, 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_viewer, R.drawable.ic_reader_webtoon_24dp), + CONTINUOUS_VERTICAL(5, R.string.vertical_plus_viewer, R.drawable.ic_reader_continuous_vertical_24dp), ; companion object { diff --git a/app/src/main/res/drawable/ic_reader_continuous_vertical_24dp.xml b/app/src/main/res/drawable/ic_reader_continuous_vertical_24dp.xml new file mode 100644 index 0000000000..7997bba7bb --- /dev/null +++ b/app/src/main/res/drawable/ic_reader_continuous_vertical_24dp.xml @@ -0,0 +1,15 @@ + + + + + diff --git a/app/src/main/res/drawable/ic_reader_default_24dp.xml b/app/src/main/res/drawable/ic_reader_default_24dp.xml new file mode 100644 index 0000000000..3ec2d7598e --- /dev/null +++ b/app/src/main/res/drawable/ic_reader_default_24dp.xml @@ -0,0 +1,12 @@ + + + + diff --git a/app/src/main/res/drawable/ic_reader_ltr_24dp.xml b/app/src/main/res/drawable/ic_reader_ltr_24dp.xml new file mode 100644 index 0000000000..2c44474e90 --- /dev/null +++ b/app/src/main/res/drawable/ic_reader_ltr_24dp.xml @@ -0,0 +1,21 @@ + + + + + + + diff --git a/app/src/main/res/drawable/ic_reader_rtl_24dp.xml b/app/src/main/res/drawable/ic_reader_rtl_24dp.xml new file mode 100644 index 0000000000..bce2932fcf --- /dev/null +++ b/app/src/main/res/drawable/ic_reader_rtl_24dp.xml @@ -0,0 +1,21 @@ + + + + + + + diff --git a/app/src/main/res/drawable/ic_reader_vertical_24dp.xml b/app/src/main/res/drawable/ic_reader_vertical_24dp.xml new file mode 100644 index 0000000000..def93b2c21 --- /dev/null +++ b/app/src/main/res/drawable/ic_reader_vertical_24dp.xml @@ -0,0 +1,12 @@ + + + + diff --git a/app/src/main/res/drawable/ic_reader_webtoon_24dp.xml b/app/src/main/res/drawable/ic_reader_webtoon_24dp.xml new file mode 100644 index 0000000000..b7683822de --- /dev/null +++ b/app/src/main/res/drawable/ic_reader_webtoon_24dp.xml @@ -0,0 +1,12 @@ + + + + diff --git a/app/src/main/res/layout/reader_activity.xml b/app/src/main/res/layout/reader_activity.xml index 6421d020d4..f12965ffe3 100644 --- a/app/src/main/res/layout/reader_activity.xml +++ b/app/src/main/res/layout/reader_activity.xml @@ -155,7 +155,7 @@ app:layout_constraintEnd_toStartOf="@id/action_rotation" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" - app:srcCompat="@drawable/ic_book_24dp" + app:srcCompat="@drawable/ic_reader_default_24dp" app:tint="?attr/colorOnPrimary" />