From 9cb9e93dd25f38fd273195f09c31f73e1eb5fc30 Mon Sep 17 00:00:00 2001 From: Kevin Hester Date: Sat, 6 Feb 2021 09:29:11 +0800 Subject: [PATCH 1/7] never use app specific icons when <= android 5.1.1 --- .../mesh/service/MeshServiceNotifications.kt | 29 ++++++++++++------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/com/geeksville/mesh/service/MeshServiceNotifications.kt b/app/src/main/java/com/geeksville/mesh/service/MeshServiceNotifications.kt index 1217c469..67b4903a 100644 --- a/app/src/main/java/com/geeksville/mesh/service/MeshServiceNotifications.kt +++ b/app/src/main/java/com/geeksville/mesh/service/MeshServiceNotifications.kt @@ -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) From 9c15e22b8fe2dd372bfa579fb6b200811ef28f86 Mon Sep 17 00:00:00 2001 From: Kevin Hester Date: Sat, 6 Feb 2021 09:49:03 +0800 Subject: [PATCH 2/7] don't let report bug get too wide (especially for Russian) --- app/src/main/res/layout/settings_fragment.xml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/src/main/res/layout/settings_fragment.xml b/app/src/main/res/layout/settings_fragment.xml index b15dc757..2d14ef46 100644 --- a/app/src/main/res/layout/settings_fragment.xml +++ b/app/src/main/res/layout/settings_fragment.xml @@ -88,6 +88,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" @@ -100,13 +101,15 @@