mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-03-24 00:33:14 -04:00
text message gui for sneding kinda works
This commit is contained in:
@@ -320,14 +320,9 @@ class MainActivity : AppCompatActivity(), Logging,
|
||||
MeshProtos.Data.Type.CLEAR_TEXT_VALUE -> {
|
||||
// FIXME - use the real time from the packet
|
||||
// FIXME - don't just slam in a new list each time, it probably causes extra drawing. Figure out how to be Compose smarter...
|
||||
val modded = MessagesState.messages.value.toMutableList()
|
||||
modded.add(
|
||||
TextMessage(
|
||||
sender,
|
||||
payload.toString(utf8)
|
||||
)
|
||||
)
|
||||
MessagesState.messages.value = modded
|
||||
val msg = TextMessage(sender, payload.toString(utf8))
|
||||
|
||||
MessagesState.addMessage(msg)
|
||||
}
|
||||
else -> TODO()
|
||||
}
|
||||
|
||||
@@ -46,5 +46,6 @@ object NodeDB {
|
||||
/// A map from nodeid to to nodeinfo
|
||||
val nodes = mutableStateOf(testNodes.map { it.user!!.id to it }.toMap())
|
||||
|
||||
val ourNodeInfo get() = nodes.value[myId.value!!] ?: error("our node not found")
|
||||
/// Could be null if we haven't received our node DB yet
|
||||
val ourNodeInfo get() = nodes.value[myId.value!!]
|
||||
}
|
||||
@@ -26,7 +26,7 @@ import com.google.protobuf.ByteString
|
||||
import java.nio.charset.Charset
|
||||
|
||||
|
||||
class RadioNotConnectedException() : Exception("Can't find radio")
|
||||
class RadioNotConnectedException() : Exception("Not connected to radio")
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.geeksville.mesh.ui
|
||||
|
||||
import android.os.RemoteException
|
||||
import androidx.compose.Composable
|
||||
import androidx.compose.state
|
||||
import androidx.ui.core.Modifier
|
||||
@@ -118,11 +119,15 @@ fun MessagesContent() {
|
||||
var error: String? = null
|
||||
val service = UIState.meshService
|
||||
if (service != null)
|
||||
service.sendData(
|
||||
null,
|
||||
str.toByteArray(utf8),
|
||||
MeshProtos.Data.Type.CLEAR_TEXT_VALUE
|
||||
)
|
||||
try {
|
||||
service.sendData(
|
||||
null,
|
||||
str.toByteArray(utf8),
|
||||
MeshProtos.Data.Type.CLEAR_TEXT_VALUE
|
||||
)
|
||||
} catch (ex: RemoteException) {
|
||||
error = "Error: ${ex.message}"
|
||||
}
|
||||
else
|
||||
error = "Error: No Mesh service"
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ fun UserIcon(user: NodeInfo? = null, modifier: Modifier = Modifier.None) {
|
||||
modifier = LayoutGravity.Center
|
||||
)
|
||||
val ourNodeInfo = NodeDB.ourNodeInfo
|
||||
val distance = ourNodeInfo.distanceStr(user)
|
||||
val distance = ourNodeInfo?.distanceStr(user)
|
||||
if (distance != null)
|
||||
Text(distance, modifier = LayoutGravity.Center)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user