1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-10 12:09:27 +01:00

Adds a specific Notifications Channel to Connection Status Notifications

This commit is contained in:
Roberto P. Rubio 2023-12-26 05:46:24 +01:00 committed by José Rebelo
parent fa6489b300
commit 6cc57a15f5
2 changed files with 10 additions and 2 deletions

View File

@ -68,6 +68,7 @@ import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_REC
public class GB {
public static final String NOTIFICATION_CHANNEL_ID = "gadgetbridge";
public static final String NOTIFICATION_CHANNEL_ID_CONNECTION_STATUS = "gadgetbridge connection status";
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";
@ -115,6 +116,12 @@ public class GB {
NotificationManager.IMPORTANCE_LOW);
notificationManager.createNotificationChannel(channelGeneral);
NotificationChannel channelConnwectionStatus = new NotificationChannel(
NOTIFICATION_CHANNEL_ID_CONNECTION_STATUS,
context.getString(R.string.notification_channel_connection_status_name),
NotificationManager.IMPORTANCE_LOW);
notificationManager.createNotificationChannel(channelConnwectionStatus);
NotificationChannel channelHighPriority = new NotificationChannel(
NOTIFICATION_CHANNEL_HIGH_PRIORITY_ID,
context.getString(R.string.notification_channel_high_priority_name),
@ -154,7 +161,7 @@ public class GB {
}
public static Notification createNotification(List<GBDevice> devices, Context context) {
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, NOTIFICATION_CHANNEL_ID);
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, NOTIFICATION_CHANNEL_ID_CONNECTION_STATUS);
if(devices.size() == 0){
builder.setContentTitle(context.getString(R.string.info_no_devices_connected))
.setSmallIcon(R.drawable.ic_notification_disconnected)
@ -258,7 +265,7 @@ public class GB {
}
public static Notification createNotification(String text, Context context) {
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, NOTIFICATION_CHANNEL_ID);
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, NOTIFICATION_CHANNEL_ID_CONNECTION_STATUS);
builder.setTicker(text)
.setContentText(text)
.setSmallIcon(R.drawable.ic_notification_disconnected)

View File

@ -2494,4 +2494,5 @@
<string name="pref_summary_fossil_hr_nav_foreground">Whether the navigation app should automatically come to the foreground when it receives a navigation instruction</string>
<string name="pref_title_fossil_hr_nav_vibrate">Vibrate on new instruction</string>
<string name="pref_summary_fossil_hr_nav_vibrate">Whether the watch should vibrate on every new or changed navigation instruction (only when the app is in the foreground)</string>
<string name="notification_channel_connection_status_name">Connection Status</string>
</resources>