mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-04 22:23:47 -04:00
add warning text for downrev apps
This commit is contained in:
@@ -20,10 +20,14 @@ import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.os.Handler
|
||||
import android.os.RemoteException
|
||||
import android.text.SpannableString
|
||||
import android.text.method.LinkMovementMethod
|
||||
import android.text.util.Linkify
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.view.MotionEvent
|
||||
import android.view.View
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import androidx.activity.viewModels
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
@@ -64,6 +68,7 @@ import java.nio.charset.Charset
|
||||
import java.text.DateFormat
|
||||
import java.util.*
|
||||
|
||||
|
||||
/*
|
||||
UI design
|
||||
|
||||
@@ -619,26 +624,38 @@ class MainActivity : AppCompatActivity(), Logging,
|
||||
|
||||
debug("Getting latest radioconfig from service")
|
||||
try {
|
||||
model.radioConfig.value =
|
||||
MeshProtos.RadioConfig.parseFrom(service.radioConfig)
|
||||
|
||||
val info = service.myNodeInfo
|
||||
model.myNodeInfo.value = info
|
||||
|
||||
val isOld = info.minAppVersion > BuildConfig.VERSION_CODE
|
||||
if (isOld)
|
||||
MaterialAlertDialogBuilder(this)
|
||||
if (isOld) {
|
||||
// make links clickable per https://stackoverflow.com/a/62642807
|
||||
val messageStr = getText(R.string.must_update)
|
||||
|
||||
val builder = MaterialAlertDialogBuilder(this)
|
||||
.setTitle(getString(R.string.app_too_old))
|
||||
.setMessage(getString(R.string.must_update))
|
||||
.setMessage(messageStr)
|
||||
.setPositiveButton("Okay") { _, _ ->
|
||||
info("User acknowledged app is old")
|
||||
}
|
||||
.show()
|
||||
|
||||
updateNodesFromDevice()
|
||||
val dialog = builder.show()
|
||||
|
||||
// we have a connection to our device now, do the channel change
|
||||
perhapsChangeChannel()
|
||||
// Make the textview clickable. Must be called after show()
|
||||
val view = (dialog.findViewById(android.R.id.message) as TextView?)!!
|
||||
// Linkify.addLinks(view, Linkify.ALL) // not needed with this method
|
||||
view.movementMethod = LinkMovementMethod.getInstance()
|
||||
} else {
|
||||
// If our app is too old, we probably don't understand the new radioconfig messages
|
||||
|
||||
model.radioConfig.value =
|
||||
MeshProtos.RadioConfig.parseFrom(service.radioConfig)
|
||||
|
||||
updateNodesFromDevice()
|
||||
|
||||
// we have a connection to our device now, do the channel change
|
||||
perhapsChangeChannel()
|
||||
}
|
||||
} catch (ex: RemoteException) {
|
||||
warn("Abandoning connect $ex, because we probably just lost device connection")
|
||||
model.isConnected.value = oldConnection
|
||||
@@ -931,7 +948,8 @@ class MainActivity : AppCompatActivity(), Logging,
|
||||
}
|
||||
|
||||
override fun onPrepareOptionsMenu(menu: Menu): Boolean {
|
||||
menu.findItem(R.id.stress_test).isVisible = BuildConfig.DEBUG // only show stress test for debug builds (for now)
|
||||
menu.findItem(R.id.stress_test).isVisible =
|
||||
BuildConfig.DEBUG // only show stress test for debug builds (for now)
|
||||
return super.onPrepareOptionsMenu(menu)
|
||||
}
|
||||
|
||||
@@ -972,7 +990,7 @@ class MainActivity : AppCompatActivity(), Logging,
|
||||
)
|
||||
}
|
||||
item.isChecked = !item.isChecked // toggle ping test
|
||||
if(item.isChecked)
|
||||
if (item.isChecked)
|
||||
postPing()
|
||||
else
|
||||
handler.removeCallbacksAndMessages(null)
|
||||
|
||||
@@ -73,6 +73,9 @@ class MeshService : Service(), Logging {
|
||||
class NodeNumNotFoundException(id: Int) : NodeNotFoundException("NodeNum not found $id")
|
||||
class IdNotFoundException(id: String) : NodeNotFoundException("ID not found $id")
|
||||
|
||||
class NoRadioConfigException(message: String = "No radio settings received (is our app too old?)") :
|
||||
RadioNotConnectedException(message)
|
||||
|
||||
/** We treat software update as similar to loss of comms to the regular bluetooth service (so things like sendPosition for background GPS ignores the problem */
|
||||
class IsUpdatingException() :
|
||||
RadioNotConnectedException("Operation prohibited during firmware update")
|
||||
@@ -1589,7 +1592,7 @@ class MeshService : Service(), Logging {
|
||||
|
||||
override fun getRadioConfig(): ByteArray = toRemoteExceptions {
|
||||
this@MeshService.radioConfig?.toByteArray()
|
||||
?: throw RadioNotConnectedException()
|
||||
?: throw NoRadioConfigException()
|
||||
}
|
||||
|
||||
override fun setRadioConfig(payload: ByteArray) = toRemoteExceptions {
|
||||
|
||||
@@ -26,6 +26,7 @@ open class RadioNotConnectedException(message: String = "Not connected to radio"
|
||||
BLEException(message)
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Handles the bluetooth link with a mesh radio device. Does not cache any device state,
|
||||
* just does bluetooth comms etc...
|
||||
|
||||
Reference in New Issue
Block a user