add warning text for downrev apps

1.2-legacy
Kevin Hester 2021-03-02 13:22:55 +08:00
rodzic d33defb502
commit ae402e8fd2
5 zmienionych plików z 38 dodań i 16 usunięć

Wyświetl plik

@ -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)

Wyświetl plik

@ -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 {

Wyświetl plik

@ -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...

@ -1 +1 @@
Subproject commit b1aed06442025624841b2288fac273d9bc41c438
Subproject commit 512d1aca0a066107de749c0c47397c7f9bf9cb99

Wyświetl plik

@ -60,8 +60,8 @@
<string name="not_connected">Not connected, select radio below</string>
<string name="connected_sleeping">Connected to radio, but it is sleeping</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>
<string name="app_too_old">Application update required</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 firmware. Please read our <a href="https://www.meshtastic.org/software/android-too-old.html">wiki</a> on this topic.</string>
<string name="none">None (disable)</string>
<string name="modem_config_short">Short range (but fast)</string>
<string name="modem_config_medium">Medium range (but fast)</string>