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

map more apps to notification types (icons and colors on the pebble)

This commit is contained in:
Andreas Shimokawa 2016-10-11 11:54:52 +02:00
parent 18bcfe78b9
commit cd195a5969
10 changed files with 83 additions and 43 deletions

View File

@ -85,11 +85,25 @@ public final class PebbleIconID {
public static final int SETTINGS = 83;
public static final int SUNRISE = 84;
public static final int SUNSET = 85;
public static final int FACETIME_DISMISSED = 86;
public static final int FACETIME_INCOMING = 87;
public static final int FACETIME_OUTGOING = 88;
public static final int FACETIME_MISSED = 89;
public static final int FACETIME_DURING = 90;
public static final int BLUESCREEN_OF_DEATH = 91;
public static final int START_MUSIC_PHONE = 92;
public static final int RESULT_UNMUTE = 86;
public static final int RESULT_UNMUTE_ALT = 94;
public static final int DURING_PHONE_CALL_CENTERED = 95;
public static final int TIMELINE_EMPTY_CALENDAR = 96;
public static final int THUMBS_UP = 97;
public static final int ARROW_UP = 98;
public static final int ARROW_DOWN = 99;
public static final int ACTIVITY = 100;
public static final int SLEEP = 101;
public static final int REWARD_BAD = 102;
public static final int REWARD_GOOD = 103;
public static final int REWARD_AVERAGE = 104;
public static final int NOTIFICATION_FACETIME = 110;
// 4.x only from here
public static final int NOTIFICATION_AMAZON = 111;
public static final int NOTIFICATION_GOOGLE_MAPS = 112;
public static final int NOTIFICATION_GOOGLE_PHOTOS = 113;
public static final int NOTIFICATION_IOS_PHOTOS = 114;
public static final int NOTIFICATION_LINKEDIN = 115;
public static final int NOTIFICATION_SLACK = 116;
}

View File

@ -54,7 +54,7 @@ public class K9Receiver extends BroadcastReceiver {
NotificationSpec notificationSpec = new NotificationSpec();
notificationSpec.id = -1;
notificationSpec.type = NotificationType.EMAIL;
notificationSpec.type = NotificationType.GENERIC_EMAIL;
/*
* there seems to be no way to specify the the uri in the where clause.

View File

@ -257,27 +257,31 @@ public class NotificationListener extends NotificationListenerService {
break;
case "com.fsck.k9":
case "com.android.email":
notificationSpec.type = NotificationType.EMAIL;
notificationSpec.type = NotificationType.GENERIC_EMAIL;
break;
case "com.moez.QKSMS":
case "com.android.mms":
case "com.android.messaging":
case "com.sonyericsson.conversations":
case "org.smssecure.smssecure":
notificationSpec.type = NotificationType.SMS;
notificationSpec.type = NotificationType.GENERIC_SMS;
break;
case "eu.siacs.conversations":
notificationSpec.type = NotificationType.CONVERSATIONS;
break;
case "org.thoughtcrime.securesms":
notificationSpec.type = NotificationType.CHAT;
notificationSpec.type = NotificationType.SIGNAL;
break;
case "org.telegram.messenger":
notificationSpec.type = NotificationType.TELEGRAM;
break;
case "com.facebook.orca":
case "com.facebook.katana":
case "org.indywidualni.fblite":
notificationSpec.type = NotificationType.FACEBOOK;
break;
case "com.facebook.orca":
notificationSpec.type = NotificationType.FACEBOOK_MESSENGER;
break;
default:
notificationSpec.type = NotificationType.UNKNOWN;
break;

View File

@ -61,7 +61,10 @@ public class PebbleReceiver extends BroadcastReceiver {
notificationSpec.type = NotificationType.UNKNOWN;
String sender = intent.getStringExtra("sender");
if ("Conversations".equals(sender)) {
notificationSpec.type = NotificationType.CHAT;
notificationSpec.type = NotificationType.CONVERSATIONS;
}
else if ("OsmAnd".equals(sender)) {
notificationSpec.type = NotificationType.GENERIC_NAVIGATION;
}
GBApplication.deviceService().onNotification(notificationSpec);
}

View File

@ -31,7 +31,7 @@ public class SMSReceiver extends BroadcastReceiver {
NotificationSpec notificationSpec = new NotificationSpec();
notificationSpec.id = -1;
notificationSpec.type = NotificationType.SMS;
notificationSpec.type = NotificationType.GENERIC_SMS;
Bundle bundle = intent.getExtras();
if (bundle != null) {

View File

@ -4,10 +4,13 @@ public enum NotificationType {
UNKNOWN,
CHAT,
EMAIL,
CONVERSATIONS,
GENERIC_EMAIL,
GENERIC_NAVIGATION,
GENERIC_SMS,
FACEBOOK,
SMS,
FACEBOOK_MESSENGER,
SIGNAL,
TWITTER,
TELEGRAM;

View File

@ -310,14 +310,14 @@ public class DeviceCommunicationService extends Service implements SharedPrefere
notificationSpec.id = intent.getIntExtra(EXTRA_NOTIFICATION_ID, -1);
notificationSpec.flags = intent.getIntExtra(EXTRA_NOTIFICATION_FLAGS, 0);
notificationSpec.sourceName = intent.getStringExtra(EXTRA_NOTIFICATION_SOURCENAME);
if (notificationSpec.type == NotificationType.SMS && notificationSpec.phoneNumber != null) {
if (notificationSpec.type == NotificationType.GENERIC_SMS && notificationSpec.phoneNumber != null) {
notificationSpec.sender = getContactDisplayNameByNumber(notificationSpec.phoneNumber);
notificationSpec.id = mRandom.nextInt(); // FIXME: add this in external SMS Receiver?
GBApplication.getIDSenderLookup().add(notificationSpec.id, notificationSpec.phoneNumber);
}
if (((notificationSpec.flags & NotificationSpec.FLAG_WEARABLE_REPLY) > 0)
|| (notificationSpec.type == NotificationType.SMS && notificationSpec.phoneNumber != null)) {
|| (notificationSpec.type == NotificationType.GENERIC_SMS && notificationSpec.phoneNumber != null)) {
// NOTE: maybe not where it belongs
if (prefs.getBoolean("pebble_force_untested", false)) {
// I would rather like to save that as an array in ShadredPreferences

View File

@ -554,11 +554,15 @@ public class MiBand2Support extends AbstractBTLEDeviceSupport {
String task;
int alertLevel;
switch (notificationSpec.type) {
case SMS:
case CONVERSATIONS:
task = "conversations message received";
alertLevel = MiBand2Service.ALERT_LEVEL_MESSAGE;
break;
case GENERIC_SMS:
task = "sms received";
alertLevel = MiBand2Service.ALERT_LEVEL_MESSAGE;
break;
case EMAIL:
case GENERIC_EMAIL:
task = "email received";
alertLevel = MiBand2Service.ALERT_LEVEL_MESSAGE;
break;
@ -566,6 +570,14 @@ public class MiBand2Support extends AbstractBTLEDeviceSupport {
task = "facebook message received";
alertLevel = MiBand2Service.ALERT_LEVEL_MESSAGE;
break;
case FACEBOOK_MESSENGER:
task = "facebook messenger message received";
alertLevel = MiBand2Service.ALERT_LEVEL_MESSAGE;
break;
case SIGNAL:
task = "signal message received";
alertLevel = MiBand2Service.ALERT_LEVEL_MESSAGE;
break;
case TWITTER:
task = "twitter message received";
alertLevel = MiBand2Service.ALERT_LEVEL_MESSAGE;
@ -574,10 +586,6 @@ public class MiBand2Support extends AbstractBTLEDeviceSupport {
task = "telegram message received";
alertLevel = MiBand2Service.ALERT_LEVEL_MESSAGE;
break;
case CHAT:
task = "chat message received";
alertLevel = MiBand2Service.ALERT_LEVEL_MESSAGE;
break;
case UNKNOWN:
default:
task = "generic notification received";

View File

@ -536,22 +536,18 @@ public class MiBandSupport extends AbstractBTLEDeviceSupport {
public void onNotification(NotificationSpec notificationSpec) {
String origin = notificationSpec.type.getFixedValue();
switch (notificationSpec.type) {
case SMS:
case GENERIC_SMS:
performPreferredNotification("sms received", origin, null);
break;
case EMAIL:
case GENERIC_EMAIL:
performPreferredNotification("email received", origin, null);
break;
case CHAT:
performPreferredNotification("chat message received", origin, null);
break;
case TELEGRAM:
performPreferredNotification("chat message received", origin, null);
break;
case TWITTER:
performPreferredNotification("chat message received", origin, null);
break;
case CONVERSATIONS:
case FACEBOOK:
case FACEBOOK_MESSENGER:
case SIGNAL:
case TELEGRAM:
case TWITTER:
performPreferredNotification("chat message received", origin, null);
break;
case UNKNOWN:

View File

@ -464,7 +464,7 @@ public class PebbleProtocol extends GBDeviceProtocol {
if (mFwMajor >= 3) {
// 3.x notification
return encodeBlobdbNotification(id, (int) (ts & 0xffffffffL), title, subtitle, notificationSpec.body, notificationSpec.sourceName, hasHandle, notificationSpec.type, notificationSpec.cannedReplies);
} else if (mForceProtocol || notificationSpec.type != NotificationType.EMAIL) {
} else if (mForceProtocol || notificationSpec.type != NotificationType.GENERIC_EMAIL) {
// 2.x notification
return encodeExtensibleNotification(id, (int) (ts & 0xffffffffL), title, subtitle, notificationSpec.body, notificationSpec.sourceName, hasHandle, notificationSpec.cannedReplies);
} else {
@ -834,11 +834,19 @@ public class PebbleProtocol extends GBDeviceProtocol {
int icon_id;
byte color_id;
switch (notificationType) {
case EMAIL:
case CONVERSATIONS:
icon_id = PebbleIconID.NOTIFICATION_HIPCHAT;
color_id = PebbleColor.Inchworm;
break;
case GENERIC_EMAIL:
icon_id = PebbleIconID.GENERIC_EMAIL;
color_id = PebbleColor.JaegerGreen;
break;
case SMS:
case GENERIC_NAVIGATION:
icon_id = mFwMajor >= 4 ? PebbleIconID.NOTIFICATION_GOOGLE_MAPS : PebbleIconID.LOCATION;
color_id = PebbleColor.Orange;
break;
case GENERIC_SMS:
icon_id = PebbleIconID.GENERIC_SMS;
color_id = PebbleColor.VividViolet;
break;
@ -848,16 +856,20 @@ public class PebbleProtocol extends GBDeviceProtocol {
break;
case FACEBOOK:
icon_id = PebbleIconID.NOTIFICATION_FACEBOOK;
color_id = PebbleColor.VeryLightBlue;
color_id = PebbleColor.Liberty;
break;
case CHAT:
icon_id = PebbleIconID.NOTIFICATION_HIPCHAT;
color_id = PebbleColor.Inchworm;
case FACEBOOK_MESSENGER:
icon_id = PebbleIconID.NOTIFICATION_FACEBOOK_MESSENGER;
color_id = PebbleColor.VeryLightBlue;
break;
case TELEGRAM:
icon_id = PebbleIconID.NOTIFICATION_TELEGRAM;
color_id = PebbleColor.PictonBlue;
break;
case SIGNAL:
icon_id = PebbleIconID.NOTIFICATION_HIPCHAT;
color_id = PebbleColor.BlueMoon;
break;
default:
icon_id = PebbleIconID.NOTIFICATION_GENERIC;
color_id = PebbleColor.Red;