fix: converter backwards compatibility
Fixes database converter to allow for backwards compatabilty.
This commit is contained in:
parent
b70ecbdfff
commit
e0cce8fba4
|
@ -14,8 +14,8 @@ android {
|
||||||
applicationId = "com.zaneschepke.wireguardautotunnel"
|
applicationId = "com.zaneschepke.wireguardautotunnel"
|
||||||
minSdk = 26
|
minSdk = 26
|
||||||
targetSdk = 34
|
targetSdk = 34
|
||||||
versionCode = 31900
|
versionCode = 32000
|
||||||
versionName = "3.1.9"
|
versionName = "3.2.0"
|
||||||
|
|
||||||
ksp {
|
ksp {
|
||||||
arg("room.schemaLocation", "$projectDir/schemas")
|
arg("room.schemaLocation", "$projectDir/schemas")
|
||||||
|
|
|
@ -12,6 +12,12 @@ class DatabaseListConverters {
|
||||||
@TypeConverter
|
@TypeConverter
|
||||||
fun stringToList(value: String): MutableList<String> {
|
fun stringToList(value: String): MutableList<String> {
|
||||||
if(value.isEmpty()) return mutableListOf()
|
if(value.isEmpty()) return mutableListOf()
|
||||||
return Json.decodeFromString<MutableList<String>>(value)
|
return try {
|
||||||
|
Json.decodeFromString<MutableList<String>>(value)
|
||||||
|
} catch (e : Exception) {
|
||||||
|
val list = value.split(",").toMutableList()
|
||||||
|
val json = listToString(list)
|
||||||
|
Json.decodeFromString<MutableList<String>>(json)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -159,8 +159,8 @@ fun MainScreen(
|
||||||
scope.launch(Dispatchers.IO) {
|
scope.launch(Dispatchers.IO) {
|
||||||
try {
|
try {
|
||||||
viewModel.onTunnelFileSelected(data)
|
viewModel.onTunnelFileSelected(data)
|
||||||
} catch (e : Exception) {
|
} catch (e : WgTunnelException) {
|
||||||
showSnackbarMessage(e.message ?: context.getString(R.string.unknown_error))
|
showSnackbarMessage(e.message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -171,8 +171,8 @@ fun MainScreen(
|
||||||
scope.launch {
|
scope.launch {
|
||||||
try {
|
try {
|
||||||
viewModel.onTunnelQrResult(it.contents)
|
viewModel.onTunnelQrResult(it.contents)
|
||||||
} catch (e: Exception) {
|
} catch (e: WgTunnelException) {
|
||||||
showSnackbarMessage(context.getString(R.string.qr_result_failed))
|
showSnackbarMessage(e.message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue