mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-07 11:17:25 +01:00
Show toast when toggling crop borders
Consistent with reading mode and orientation shortcuts.
This commit is contained in:
parent
fce81dd6d9
commit
1feac9c559
@ -38,8 +38,9 @@ operator fun <T> Preference<Set<T>>.minusAssign(item: T) {
|
|||||||
set(get() - item)
|
set(get() - item)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Preference<Boolean>.toggle() {
|
fun Preference<Boolean>.toggle(): Boolean {
|
||||||
set(!get())
|
set(!get())
|
||||||
|
return get()
|
||||||
}
|
}
|
||||||
|
|
||||||
class PreferencesHelper(val context: Context) {
|
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
|
// Rotation
|
||||||
with(binding.actionRotation) {
|
with(binding.actionRotation) {
|
||||||
setTooltip(R.string.rotation_type)
|
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
|
// Settings sheet
|
||||||
with(binding.actionSettings) {
|
with(binding.actionSettings) {
|
||||||
setTooltip(R.string.action_settings)
|
setTooltip(R.string.action_settings)
|
||||||
|
@ -277,6 +277,8 @@
|
|||||||
<string name="pref_true_color">32-bit color</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_true_color_summary">Reduces banding, but impacts performance</string>
|
||||||
<string name="pref_crop_borders">Crop borders</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_custom_brightness">Custom brightness</string>
|
||||||
<string name="pref_grayscale">Grayscale</string>
|
<string name="pref_grayscale">Grayscale</string>
|
||||||
<string name="pref_custom_color_filter">Custom color filter</string>
|
<string name="pref_custom_color_filter">Custom color filter</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user