Minor cleanup

(cherry picked from commit a3992d9fbeb2b215ecb94dacc9b182a80bffb4c9)

# Conflicts:
#	app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt
This commit is contained in:
arkon 2021-04-03 10:12:31 -04:00 committed by Jobobby04
parent 74795bcc5e
commit 3aa5a36fdd
6 changed files with 14 additions and 15 deletions

View File

@ -22,7 +22,7 @@ import java.util.Locale
import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys
import eu.kanade.tachiyomi.data.preference.PreferenceValues as Values
fun <T> Preference<T>.asImmediateFlow(block: (value: T) -> Unit): Flow<T> {
fun <T> Preference<T>.asImmediateFlow(block: (T) -> Unit): Flow<T> {
block(get())
return asFlow()
.onEach { block(it) }

View File

@ -42,6 +42,7 @@ import eu.kanade.tachiyomi.ui.recent.history.HistoryController
import eu.kanade.tachiyomi.ui.recent.updates.UpdatesController
import eu.kanade.tachiyomi.util.lang.launchIO
import eu.kanade.tachiyomi.util.lang.launchUI
import eu.kanade.tachiyomi.util.system.toast
import exh.EXHMigrations
import exh.eh.EHentaiUpdateWorker
import exh.source.BlacklistedSources
@ -362,11 +363,8 @@ class MainActivity : BaseViewBindingActivity<MainActivityBinding>() {
private suspend fun resetExitConfirmation() {
isConfirmingExit = true
val toast = Toast.makeText(this, R.string.confirm_exit, Toast.LENGTH_LONG)
toast.show()
val toast = toast(R.string.confirm_exit, Toast.LENGTH_LONG)
delay(2000)
toast.cancel()
isConfirmingExit = false
}

View File

@ -889,9 +889,8 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
val defaultReaderType = manga.defaultReaderType(manga.mangaType(sourceName = sourceManager.getOrStub(manga.source).name))
if (preferences.useAutoWebtoon().get() && manga.viewer == 0 && defaultReaderType != null && defaultReaderType == ReadingModeType.WEBTOON.prefValue) {
readingModeToast?.cancel()
readingModeToast = Toast.makeText(this, resources.getString(R.string.eh_auto_webtoon_snack), Toast.LENGTH_SHORT).also {
readingModeToast = this.toast(resources.getString(R.string.eh_auto_webtoon_snack)) {
it.setGravity(Gravity.CENTER_VERTICAL or Gravity.CENTER_HORIZONTAL, 0, 0)
it.show()
}
} else if (preferences.showReadingMode()) {
// SY <--
@ -950,9 +949,8 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
private fun showReadingModeToast(mode: Int) {
val strings = resources.getStringArray(R.array.viewers_selector)
readingModeToast?.cancel()
readingModeToast = Toast.makeText(this, strings[mode], Toast.LENGTH_SHORT).also {
readingModeToast = toast(strings[mode]) {
it.setGravity(Gravity.CENTER_VERTICAL or Gravity.CENTER_HORIZONTAL, 0, 0)
it.show()
}
}

View File

@ -363,9 +363,9 @@ class WebtoonPageHolder(
private fun initSubsamplingImageView(): SubsamplingScaleImageView {
val config = viewer.config
val imageCropBorders = if (!viewer.isContinuous) config.continuousCropBorders else config.imageCropBorders
if (subsamplingImageView != null) {
// SY -->
val imageCropBorders = if (!viewer.isContinuous) config.continuousCropBorders else config.imageCropBorders
if (imageCropBorders != cropBorders) {
cropBorders = imageCropBorders
subsamplingImageView!!.setCropBorders(imageCropBorders)

View File

@ -42,8 +42,8 @@ import kotlin.math.roundToInt
* @param resource the text resource.
* @param duration the duration of the toast. Defaults to short.
*/
fun Context.toast(@StringRes resource: Int, duration: Int = Toast.LENGTH_SHORT): Toast {
return Toast.makeText(this, resource, duration).also { it.show() }
fun Context.toast(@StringRes resource: Int, duration: Int = Toast.LENGTH_SHORT, block: (Toast) -> Unit = {}): Toast {
return toast(getString(resource), duration, block)
}
/**
@ -52,8 +52,11 @@ fun Context.toast(@StringRes resource: Int, duration: Int = Toast.LENGTH_SHORT):
* @param text the text to display.
* @param duration the duration of the toast. Defaults to short.
*/
fun Context.toast(text: String?, duration: Int = Toast.LENGTH_SHORT): Toast {
return Toast.makeText(this, text.orEmpty(), duration).also { it.show() }
fun Context.toast(text: String?, duration: Int = Toast.LENGTH_SHORT, block: (Toast) -> Unit = {}): Toast {
return Toast.makeText(this, text.orEmpty(), duration).also {
block(it)
it.show()
}
}
/**

View File

@ -253,7 +253,7 @@
<!-- Reader section -->
<string name="pref_fullscreen">Fullscreen</string>
<string name="pref_show_navigation_mode">Show navigation layout overlay</string>
<string name="pref_show_navigation_mode_summary">Briefly show tap zones when reader is opened</string>
<string name="pref_show_navigation_mode_summary">Show tap zones when reader is opened</string>
<string name="pref_dual_page_split">Dual page split</string>
<string name="pref_dual_page_invert">Invert dual page split placement</string>
<string name="pref_dual_page_invert_summary">If the placement of the dual page split doesn\'t match reading direction</string>