Skip to content

Commit a3a4af6

Browse files
authored
Merge pull request #1517 from keymapperorg/develop
Release 2.8.2
2 parents 5ad6088 + fa65181 commit a3a4af6

File tree

17 files changed

+34
-86
lines changed

17 files changed

+34
-86
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
## [2.8.2](https://github.com/sds100/KeyMapper/releases/tag/v2.8.2)
2+
3+
## Changes
4+
5+
- #1514, #1454 Improving naming of assistant trigger to also refer to the side key and do not force the user to select Key Mapper as the assistant.
6+
7+
## Bug fixes
8+
- #1461 fix: crash on startup due to getting MotionEvent device
9+
-
110
## [2.8.1](https://github.com/sds100/KeyMapper/releases/tag/v2.8.1)
211

312
#### 18 February 2025

app/src/main/AndroidManifest.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,14 @@
8181
android:theme="@style/AppTheme.NoActionBar"
8282
tools:ignore="GoogleAppIndexingWarning">
8383

84+
<!-- relinquishTaskIdentity is required because the intent-filter has the
85+
DEFAULT category. If relinquishTaskIdentity is false then when the user resumes the
86+
app from the launcher they are taken back to the SplashActivity, and consequently the
87+
home fragment in MainActivity. -->
8488
<activity
8589
android:name=".SplashActivity"
8690
android:exported="true"
91+
android:relinquishTaskIdentity="true"
8792
android:theme="@style/Theme.App.Starting">
8893
<intent-filter>
8994
<action android:name="android.intent.action.MAIN" />

app/src/main/java/io/github/sds100/keymapper/mappings/keymaps/DisplayKeyMapUseCase.kt

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -118,15 +118,6 @@ class DisplayKeyMapUseCaseImpl(
118118
errors.add(TriggerError.ASSISTANT_TRIGGER_NOT_PURCHASED)
119119
}
120120

121-
val isKeyMapperDeviceAssistant = permissionAdapter.isGranted(Permission.DEVICE_ASSISTANT)
122-
123-
// Show an error if Key Mapper isn't selected as the device assistant
124-
// and an assistant trigger is used. The error shouldn't be shown
125-
// if the assistant trigger feature is not purchased.
126-
if (containsDeviceAssistantTrigger && isAssistantTriggerPurchased && !isKeyMapperDeviceAssistant) {
127-
errors.add(TriggerError.ASSISTANT_NOT_SELECTED)
128-
}
129-
130121
val containsDpadKey = trigger.keys
131122
.mapNotNull { it as? KeyCodeTriggerKey }
132123
.any { InputEventUtils.isDpadKeyCode(it.keyCode) && it.detectionSource == KeyEventDetectionSource.INPUT_METHOD }

app/src/main/java/io/github/sds100/keymapper/mappings/keymaps/KeyMapListItemCreator.kt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,6 @@ class KeyMapListItemCreator(
120120
error = Error.CantDetectKeyEventsInPhoneCall,
121121
)
122122

123-
TriggerError.ASSISTANT_NOT_SELECTED -> ChipUi.Error(
124-
id = error.toString(),
125-
text = getString(R.string.trigger_error_assistant_activity_not_chosen),
126-
error = Error.PermissionDenied(Permission.DEVICE_ASSISTANT),
127-
)
128-
129123
TriggerError.ASSISTANT_TRIGGER_NOT_PURCHASED -> ChipUi.Error(
130124
id = error.toString(),
131125
text = getString(R.string.trigger_error_assistant_not_purchased),

app/src/main/java/io/github/sds100/keymapper/mappings/keymaps/detection/DpadMotionEventTracker.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package io.github.sds100.keymapper.mappings.keymaps.detection
22

33
import android.view.KeyEvent
4+
import io.github.sds100.keymapper.system.devices.InputDeviceInfo
45
import io.github.sds100.keymapper.system.inputevents.InputEventUtils
56
import io.github.sds100.keymapper.system.inputevents.MyKeyEvent
67
import io.github.sds100.keymapper.system.inputevents.MyMotionEvent
@@ -62,11 +63,11 @@ class DpadMotionEventTracker {
6263
* @return An array of key events. Empty if no DPAD buttons changed.
6364
*/
6465
fun convertMotionEvent(event: MyMotionEvent): List<MyKeyEvent> {
65-
val oldState = dpadState[event.device.descriptor] ?: 0
66+
val oldState = dpadState[event.device.getDescriptor()] ?: 0
6667
val newState = eventToDpadState(event)
6768
val diff = oldState xor newState
6869

69-
dpadState[event.device.descriptor] = newState
70+
dpadState[event.device.getDescriptor()] = newState
7071

7172
// If no dpad keys changed then return null
7273
if (diff == 0) {
@@ -114,6 +115,10 @@ class DpadMotionEventTracker {
114115
dpadState.clear()
115116
}
116117

118+
private fun InputDeviceInfo?.getDescriptor(): String {
119+
return this?.descriptor ?: ""
120+
}
121+
117122
private fun eventToDpadState(event: MyMotionEvent): Int {
118123
var state = 0
119124

app/src/main/java/io/github/sds100/keymapper/mappings/keymaps/trigger/BaseConfigTriggerViewModel.kt

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -378,11 +378,6 @@ abstract class BaseConfigTriggerViewModel(
378378
text = getString(R.string.trigger_error_cant_detect_in_phone_call),
379379
)
380380

381-
TriggerError.ASSISTANT_NOT_SELECTED -> TextListItem.Error(
382-
id = error.toString(),
383-
text = getString(R.string.trigger_error_assistant_activity_not_chosen),
384-
)
385-
386381
TriggerError.ASSISTANT_TRIGGER_NOT_PURCHASED -> TextListItem.Error(
387382
id = error.toString(),
388383
text = getString(R.string.trigger_error_assistant_not_purchased),
@@ -521,10 +516,6 @@ abstract class BaseConfigTriggerViewModel(
521516
displayKeyMap.fixError(Error.CantDetectKeyEventsInPhoneCall)
522517
}
523518

524-
TriggerError.ASSISTANT_NOT_SELECTED -> {
525-
displayKeyMap.fixError(Error.PermissionDenied(Permission.DEVICE_ASSISTANT))
526-
}
527-
528519
TriggerError.ASSISTANT_TRIGGER_NOT_PURCHASED -> {
529520
showAdvancedTriggersBottomSheet = true
530521
}

app/src/main/java/io/github/sds100/keymapper/mappings/keymaps/trigger/TriggerError.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ enum class TriggerError {
88
SCREEN_OFF_ROOT_DENIED,
99
CANT_DETECT_IN_PHONE_CALL,
1010

11-
// Key Mapper is not selected as the assistant activity. This is required for assistant
12-
// triggers.
13-
ASSISTANT_NOT_SELECTED,
14-
1511
// This error appears when a key map has an assistant trigger but the user hasn't purchased
1612
// the product.
1713
ASSISTANT_TRIGGER_NOT_PURCHASED,

app/src/main/java/io/github/sds100/keymapper/system/accessibility/MyAccessibilityService.kt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,7 @@ class MyAccessibilityService :
111111
override fun onKeyEvent(event: KeyEvent?): Boolean {
112112
event ?: return false
113113

114-
val device = if (event.device == null) {
115-
null
116-
} else {
117-
InputDeviceUtils.createInputDeviceInfo(event.device)
118-
}
114+
val device = event.device?.let { InputDeviceUtils.createInputDeviceInfo(it) }
119115

120116
if (controller != null) {
121117
return controller!!.onKeyEventFromIme(

app/src/main/java/io/github/sds100/keymapper/system/inputevents/MyMotionEvent.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import io.github.sds100.keymapper.system.devices.InputDeviceUtils
1010
*/
1111
data class MyMotionEvent(
1212
val metaState: Int,
13-
val device: InputDeviceInfo,
13+
val device: InputDeviceInfo?,
1414
val axisHatX: Float,
1515
val axisHatY: Float,
1616
val isDpad: Boolean,
@@ -19,7 +19,7 @@ data class MyMotionEvent(
1919
fun fromMotionEvent(event: MotionEvent): MyMotionEvent {
2020
return MyMotionEvent(
2121
metaState = event.metaState,
22-
device = InputDeviceUtils.createInputDeviceInfo(event.device),
22+
device = event.device?.let { InputDeviceUtils.createInputDeviceInfo(it) },
2323
axisHatX = event.getAxisValue(MotionEvent.AXIS_HAT_X),
2424
axisHatY = event.getAxisValue(MotionEvent.AXIS_HAT_Y),
2525
isDpad = InputEventUtils.isDpadDevice(event),

app/src/main/java/io/github/sds100/keymapper/system/permissions/AndroidPermissionAdapter.kt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,10 @@ import io.github.sds100.keymapper.system.apps.PackageManagerAdapter
2525
import io.github.sds100.keymapper.system.root.SuAdapter
2626
import io.github.sds100.keymapper.util.Error
2727
import io.github.sds100.keymapper.util.Result
28-
import io.github.sds100.keymapper.util.Success
2928
import io.github.sds100.keymapper.util.getIdentifier
3029
import io.github.sds100.keymapper.util.onFailure
3130
import io.github.sds100.keymapper.util.onSuccess
3231
import io.github.sds100.keymapper.util.success
33-
import io.github.sds100.keymapper.util.then
34-
import io.github.sds100.keymapper.util.valueIfFailure
3532
import kotlinx.coroutines.CoroutineScope
3633
import kotlinx.coroutines.flow.Flow
3734
import kotlinx.coroutines.flow.MutableSharedFlow
@@ -338,11 +335,6 @@ class AndroidPermissionAdapter(
338335
} else {
339336
true
340337
}
341-
342-
Permission.DEVICE_ASSISTANT ->
343-
packageManagerAdapter.getDeviceAssistantPackage()
344-
.then { Success(it == Constants.PACKAGE_NAME) }
345-
.valueIfFailure { false }
346338
}
347339

348340
override fun isGrantedFlow(permission: Permission): Flow<Boolean> = callbackFlow {

0 commit comments

Comments
 (0)