mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-06-10 00:27:45 +00:00
better checks for custom json layouts
and a todo
This commit is contained in:
parent
fe59a598b7
commit
846388de97
3 changed files with 3 additions and 2 deletions
|
@ -89,6 +89,8 @@ fun checkLayout(layoutContent: String, context: Context): Boolean {
|
||||||
return checkKeys(keys)
|
return checkKeys(keys)
|
||||||
} catch (e: SerializationException) {
|
} catch (e: SerializationException) {
|
||||||
Log.w(TAG, "json parsing error", e)
|
Log.w(TAG, "json parsing error", e)
|
||||||
|
if (layoutContent.trimStart().startsWith("[") && layoutContent.trimEnd().endsWith("]") && layoutContent.contains("},"))
|
||||||
|
return false // we're sure enough it's a json
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.w(TAG, "json layout parsed, but considered invalid", e)
|
Log.w(TAG, "json layout parsed, but considered invalid", e)
|
||||||
return false
|
return false
|
||||||
|
|
|
@ -7,7 +7,6 @@ import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
|
||||||
import androidx.compose.runtime.rememberCoroutineScope
|
import androidx.compose.runtime.rememberCoroutineScope
|
||||||
import androidx.compose.runtime.saveable.rememberSaveable
|
import androidx.compose.runtime.saveable.rememberSaveable
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
|
|
|
@ -5,7 +5,6 @@ import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
|
||||||
import androidx.compose.runtime.saveable.rememberSaveable
|
import androidx.compose.runtime.saveable.rememberSaveable
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
|
@ -47,6 +46,7 @@ fun LayoutEditPreference(
|
||||||
it.name.startsWith("$layout.")
|
it.name.startsWith("$layout.")
|
||||||
else it.name.startsWith("$CUSTOM_LAYOUT_PREFIX$layout.")
|
else it.name.startsWith("$CUSTOM_LAYOUT_PREFIX$layout.")
|
||||||
}?.name
|
}?.name
|
||||||
|
// todo: never set originalLayout null if custom layout file does not exist!
|
||||||
val originalLayout = if (customLayoutName != null) null
|
val originalLayout = if (customLayoutName != null) null
|
||||||
else getDefaultLayout(layout)?.let { ctx.assets.open("layouts" + File.separator + it).reader().readText() }
|
else getDefaultLayout(layout)?.let { ctx.assets.open("layouts" + File.separator + it).reader().readText() }
|
||||||
LayoutEditDialog(
|
LayoutEditDialog(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue