fix node id lookups

1.2-legacy
geeksville 2020-02-25 10:30:10 -08:00
rodzic 2c8c7ac8d6
commit b5fc637f30
5 zmienionych plików z 37 dodań i 22 usunięć

Wyświetl plik

@ -1,6 +1,7 @@
# High priority
MVP features required for first public alpha
* don't show test texts when not under emulator
* make a boot screen explaining this is an early alpha, tell user to go to settings if they have a radio, otherwise go to website
* show offline nodes as greyed out
* make node list view not look like ass

Wyświetl plik

@ -288,6 +288,20 @@ class MainActivity : AppCompatActivity(), Logging,
// everytime the radio reconnects, we slam in our current owner data, the radio is smart enough to only broadcast if needed
UIState.setOwner(this)
val m = UIState.meshService!!
// Pull down our real node ID
NodeDB.myId.value = m.myId
// Update our nodeinfos based on data from the device
NodeDB.nodes.clear()
NodeDB.nodes.putAll(
m.nodes.map
{
it.user?.id!! to it
}
)
}
}
@ -347,15 +361,6 @@ class MainActivity : AppCompatActivity(), Logging,
onMeshConnectionChanged(m.isConnected)
debug("connected to mesh service, isConnected=${UIState.isConnected.value}")
// Update our nodeinfos based on data from the device
NodeDB.nodes.clear()
NodeDB.nodes.putAll(
m.nodes.map
{
it.user?.id!! to it
}
)
}
override fun onDisconnected() {

Wyświetl plik

@ -495,8 +495,9 @@ class MeshService : Service(), Logging {
/// Update our DB of users based on someone sending out a User subpacket
private fun handleReceivedUser(fromNum: Int, p: MeshProtos.User) {
updateNodeInfo(fromNum) {
val oldId = it.user?.id.orEmpty()
it.user = MeshUser(
p.id,
if (p.id.isNotEmpty()) p.id else oldId, // If the new update doesn't contain an ID keep our old value
p.longName,
p.shortName
)

Wyświetl plik

@ -1,6 +1,8 @@
package com.geeksville.mesh.ui
import androidx.compose.Composable
import androidx.compose.ambient
import androidx.ui.core.ContextAmbient
import androidx.ui.core.Text
import androidx.ui.foundation.Clickable
import androidx.ui.foundation.DrawImage
@ -10,7 +12,9 @@ import androidx.ui.material.ripple.Ripple
import androidx.ui.res.imageResource
import androidx.ui.tooling.preview.Preview
import androidx.ui.unit.dp
import com.geeksville.android.GeeksvilleApplication
import com.geeksville.android.Logging
import com.geeksville.android.toast
import com.geeksville.mesh.R
/// The Compose IDE preview doesn't like the protobufs
@ -21,6 +25,7 @@ object ChannelLog : Logging
@Composable
fun ChannelContent(channel: Channel = Channel("Default", 7)) {
val typography = MaterialTheme.typography()
val context = ambient(ContextAmbient)
Column(modifier = LayoutSize.Fill + LayoutPadding(16.dp)) {
Text(
@ -37,7 +42,8 @@ fun ChannelContent(channel: Channel = Channel("Default", 7)) {
Ripple(bounded = false) {
Clickable(onClick = {
TODO()
GeeksvilleApplication.analytics.track("channel_share") // track how many times users share channels
context.toast("Channel sharing is not yet implemented")
}) {
VectorImage(
id = R.drawable.ic_twotone_share_24,

Wyświetl plik

@ -48,17 +48,19 @@ fun HomeContent() {
Column {
Text("Connected")
/// Create a software update button
val context = ambient(ContextAmbient)
RadioInterfaceService.getBondedDeviceAddress(context)?.let { macAddress ->
Button(text = "Update firmware",
onClick = {
SoftwareUpdateService.enqueueWork(
context,
SoftwareUpdateService.startUpdateIntent(macAddress)
)
}
)
if (false) { // hide the firmware update button for now, it is kinda ugly and users don't need it yet
/// Create a software update button
val context = ambient(ContextAmbient)
RadioInterfaceService.getBondedDeviceAddress(context)?.let { macAddress ->
Button(text = "Update firmware",
onClick = {
SoftwareUpdateService.enqueueWork(
context,
SoftwareUpdateService.startUpdateIntent(macAddress)
)
}
)
}
}
}
} else {