From 6daefd3b3c9cc321fdad6428c4a06dece3661f28 Mon Sep 17 00:00:00 2001 From: Tim Kluge Date: Tue, 10 Dec 2024 21:38:27 +0100 Subject: [PATCH] ref #6: Only hide matching powerbar --- .../kotlin/de/timklge/karoopowerbar/Window.kt | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/app/src/main/kotlin/de/timklge/karoopowerbar/Window.kt b/app/src/main/kotlin/de/timklge/karoopowerbar/Window.kt index a6f7b0d..3315553 100644 --- a/app/src/main/kotlin/de/timklge/karoopowerbar/Window.kt +++ b/app/src/main/kotlin/de/timklge/karoopowerbar/Window.kt @@ -258,14 +258,16 @@ class Window( val duration = intent.getLongExtra("duration", 15_000) Log.d(TAG, "Received broadcast to hide $location powerbar for $duration ms") - currentHideJob?.cancel() - currentHideJob = CoroutineScope(Dispatchers.Main).launch { - rootView.visibility = View.INVISIBLE - withContext(Dispatchers.Default){ - delay(duration) + if (location == powerbarLocation) { + currentHideJob?.cancel() + currentHideJob = CoroutineScope(Dispatchers.Main).launch { + rootView.visibility = View.INVISIBLE + withContext(Dispatchers.Default) { + delay(duration) + } + rootView.visibility = View.VISIBLE + currentHideJob = null } - rootView.visibility = View.VISIBLE - currentHideJob = null } } }