kopia lustrzana https://github.com/meshtastic/Meshtastic-Android
add warning text for downrev apps
rodzic
d33defb502
commit
ae402e8fd2
|
@ -20,10 +20,14 @@ import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
import android.os.RemoteException
|
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.Menu
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import android.view.MotionEvent
|
import android.view.MotionEvent
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
import android.widget.TextView
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.activity.viewModels
|
import androidx.activity.viewModels
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
@ -64,6 +68,7 @@ import java.nio.charset.Charset
|
||||||
import java.text.DateFormat
|
import java.text.DateFormat
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
UI design
|
UI design
|
||||||
|
|
||||||
|
@ -619,26 +624,38 @@ class MainActivity : AppCompatActivity(), Logging,
|
||||||
|
|
||||||
debug("Getting latest radioconfig from service")
|
debug("Getting latest radioconfig from service")
|
||||||
try {
|
try {
|
||||||
model.radioConfig.value =
|
|
||||||
MeshProtos.RadioConfig.parseFrom(service.radioConfig)
|
|
||||||
|
|
||||||
val info = service.myNodeInfo
|
val info = service.myNodeInfo
|
||||||
model.myNodeInfo.value = info
|
model.myNodeInfo.value = info
|
||||||
|
|
||||||
val isOld = info.minAppVersion > BuildConfig.VERSION_CODE
|
val isOld = info.minAppVersion > BuildConfig.VERSION_CODE
|
||||||
if (isOld)
|
if (isOld) {
|
||||||
MaterialAlertDialogBuilder(this)
|
// 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))
|
.setTitle(getString(R.string.app_too_old))
|
||||||
.setMessage(getString(R.string.must_update))
|
.setMessage(messageStr)
|
||||||
.setPositiveButton("Okay") { _, _ ->
|
.setPositiveButton("Okay") { _, _ ->
|
||||||
info("User acknowledged app is old")
|
info("User acknowledged app is old")
|
||||||
}
|
}
|
||||||
.show()
|
|
||||||
|
|
||||||
updateNodesFromDevice()
|
val dialog = builder.show()
|
||||||
|
|
||||||
// we have a connection to our device now, do the channel change
|
// Make the textview clickable. Must be called after show()
|
||||||
perhapsChangeChannel()
|
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) {
|
} catch (ex: RemoteException) {
|
||||||
warn("Abandoning connect $ex, because we probably just lost device connection")
|
warn("Abandoning connect $ex, because we probably just lost device connection")
|
||||||
model.isConnected.value = oldConnection
|
model.isConnected.value = oldConnection
|
||||||
|
@ -931,7 +948,8 @@ class MainActivity : AppCompatActivity(), Logging,
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPrepareOptionsMenu(menu: Menu): Boolean {
|
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)
|
return super.onPrepareOptionsMenu(menu)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -972,7 +990,7 @@ class MainActivity : AppCompatActivity(), Logging,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
item.isChecked = !item.isChecked // toggle ping test
|
item.isChecked = !item.isChecked // toggle ping test
|
||||||
if(item.isChecked)
|
if (item.isChecked)
|
||||||
postPing()
|
postPing()
|
||||||
else
|
else
|
||||||
handler.removeCallbacksAndMessages(null)
|
handler.removeCallbacksAndMessages(null)
|
||||||
|
|
|
@ -73,6 +73,9 @@ class MeshService : Service(), Logging {
|
||||||
class NodeNumNotFoundException(id: Int) : NodeNotFoundException("NodeNum not found $id")
|
class NodeNumNotFoundException(id: Int) : NodeNotFoundException("NodeNum not found $id")
|
||||||
class IdNotFoundException(id: String) : NodeNotFoundException("ID 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 */
|
/** 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() :
|
class IsUpdatingException() :
|
||||||
RadioNotConnectedException("Operation prohibited during firmware update")
|
RadioNotConnectedException("Operation prohibited during firmware update")
|
||||||
|
@ -1589,7 +1592,7 @@ class MeshService : Service(), Logging {
|
||||||
|
|
||||||
override fun getRadioConfig(): ByteArray = toRemoteExceptions {
|
override fun getRadioConfig(): ByteArray = toRemoteExceptions {
|
||||||
this@MeshService.radioConfig?.toByteArray()
|
this@MeshService.radioConfig?.toByteArray()
|
||||||
?: throw RadioNotConnectedException()
|
?: throw NoRadioConfigException()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setRadioConfig(payload: ByteArray) = toRemoteExceptions {
|
override fun setRadioConfig(payload: ByteArray) = toRemoteExceptions {
|
||||||
|
|
|
@ -26,6 +26,7 @@ open class RadioNotConnectedException(message: String = "Not connected to radio"
|
||||||
BLEException(message)
|
BLEException(message)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles the bluetooth link with a mesh radio device. Does not cache any device state,
|
* Handles the bluetooth link with a mesh radio device. Does not cache any device state,
|
||||||
* just does bluetooth comms etc...
|
* just does bluetooth comms etc...
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit b1aed06442025624841b2288fac273d9bc41c438
|
Subproject commit 512d1aca0a066107de749c0c47397c7f9bf9cb99
|
|
@ -60,8 +60,8 @@
|
||||||
<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="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.</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="none">None (disable)</string>
|
||||||
<string name="modem_config_short">Short range (but fast)</string>
|
<string name="modem_config_short">Short range (but fast)</string>
|
||||||
<string name="modem_config_medium">Medium range (but fast)</string>
|
<string name="modem_config_medium">Medium range (but fast)</string>
|
||||||
|
|
Ładowanie…
Reference in New Issue