mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
mock interface now pretty completely simulates a real device
This commit is contained in:
parent
a0160cadf9
commit
7d846461e4
7 changed files with 103 additions and 43 deletions
|
|
@ -2,13 +2,13 @@ package com.geeksville.mesh.model
|
|||
|
||||
import android.os.RemoteException
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.geeksville.android.BuildUtils.isEmulator
|
||||
import com.geeksville.android.Logging
|
||||
import com.geeksville.mesh.DataPacket
|
||||
import com.geeksville.mesh.MessageStatus
|
||||
|
||||
|
||||
class MessagesState(private val ui: UIViewModel) : Logging {
|
||||
/* We now provide fake messages a via MockInterface
|
||||
private val testTexts = listOf(
|
||||
DataPacket(
|
||||
"+16508765310",
|
||||
|
|
@ -18,10 +18,10 @@ class MessagesState(private val ui: UIViewModel) : Logging {
|
|||
"+16508765311",
|
||||
"Help! I've fallen and I can't get up."
|
||||
)
|
||||
)
|
||||
) */
|
||||
|
||||
/// This is the inner storage for messages
|
||||
private val messagesList = (if (isEmulator) testTexts else emptyList()).toMutableList()
|
||||
private val messagesList = emptyList<DataPacket>().toMutableList()
|
||||
|
||||
// If the following (unused otherwise) line is commented out, the IDE preview window works.
|
||||
// if left in the preview always renders as empty.
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package com.geeksville.mesh.model
|
||||
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.geeksville.android.BuildUtils.isEmulator
|
||||
import com.geeksville.mesh.MeshUser
|
||||
import com.geeksville.mesh.NodeInfo
|
||||
import com.geeksville.mesh.Position
|
||||
|
|
@ -43,15 +42,15 @@ class NodeDB(private val ui: UIViewModel) {
|
|||
)
|
||||
}
|
||||
|
||||
private val seedWithTestNodes = isEmulator
|
||||
private val seedWithTestNodes = false
|
||||
|
||||
/// The unique ID of our node
|
||||
val myId = object : MutableLiveData<String?>(if (isEmulator) "+16508765309" else null) {}
|
||||
val myId = object : MutableLiveData<String?>(if (seedWithTestNodes) "+16508765309" else null) {}
|
||||
|
||||
/// A map from nodeid to to nodeinfo
|
||||
val nodes =
|
||||
object :
|
||||
MutableLiveData<Map<String, NodeInfo>>(mapOf(*(if (isEmulator) testNodes else listOf()).map { it.user!!.id to it }
|
||||
MutableLiveData<Map<String, NodeInfo>>(mapOf(*(if (seedWithTestNodes) testNodes else listOf()).map { it.user!!.id to it }
|
||||
.toTypedArray())) {}
|
||||
|
||||
/// Could be null if we haven't received our node DB yet
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import androidx.lifecycle.AndroidViewModel
|
|||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.geeksville.android.BuildUtils.isEmulator
|
||||
import com.geeksville.android.Logging
|
||||
import com.geeksville.mesh.IMeshService
|
||||
import com.geeksville.mesh.MeshProtos
|
||||
|
|
@ -77,10 +76,7 @@ class UIViewModel(app: Application) : AndroidViewModel(app), Logging {
|
|||
fun getChannel(c: MeshProtos.RadioConfig?): Channel? {
|
||||
val channel = c?.channelSettings?.let { Channel(it) }
|
||||
|
||||
return if (channel == null && isEmulator)
|
||||
Channel.emulated
|
||||
else
|
||||
channel
|
||||
return channel
|
||||
}
|
||||
|
||||
fun getPreferences(context: Context): SharedPreferences =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue