improve popup key handling and update tests

remove outdated part from layouts.md
fixes #883
This commit is contained in:
Helium314 2024-06-19 22:42:36 +02:00
parent 5b7f4dae4c
commit 3e74a29f2e
8 changed files with 291 additions and 136 deletions

View file

@ -92,7 +92,7 @@ private fun checkLayout(layoutContent: String, context: Context): Boolean? {
return null
return false
} catch (e: Exception) { Log.w(TAG, "error parsing custom simple layout", e) }
if (layoutContent.startsWith("[")) {
if (layoutContent.trimStart().startsWith("[")) {
// layout can't be loaded, assume it's json -> load json layout again because the error message shown to the user is from the most recent error
try {
RawKeyboardParser.parseJsonString(layoutContent).map { row -> row.mapNotNull { it.compute(params)?.toKeyParams(params) } }
@ -101,7 +101,7 @@ private fun checkLayout(layoutContent: String, context: Context): Boolean? {
return null
}
private fun checkKeys(keys: List<List<Key.KeyParams>>): Boolean {
fun checkKeys(keys: List<List<Key.KeyParams>>): Boolean {
if (keys.isEmpty() || keys.any { it.isEmpty() }) {
Log.w(TAG, "empty rows")
return false