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

Improve Telegram notifications

* Display Telegram private chat notifications
* Display Telegram call notifications
This commit is contained in:
Davis Mosenkovs 2023-10-10 00:32:36 +03:00
parent c4bc43d918
commit 03c25722b2

View File

@ -318,7 +318,7 @@ public class NotificationListener extends NotificationListenerService {
if (NotificationCompat.CATEGORY_CALL.equals(sbn.getNotification().category) if (NotificationCompat.CATEGORY_CALL.equals(sbn.getNotification().category)
&& prefs.getBoolean("notification_support_voip_calls", false) && prefs.getBoolean("notification_support_voip_calls", false)
&& sbn.isOngoing()) { && (sbn.isOngoing() || shouldDisplayNonOngoingCallNotification(sbn))) {
handleCallNotification(sbn); handleCallNotification(sbn);
return; return;
} }
@ -910,6 +910,17 @@ public class NotificationListener extends NotificationListenerService {
return !sbn.getUser().equals(currentUser); 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) { private boolean shouldIgnoreNotification(StatusBarNotification sbn, boolean remove) {
Notification notification = sbn.getNotification(); Notification notification = sbn.getNotification();
String source = sbn.getPackageName(); String source = sbn.getPackageName();
@ -919,6 +930,7 @@ public class NotificationListener extends NotificationListenerService {
//some Apps always mark their notifcations as read-only //some Apps always mark their notifcations as read-only
if (NotificationCompat.getLocalOnly(notification) && if (NotificationCompat.getLocalOnly(notification) &&
type != NotificationType.WECHAT && type != NotificationType.WECHAT &&
type != NotificationType.TELEGRAM &&
type != NotificationType.OUTLOOK && type != NotificationType.OUTLOOK &&
type != NotificationType.SKYPE) { //see https://github.com/Freeyourgadget/Gadgetbridge/issues/1109 type != NotificationType.SKYPE) { //see https://github.com/Freeyourgadget/Gadgetbridge/issues/1109
LOG.info("Ignoring notification, local only"); LOG.info("Ignoring notification, local only");