Skip to content

Commit

Permalink
fix (keymap detection): keymaps with multiple actions wouldn't perfor…
Browse files Browse the repository at this point in the history
…m all the actions
  • Loading branch information
sds100 committed Jun 8, 2020
1 parent 6d50d84 commit a0739c1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ class MyAccessibilityService : AccessibilityService(),
})

mKeymapDetectionDelegate.performAction.observe(this, EventObserver { model ->
Timber.d("perform action ${model.action.uniqueId}")

model.action.canBePerformed(this).onSuccess {
mActionPerformerDelegate.performAction(model)
}.onFailure {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.github.sds100.keymapper.util.delegate

import android.view.KeyEvent
import androidx.annotation.MainThread
import androidx.collection.SparseArrayCompat
import androidx.collection.keyIterator
import androidx.collection.valueIterator
Expand Down Expand Up @@ -1052,10 +1053,12 @@ class KeymapDetectionDelegate(private val mCoroutineScope: CoroutineScope,
return false
}

@MainThread
private fun performAction(action: Action, showToast: Boolean) {
val metaState = mMetaStateFromKeyEvent.withFlag(mMetaStateFromActions)
Timber.d("current metastate = $metaState")
performAction.postValue(Event(PerformActionModel(action, metaState, showToast)))
//Don't use postValue because multiple actions can't be performed at the same time
performAction.value = Event(PerformActionModel(action, metaState, showToast))
}

private val Int.clickType
Expand Down

0 comments on commit a0739c1

Please sign in to comment.