Reading mode snackbar

(cherry picked from commit 3899938b253c9ebe149cdfdfae1bb36a3c393a43)

# Conflicts:
#	app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt
This commit is contained in:
arkon 2020-06-07 11:14:19 -04:00 committed by Jobobby04
parent 46a9fac1f0
commit e4f8958953
6 changed files with 24 additions and 7 deletions

View File

@ -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"

View File

@ -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)

View File

@ -647,19 +647,24 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
viewer = newViewer
binding.viewerContainer.addView(newViewer.getView())
val defaultReaderType = manga.defaultReaderType()
if (preferences.eh_useAutoWebtoon().get() && manga.viewer == 0 && defaultReaderType != null && defaultReaderType == WEBTOON) {
binding.root.snack(resources.getString(R.string.eh_auto_webtoon_snack), Snackbar.LENGTH_LONG)
} else if (preferences.showReadingMode()) {
showReadingModeSnackbar(presenter.getMangaViewer())
}
binding.toolbar.title = manga.title
binding.pageSeekbar.isRTL = newViewer is R2LPagerViewer
binding.pleaseWait.visible()
binding.pleaseWait.startAnimation(AnimationUtils.loadAnimation(this, R.anim.fade_in_long))
}
if (preferences.eh_useAutoWebtoon().get()) {
val defaultReaderType = manga.defaultReaderType()
if (manga.viewer == 0 && defaultReaderType != null && defaultReaderType == WEBTOON) {
binding.readerLayout.snack(resources.getString(R.string.eh_auto_webtoon_snack), Snackbar.LENGTH_LONG) {}
}
}
private fun showReadingModeSnackbar(mode: Int) {
val strings = resources.getStringArray(R.array.viewers_selector)
binding.root.snack(strings[mode], Snackbar.LENGTH_SHORT)
}
/**

View File

@ -74,6 +74,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

View File

@ -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)

View File

@ -231,6 +231,8 @@
<string name="pref_page_transitions">Animate page transitions</string>
<string name="pref_double_tap_anim_speed">Double tap animation speed</string>
<string name="pref_show_page_number">Show page number</string>
<string name="pref_show_reading_mode">Show reading mode</string>
<string name="pref_show_reading_mode_summary">Briefly show current mode when reader is opened</string>
<string name="pref_true_color">32-bit color</string>
<string name="pref_true_color_summary">Reduces banding, but impacts performance</string>
<string name="pref_crop_borders">Crop borders</string>