kopia lustrzana https://github.com/meshtastic/Meshtastic-Android
remove deprecations
rodzic
55d0110ff2
commit
dbc91e4ac5
|
@ -9,7 +9,6 @@ import kotlinx.serialization.Serializable
|
||||||
data class MyNodeInfo(
|
data class MyNodeInfo(
|
||||||
val myNodeNum: Int,
|
val myNodeNum: Int,
|
||||||
val hasGPS: Boolean,
|
val hasGPS: Boolean,
|
||||||
val region: String?,
|
|
||||||
val model: String?,
|
val model: String?,
|
||||||
val firmwareVersion: String?,
|
val firmwareVersion: String?,
|
||||||
val couldUpdate: Boolean, // this application contains a software load we _could_ install if you want
|
val couldUpdate: Boolean, // this application contains a software load we _could_ install if you want
|
||||||
|
@ -20,14 +19,13 @@ data class MyNodeInfo(
|
||||||
val maxChannels: Int
|
val maxChannels: 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 $firmwareVersion"
|
||||||
|
|
||||||
constructor(parcel: Parcel) : this(
|
constructor(parcel: Parcel) : this(
|
||||||
parcel.readInt(),
|
parcel.readInt(),
|
||||||
parcel.readByte() != 0.toByte(),
|
parcel.readByte() != 0.toByte(),
|
||||||
parcel.readString(),
|
parcel.readString(),
|
||||||
parcel.readString(),
|
parcel.readString(),
|
||||||
parcel.readString(),
|
|
||||||
parcel.readByte() != 0.toByte(),
|
parcel.readByte() != 0.toByte(),
|
||||||
parcel.readByte() != 0.toByte(),
|
parcel.readByte() != 0.toByte(),
|
||||||
parcel.readLong(),
|
parcel.readLong(),
|
||||||
|
@ -40,7 +38,6 @@ data class MyNodeInfo(
|
||||||
override fun writeToParcel(parcel: Parcel, flags: Int) {
|
override fun writeToParcel(parcel: Parcel, flags: Int) {
|
||||||
parcel.writeInt(myNodeNum)
|
parcel.writeInt(myNodeNum)
|
||||||
parcel.writeByte(if (hasGPS) 1 else 0)
|
parcel.writeByte(if (hasGPS) 1 else 0)
|
||||||
parcel.writeString(region)
|
|
||||||
parcel.writeString(model)
|
parcel.writeString(model)
|
||||||
parcel.writeString(firmwareVersion)
|
parcel.writeString(firmwareVersion)
|
||||||
parcel.writeByte(if (couldUpdate) 1 else 0)
|
parcel.writeByte(if (couldUpdate) 1 else 0)
|
||||||
|
|
|
@ -52,8 +52,8 @@ class MeshService : Service(), Logging {
|
||||||
|
|
||||||
/// Intents broadcast by MeshService
|
/// Intents broadcast by MeshService
|
||||||
|
|
||||||
@Deprecated(message = "Does not filter by port number. For legacy reasons only broadcast for UNKNOWN_APP, switch to ACTION_RECEIVED")
|
/* @Deprecated(message = "Does not filter by port number. For legacy reasons only broadcast for UNKNOWN_APP, switch to ACTION_RECEIVED")
|
||||||
const val ACTION_RECEIVED_DATA = "$prefix.RECEIVED_DATA"
|
const val ACTION_RECEIVED_DATA = "$prefix.RECEIVED_DATA" */
|
||||||
|
|
||||||
fun actionReceived(portNum: String) = "$prefix.RECEIVED.$portNum"
|
fun actionReceived(portNum: String) = "$prefix.RECEIVED.$portNum"
|
||||||
|
|
||||||
|
@ -724,6 +724,7 @@ class MeshService : Service(), Logging {
|
||||||
|
|
||||||
// Handle new style routing info
|
// Handle new style routing info
|
||||||
Portnums.PortNum.ROUTING_APP_VALUE -> {
|
Portnums.PortNum.ROUTING_APP_VALUE -> {
|
||||||
|
shouldBroadcast = true // We always send acks to other apps, because they might care about the messages they sent
|
||||||
val u = MeshProtos.Routing.parseFrom(data.payload)
|
val u = MeshProtos.Routing.parseFrom(data.payload)
|
||||||
if (u.errorReasonValue == MeshProtos.Routing.Error.NONE_VALUE)
|
if (u.errorReasonValue == MeshProtos.Routing.Error.NONE_VALUE)
|
||||||
handleAckNak(true, data.requestId)
|
handleAckNak(true, data.requestId)
|
||||||
|
@ -1231,7 +1232,6 @@ class MeshService : Service(), Logging {
|
||||||
MyNodeInfo(
|
MyNodeInfo(
|
||||||
myNodeNum,
|
myNodeNum,
|
||||||
hasGps,
|
hasGps,
|
||||||
region,
|
|
||||||
hwModel,
|
hwModel,
|
||||||
firmwareVersion,
|
firmwareVersion,
|
||||||
firmwareUpdateFilename != null,
|
firmwareUpdateFilename != null,
|
||||||
|
@ -1260,7 +1260,7 @@ class MeshService : Service(), Logging {
|
||||||
|
|
||||||
/// Track types of devices and firmware versions in use
|
/// Track types of devices and firmware versions in use
|
||||||
GeeksvilleApplication.analytics.setUserInfo(
|
GeeksvilleApplication.analytics.setUserInfo(
|
||||||
DataPair("region", mi.region),
|
// DataPair("region", mi.region),
|
||||||
DataPair("firmware", mi.firmwareVersion),
|
DataPair("firmware", mi.firmwareVersion),
|
||||||
DataPair("has_gps", mi.hasGPS),
|
DataPair("has_gps", mi.hasGPS),
|
||||||
DataPair("hw_model", mi.model),
|
DataPair("hw_model", mi.model),
|
||||||
|
@ -1275,8 +1275,8 @@ class MeshService : Service(), Logging {
|
||||||
|
|
||||||
// We also include this info, because it is required to correctly decode address from the map file
|
// We also include this info, because it is required to correctly decode address from the map file
|
||||||
DataPair("firmware", mi.firmwareVersion),
|
DataPair("firmware", mi.firmwareVersion),
|
||||||
DataPair("hw_model", mi.model),
|
DataPair("hw_model", mi.model)
|
||||||
DataPair("region", mi.region)
|
// DataPair("region", mi.region)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1301,7 +1301,8 @@ class MeshService : Service(), Logging {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (curRegionValue == RadioConfigProtos.RegionCode.Unset_VALUE) {
|
if (curRegionValue == RadioConfigProtos.RegionCode.Unset_VALUE) {
|
||||||
// look for a legacy region
|
TODO("Need gui for setting region")
|
||||||
|
/* // look for a legacy region
|
||||||
val legacyRegex = Regex(".+-(.+)")
|
val legacyRegex = Regex(".+-(.+)")
|
||||||
myNodeInfo?.region?.let { legacyRegion ->
|
myNodeInfo?.region?.let { legacyRegion ->
|
||||||
val matches = legacyRegex.find(legacyRegion)
|
val matches = legacyRegex.find(legacyRegion)
|
||||||
|
@ -1311,7 +1312,7 @@ class MeshService : Service(), Logging {
|
||||||
info("Upgrading legacy region $newRegion (code ${newRegion.number})")
|
info("Upgrading legacy region $newRegion (code ${newRegion.number})")
|
||||||
curRegionValue = newRegion.number
|
curRegionValue = newRegion.number
|
||||||
}
|
}
|
||||||
}
|
} */
|
||||||
}
|
}
|
||||||
|
|
||||||
// If nothing was set in our (new style radio preferences, but we now have a valid setting - slam it in)
|
// If nothing was set in our (new style radio preferences, but we now have a valid setting - slam it in)
|
||||||
|
|
|
@ -20,10 +20,12 @@ class MeshServiceBroadcasts(
|
||||||
|
|
||||||
explicitBroadcast(Intent(MeshService.actionReceived(payload.dataType)).putExtra(EXTRA_PAYLOAD, payload))
|
explicitBroadcast(Intent(MeshService.actionReceived(payload.dataType)).putExtra(EXTRA_PAYLOAD, payload))
|
||||||
|
|
||||||
|
/*
|
||||||
// For the time being we ALSO broadcast using old ACTION_RECEIVED_DATA field for any oldschool opaque packets
|
// For the time being we ALSO broadcast using old ACTION_RECEIVED_DATA field for any oldschool opaque packets
|
||||||
// newer packets (that have a non zero portnum) are only broadcast using the standard mechanism.
|
// newer packets (that have a non zero portnum) are only broadcast using the standard mechanism.
|
||||||
if(payload.dataType == Portnums.PortNum.UNKNOWN_APP_VALUE)
|
if(payload.dataType == Portnums.PortNum.UNKNOWN_APP_VALUE)
|
||||||
explicitBroadcast(Intent(MeshService.ACTION_RECEIVED_DATA).putExtra(EXTRA_PAYLOAD, payload))
|
explicitBroadcast(Intent(MeshService.ACTION_RECEIVED_DATA).putExtra(EXTRA_PAYLOAD, payload))
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
fun broadcastNodeChange(info: NodeInfo) {
|
fun broadcastNodeChange(info: NodeInfo) {
|
||||||
|
|
|
@ -108,7 +108,6 @@ class MockInterface(private val service: RadioInterfaceService) : Logging, IRadi
|
||||||
MeshProtos.FromRadio.newBuilder().apply {
|
MeshProtos.FromRadio.newBuilder().apply {
|
||||||
myInfo = MeshProtos.MyNodeInfo.newBuilder().apply {
|
myInfo = MeshProtos.MyNodeInfo.newBuilder().apply {
|
||||||
myNodeNum = MY_NODE
|
myNodeNum = MY_NODE
|
||||||
region = "TW"
|
|
||||||
hwModel = "Sim"
|
hwModel = "Sim"
|
||||||
messageTimeoutMsec = 5 * 60 * 1000
|
messageTimeoutMsec = 5 * 60 * 1000
|
||||||
firmwareVersion = service.getString(R.string.cur_firmware_version)
|
firmwareVersion = service.getString(R.string.cur_firmware_version)
|
||||||
|
|
|
@ -9,6 +9,7 @@ import android.widget.EditText
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.cardview.widget.CardView
|
import androidx.cardview.widget.CardView
|
||||||
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.fragment.app.activityViewModels
|
import androidx.fragment.app.activityViewModels
|
||||||
import androidx.lifecycle.Observer
|
import androidx.lifecycle.Observer
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
|
@ -151,11 +152,11 @@ class MessagesFragment : ScreenFragment("Messages"), Logging {
|
||||||
if (isMe) {
|
if (isMe) {
|
||||||
marginParams.leftMargin = messageOffset
|
marginParams.leftMargin = messageOffset
|
||||||
marginParams.rightMargin = 0
|
marginParams.rightMargin = 0
|
||||||
holder.card.setCardBackgroundColor(resources.getColor(R.color.colorMyMsg))
|
context?.let{ holder.card.setCardBackgroundColor(ContextCompat.getColor(it, R.color.colorMyMsg)) }
|
||||||
} else {
|
} else {
|
||||||
marginParams.rightMargin = messageOffset
|
marginParams.rightMargin = messageOffset
|
||||||
marginParams.leftMargin = 0
|
marginParams.leftMargin = 0
|
||||||
holder.card.setCardBackgroundColor(resources.getColor(R.color.colorMsg))
|
context?.let{ holder.card.setCardBackgroundColor(ContextCompat.getColor(it, R.color.colorMsg)) }
|
||||||
}
|
}
|
||||||
// Hide the username chip for my messages
|
// Hide the username chip for my messages
|
||||||
if (isMe) {
|
if (isMe) {
|
||||||
|
|
Ładowanie…
Reference in New Issue