From 436e5b5c7002cfa5653aaf85fb8d2e6a3eb75d19 Mon Sep 17 00:00:00 2001 From: Dmitriy Bogdanov Date: Fri, 14 May 2021 21:03:22 +0400 Subject: [PATCH] Add a separate "low battery" notification channel --- .../nodomain/freeyourgadget/gadgetbridge/util/GB.java | 9 ++++++++- app/src/main/res/values/strings.xml | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/GB.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/GB.java index f13897e9f..418d4a98b 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/GB.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/GB.java @@ -64,6 +64,7 @@ public class GB { public static final String NOTIFICATION_CHANNEL_ID = "gadgetbridge"; public static final String NOTIFICATION_CHANNEL_HIGH_PRIORITY_ID = "gadgetbridge_high_priority"; public static final String NOTIFICATION_CHANNEL_ID_TRANSFER = "gadgetbridge transfer"; + public static final String NOTIFICATION_CHANNEL_ID_LOW_BATTERY = "low_battery"; public static final int NOTIFICATION_ID = 1; public static final int NOTIFICATION_ID_INSTALL = 2; @@ -115,6 +116,12 @@ public class GB { context.getString(R.string.notification_channel_transfer_name), NotificationManager.IMPORTANCE_LOW); notificationManager.createNotificationChannel(channelTransfer); + + NotificationChannel channelLowBattery = new NotificationChannel( + NOTIFICATION_CHANNEL_ID_LOW_BATTERY, + context.getString(R.string.notification_channel_low_battery_name), + NotificationManager.IMPORTANCE_DEFAULT); + notificationManager.createNotificationChannel(channelLowBattery); } notificationChannelsCreated = true; @@ -462,7 +469,7 @@ public class GB { PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0); - NotificationCompat.Builder nb = new NotificationCompat.Builder(context, NOTIFICATION_CHANNEL_ID) + NotificationCompat.Builder nb = new NotificationCompat.Builder(context, NOTIFICATION_CHANNEL_ID_LOW_BATTERY) .setContentTitle(context.getString(R.string.notif_battery_low_title)) .setContentText(text) .setContentIntent(pendingIntent) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 1d79c9569..edc3bc7c4 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -870,6 +870,7 @@ General High-priority Data transfer + Low battery Amazfit GTS Amazfit Verge Lite Lemfo SG2