Merge pull request #234 from geeksville/dev

kevin misc fixes
1.2-legacy
Kevin Hester 2021-02-07 13:26:26 +08:00 zatwierdzone przez GitHub
commit be738787f0
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
8 zmienionych plików z 52 dodań i 29 usunięć

Wyświetl plik

@ -31,8 +31,8 @@ android {
applicationId "com.geeksville.mesh"
minSdkVersion 21 // The oldest emulator image I have tried is 22 (though 21 probably works)
targetSdkVersion 29
versionCode 20142 // format is Mmmss (where M is 1+the numeric major number
versionName "1.1.42"
versionCode 20143 // format is Mmmss (where M is 1+the numeric major number
versionName "1.1.43"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
// per https://developer.android.com/studio/write/vector-asset-studio

Wyświetl plik

@ -805,8 +805,9 @@ class MainActivity : AppCompatActivity(), Logging,
registerMeshReceiver()
// Init our messages table with the service's record of past text messages (ignore all other message types)
val allMsgs = service.oldMessages
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}")
model.myNodeInfo.value = service.myNodeInfo
model.messagesState.setMessages(msgs)

Wyświetl plik

@ -596,17 +596,21 @@ class MeshService : Service(), Logging {
}
private fun rememberDataPacket(dataPacket: DataPacket) {
// discard old messages if needed then add the new one
while (recentDataPackets.size > 50)
recentDataPackets.removeAt(0)
// 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)
// we only care about old text messages, we just store those...
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,
// 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
if (recentDataPackets.isEmpty())
recentDataPackets = mutableListOf(dataPacket)
else
recentDataPackets.add(dataPacket)
// 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
// 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())
recentDataPackets = mutableListOf(dataPacket)
else
recentDataPackets.add(dataPacket)
}
}
/// Update our model and resend as needed for a MeshPacket we just received from the radio

Wyświetl plik

@ -7,7 +7,6 @@ import android.app.PendingIntent
import android.content.Context
import android.content.Intent
import android.graphics.Bitmap
import android.graphics.BitmapFactory
import android.graphics.Canvas
import android.graphics.Color
import android.os.Build
@ -25,8 +24,7 @@ import java.io.Closeable
class MeshServiceNotifications(
private val context: Context
) : Closeable
{
) : Closeable {
private val notificationManager: NotificationManager get() = context.notificationManager
val notifyId = 101
private var largeIcon: Bitmap? = null
@ -101,20 +99,31 @@ class MeshServiceNotifications(
summaryString: String,
senderName: String
): Notification {
// We delay making this bitmap until we know we need it
if(largeIcon == null)
largeIcon = getBitmapFromVectorDrawable(R.mipmap.ic_launcher2)
val category = if (recentReceivedText != null) Notification.CATEGORY_SERVICE else Notification.CATEGORY_MESSAGE
val category =
if (recentReceivedText != null) Notification.CATEGORY_SERVICE else Notification.CATEGORY_MESSAGE
val builder = NotificationCompat.Builder(context, channelId).setOngoing(true)
.setPriority(NotificationCompat.PRIORITY_MIN)
.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
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
.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
// if(shortContent != null) builder.setContentText(shortContent)

Wyświetl plik

@ -574,6 +574,10 @@ class SettingsFragment : ScreenFragment("Settings"), Logging {
/// Setup the ui widgets unrelated to BLE scanning
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 ->
binding.usernameEditText.setText(name)
})
@ -587,8 +591,10 @@ class SettingsFragment : ScreenFragment("Settings"), Logging {
model.isConnected.observe(viewLifecycleOwner, Observer { connectionState ->
val connected = connectionState == MeshService.ConnectionState.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)
model.ownerName.value = ""

@ -1 +1 @@
Subproject commit dfe7bc1217a00c23eecb9dfcf1d56fe95ebddc3b
Subproject commit 106f4bfdebe277ab0b86d2b8c950ab78a35b0654

Wyświetl plik

@ -91,6 +91,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:background="@color/cardview_light_background"
android:checked="true"
@ -103,13 +104,15 @@
<Button
android:id="@+id/reportBugButton"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:text="@string/report_bug"
app:layout_constrainedWidth="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintWidth_percent="0.4" />
<Button
android:id="@+id/changeRadioButton"

@ -1 +1 @@
Subproject commit d7c3fa8ab6a47169e5dc8761d03d24588c3dd845
Subproject commit e398a075921fbe051a22463c3052abdd802c3535