kopia lustrzana https://github.com/meshtastic/Meshtastic-Android
commit
be738787f0
|
@ -31,8 +31,8 @@ android {
|
||||||
applicationId "com.geeksville.mesh"
|
applicationId "com.geeksville.mesh"
|
||||||
minSdkVersion 21 // The oldest emulator image I have tried is 22 (though 21 probably works)
|
minSdkVersion 21 // The oldest emulator image I have tried is 22 (though 21 probably works)
|
||||||
targetSdkVersion 29
|
targetSdkVersion 29
|
||||||
versionCode 20142 // format is Mmmss (where M is 1+the numeric major number
|
versionCode 20143 // format is Mmmss (where M is 1+the numeric major number
|
||||||
versionName "1.1.42"
|
versionName "1.1.43"
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
|
||||||
// per https://developer.android.com/studio/write/vector-asset-studio
|
// per https://developer.android.com/studio/write/vector-asset-studio
|
||||||
|
|
|
@ -805,8 +805,9 @@ class MainActivity : AppCompatActivity(), Logging,
|
||||||
registerMeshReceiver()
|
registerMeshReceiver()
|
||||||
|
|
||||||
// Init our messages table with the service's record of past text messages (ignore all other message types)
|
// Init our messages table with the service's record of past text messages (ignore all other message types)
|
||||||
|
val allMsgs = service.oldMessages
|
||||||
val msgs =
|
val msgs =
|
||||||
service.oldMessages.filter { p -> p.dataType == Portnums.PortNum.TEXT_MESSAGE_APP_VALUE }
|
allMsgs.filter { p -> p.dataType == Portnums.PortNum.TEXT_MESSAGE_APP_VALUE }
|
||||||
debug("Service provided ${msgs.size} messages and myNodeNum ${service.myNodeInfo?.myNodeNum}")
|
debug("Service provided ${msgs.size} messages and myNodeNum ${service.myNodeInfo?.myNodeNum}")
|
||||||
model.myNodeInfo.value = service.myNodeInfo
|
model.myNodeInfo.value = service.myNodeInfo
|
||||||
model.messagesState.setMessages(msgs)
|
model.messagesState.setMessages(msgs)
|
||||||
|
|
|
@ -596,17 +596,21 @@ class MeshService : Service(), Logging {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun rememberDataPacket(dataPacket: DataPacket) {
|
private fun rememberDataPacket(dataPacket: DataPacket) {
|
||||||
// discard old messages if needed then add the new one
|
// Now that we use data packets for more things, we need to be choosier about what we keep. Since (currently - in the future less so)
|
||||||
while (recentDataPackets.size > 50)
|
// we only care about old text messages, we just store those...
|
||||||
recentDataPackets.removeAt(0)
|
if(dataPacket.dataType == Portnums.PortNum.TEXT_MESSAGE_APP_VALUE) {
|
||||||
|
// discard old messages if needed then add the new one
|
||||||
|
while (recentDataPackets.size > 50)
|
||||||
|
recentDataPackets.removeAt(0)
|
||||||
|
|
||||||
// FIXME - possible kotlin bug in 1.3.72 - it seems that if we start with the (globally shared) emptyList,
|
// FIXME - possible kotlin bug in 1.3.72 - it seems that if we start with the (globally shared) emptyList,
|
||||||
// then adding items are affecting that shared list rather than a copy. This was causing aliasing of
|
// then adding items are affecting that shared list rather than a copy. This was causing aliasing of
|
||||||
// recentDataPackets with messages.value in the GUI. So if the current list is empty we are careful to make a new list
|
// recentDataPackets with messages.value in the GUI. So if the current list is empty we are careful to make a new list
|
||||||
if (recentDataPackets.isEmpty())
|
if (recentDataPackets.isEmpty())
|
||||||
recentDataPackets = mutableListOf(dataPacket)
|
recentDataPackets = mutableListOf(dataPacket)
|
||||||
else
|
else
|
||||||
recentDataPackets.add(dataPacket)
|
recentDataPackets.add(dataPacket)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Update our model and resend as needed for a MeshPacket we just received from the radio
|
/// Update our model and resend as needed for a MeshPacket we just received from the radio
|
||||||
|
|
|
@ -7,7 +7,6 @@ import android.app.PendingIntent
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
import android.graphics.BitmapFactory
|
|
||||||
import android.graphics.Canvas
|
import android.graphics.Canvas
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
|
@ -25,8 +24,7 @@ import java.io.Closeable
|
||||||
|
|
||||||
class MeshServiceNotifications(
|
class MeshServiceNotifications(
|
||||||
private val context: Context
|
private val context: Context
|
||||||
) : Closeable
|
) : Closeable {
|
||||||
{
|
|
||||||
private val notificationManager: NotificationManager get() = context.notificationManager
|
private val notificationManager: NotificationManager get() = context.notificationManager
|
||||||
val notifyId = 101
|
val notifyId = 101
|
||||||
private var largeIcon: Bitmap? = null
|
private var largeIcon: Bitmap? = null
|
||||||
|
@ -101,20 +99,31 @@ class MeshServiceNotifications(
|
||||||
summaryString: String,
|
summaryString: String,
|
||||||
senderName: String
|
senderName: String
|
||||||
): Notification {
|
): Notification {
|
||||||
// We delay making this bitmap until we know we need it
|
val category =
|
||||||
if(largeIcon == null)
|
if (recentReceivedText != null) Notification.CATEGORY_SERVICE else Notification.CATEGORY_MESSAGE
|
||||||
largeIcon = getBitmapFromVectorDrawable(R.mipmap.ic_launcher2)
|
|
||||||
|
|
||||||
val category = if (recentReceivedText != null) Notification.CATEGORY_SERVICE else Notification.CATEGORY_MESSAGE
|
|
||||||
val builder = NotificationCompat.Builder(context, channelId).setOngoing(true)
|
val builder = NotificationCompat.Builder(context, channelId).setOngoing(true)
|
||||||
.setPriority(NotificationCompat.PRIORITY_MIN)
|
.setPriority(NotificationCompat.PRIORITY_MIN)
|
||||||
.setCategory(category)
|
.setCategory(category)
|
||||||
.setSmallIcon(if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) R.drawable.app_icon_novect else R.drawable.app_icon) // vector form icons don't work reliably on older androids
|
|
||||||
.setLargeIcon(largeIcon) // we must include a large icon because of a bug in cyanogenmod https://github.com/open-keychain/open-keychain/issues/1356#issue-89493995
|
|
||||||
.setContentTitle(summaryString) // leave this off for now so our notification looks smaller
|
.setContentTitle(summaryString) // leave this off for now so our notification looks smaller
|
||||||
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
|
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
|
||||||
.setContentIntent(openAppIntent)
|
.setContentIntent(openAppIntent)
|
||||||
|
|
||||||
|
// Set the notification icon
|
||||||
|
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP_MR1) {
|
||||||
|
// If running on really old versions of android (<= 5.1.1) (possibly only cyanogen) we might encounter a bug with setting application specific icons
|
||||||
|
// so punt and stay with just the bluetooth icon - see https://meshtastic.discourse.group/t/android-1-1-42-ready-for-alpha-testing/2399/3?u=geeksville
|
||||||
|
builder.setSmallIcon(android.R.drawable.stat_sys_data_bluetooth)
|
||||||
|
} else {
|
||||||
|
// Newer androids also support a 'large' icon
|
||||||
|
|
||||||
|
// We delay making this bitmap until we know we need it
|
||||||
|
if (largeIcon == null)
|
||||||
|
largeIcon = getBitmapFromVectorDrawable(R.mipmap.ic_launcher2)
|
||||||
|
|
||||||
|
builder.setSmallIcon(if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) R.drawable.app_icon_novect else R.drawable.app_icon) // vector form icons don't work reliably on older androids
|
||||||
|
.setLargeIcon(largeIcon)
|
||||||
|
}
|
||||||
|
|
||||||
// FIXME, show information about the nearest node
|
// FIXME, show information about the nearest node
|
||||||
// if(shortContent != null) builder.setContentText(shortContent)
|
// if(shortContent != null) builder.setContentText(shortContent)
|
||||||
|
|
||||||
|
|
|
@ -574,6 +574,10 @@ class SettingsFragment : ScreenFragment("Settings"), Logging {
|
||||||
|
|
||||||
/// Setup the ui widgets unrelated to BLE scanning
|
/// Setup the ui widgets unrelated to BLE scanning
|
||||||
private fun initCommonUI() {
|
private fun initCommonUI() {
|
||||||
|
// We want to leave these visible in the IDE, but make sure they default to not visible until we have valid data
|
||||||
|
binding.positionBroadcastPeriodView.visibility = View.GONE
|
||||||
|
binding.lsSleepView.visibility = View.GONE
|
||||||
|
|
||||||
model.ownerName.observe(viewLifecycleOwner, { name ->
|
model.ownerName.observe(viewLifecycleOwner, { name ->
|
||||||
binding.usernameEditText.setText(name)
|
binding.usernameEditText.setText(name)
|
||||||
})
|
})
|
||||||
|
@ -587,8 +591,10 @@ class SettingsFragment : ScreenFragment("Settings"), Logging {
|
||||||
model.isConnected.observe(viewLifecycleOwner, Observer { connectionState ->
|
model.isConnected.observe(viewLifecycleOwner, Observer { connectionState ->
|
||||||
val connected = connectionState == MeshService.ConnectionState.CONNECTED
|
val connected = connectionState == MeshService.ConnectionState.CONNECTED
|
||||||
binding.usernameView.isEnabled = connected
|
binding.usernameView.isEnabled = connected
|
||||||
binding.positionBroadcastPeriodView.isEnabled = connected
|
|
||||||
binding.lsSleepView.isEnabled = connected
|
// Don't even show advanced fields until after we have a connection
|
||||||
|
binding.positionBroadcastPeriodView.visibility = if (connected) View.VISIBLE else View.GONE
|
||||||
|
binding.lsSleepView.visibility = if (connected) View.VISIBLE else View.GONE
|
||||||
|
|
||||||
if (connectionState == MeshService.ConnectionState.DISCONNECTED)
|
if (connectionState == MeshService.ConnectionState.DISCONNECTED)
|
||||||
model.ownerName.value = ""
|
model.ownerName.value = ""
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit dfe7bc1217a00c23eecb9dfcf1d56fe95ebddc3b
|
Subproject commit 106f4bfdebe277ab0b86d2b8c950ab78a35b0654
|
|
@ -91,6 +91,7 @@
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="8dp"
|
android:layout_marginStart="8dp"
|
||||||
|
android:layout_marginEnd="8dp"
|
||||||
android:layout_marginBottom="8dp"
|
android:layout_marginBottom="8dp"
|
||||||
android:background="@color/cardview_light_background"
|
android:background="@color/cardview_light_background"
|
||||||
android:checked="true"
|
android:checked="true"
|
||||||
|
@ -103,13 +104,15 @@
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/reportBugButton"
|
android:id="@+id/reportBugButton"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginEnd="8dp"
|
android:layout_marginEnd="8dp"
|
||||||
android:layout_marginBottom="8dp"
|
android:layout_marginBottom="8dp"
|
||||||
android:text="@string/report_bug"
|
android:text="@string/report_bug"
|
||||||
|
app:layout_constrainedWidth="true"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent" />
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintWidth_percent="0.4" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/changeRadioButton"
|
android:id="@+id/changeRadioButton"
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit d7c3fa8ab6a47169e5dc8761d03d24588c3dd845
|
Subproject commit e398a075921fbe051a22463c3052abdd802c3535
|
Ładowanie…
Reference in New Issue