diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt index 0e16ed980..158de8207 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt @@ -21,6 +21,8 @@ object PreferenceKeys { const val showPageNumber = "pref_show_page_number_key" + const val showReadingMode = "pref_show_reading_mode" + const val trueColor = "pref_true_color_key" const val fullscreen = "fullscreen" diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt index 6171984c7..f45ab1eb7 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt @@ -83,6 +83,8 @@ class PreferencesHelper(val context: Context) { fun showPageNumber() = flowPrefs.getBoolean(Keys.showPageNumber, true) + fun showReadingMode() = prefs.getBoolean(Keys.showReadingMode, true) + fun trueColor() = flowPrefs.getBoolean(Keys.trueColor, false) fun fullscreen() = flowPrefs.getBoolean(Keys.fullscreen, true) 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 acd96820f..ad192f7d2 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 @@ -22,6 +22,7 @@ import android.view.animation.AnimationUtils import android.widget.SeekBar import androidx.core.view.ViewCompat import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView +import com.google.android.material.snackbar.Snackbar import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.database.models.Chapter import eu.kanade.tachiyomi.data.database.models.Manga @@ -42,7 +43,6 @@ import eu.kanade.tachiyomi.ui.reader.viewer.pager.L2RPagerViewer 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 -import eu.kanade.tachiyomi.util.lang.plusAssign import eu.kanade.tachiyomi.util.storage.getUriCompat import eu.kanade.tachiyomi.util.system.GLUtil import eu.kanade.tachiyomi.util.system.toast @@ -51,6 +51,7 @@ import eu.kanade.tachiyomi.util.view.gone import eu.kanade.tachiyomi.util.view.hideBar import eu.kanade.tachiyomi.util.view.isDefaultBar import eu.kanade.tachiyomi.util.view.showBar +import eu.kanade.tachiyomi.util.view.snack import eu.kanade.tachiyomi.util.view.visible import eu.kanade.tachiyomi.widget.SimpleAnimationListener import eu.kanade.tachiyomi.widget.SimpleSeekBarListener @@ -403,6 +404,10 @@ class ReaderActivity : BaseRxActivity() viewer = newViewer binding.viewerContainer.addView(newViewer.getView()) + if (preferences.showReadingMode()) { + showReadingModeSnackbar(presenter.getMangaViewer()) + } + binding.toolbar.title = manga.title binding.pageSeekbar.isRTL = newViewer is R2LPagerViewer @@ -411,6 +416,11 @@ class ReaderActivity : BaseRxActivity() binding.pleaseWait.startAnimation(AnimationUtils.loadAnimation(this, R.anim.fade_in_long)) } + private fun showReadingModeSnackbar(mode: Int) { + val strings = resources.getStringArray(R.array.viewers_selector) + binding.root.snack(strings[mode], Snackbar.LENGTH_SHORT) + } + /** * Called from the presenter whenever a new [viewerChapters] have been set. It delegates the * method to the current viewer, but also set the subtitle on the toolbar. diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsReaderController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsReaderController.kt index ae9203e4c..12fe7f5ca 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsReaderController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsReaderController.kt @@ -83,6 +83,12 @@ class SettingsReaderController : SettingsController() { titleRes = R.string.pref_show_page_number defaultValue = true } + switchPreference { + key = Keys.showReadingMode + titleRes = R.string.pref_show_reading_mode + summaryRes = R.string.pref_show_reading_mode_summary + defaultValue = true + } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { switchPreference { key = Keys.trueColor diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/view/ViewExtensions.kt b/app/src/main/java/eu/kanade/tachiyomi/util/view/ViewExtensions.kt index 82130b8de..eb3a909a4 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/view/ViewExtensions.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/view/ViewExtensions.kt @@ -33,7 +33,7 @@ fun View.getCoordinates() = Point((left + right) / 2, (top + bottom) / 2) * @param length the duration of the snack. * @param f a function to execute in the snack, allowing for example to define a custom action. */ -inline fun View.snack(message: String, length: Int = Snackbar.LENGTH_LONG, f: Snackbar.() -> Unit): Snackbar { +inline fun View.snack(message: String, length: Int = Snackbar.LENGTH_LONG, f: Snackbar.() -> Unit = {}): Snackbar { val snack = Snackbar.make(this, message, length) val textView: TextView = snack.view.findViewById(com.google.android.material.R.id.snackbar_text) textView.setTextColor(Color.WHITE) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 20e1b7144..12c349c08 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -233,6 +233,8 @@ Animate page transitions Double tap animation speed Show page number + Show reading mode + Briefly show current mode when reader is opened 32-bit color Reduces banding, but impacts performance Crop borders