From 03c25722b216b5a337a8d00d1a69d930b64f2300 Mon Sep 17 00:00:00 2001 From: Davis Mosenkovs Date: Tue, 10 Oct 2023 00:32:36 +0300 Subject: [PATCH] Improve Telegram notifications * Display Telegram private chat notifications * Display Telegram call notifications --- .../externalevents/NotificationListener.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/NotificationListener.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/NotificationListener.java index 32651e829..56f0197c1 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/NotificationListener.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/NotificationListener.java @@ -318,7 +318,7 @@ public class NotificationListener extends NotificationListenerService { if (NotificationCompat.CATEGORY_CALL.equals(sbn.getNotification().category) && prefs.getBoolean("notification_support_voip_calls", false) - && sbn.isOngoing()) { + && (sbn.isOngoing() || shouldDisplayNonOngoingCallNotification(sbn))) { handleCallNotification(sbn); return; } @@ -910,6 +910,17 @@ public class NotificationListener extends NotificationListenerService { return !sbn.getUser().equals(currentUser); } + private boolean shouldDisplayNonOngoingCallNotification(StatusBarNotification sbn) { + String source = sbn.getPackageName(); + NotificationType type = AppNotificationType.getInstance().get(source); + + if (type == NotificationType.TELEGRAM) { + return true; + } + + return false; + } + private boolean shouldIgnoreNotification(StatusBarNotification sbn, boolean remove) { Notification notification = sbn.getNotification(); String source = sbn.getPackageName(); @@ -919,6 +930,7 @@ public class NotificationListener extends NotificationListenerService { //some Apps always mark their notifcations as read-only if (NotificationCompat.getLocalOnly(notification) && type != NotificationType.WECHAT && + type != NotificationType.TELEGRAM && type != NotificationType.OUTLOOK && type != NotificationType.SKYPE) { //see https://github.com/Freeyourgadget/Gadgetbridge/issues/1109 LOG.info("Ignoring notification, local only");