Skip to content

Commit 73df981

Browse files
Pause: keep accessibility overlay attached on pause (#2234)
- Replace SwitchifyAccessibilityWindow.hide()/show() with ScanningManager.reset() in PauseManager so pause no longer tears down the WindowManager view; instead it stops auto-scan, drops technique UI (item-scan highlights, point-scan lines, radar dot), and closes any open menu while keeping the overlay attached. - Drop the 1s UI_DELAY_MS waits on both pause and resume: they only existed to coordinate with the window addView/removeView transition, which no longer happens. Resume HUD now shows immediately. - Mid-scan pause via ACTION_PAUSE now cleanly clears scanning UI instead of ripping the whole overlay out. Closes #2233 Co-authored-by: Owen McGirr <o.a.mcgirr@gmail.com>
1 parent b0c783b commit 73df981

1 file changed

Lines changed: 13 additions & 27 deletions

File tree

  • app/src/main/java/com/enaboapps/switchify/service/pauseresume

app/src/main/java/com/enaboapps/switchify/service/pauseresume/PauseManager.kt

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import android.content.Context
44
import android.content.Intent
55
import com.enaboapps.switchify.R
66
import com.enaboapps.switchify.backend.preferences.PreferenceManager
7+
import com.enaboapps.switchify.service.core.ServiceCore
78
import com.enaboapps.switchify.service.window.ServiceMessageHUD
8-
import com.enaboapps.switchify.service.window.SwitchifyAccessibilityWindow
99
import kotlinx.coroutines.CoroutineScope
1010
import kotlinx.coroutines.Dispatchers
1111
import kotlinx.coroutines.Job
@@ -23,7 +23,6 @@ class PauseManager private constructor() {
2323

2424
companion object {
2525
private const val DEFAULT_PAUSE_TIMEOUT_MS = 30000L // 30 seconds
26-
private const val UI_DELAY_MS = 1000L // 1 second delay for UI transitions
2726

2827
// Broadcast actions
2928
const val ACTION_PAUSE_STARTED = "com.enaboapps.switchify.PAUSE_STARTED"
@@ -64,7 +63,7 @@ class PauseManager private constructor() {
6463

6564
/**
6665
* Starts the pause mode if not already paused.
67-
* Shows pause message, hides service window, and notifies all listeners.
66+
* Shows pause message, clears scanning UI and any open menu, and notifies all listeners.
6867
*/
6968
fun startPause() {
7069
if (pauseJob != null) return
@@ -104,14 +103,9 @@ class PauseManager private constructor() {
104103
)
105104
}
106105

107-
pauseJob = coroutineScope.launch {
108-
// Give the pause message time to show before hiding the window
109-
delay(UI_DELAY_MS)
110-
111-
// Hide the service window when pausing
112-
SwitchifyAccessibilityWindow.instance.hide()
106+
ServiceCore.getScanningManager()?.reset()
113107

114-
// Monitor for pause timeout
108+
pauseJob = coroutineScope.launch {
115109
while (isPaused) {
116110
delay(pauseTimeoutMs)
117111
if (System.currentTimeMillis() - pauseTimestamp > pauseTimeoutMs) {
@@ -156,31 +150,23 @@ class PauseManager private constructor() {
156150

157151
/**
158152
* Resumes from pause mode.
159-
* Shows service window, displays resume message, and notifies all listeners.
153+
* Displays resume message and notifies all listeners.
160154
*/
161155
fun resume() {
162156
isPaused = false
163157
pauseJob?.cancel()
164158
pauseJob = null
165159

166-
coroutineScope.launch {
167-
// Show the service window when resuming
168-
SwitchifyAccessibilityWindow.instance.show()
169-
170-
// Give the window time to show before displaying the message
171-
delay(UI_DELAY_MS)
160+
ServiceMessageHUD.instance.showMessage(
161+
R.string.hud_pause_resume,
162+
ServiceMessageHUD.MessageType.DISAPPEARING
163+
)
172164

173-
ServiceMessageHUD.instance.showMessage(
174-
R.string.hud_pause_resume,
175-
ServiceMessageHUD.MessageType.DISAPPEARING
165+
// Send broadcast that pause has ended
166+
contextRef?.get()?.let { context ->
167+
context.sendBroadcast(
168+
Intent(ACTION_PAUSE_ENDED).setPackage(context.packageName)
176169
)
177-
178-
// Send broadcast that pause has ended
179-
contextRef?.get()?.let { context ->
180-
context.sendBroadcast(
181-
Intent(ACTION_PAUSE_ENDED).setPackage(context.packageName)
182-
)
183-
}
184170
}
185171
}
186172

0 commit comments

Comments
 (0)