text message gui for sneding kinda works

1.2-legacy
geeksville 2020-02-17 15:56:04 -08:00
rodzic 165df2c4de
commit b3026ba6be
6 zmienionych plików z 18 dodań i 16 usunięć

Wyświetl plik

@ -8,6 +8,7 @@ MVP features required for first public alpha
* let user set name and shortname
* take video
* when we connect to radio, distances to nodes in the chat log should automatically redraw
* show pointer arrow on the outside of the user icons, always pointing towoards them
* stop scan when we start the service
* set the radio by using the service

Wyświetl plik

@ -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()
}

Wyświetl plik

@ -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!!]
}

Wyświetl plik

@ -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")
/**

Wyświetl plik

@ -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"

Wyświetl plik

@ -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)
}