1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-27 20:36:51 +01:00

Add a separate "low battery" notification channel

This commit is contained in:
Dmitriy Bogdanov 2021-05-14 21:03:22 +04:00 committed by Gitea
parent b719f626c5
commit 436e5b5c70
2 changed files with 9 additions and 1 deletions

View File

@ -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)

View File

@ -870,6 +870,7 @@
<string name="notification_channel_name">General</string>
<string name="notification_channel_high_priority_name">High-priority</string>
<string name="notification_channel_transfer_name">Data transfer</string>
<string name="notification_channel_low_battery_name">Low battery</string>
<string name="devicetype_amazfit_gts">Amazfit GTS</string>
<string name="devicetype_amazfit_vergel">Amazfit Verge Lite</string>
<string name="devicetype_sg2">Lemfo SG2</string>