Show toast when toggling crop borders
Consistent with reading mode and orientation shortcuts. (cherry picked from commit 1feac9c5594e85a9e8ef82ac69cb048b7eda2598) # Conflicts: # app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt
This commit is contained in:
parent
ef02bd112c
commit
5fa3d55bc9
@ -40,8 +40,9 @@ operator fun <T> Preference<Set<T>>.minusAssign(item: T) {
|
||||
set(get() - item)
|
||||
}
|
||||
|
||||
fun Preference<Boolean>.toggle() {
|
||||
fun Preference<Boolean>.toggle(): Boolean {
|
||||
set(!get())
|
||||
return get()
|
||||
}
|
||||
|
||||
class PreferencesHelper(val context: Context) {
|
||||
|
@ -490,6 +490,45 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
|
||||
}
|
||||
}
|
||||
|
||||
// Crop borders
|
||||
with(binding.actionCropBorders) {
|
||||
setTooltip(R.string.pref_crop_borders)
|
||||
|
||||
setOnClickListener {
|
||||
// SY -->
|
||||
val mangaViewer = presenter.getMangaReadingMode()
|
||||
// SY <--
|
||||
val isPagerType = ReadingModeType.isPagerType(mangaViewer)
|
||||
val enabled = if (isPagerType) {
|
||||
preferences.cropBorders().toggle()
|
||||
} else {
|
||||
// SY -->
|
||||
if (ReadingModeType.fromPreference(mangaViewer) == ReadingModeType.CONTINUOUS_VERTICAL) {
|
||||
preferences.cropBordersContinuousVertical().toggle()
|
||||
} else {
|
||||
preferences.cropBordersWebtoon().toggle()
|
||||
}
|
||||
// SY <--
|
||||
}
|
||||
|
||||
menuToggleToast?.cancel()
|
||||
menuToggleToast = toast(
|
||||
if (enabled) {
|
||||
R.string.on
|
||||
} else {
|
||||
R.string.off
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
updateCropBordersShortcut()
|
||||
listOf(preferences.cropBorders(), preferences.cropBordersWebtoon() /* SY --> */, preferences.cropBordersContinuousVertical()/* SY <-- */)
|
||||
.forEach { pref ->
|
||||
pref.asFlow()
|
||||
.onEach { updateCropBordersShortcut() }
|
||||
.launchIn(lifecycleScope)
|
||||
}
|
||||
|
||||
// Rotation
|
||||
with(binding.actionRotation) {
|
||||
setTooltip(R.string.rotation_type)
|
||||
@ -512,34 +551,6 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
|
||||
}
|
||||
}
|
||||
|
||||
// Crop borders
|
||||
with(binding.actionCropBorders) {
|
||||
setTooltip(R.string.pref_crop_borders)
|
||||
|
||||
setOnClickListener {
|
||||
val mangaViewer = presenter.getMangaReadingMode()
|
||||
val isPagerType = ReadingModeType.isPagerType(mangaViewer)
|
||||
if (isPagerType) {
|
||||
preferences.cropBorders().toggle()
|
||||
} else {
|
||||
// SY -->
|
||||
if (ReadingModeType.fromPreference(mangaViewer) == ReadingModeType.CONTINUOUS_VERTICAL) {
|
||||
preferences.cropBordersContinuousVertical().toggle()
|
||||
} else {
|
||||
preferences.cropBordersWebtoon().toggle()
|
||||
}
|
||||
// SY <--
|
||||
}
|
||||
}
|
||||
}
|
||||
updateCropBordersShortcut()
|
||||
listOf(preferences.cropBorders(), preferences.cropBordersWebtoon() /* SY --> */, preferences.cropBordersContinuousVertical()/* SY <-- */)
|
||||
.forEach { pref ->
|
||||
pref.asFlow()
|
||||
.onEach { updateCropBordersShortcut() }
|
||||
.launchIn(lifecycleScope)
|
||||
}
|
||||
|
||||
// Settings sheet
|
||||
with(binding.actionSettings) {
|
||||
setTooltip(R.string.action_settings)
|
||||
|
@ -277,6 +277,8 @@
|
||||
<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>
|
||||
<string name="on">On</string>
|
||||
<string name="off">Off</string>
|
||||
<string name="pref_custom_brightness">Custom brightness</string>
|
||||
<string name="pref_grayscale">Grayscale</string>
|
||||
<string name="pref_custom_color_filter">Custom color filter</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user