kopia lustrzana https://github.com/meshtastic/Meshtastic-Android
use encodeToByteArray / decodeToString methods
rodzic
e816b03f47
commit
5c3595931f
|
@ -4,8 +4,6 @@ import android.os.Parcel
|
|||
import android.os.Parcelable
|
||||
import kotlinx.parcelize.Parcelize
|
||||
import kotlinx.serialization.Serializable
|
||||
import java.nio.charset.Charset
|
||||
|
||||
|
||||
@Parcelize
|
||||
enum class MessageStatus : Parcelable {
|
||||
|
@ -43,7 +41,7 @@ data class DataPacket(
|
|||
*/
|
||||
constructor(to: String?, channel: Int, text: String) : this(
|
||||
to = to,
|
||||
bytes = text.toByteArray(utf8),
|
||||
bytes = text.encodeToByteArray(),
|
||||
dataType = Portnums.PortNum.TEXT_MESSAGE_APP_VALUE,
|
||||
channel = channel
|
||||
)
|
||||
|
@ -53,7 +51,7 @@ data class DataPacket(
|
|||
*/
|
||||
val text: String?
|
||||
get() = if (dataType == Portnums.PortNum.TEXT_MESSAGE_APP_VALUE)
|
||||
bytes?.toString(utf8)
|
||||
bytes?.decodeToString()
|
||||
else
|
||||
null
|
||||
|
||||
|
@ -159,7 +157,5 @@ data class DataPacket(
|
|||
override fun newArray(size: Int): Array<DataPacket?> {
|
||||
return arrayOfNulls(size)
|
||||
}
|
||||
|
||||
val utf8: Charset = Charset.forName("UTF-8")
|
||||
}
|
||||
}
|
|
@ -52,7 +52,6 @@ import kotlinx.coroutines.CoroutineScope
|
|||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.cancel
|
||||
import java.nio.charset.Charset
|
||||
import java.text.DateFormat
|
||||
import java.util.Date
|
||||
import javax.inject.Inject
|
||||
|
@ -106,8 +105,6 @@ eventually:
|
|||
make a custom theme: https://github.com/material-components/material-components-android/tree/master/material-theme-builder
|
||||
*/
|
||||
|
||||
val utf8: Charset = Charset.forName("UTF-8")
|
||||
|
||||
@AndroidEntryPoint
|
||||
class MainActivity : BaseActivity(), Logging {
|
||||
|
||||
|
|
|
@ -211,7 +211,7 @@ class MeshService : Service(), Logging {
|
|||
|
||||
private fun updateMessageNotification(message: DataPacket) =
|
||||
serviceNotifications.updateMessageNotification(
|
||||
getSenderName(message), message.bytes!!.toString(utf8)
|
||||
getSenderName(message), message.bytes!!.decodeToString()
|
||||
)
|
||||
|
||||
/**
|
||||
|
|
Ładowanie…
Reference in New Issue