kopia lustrzana https://github.com/meshtastic/Meshtastic-Android
don't let users try to send texts if we don't have a node id
rodzic
547e59754d
commit
fdd3b48364
|
@ -44,7 +44,7 @@ class NodeDB(private val ui: UIViewModel) {
|
|||
private val seedWithTestNodes = isEmulator
|
||||
|
||||
/// The unique ID of our node
|
||||
val myId = object : MutableLiveData<String>(if (isEmulator) "+16508765309" else "invalid") {}
|
||||
val myId = object : MutableLiveData<String?>(if (isEmulator) "+16508765309" else null) {}
|
||||
|
||||
/// A map from nodeid to to nodeinfo
|
||||
val nodes =
|
||||
|
@ -53,5 +53,5 @@ class NodeDB(private val ui: UIViewModel) {
|
|||
.toTypedArray())) {}
|
||||
|
||||
/// Could be null if we haven't received our node DB yet
|
||||
val ourNodeInfo get() = nodes.value!![myId.value]
|
||||
val ourNodeInfo get() = nodes.value?.get(myId.value)
|
||||
}
|
|
@ -14,6 +14,7 @@ import com.geeksville.android.Logging
|
|||
import com.geeksville.mesh.R
|
||||
import com.geeksville.mesh.model.TextMessage
|
||||
import com.geeksville.mesh.model.UIViewModel
|
||||
import com.geeksville.mesh.service.MeshService
|
||||
import kotlinx.android.synthetic.main.adapter_message_layout.view.*
|
||||
import kotlinx.android.synthetic.main.messages_fragment.*
|
||||
import java.text.SimpleDateFormat
|
||||
|
@ -167,6 +168,12 @@ class MessagesFragment : ScreenFragment("Messages"), Logging {
|
|||
model.messagesState.messages.observe(viewLifecycleOwner, Observer { it ->
|
||||
messagesAdapter.onMessagesChanged(it)
|
||||
})
|
||||
|
||||
model.isConnected.observe(viewLifecycleOwner, Observer { connected ->
|
||||
// If we don't know our node ID and we are offline don't let user try to send
|
||||
textInputLayout.isEnabled =
|
||||
connected != MeshService.ConnectionState.DISCONNECTED || model.nodeDB.myId.value != null
|
||||
})
|
||||
}
|
||||
|
||||
private val dateFormat = SimpleDateFormat("h:mm a")
|
||||
|
|
Ładowanie…
Reference in New Issue