fix(android): resolve Kotlin compilation errors
- Fix DeepLinkSheet import: com.clawdbot → bot.molt - Remove duplicate helper functions from NodeGatewaySync.kt - Make shared helpers internal in NodeRuntime.kt - Rename a2ui constants to uppercase (A2UI_READY_CHECK_JS, A2UI_RESET_JS) - Add missing padding/size imports in SettingsSheet.kt - Update EncryptedSharedPreferences to use MasterKey API Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
6b11f9da2f
commit
0f2f594de4
@ -258,71 +258,3 @@ internal fun NodeRuntime.parseLocationParams(paramsJson: String?): Triple<Long?,
|
|||||||
val desiredAccuracy = (root?.get("desiredAccuracy") as? JsonPrimitive)?.content?.trim()?.lowercase()
|
val desiredAccuracy = (root?.get("desiredAccuracy") as? JsonPrimitive)?.content?.trim()?.lowercase()
|
||||||
return Triple(maxAgeMs, timeoutMs, desiredAccuracy)
|
return Triple(maxAgeMs, timeoutMs, desiredAccuracy)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - A2UI JavaScript Constants
|
|
||||||
|
|
||||||
internal const val A2UI_READY_CHECK_JS: String = """
|
|
||||||
(() => {
|
|
||||||
try {
|
|
||||||
return !!globalThis.clawdbotA2UI && typeof globalThis.clawdbotA2UI.applyMessages === 'function';
|
|
||||||
} catch (_) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
})()
|
|
||||||
"""
|
|
||||||
|
|
||||||
internal const val A2UI_RESET_JS: String = """
|
|
||||||
(() => {
|
|
||||||
try {
|
|
||||||
if (!globalThis.clawdbotA2UI) return { ok: false, error: "missing clawdbotA2UI" };
|
|
||||||
return globalThis.clawdbotA2UI.reset();
|
|
||||||
} catch (e) {
|
|
||||||
return { ok: false, error: String(e?.message ?? e) };
|
|
||||||
}
|
|
||||||
})()
|
|
||||||
"""
|
|
||||||
|
|
||||||
internal fun a2uiApplyMessagesJS(messagesJson: String): String {
|
|
||||||
return """
|
|
||||||
(() => {
|
|
||||||
try {
|
|
||||||
if (!globalThis.clawdbotA2UI) return { ok: false, error: "missing clawdbotA2UI" };
|
|
||||||
const messages = $messagesJson;
|
|
||||||
return globalThis.clawdbotA2UI.applyMessages(messages);
|
|
||||||
} catch (e) {
|
|
||||||
return { ok: false, error: String(e?.message ?? e) };
|
|
||||||
}
|
|
||||||
})()
|
|
||||||
""".trimIndent()
|
|
||||||
}
|
|
||||||
|
|
||||||
internal const val DEFAULT_SEAM_COLOR_ARGB: Long = 0xFF4F7A9A
|
|
||||||
|
|
||||||
internal fun parseHexColorArgb(raw: String?): Long? {
|
|
||||||
val trimmed = raw?.trim().orEmpty()
|
|
||||||
if (trimmed.isEmpty()) return null
|
|
||||||
val hex = if (trimmed.startsWith("#")) trimmed.drop(1) else trimmed
|
|
||||||
if (hex.length != 6) return null
|
|
||||||
val rgb = hex.toLongOrNull(16) ?: return null
|
|
||||||
return 0xFF000000L or rgb
|
|
||||||
}
|
|
||||||
|
|
||||||
// MARK: - JSON Helpers
|
|
||||||
|
|
||||||
internal fun kotlinx.serialization.json.JsonElement?.asObjectOrNull(): JsonObject? = this as? JsonObject
|
|
||||||
|
|
||||||
internal fun kotlinx.serialization.json.JsonElement?.asStringOrNull(): String? =
|
|
||||||
when (this) {
|
|
||||||
is kotlinx.serialization.json.JsonNull -> null
|
|
||||||
is JsonPrimitive -> content
|
|
||||||
else -> null
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun String.toJsonStringInternal(): String {
|
|
||||||
val escaped = this
|
|
||||||
.replace("\\", "\\\\")
|
|
||||||
.replace("\"", "\\\"")
|
|
||||||
.replace("\n", "\\n")
|
|
||||||
.replace("\r", "\\r")
|
|
||||||
return "\"$escaped\""
|
|
||||||
}
|
|
||||||
|
|||||||
@ -1201,9 +1201,9 @@ class NodeRuntime(context: Context) {
|
|||||||
|
|
||||||
private data class Quad<A, B, C, D>(val first: A, val second: B, val third: C, val fourth: D)
|
private data class Quad<A, B, C, D>(val first: A, val second: B, val third: C, val fourth: D)
|
||||||
|
|
||||||
private const val DEFAULT_SEAM_COLOR_ARGB: Long = 0xFF4F7A9A
|
internal const val DEFAULT_SEAM_COLOR_ARGB: Long = 0xFF4F7A9A
|
||||||
|
|
||||||
private const val a2uiReadyCheckJS: String =
|
internal const val A2UI_READY_CHECK_JS: String =
|
||||||
"""
|
"""
|
||||||
(() => {
|
(() => {
|
||||||
try {
|
try {
|
||||||
@ -1214,7 +1214,7 @@ private const val a2uiReadyCheckJS: String =
|
|||||||
})()
|
})()
|
||||||
"""
|
"""
|
||||||
|
|
||||||
private const val a2uiResetJS: String =
|
internal const val A2UI_RESET_JS: String =
|
||||||
"""
|
"""
|
||||||
(() => {
|
(() => {
|
||||||
try {
|
try {
|
||||||
@ -1226,7 +1226,7 @@ private const val a2uiResetJS: String =
|
|||||||
})()
|
})()
|
||||||
"""
|
"""
|
||||||
|
|
||||||
private fun a2uiApplyMessagesJS(messagesJson: String): String {
|
internal fun a2uiApplyMessagesJS(messagesJson: String): String {
|
||||||
return """
|
return """
|
||||||
(() => {
|
(() => {
|
||||||
try {
|
try {
|
||||||
@ -1249,16 +1249,16 @@ private fun String.toJsonString(): String {
|
|||||||
return "\"$escaped\""
|
return "\"$escaped\""
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun JsonElement?.asObjectOrNull(): JsonObject? = this as? JsonObject
|
internal fun JsonElement?.asObjectOrNull(): JsonObject? = this as? JsonObject
|
||||||
|
|
||||||
private fun JsonElement?.asStringOrNull(): String? =
|
internal fun JsonElement?.asStringOrNull(): String? =
|
||||||
when (this) {
|
when (this) {
|
||||||
is JsonNull -> null
|
is JsonNull -> null
|
||||||
is JsonPrimitive -> content
|
is JsonPrimitive -> content
|
||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun parseHexColorArgb(raw: String?): Long? {
|
internal fun parseHexColorArgb(raw: String?): Long? {
|
||||||
val trimmed = raw?.trim().orEmpty()
|
val trimmed = raw?.trim().orEmpty()
|
||||||
if (trimmed.isEmpty()) return null
|
if (trimmed.isEmpty()) return null
|
||||||
val hex = if (trimmed.startsWith("#")) trimmed.drop(1) else trimmed
|
val hex = if (trimmed.startsWith("#")) trimmed.drop(1) else trimmed
|
||||||
|
|||||||
@ -146,12 +146,13 @@ object PushTokenStore {
|
|||||||
|
|
||||||
private fun getSecurePrefs(context: Context): android.content.SharedPreferences {
|
private fun getSecurePrefs(context: Context): android.content.SharedPreferences {
|
||||||
return try {
|
return try {
|
||||||
|
val masterKey = androidx.security.crypto.MasterKey.Builder(context)
|
||||||
|
.setKeyScheme(androidx.security.crypto.MasterKey.KeyScheme.AES256_GCM)
|
||||||
|
.build()
|
||||||
androidx.security.crypto.EncryptedSharedPreferences.create(
|
androidx.security.crypto.EncryptedSharedPreferences.create(
|
||||||
context,
|
context,
|
||||||
PREFS_NAME,
|
PREFS_NAME,
|
||||||
androidx.security.crypto.MasterKeys.getOrCreate(
|
masterKey,
|
||||||
androidx.security.crypto.MasterKeys.AES256_GCM_SPEC
|
|
||||||
),
|
|
||||||
androidx.security.crypto.EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV,
|
androidx.security.crypto.EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV,
|
||||||
androidx.security.crypto.EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM
|
androidx.security.crypto.EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM
|
||||||
)
|
)
|
||||||
|
|||||||
@ -56,7 +56,7 @@ import androidx.compose.runtime.getValue
|
|||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import com.clawdbot.android.DeepLinkSheet
|
import bot.molt.android.DeepLinkSheet
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.Color as ComposeColor
|
import androidx.compose.ui.graphics.Color as ComposeColor
|
||||||
|
|||||||
@ -23,7 +23,9 @@ import androidx.compose.foundation.layout.fillMaxWidth
|
|||||||
import androidx.compose.foundation.layout.height
|
import androidx.compose.foundation.layout.height
|
||||||
import androidx.compose.foundation.layout.imePadding
|
import androidx.compose.foundation.layout.imePadding
|
||||||
import androidx.compose.foundation.layout.only
|
import androidx.compose.foundation.layout.only
|
||||||
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.layout.safeDrawing
|
import androidx.compose.foundation.layout.safeDrawing
|
||||||
|
import androidx.compose.foundation.layout.size
|
||||||
import androidx.compose.foundation.layout.windowInsetsPadding
|
import androidx.compose.foundation.layout.windowInsetsPadding
|
||||||
import androidx.compose.foundation.lazy.LazyColumn
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
import androidx.compose.foundation.lazy.items
|
import androidx.compose.foundation.lazy.items
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user