only seed with test data if we are on the emulator

1.2-legacy
geeksville 2020-02-25 10:48:54 -08:00
rodzic b5fc637f30
commit 8089475622
4 zmienionych plików z 11 dodań i 5 usunięć

Wyświetl plik

@ -1,6 +1,7 @@
package com.geeksville.mesh
import android.os.Debug
import com.geeksville.android.BuildUtils.isEmulator
import com.geeksville.android.GeeksvilleApplication
import com.geeksville.android.Logging
import com.geeksville.util.Exceptions
@ -16,7 +17,7 @@ class MeshUtilApplication : GeeksvilleApplication(null, "58e72ccc361883ea502510b
// We default to off in the manifest, FIXME turn on only if user approves
// leave off when running in the debugger
if (!BuildConfig.DEBUG || !Debug.isDebuggerConnected()) {
if (!isEmulator && (!BuildConfig.DEBUG || !Debug.isDebuggerConnected())) {
val crashlytics = FirebaseCrashlytics.getInstance()
crashlytics.setCrashlyticsCollectionEnabled(true)

Wyświetl plik

@ -115,7 +115,7 @@ data class NodeInfo(
fun distance(o: NodeInfo?): Int? {
val p = position
val op = o?.position
return if (p != null && op != null)
return if (p != null && op != null && p.latitude != 0.0 && op.longitude != 0.0)
p.distance(op).toInt()
else
null

Wyświetl plik

@ -2,6 +2,7 @@ package com.geeksville.mesh.model
import android.os.RemoteException
import androidx.compose.frames.modelListOf
import com.geeksville.android.BuildUtils.isEmulator
import com.geeksville.android.Logging
import com.geeksville.mesh.MeshProtos
import com.geeksville.mesh.utf8
@ -34,7 +35,7 @@ object MessagesState : Logging {
// If the following (unused otherwise) line is commented out, the IDE preview window works.
// if left in the preview always renders as empty.
val messages = modelListOf(*testTexts)
val messages = modelListOf(* if (isEmulator) testTexts else arrayOf())
/// add a message our GUI list of past msgs
fun addMessage(m: TextMessage) {

Wyświetl plik

@ -1,6 +1,7 @@
package com.geeksville.mesh.model
import androidx.compose.mutableStateOf
import com.geeksville.android.BuildUtils.isEmulator
import com.geeksville.mesh.MeshUser
import com.geeksville.mesh.NodeInfo
import com.geeksville.mesh.Position
@ -38,11 +39,14 @@ object NodeDB {
)
}
private val seedWithTestNodes = isEmulator
/// The unique ID of our node
val myId = mutableStateOf("+16508765309")
val myId = mutableStateOf(if (isEmulator) "+16508765309" else "invalid")
/// A map from nodeid to to nodeinfo
val nodes = mutableMapOf(* testNodes.map { it.user!!.id to it }.toTypedArray())
val nodes =
mutableMapOf(* (if (isEmulator) testNodes else listOf()).map { it.user!!.id to it }.toTypedArray())
/// Could be null if we haven't received our node DB yet
val ourNodeInfo get() = nodes[myId.value]