kopia lustrzana https://github.com/meshtastic/Meshtastic-Android
add a min appVersion check, so devices can tell user when android app needs
updatepull/40/head
rodzic
ecae22d28d
commit
9254a90774
|
@ -548,7 +548,18 @@ class MainActivity : AppCompatActivity(), Logging,
|
||||||
model.radioConfig.value =
|
model.radioConfig.value =
|
||||||
MeshProtos.RadioConfig.parseFrom(service.radioConfig)
|
MeshProtos.RadioConfig.parseFrom(service.radioConfig)
|
||||||
|
|
||||||
model.myNodeInfo.value = service.myNodeInfo
|
val info = service.myNodeInfo
|
||||||
|
model.myNodeInfo.value = info
|
||||||
|
|
||||||
|
val isOld = info.minAppVersion > BuildConfig.VERSION_CODE
|
||||||
|
if (isOld)
|
||||||
|
MaterialAlertDialogBuilder(this)
|
||||||
|
.setTitle(getString(R.string.app_too_old))
|
||||||
|
.setMessage(getString(R.string.must_update))
|
||||||
|
.setPositiveButton("Okay") { _, _ ->
|
||||||
|
info("User acknowledged app is old")
|
||||||
|
}
|
||||||
|
.show()
|
||||||
|
|
||||||
updateNodesFromDevice()
|
updateNodesFromDevice()
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,8 @@ data class MyNodeInfo(
|
||||||
val currentPacketId: Long,
|
val currentPacketId: Long,
|
||||||
val nodeNumBits: Int,
|
val nodeNumBits: Int,
|
||||||
val packetIdBits: Int,
|
val packetIdBits: Int,
|
||||||
val messageTimeoutMsec: Int
|
val messageTimeoutMsec: Int,
|
||||||
|
val minAppVersion: Int
|
||||||
) : Parcelable {
|
) : Parcelable {
|
||||||
/** A human readable description of the software/hardware version */
|
/** A human readable description of the software/hardware version */
|
||||||
val firmwareString: String get() = "$model $region/$firmwareVersion"
|
val firmwareString: String get() = "$model $region/$firmwareVersion"
|
||||||
|
@ -33,6 +34,7 @@ data class MyNodeInfo(
|
||||||
parcel.readLong(),
|
parcel.readLong(),
|
||||||
parcel.readInt(),
|
parcel.readInt(),
|
||||||
parcel.readInt(),
|
parcel.readInt(),
|
||||||
|
parcel.readInt(),
|
||||||
parcel.readInt()
|
parcel.readInt()
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
@ -49,6 +51,7 @@ data class MyNodeInfo(
|
||||||
parcel.writeInt(nodeNumBits)
|
parcel.writeInt(nodeNumBits)
|
||||||
parcel.writeInt(packetIdBits)
|
parcel.writeInt(packetIdBits)
|
||||||
parcel.writeInt(messageTimeoutMsec)
|
parcel.writeInt(messageTimeoutMsec)
|
||||||
|
parcel.writeInt(minAppVersion)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun describeContents(): Int {
|
override fun describeContents(): Int {
|
||||||
|
|
|
@ -5,9 +5,7 @@ import androidx.lifecycle.MutableLiveData
|
||||||
import com.geeksville.android.BuildUtils.isEmulator
|
import com.geeksville.android.BuildUtils.isEmulator
|
||||||
import com.geeksville.android.Logging
|
import com.geeksville.android.Logging
|
||||||
import com.geeksville.mesh.DataPacket
|
import com.geeksville.mesh.DataPacket
|
||||||
import com.geeksville.mesh.MeshProtos
|
|
||||||
import com.geeksville.mesh.MessageStatus
|
import com.geeksville.mesh.MessageStatus
|
||||||
import com.geeksville.mesh.utf8
|
|
||||||
|
|
||||||
|
|
||||||
class MessagesState(private val ui: UIViewModel) : Logging {
|
class MessagesState(private val ui: UIViewModel) : Logging {
|
||||||
|
@ -31,12 +29,14 @@ class MessagesState(private val ui: UIViewModel) : Logging {
|
||||||
|
|
||||||
/// add a message our GUI list of past msgs
|
/// add a message our GUI list of past msgs
|
||||||
fun addMessage(m: DataPacket) {
|
fun addMessage(m: DataPacket) {
|
||||||
|
debug("Adding message to view id=${m.id}")
|
||||||
// FIXME - don't just slam in a new list each time, it probably causes extra drawing.
|
// FIXME - don't just slam in a new list each time, it probably causes extra drawing.
|
||||||
messages.value = messages.value!! + m
|
messages.value = messages.value!! + m
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateStatus(id: Int, status: MessageStatus) {
|
fun updateStatus(id: Int, status: MessageStatus) {
|
||||||
// Super inefficent but this is rare
|
// Super inefficent but this is rare
|
||||||
|
debug("Handling message status change $id: $status")
|
||||||
val msgs = messages.value!!
|
val msgs = messages.value!!
|
||||||
|
|
||||||
msgs.find { it.id == id }?.let { p ->
|
msgs.find { it.id == id }?.let { p ->
|
||||||
|
@ -55,11 +55,8 @@ class MessagesState(private val ui: UIViewModel) : Logging {
|
||||||
fun sendMessage(str: String, dest: String = DataPacket.ID_BROADCAST) {
|
fun sendMessage(str: String, dest: String = DataPacket.ID_BROADCAST) {
|
||||||
|
|
||||||
val service = ui.meshService
|
val service = ui.meshService
|
||||||
val p = DataPacket(
|
val p = DataPacket(dest, str)
|
||||||
dest,
|
|
||||||
str.toByteArray(utf8),
|
|
||||||
MeshProtos.Data.Type.CLEAR_TEXT_VALUE
|
|
||||||
)
|
|
||||||
if (service != null)
|
if (service != null)
|
||||||
try {
|
try {
|
||||||
service.send(p)
|
service.send(p)
|
||||||
|
@ -69,6 +66,7 @@ class MessagesState(private val ui: UIViewModel) : Logging {
|
||||||
else
|
else
|
||||||
p.errorMessage = "Error: No Mesh service"
|
p.errorMessage = "Error: No Mesh service"
|
||||||
|
|
||||||
|
// FIXME - why is the first time we are called p is already in the list at this point?
|
||||||
addMessage(p)
|
addMessage(p)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1228,7 +1228,8 @@ class MeshService : Service(), Logging {
|
||||||
currentPacketId.toLong() and 0xffffffffL,
|
currentPacketId.toLong() and 0xffffffffL,
|
||||||
if (nodeNumBits == 0) 8 else nodeNumBits,
|
if (nodeNumBits == 0) 8 else nodeNumBits,
|
||||||
if (packetIdBits == 0) 8 else packetIdBits,
|
if (packetIdBits == 0) 8 else packetIdBits,
|
||||||
if (messageTimeoutMsec == 0) 5 * 60 * 1000 else messageTimeoutMsec // constants from current device code
|
if (messageTimeoutMsec == 0) 5 * 60 * 1000 else messageTimeoutMsec, // constants from current device code
|
||||||
|
minAppVersion
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1543,8 +1544,6 @@ class MeshService : Service(), Logging {
|
||||||
"num_data_sent",
|
"num_data_sent",
|
||||||
DataPair(1)
|
DataPair(1)
|
||||||
)
|
)
|
||||||
|
|
||||||
connectionState == ConnectionState.CONNECTED
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit e9c7f9b95d490aea3f0f213d4666d2dbf7e2111c
|
Subproject commit 9d083d5d4ff4ef095135b18468004eaba77cb691
|
|
@ -59,4 +59,6 @@
|
||||||
<string name="not_connected">Not connected, select radio below</string>
|
<string name="not_connected">Not connected, select radio below</string>
|
||||||
<string name="connected_sleeping">Connected to radio, but it is sleeping</string>
|
<string name="connected_sleeping">Connected to radio, but it is sleeping</string>
|
||||||
<string name="update_to">Update to %s</string>
|
<string name="update_to">Update to %s</string>
|
||||||
|
<string name="app_too_old">Application too old</string>
|
||||||
|
<string name="must_update">You must update this application on the Google Play store (or Github). It is too old to talk to this radio.</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit a7b2f95341876ae96525c9cd38fa2fa0cc833351
|
Subproject commit 62172dbfa2d85a389f6edaea6b416663e8bf4d2c
|
Plik binarny nie jest wyświetlany.
Po Szerokość: | Wysokość: | Rozmiar: 42 KiB |
Ładowanie…
Reference in New Issue