mirror of
https://github.com/mihonapp/mihon.git
synced 2025-07-14 19:55:11 +02:00
Show toast when toggling crop borders
Consistent with reading mode and orientation shortcuts.
This commit is contained in:
@ -38,8 +38,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) {
|
||||
|
@ -378,6 +378,36 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
|
||||
}
|
||||
}
|
||||
|
||||
// Crop borders
|
||||
with(binding.actionCropBorders) {
|
||||
setTooltip(R.string.pref_crop_borders)
|
||||
|
||||
setOnClickListener {
|
||||
val isPagerType = ReadingModeType.isPagerType(presenter.getMangaReadingMode())
|
||||
val enabled = if (isPagerType) {
|
||||
preferences.cropBorders().toggle()
|
||||
} else {
|
||||
preferences.cropBordersWebtoon().toggle()
|
||||
}
|
||||
|
||||
menuToggleToast?.cancel()
|
||||
menuToggleToast = toast(
|
||||
if (enabled) {
|
||||
R.string.on
|
||||
} else {
|
||||
R.string.off
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
updateCropBordersShortcut()
|
||||
listOf(preferences.cropBorders(), preferences.cropBordersWebtoon())
|
||||
.forEach { pref ->
|
||||
pref.asFlow()
|
||||
.onEach { updateCropBordersShortcut() }
|
||||
.launchIn(lifecycleScope)
|
||||
}
|
||||
|
||||
// Rotation
|
||||
with(binding.actionRotation) {
|
||||
setTooltip(R.string.rotation_type)
|
||||
@ -400,27 +430,6 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
|
||||
}
|
||||
}
|
||||
|
||||
// Crop borders
|
||||
with(binding.actionCropBorders) {
|
||||
setTooltip(R.string.pref_crop_borders)
|
||||
|
||||
setOnClickListener {
|
||||
val isPagerType = ReadingModeType.isPagerType(presenter.getMangaReadingMode())
|
||||
if (isPagerType) {
|
||||
preferences.cropBorders().toggle()
|
||||
} else {
|
||||
preferences.cropBordersWebtoon().toggle()
|
||||
}
|
||||
}
|
||||
}
|
||||
updateCropBordersShortcut()
|
||||
listOf(preferences.cropBorders(), preferences.cropBordersWebtoon())
|
||||
.forEach { pref ->
|
||||
pref.asFlow()
|
||||
.onEach { updateCropBordersShortcut() }
|
||||
.launchIn(lifecycleScope)
|
||||
}
|
||||
|
||||
// Settings sheet
|
||||
with(binding.actionSettings) {
|
||||
setTooltip(R.string.action_settings)
|
||||
|
Reference in New Issue
Block a user