Improve blocker flashing

This commit is contained in:
DBotThePony 2023-07-18 01:54:21 +07:00
parent 0e9a480dd8
commit 25875b162e
Signed by: DBot
GPG Key ID: DCC23B5715498507

View File

@ -403,12 +403,10 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
var isFlashing: Boolean var isFlashing: Boolean
get() { get() {
if (flashingSince == null) { val flashingSince = flashingSince ?: return false
return false
}
if (flashingSince!!.millis >= 1200L) { if (flashingSince.millis >= 1200L) {
flashingSince = null this.flashingSince = null
return false return false
} }
@ -416,8 +414,14 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
} }
set(value) { set(value) {
if (value) { if (value) {
if (screen is MatteryScreen<*>) {
screen.popup(findAbsoluteRoot() as EditablePanel<MatteryScreen<*>>)
}
if (!flashAnyBlocker(true)) {
flashingSince = SystemTime() flashingSince = SystemTime()
popup() findAbsoluteRoot().requestFocus()
}
} else { } else {
flashingSince = null flashingSince = null
} }
@ -466,23 +470,7 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
} }
protected fun flashAnyBlocker(doFlash: Boolean = true): Boolean { protected fun flashAnyBlocker(doFlash: Boolean = true): Boolean {
var blockingWindow = blockingWindow return findAbsoluteRoot().flashAnyBlockerInner(doFlash)
var parent = parent
while (blockingWindow == null && parent != null) {
blockingWindow = parent.blockingWindow
parent = parent.parent
}
if (blockingWindow == null) {
return flashAnyBlockerInner(doFlash)
}
if (doFlash) {
blockingWindow.isFlashing = true
}
return true
} }
@JvmOverloads @JvmOverloads
@ -1732,17 +1720,17 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
isRemoved = true isRemoved = true
} }
fun popup(focus: Boolean = true) { fun popup(focus: Boolean = true, doFlash: Boolean = true) {
if (isRemoved) { if (isRemoved) {
return return
} }
if (screen is MatteryScreen<*> && parent == null) { if (screen is MatteryScreen<*>) {
screen.popup(this as EditablePanel<MatteryScreen<*>>) screen.popup(findAbsoluteRoot() as EditablePanel<MatteryScreen<*>>)
} }
if (focus) { if (focus && !flashAnyBlocker(doFlash)) {
requestFocus() findAbsoluteRoot().requestFocus()
} }
} }