Skip to content

Commit 9a92925

Browse files
committed
Merge branch 'develop' into copilot/modify-system-settings-permission
2 parents f300bf8 + 04328e3 commit 9a92925

File tree

8 files changed

+33
-15
lines changed

8 files changed

+33
-15
lines changed

app/version.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
VERSION_NAME=4.0.0-beta.2
2-
VERSION_CODE=187
1+
VERSION_NAME=4.0.0-beta.3
2+
VERSION_CODE=189
33
VERSION_NUM=01

base/src/main/java/io/github/sds100/keymapper/base/backup/BackupManager.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -780,6 +780,7 @@ class BackupManagerImpl @Inject constructor(
780780
private fun getSoundUidsToBackup(keyMapList: List<KeyMapEntity>): Set<String> {
781781
val soundActions = keyMapList
782782
.flatMap { it.actionList }
783+
.filterNotNull()
783784
.filter { it.type == ActionEntity.Type.SOUND }
784785

785786
return soundActions

base/src/main/java/io/github/sds100/keymapper/base/input/InputEventHub.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ class InputEventHubImpl @Inject constructor(
343343
val androidKeyEvent = event.toAndroidKeyEvent(flags = KeyEvent.FLAG_FROM_SYSTEM)
344344

345345
if (logInputEventsEnabled.value) {
346-
Timber.d("Injecting key event $androidKeyEvent with system bridge")
346+
Timber.d("Injecting key event with system bridge $androidKeyEvent")
347347
}
348348

349349
return withContext(Dispatchers.IO) {

base/src/main/java/io/github/sds100/keymapper/base/keymaps/KeyMap.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,9 @@ object KeyMapEntityMapper {
112112
entity: KeyMapEntity,
113113
floatingButtons: List<FloatingButtonEntityWithLayout>,
114114
): KeyMap {
115-
val actionList = entity.actionList.mapNotNull { ActionEntityMapper.fromEntity(it) }
115+
val actionList = entity.actionList
116+
.filterNotNull()
117+
.mapNotNull { ActionEntityMapper.fromEntity(it) }
116118

117119
val constraintList =
118120
entity.constraintList.map { ConstraintEntityMapper.fromEntity(it) }.toSet()

data/src/main/java/io/github/sds100/keymapper/data/db/typeconverter/ActionListTypeConverter.kt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,15 @@ import com.github.salomonbrys.kotson.fromJson
55
import com.github.salomonbrys.kotson.registerTypeAdapter
66
import com.google.gson.GsonBuilder
77
import io.github.sds100.keymapper.data.entities.ActionEntity
8-
import io.github.sds100.keymapper.data.entities.ConstraintEntity
98

109
class ActionListTypeConverter {
11-
private val gson = GsonBuilder().registerTypeAdapter(ConstraintEntity.DESERIALIZER).create()
10+
private val gson = GsonBuilder().registerTypeAdapter(ActionEntity.DESERIALIZER).create()
1211

1312
@TypeConverter
14-
fun toActionList(json: String): List<ActionEntity> {
15-
return gson.fromJson<MutableList<ActionEntity>>(json)
13+
fun toActionList(json: String): List<ActionEntity?> {
14+
return gson.fromJson<MutableList<ActionEntity?>>(json)
1615
}
1716

1817
@TypeConverter
19-
fun toJsonString(actionList: List<ActionEntity>): String = gson.toJson(actionList)!!
18+
fun toJsonString(actionList: List<ActionEntity?>): String = gson.toJson(actionList)!!
2019
}

data/src/main/java/io/github/sds100/keymapper/data/entities/ActionEntity.kt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,18 @@ data class ActionEntity(
144144
const val EXTRA_SETTING_TYPE = "extra_setting_type"
145145

146146
val DESERIALIZER = jsonDeserializer {
147-
val typeString by it.json.byString(NAME_ACTION_TYPE)
148-
val type = Type.valueOf(typeString)
147+
val typeString by it.json.byNullableString(NAME_ACTION_TYPE)
148+
// If it is an unknown type then do not deserialize
149+
if (typeString == null) {
150+
return@jsonDeserializer null
151+
}
152+
153+
val type: Type = try {
154+
Type.valueOf(typeString!!)
155+
} catch (e: IllegalArgumentException) {
156+
// If it is an unknown type then do not deserialize
157+
return@jsonDeserializer null
158+
}
149159

150160
val data by it.json.byString(NAME_DATA)
151161

data/src/main/java/io/github/sds100/keymapper/data/entities/FingerprintMapEntity.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,12 @@ data class FingerprintMapEntity(
1717
@PrimaryKey
1818
val id: Int = ID_UNKNOWN,
1919

20+
/**
21+
* The action can be null if it wasn't deserialized successfully.
22+
*/
2023
@SerializedName(NAME_ACTION_LIST)
2124
@ColumnInfo(name = FingerprintMapDao.KEY_ACTION_LIST)
22-
val actionList: List<ActionEntity> = listOf(),
25+
val actionList: List<ActionEntity?> = listOf(),
2326

2427
@SerializedName(NAME_CONSTRAINTS)
2528
@ColumnInfo(name = FingerprintMapDao.KEY_CONSTRAINT_LIST)
@@ -63,7 +66,7 @@ data class FingerprintMapEntity(
6366
val id by it.json.byNullableInt(NAME_ID)
6467

6568
val actionListJson by it.json.byArray(NAME_ACTION_LIST)
66-
val actionList = it.context.deserialize<List<ActionEntity>>(actionListJson)
69+
val actionList = it.context.deserialize<List<ActionEntity?>>(actionListJson)
6770

6871
val extrasJson by it.json.byArray(NAME_EXTRAS)
6972
val extras = it.context.deserialize<List<EntityExtra>>(extrasJson)

data/src/main/java/io/github/sds100/keymapper/data/entities/KeyMapEntity.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,12 @@ data class KeyMapEntity(
4141
@ColumnInfo(name = KeyMapDao.KEY_TRIGGER)
4242
val trigger: TriggerEntity = TriggerEntity(),
4343

44+
/**
45+
* The action can be null if it wasn't deserialized successfully.
46+
*/
4447
@SerializedName(NAME_ACTION_LIST)
4548
@ColumnInfo(name = KeyMapDao.KEY_ACTION_LIST)
46-
val actionList: List<ActionEntity> = listOf(),
49+
val actionList: List<ActionEntity?> = listOf(),
4750

4851
@SerializedName(NAME_CONSTRAINT_LIST)
4952
@ColumnInfo(name = KeyMapDao.KEY_CONSTRAINT_LIST)
@@ -87,7 +90,7 @@ data class KeyMapEntity(
8790

8891
val DESERIALIZER = jsonDeserializer {
8992
val actionListJsonArray by it.json.byArray(NAME_ACTION_LIST)
90-
val actionList = it.context.deserialize<List<ActionEntity>>(actionListJsonArray)
93+
val actionList = it.context.deserialize<List<ActionEntity?>>(actionListJsonArray)
9194

9295
val triggerJsonObject by it.json.byObject(NAME_TRIGGER)
9396
val trigger = it.context.deserialize<TriggerEntity>(triggerJsonObject)

0 commit comments

Comments
 (0)