mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-04-19 21:59:11 +00:00
better error message when loading invalid json layout
This commit is contained in:
parent
b47bc52e7d
commit
dab2fa4f42
1 changed files with 6 additions and 2 deletions
|
@ -92,6 +92,12 @@ private fun checkLayout(layoutContent: String, context: Context): Boolean? {
|
||||||
return null
|
return null
|
||||||
return false
|
return false
|
||||||
} catch (e: Exception) { Log.w(TAG, "error parsing custom simple layout", e) }
|
} catch (e: Exception) { Log.w(TAG, "error parsing custom simple layout", e) }
|
||||||
|
if (layoutContent.startsWith("[")) {
|
||||||
|
// layout can't be loaded, assume it's json -> try json layout again because of error message readout
|
||||||
|
try {
|
||||||
|
JsonKeyboardParser(params, context).parseLayoutString(layoutContent)
|
||||||
|
} catch (e: Exception) { Log.w(TAG, "error parsing custom json layout", e) }
|
||||||
|
}
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,8 +157,6 @@ fun editCustomLayout(layoutName: String, context: Context, startContent: String?
|
||||||
val isJson = checkLayout(content, context)
|
val isJson = checkLayout(content, context)
|
||||||
if (isJson == null) {
|
if (isJson == null) {
|
||||||
editCustomLayout(layoutName, context, content)
|
editCustomLayout(layoutName, context, content)
|
||||||
// todo: this actually always returns the "simple layout" error, even on a json layout with a single small error
|
|
||||||
// -> check in inverse expected order (set depending in current file name)
|
|
||||||
infoDialog(context, context.getString(R.string.layout_error, Log.getLog(10).lastOrNull { it.tag == TAG }?.message))
|
infoDialog(context, context.getString(R.string.layout_error, Log.getLog(10).lastOrNull { it.tag == TAG }?.message))
|
||||||
} else {
|
} else {
|
||||||
val wasJson = file.name.substringAfterLast(".") == "json"
|
val wasJson = file.name.substringAfterLast(".") == "json"
|
||||||
|
|
Loading…
Add table
Reference in a new issue