Android: add canvas hasContent state tracking
Tracks whether the canvas has navigated content to support conditional UI rendering based on canvas state. AI-assisted (Claude) - lightly tested
This commit is contained in:
parent
275b908d0e
commit
55631f83a1
@ -53,6 +53,7 @@ class MainViewModel(app: Application) : AndroidViewModel(app) {
|
|||||||
val manualTls: StateFlow<Boolean> = runtime.manualTls
|
val manualTls: StateFlow<Boolean> = runtime.manualTls
|
||||||
val manualToken: StateFlow<String> = runtime.manualToken
|
val manualToken: StateFlow<String> = runtime.manualToken
|
||||||
val canvasDebugStatusEnabled: StateFlow<Boolean> = runtime.canvasDebugStatusEnabled
|
val canvasDebugStatusEnabled: StateFlow<Boolean> = runtime.canvasDebugStatusEnabled
|
||||||
|
val canvasHasContent: StateFlow<Boolean> = runtime.canvasHasContent
|
||||||
|
|
||||||
val chatSessionKey: StateFlow<String> = runtime.chatSessionKey
|
val chatSessionKey: StateFlow<String> = runtime.chatSessionKey
|
||||||
val chatSessionId: StateFlow<String?> = runtime.chatSessionId
|
val chatSessionId: StateFlow<String?> = runtime.chatSessionId
|
||||||
|
|||||||
@ -330,6 +330,7 @@ class NodeRuntime(context: Context) {
|
|||||||
val manualToken: StateFlow<String> = prefs.manualToken
|
val manualToken: StateFlow<String> = prefs.manualToken
|
||||||
val lastDiscoveredStableId: StateFlow<String> = prefs.lastDiscoveredStableId
|
val lastDiscoveredStableId: StateFlow<String> = prefs.lastDiscoveredStableId
|
||||||
val canvasDebugStatusEnabled: StateFlow<Boolean> = prefs.canvasDebugStatusEnabled
|
val canvasDebugStatusEnabled: StateFlow<Boolean> = prefs.canvasDebugStatusEnabled
|
||||||
|
val canvasHasContent: StateFlow<Boolean> = canvas.hasContent
|
||||||
|
|
||||||
private var didAutoConnect = false
|
private var didAutoConnect = false
|
||||||
private var suppressWakeWordsSync = false
|
private var suppressWakeWordsSync = false
|
||||||
|
|||||||
@ -8,6 +8,9 @@ import android.webkit.WebView
|
|||||||
import androidx.core.graphics.createBitmap
|
import androidx.core.graphics.createBitmap
|
||||||
import androidx.core.graphics.scale
|
import androidx.core.graphics.scale
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
|
import kotlinx.coroutines.flow.StateFlow
|
||||||
|
import kotlinx.coroutines.flow.asStateFlow
|
||||||
import kotlinx.coroutines.suspendCancellableCoroutine
|
import kotlinx.coroutines.suspendCancellableCoroutine
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import java.io.ByteArrayOutputStream
|
import java.io.ByteArrayOutputStream
|
||||||
@ -21,6 +24,8 @@ import com.clawdbot.android.BuildConfig
|
|||||||
import kotlin.coroutines.resume
|
import kotlin.coroutines.resume
|
||||||
|
|
||||||
class CanvasController {
|
class CanvasController {
|
||||||
|
private val _hasContent = MutableStateFlow(false)
|
||||||
|
val hasContent: StateFlow<Boolean> = _hasContent.asStateFlow()
|
||||||
enum class SnapshotFormat(val rawValue: String) {
|
enum class SnapshotFormat(val rawValue: String) {
|
||||||
Png("png"),
|
Png("png"),
|
||||||
Jpeg("jpeg"),
|
Jpeg("jpeg"),
|
||||||
@ -48,6 +53,7 @@ class CanvasController {
|
|||||||
fun navigate(url: String) {
|
fun navigate(url: String) {
|
||||||
val trimmed = url.trim()
|
val trimmed = url.trim()
|
||||||
this.url = if (trimmed.isBlank() || trimmed == "/") null else trimmed
|
this.url = if (trimmed.isBlank() || trimmed == "/") null else trimmed
|
||||||
|
_hasContent.value = this.url != null
|
||||||
reload()
|
reload()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user