This commit is contained in:
Milos Kozak 2022-04-23 15:46:32 +02:00
parent aedd3ced33
commit 76124ec11e

View file

@ -209,7 +209,10 @@ class DataHandlerWear @Inject constructor(
cancelIntent.action = DataLayerListenerServiceWear.INTENT_CANCEL_BOLUS cancelIntent.action = DataLayerListenerServiceWear.INTENT_CANCEL_BOLUS
val cancelPendingIntent = PendingIntent.getService(context, 0, cancelIntent, PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT) val cancelPendingIntent = PendingIntent.getService(context, 0, cancelIntent, PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT)
val notificationBuilder: NotificationCompat.Builder = val notificationBuilder: NotificationCompat.Builder =
NotificationCompat.Builder(context, if (vibrate) DataLayerListenerServiceWear.AAPS_NOTIFY_CHANNEL_ID_BOLUS_PROGRESS else DataLayerListenerServiceWear.AAPS_NOTIFY_CHANNEL_ID_BOLUS_PROGRESS_SILENT) NotificationCompat.Builder(
context,
if (vibrate) DataLayerListenerServiceWear.AAPS_NOTIFY_CHANNEL_ID_BOLUS_PROGRESS else DataLayerListenerServiceWear.AAPS_NOTIFY_CHANNEL_ID_BOLUS_PROGRESS_SILENT
)
.setSmallIcon(R.drawable.ic_icon) .setSmallIcon(R.drawable.ic_icon)
.setContentTitle(context.getString(R.string.bolus_progress)) .setContentTitle(context.getString(R.string.bolus_progress))
.setContentText("${bolusProgress.percent}% - ${bolusProgress.status}") .setContentText("${bolusProgress.percent}% - ${bolusProgress.status}")
@ -265,15 +268,15 @@ class DataHandlerWear @Inject constructor(
// Register the channel with the system; you can't change the importance // Register the channel with the system; you can't change the importance
// or other notification behaviors after this // or other notification behaviors after this
val notificationManager = context.getSystemService(NotificationManager::class.java) context.getSystemService(NotificationManager::class.java).createNotificationChannel(channel)
notificationManager.createNotificationChannel(channel)
} }
@Suppress("DEPRECATION")
var builder = NotificationCompat.Builder(context, DataLayerListenerServiceWear.AAPS_NOTIFY_CHANNEL_ID_OPEN_LOOP) var builder = NotificationCompat.Builder(context, DataLayerListenerServiceWear.AAPS_NOTIFY_CHANNEL_ID_OPEN_LOOP)
builder = builder.setSmallIcon(R.drawable.notif_icon) .setSmallIcon(R.drawable.notif_icon)
.setContentTitle(command.title) .setContentTitle(command.title)
.setContentText(command.message) .setContentText(command.message)
.setPriority(Notification.PRIORITY_HIGH)
.setVibrate(longArrayOf(1000, 1000, 1000, 1000, 1000)) .setVibrate(longArrayOf(1000, 1000, 1000, 1000, 1000))
.setPriority(Notification.PRIORITY_HIGH) // suppress deprecation, ignored for API >= 26
// Creates an explicit intent for an Activity in your app // Creates an explicit intent for an Activity in your app
val intent = Intent(context, AcceptActivity::class.java).apply { val intent = Intent(context, AcceptActivity::class.java).apply {