Add cahannel and category to notifcation

This commit is contained in:
Me7c7 2025-01-03 18:17:34 +02:00 committed by José Rebelo
parent 61831b8a9d
commit 0429c2f3c8
5 changed files with 16 additions and 1 deletions

View File

@ -35,6 +35,7 @@ import android.graphics.Color;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.media.session.MediaController; import android.media.session.MediaController;
import android.media.session.MediaSession; import android.media.session.MediaSession;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.PowerManager; import android.os.PowerManager;
@ -383,6 +384,12 @@ public class NotificationListener extends NotificationListenerService {
notificationSpec.type = AppNotificationType.getInstance().get(source); notificationSpec.type = AppNotificationType.getInstance().get(source);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
notificationSpec.channelId = notification.getChannelId();
}
notificationSpec.category = notification.category;
//FIXME: some quirks lookup table would be the minor evil here //FIXME: some quirks lookup table would be the minor evil here
if (source.startsWith("com.fsck.k9")) { if (source.startsWith("com.fsck.k9")) {
if (NotificationCompat.isGroupSummary(notification)) { if (NotificationCompat.isGroupSummary(notification)) {

View File

@ -180,7 +180,9 @@ public class GBDeviceService implements DeviceService {
.putExtra(EXTRA_NOTIFICATION_SOURCEAPPID, notificationSpec.sourceAppId) .putExtra(EXTRA_NOTIFICATION_SOURCEAPPID, notificationSpec.sourceAppId)
.putExtra(EXTRA_NOTIFICATION_ICONID, notificationSpec.iconId) .putExtra(EXTRA_NOTIFICATION_ICONID, notificationSpec.iconId)
.putExtra(NOTIFICATION_PICTURE_PATH, notificationSpec.picturePath) .putExtra(NOTIFICATION_PICTURE_PATH, notificationSpec.picturePath)
.putExtra(EXTRA_NOTIFICATION_DNDSUPPRESSED, notificationSpec.dndSuppressed); .putExtra(EXTRA_NOTIFICATION_DNDSUPPRESSED, notificationSpec.dndSuppressed)
.putExtra(EXTRA_NOTIFICATION_CHANNEL_ID, notificationSpec.channelId)
.putExtra(EXTRA_NOTIFICATION_CATEGORY, notificationSpec.category);
invokeService(intent); invokeService(intent);
} }

View File

@ -101,6 +101,8 @@ public interface DeviceService extends EventHandler {
String EXTRA_NOTIFICATION_ICONID = "notification_iconid"; String EXTRA_NOTIFICATION_ICONID = "notification_iconid";
String NOTIFICATION_PICTURE_PATH = "notification_picture_path"; String NOTIFICATION_PICTURE_PATH = "notification_picture_path";
String EXTRA_NOTIFICATION_DNDSUPPRESSED = "notification_dndsuppressed"; String EXTRA_NOTIFICATION_DNDSUPPRESSED = "notification_dndsuppressed";
String EXTRA_NOTIFICATION_CHANNEL_ID = "notification_channel_id";
String EXTRA_NOTIFICATION_CATEGORY = "notification_category";
String EXTRA_FIND_START = "find_start"; String EXTRA_FIND_START = "find_start";
String EXTRA_VIBRATION_INTENSITY = "vibration_intensity"; String EXTRA_VIBRATION_INTENSITY = "vibration_intensity";
String EXTRA_CALL_COMMAND = "call_command"; String EXTRA_CALL_COMMAND = "call_command";

View File

@ -34,6 +34,8 @@ public class NotificationSpec {
public String body; public String body;
public NotificationType type; public NotificationType type;
public String sourceName; public String sourceName;
public String channelId;
public String category;
public String[] cannedReplies; public String[] cannedReplies;
/** /**
* Wearable actions that were attached to the incoming notifications and will be passed to the gadget (includes the "reply" action) * Wearable actions that were attached to the incoming notifications and will be passed to the gadget (includes the "reply" action)

View File

@ -864,6 +864,8 @@ public class DeviceCommunicationService extends Service implements SharedPrefere
notificationSpec.iconId = intentCopy.getIntExtra(EXTRA_NOTIFICATION_ICONID, 0); notificationSpec.iconId = intentCopy.getIntExtra(EXTRA_NOTIFICATION_ICONID, 0);
notificationSpec.picturePath = intent.getStringExtra(NOTIFICATION_PICTURE_PATH); notificationSpec.picturePath = intent.getStringExtra(NOTIFICATION_PICTURE_PATH);
notificationSpec.dndSuppressed = intentCopy.getIntExtra(EXTRA_NOTIFICATION_DNDSUPPRESSED, 0); notificationSpec.dndSuppressed = intentCopy.getIntExtra(EXTRA_NOTIFICATION_DNDSUPPRESSED, 0);
notificationSpec.channelId = intentCopy.getStringExtra(EXTRA_NOTIFICATION_CHANNEL_ID);
notificationSpec.category = intentCopy.getStringExtra(EXTRA_NOTIFICATION_CATEGORY);
if (notificationSpec.type == NotificationType.GENERIC_SMS && notificationSpec.phoneNumber != null) { if (notificationSpec.type == NotificationType.GENERIC_SMS && notificationSpec.phoneNumber != null) {
GBApplication.getIDSenderLookup().add(notificationSpec.getId(), notificationSpec.phoneNumber); GBApplication.getIDSenderLookup().add(notificationSpec.getId(), notificationSpec.phoneNumber);