Skip to content

Commit

Permalink
Fix to swipe lock dismissal
Browse files Browse the repository at this point in the history
  • Loading branch information
OwenMcGirr committed Mar 7, 2024
1 parent ec1d29a commit 4ce9f9f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.enaboapps.switchify.service.switches
import android.content.Context
import android.util.Log
import com.enaboapps.switchify.preferences.PreferenceManager
import com.enaboapps.switchify.service.gestures.GestureManager
import com.enaboapps.switchify.service.scanning.ScanningManager
import com.enaboapps.switchify.service.selection.AutoSelectionHandler
import com.enaboapps.switchify.switches.SwitchAction
Expand Down Expand Up @@ -85,14 +84,6 @@ class SwitchListener(
val switchHoldTime =
preferenceManager.getLongValue(PreferenceManager.PREFERENCE_KEY_SWITCH_HOLD_TIME)

// Toggle swipe lock if time elapsed is greater than hold time
if (timeElapsed > switchHoldTime && GestureManager.getInstance()
.isSwipeLockEnabled()
) {
GestureManager.getInstance().toggleSwipeLock()
return true
}

// Check selection handling
if (AutoSelectionHandler.isAutoSelectInProgress()) {
AutoSelectionHandler.performSelectionAction() // Interrupt auto-select process
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.enaboapps.switchify.service.switches

import android.content.Context
import com.enaboapps.switchify.preferences.PreferenceManager
import com.enaboapps.switchify.service.gestures.GestureManager
import com.enaboapps.switchify.service.scanning.ScanningManager
import com.enaboapps.switchify.switches.SwitchAction
import kotlinx.coroutines.CoroutineScope
Expand Down Expand Up @@ -29,6 +30,13 @@ object SwitchLongPressHandler {
PreferenceManager(context).getLongValue(PreferenceManager.PREFERENCE_KEY_SWITCH_HOLD_TIME)
longPressJob = CoroutineScope(Dispatchers.Main).launch {
delay(holdTime)

// Toggle swipe lock if enabled
if (GestureManager.getInstance().isSwipeLockEnabled()) {
GestureManager.getInstance().toggleSwipeLock()
return@launch
}

longPressAction?.let {
scanningManager.performAction(it)
}
Expand Down

0 comments on commit 4ce9f9f

Please sign in to comment.