Skip to content

Commit e54ba1c

Browse files
committed
亮屏后恢复自动关闭的悬浮窗
1 parent 6add694 commit e54ba1c

3 files changed

Lines changed: 34 additions & 12 deletions

File tree

app/src/main/assets/kr-script/more.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,6 @@
6868
id="page-google"
6969
config="aosp/aosp.xml"
7070
desc="越接近原生的系统越适用" title="AOSP专属" />
71-
<page
72-
id="page-meizu"
73-
config="flyme/flyme.xml"
74-
desc="适用于Flyme系统的选项" title="Flyme专属"
75-
visible="run common/flyme_support.sh" />
7671
<page
7772
id="page-mtk"
7873
config-sh="file:///android_asset/kr-script/mtk/mtk.sh"

app/src/main/java/com/omarea/Scene.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ class Scene : Application() {
141141
// 充电曲线
142142
EventBus.subscibe(ChargeCurve(this))
143143

144+
// 息屏自动关闭悬浮窗
144145
EventBus.subscibe(ScreenOffCleanup(context))
145146
}
146147
}

app/src/main/java/com/omarea/data/customer/ScreenOffCleanup.kt

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,43 @@ import com.omarea.vtools.popup.FloatTaskManager
1111

1212
class ScreenOffCleanup(private val context: Context) : IEventReceiver {
1313
override fun eventFilter(eventType: EventType): Boolean {
14-
return eventType == EventType.SCREEN_OFF
14+
return eventType == EventType.SCREEN_OFF || eventType == EventType.SCREEN_ON
1515
}
1616

17+
private val status = booleanArrayOf(false, false, false, false)
1718
override fun onReceive(eventType: EventType) {
18-
Scene.post(Runnable{
19-
FloatMonitorGame(context).hidePopupWindow()
20-
FloatTaskManager(context).hidePopupWindow()
21-
FloatFpsWatch(context).hidePopupWindow()
22-
FloatMonitor(context).hidePopupWindow()
23-
})
19+
Scene.post {
20+
if (eventType == EventType.SCREEN_OFF) {
21+
status[0] = FloatMonitorGame.show == true
22+
status[1] = FloatTaskManager.show == true
23+
status[2] = FloatFpsWatch.show == true
24+
status[3] = FloatMonitor.show == true
25+
26+
FloatMonitorGame(context).hidePopupWindow()
27+
FloatTaskManager(context).hidePopupWindow()
28+
FloatFpsWatch(context).hidePopupWindow()
29+
FloatMonitor(context).hidePopupWindow()
30+
} else if (eventType == EventType.SCREEN_ON) {
31+
if (status[0]) {
32+
FloatMonitorGame(context).showPopupWindow()
33+
status[0] = false
34+
}
35+
if (status[1]) {
36+
FloatTaskManager(context).showPopupWindow()
37+
status[1] = false
38+
}
39+
if (status[2]) {
40+
FloatFpsWatch(context).showPopupWindow()
41+
status[2] = false
42+
}
43+
if (status[3]) {
44+
FloatMonitor(context).showPopupWindow()
45+
status[3] = false
46+
}
47+
}
48+
}
2449
}
50+
2551
override val isAsync: Boolean
2652
get() = false
2753
}

0 commit comments

Comments
 (0)