map more apps to notification types (icons and colors on the pebble)
This commit is contained in:
parent
18bcfe78b9
commit
cd195a5969
|
@ -85,11 +85,25 @@ public final class PebbleIconID {
|
||||||
public static final int SETTINGS = 83;
|
public static final int SETTINGS = 83;
|
||||||
public static final int SUNRISE = 84;
|
public static final int SUNRISE = 84;
|
||||||
public static final int SUNSET = 85;
|
public static final int SUNSET = 85;
|
||||||
public static final int FACETIME_DISMISSED = 86;
|
public static final int RESULT_UNMUTE = 86;
|
||||||
public static final int FACETIME_INCOMING = 87;
|
public static final int RESULT_UNMUTE_ALT = 94;
|
||||||
public static final int FACETIME_OUTGOING = 88;
|
public static final int DURING_PHONE_CALL_CENTERED = 95;
|
||||||
public static final int FACETIME_MISSED = 89;
|
public static final int TIMELINE_EMPTY_CALENDAR = 96;
|
||||||
public static final int FACETIME_DURING = 90;
|
public static final int THUMBS_UP = 97;
|
||||||
public static final int BLUESCREEN_OF_DEATH = 91;
|
public static final int ARROW_UP = 98;
|
||||||
public static final int START_MUSIC_PHONE = 92;
|
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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ public class K9Receiver extends BroadcastReceiver {
|
||||||
|
|
||||||
NotificationSpec notificationSpec = new NotificationSpec();
|
NotificationSpec notificationSpec = new NotificationSpec();
|
||||||
notificationSpec.id = -1;
|
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.
|
* there seems to be no way to specify the the uri in the where clause.
|
||||||
|
|
|
@ -257,27 +257,31 @@ public class NotificationListener extends NotificationListenerService {
|
||||||
break;
|
break;
|
||||||
case "com.fsck.k9":
|
case "com.fsck.k9":
|
||||||
case "com.android.email":
|
case "com.android.email":
|
||||||
notificationSpec.type = NotificationType.EMAIL;
|
notificationSpec.type = NotificationType.GENERIC_EMAIL;
|
||||||
break;
|
break;
|
||||||
case "com.moez.QKSMS":
|
case "com.moez.QKSMS":
|
||||||
case "com.android.mms":
|
case "com.android.mms":
|
||||||
case "com.android.messaging":
|
case "com.android.messaging":
|
||||||
case "com.sonyericsson.conversations":
|
case "com.sonyericsson.conversations":
|
||||||
case "org.smssecure.smssecure":
|
case "org.smssecure.smssecure":
|
||||||
notificationSpec.type = NotificationType.SMS;
|
notificationSpec.type = NotificationType.GENERIC_SMS;
|
||||||
break;
|
break;
|
||||||
case "eu.siacs.conversations":
|
case "eu.siacs.conversations":
|
||||||
|
notificationSpec.type = NotificationType.CONVERSATIONS;
|
||||||
|
break;
|
||||||
case "org.thoughtcrime.securesms":
|
case "org.thoughtcrime.securesms":
|
||||||
notificationSpec.type = NotificationType.CHAT;
|
notificationSpec.type = NotificationType.SIGNAL;
|
||||||
break;
|
break;
|
||||||
case "org.telegram.messenger":
|
case "org.telegram.messenger":
|
||||||
notificationSpec.type = NotificationType.TELEGRAM;
|
notificationSpec.type = NotificationType.TELEGRAM;
|
||||||
break;
|
break;
|
||||||
case "com.facebook.orca":
|
|
||||||
case "com.facebook.katana":
|
case "com.facebook.katana":
|
||||||
case "org.indywidualni.fblite":
|
case "org.indywidualni.fblite":
|
||||||
notificationSpec.type = NotificationType.FACEBOOK;
|
notificationSpec.type = NotificationType.FACEBOOK;
|
||||||
break;
|
break;
|
||||||
|
case "com.facebook.orca":
|
||||||
|
notificationSpec.type = NotificationType.FACEBOOK_MESSENGER;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
notificationSpec.type = NotificationType.UNKNOWN;
|
notificationSpec.type = NotificationType.UNKNOWN;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -61,7 +61,10 @@ public class PebbleReceiver extends BroadcastReceiver {
|
||||||
notificationSpec.type = NotificationType.UNKNOWN;
|
notificationSpec.type = NotificationType.UNKNOWN;
|
||||||
String sender = intent.getStringExtra("sender");
|
String sender = intent.getStringExtra("sender");
|
||||||
if ("Conversations".equals(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);
|
GBApplication.deviceService().onNotification(notificationSpec);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ public class SMSReceiver extends BroadcastReceiver {
|
||||||
|
|
||||||
NotificationSpec notificationSpec = new NotificationSpec();
|
NotificationSpec notificationSpec = new NotificationSpec();
|
||||||
notificationSpec.id = -1;
|
notificationSpec.id = -1;
|
||||||
notificationSpec.type = NotificationType.SMS;
|
notificationSpec.type = NotificationType.GENERIC_SMS;
|
||||||
|
|
||||||
Bundle bundle = intent.getExtras();
|
Bundle bundle = intent.getExtras();
|
||||||
if (bundle != null) {
|
if (bundle != null) {
|
||||||
|
|
|
@ -4,10 +4,13 @@ public enum NotificationType {
|
||||||
|
|
||||||
UNKNOWN,
|
UNKNOWN,
|
||||||
|
|
||||||
CHAT,
|
CONVERSATIONS,
|
||||||
EMAIL,
|
GENERIC_EMAIL,
|
||||||
|
GENERIC_NAVIGATION,
|
||||||
|
GENERIC_SMS,
|
||||||
FACEBOOK,
|
FACEBOOK,
|
||||||
SMS,
|
FACEBOOK_MESSENGER,
|
||||||
|
SIGNAL,
|
||||||
TWITTER,
|
TWITTER,
|
||||||
TELEGRAM;
|
TELEGRAM;
|
||||||
|
|
||||||
|
|
|
@ -310,14 +310,14 @@ public class DeviceCommunicationService extends Service implements SharedPrefere
|
||||||
notificationSpec.id = intent.getIntExtra(EXTRA_NOTIFICATION_ID, -1);
|
notificationSpec.id = intent.getIntExtra(EXTRA_NOTIFICATION_ID, -1);
|
||||||
notificationSpec.flags = intent.getIntExtra(EXTRA_NOTIFICATION_FLAGS, 0);
|
notificationSpec.flags = intent.getIntExtra(EXTRA_NOTIFICATION_FLAGS, 0);
|
||||||
notificationSpec.sourceName = intent.getStringExtra(EXTRA_NOTIFICATION_SOURCENAME);
|
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.sender = getContactDisplayNameByNumber(notificationSpec.phoneNumber);
|
||||||
|
|
||||||
notificationSpec.id = mRandom.nextInt(); // FIXME: add this in external SMS Receiver?
|
notificationSpec.id = mRandom.nextInt(); // FIXME: add this in external SMS Receiver?
|
||||||
GBApplication.getIDSenderLookup().add(notificationSpec.id, notificationSpec.phoneNumber);
|
GBApplication.getIDSenderLookup().add(notificationSpec.id, notificationSpec.phoneNumber);
|
||||||
}
|
}
|
||||||
if (((notificationSpec.flags & NotificationSpec.FLAG_WEARABLE_REPLY) > 0)
|
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
|
// NOTE: maybe not where it belongs
|
||||||
if (prefs.getBoolean("pebble_force_untested", false)) {
|
if (prefs.getBoolean("pebble_force_untested", false)) {
|
||||||
// I would rather like to save that as an array in ShadredPreferences
|
// I would rather like to save that as an array in ShadredPreferences
|
||||||
|
|
|
@ -554,11 +554,15 @@ public class MiBand2Support extends AbstractBTLEDeviceSupport {
|
||||||
String task;
|
String task;
|
||||||
int alertLevel;
|
int alertLevel;
|
||||||
switch (notificationSpec.type) {
|
switch (notificationSpec.type) {
|
||||||
case SMS:
|
case CONVERSATIONS:
|
||||||
|
task = "conversations message received";
|
||||||
|
alertLevel = MiBand2Service.ALERT_LEVEL_MESSAGE;
|
||||||
|
break;
|
||||||
|
case GENERIC_SMS:
|
||||||
task = "sms received";
|
task = "sms received";
|
||||||
alertLevel = MiBand2Service.ALERT_LEVEL_MESSAGE;
|
alertLevel = MiBand2Service.ALERT_LEVEL_MESSAGE;
|
||||||
break;
|
break;
|
||||||
case EMAIL:
|
case GENERIC_EMAIL:
|
||||||
task = "email received";
|
task = "email received";
|
||||||
alertLevel = MiBand2Service.ALERT_LEVEL_MESSAGE;
|
alertLevel = MiBand2Service.ALERT_LEVEL_MESSAGE;
|
||||||
break;
|
break;
|
||||||
|
@ -566,6 +570,14 @@ public class MiBand2Support extends AbstractBTLEDeviceSupport {
|
||||||
task = "facebook message received";
|
task = "facebook message received";
|
||||||
alertLevel = MiBand2Service.ALERT_LEVEL_MESSAGE;
|
alertLevel = MiBand2Service.ALERT_LEVEL_MESSAGE;
|
||||||
break;
|
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:
|
case TWITTER:
|
||||||
task = "twitter message received";
|
task = "twitter message received";
|
||||||
alertLevel = MiBand2Service.ALERT_LEVEL_MESSAGE;
|
alertLevel = MiBand2Service.ALERT_LEVEL_MESSAGE;
|
||||||
|
@ -574,10 +586,6 @@ public class MiBand2Support extends AbstractBTLEDeviceSupport {
|
||||||
task = "telegram message received";
|
task = "telegram message received";
|
||||||
alertLevel = MiBand2Service.ALERT_LEVEL_MESSAGE;
|
alertLevel = MiBand2Service.ALERT_LEVEL_MESSAGE;
|
||||||
break;
|
break;
|
||||||
case CHAT:
|
|
||||||
task = "chat message received";
|
|
||||||
alertLevel = MiBand2Service.ALERT_LEVEL_MESSAGE;
|
|
||||||
break;
|
|
||||||
case UNKNOWN:
|
case UNKNOWN:
|
||||||
default:
|
default:
|
||||||
task = "generic notification received";
|
task = "generic notification received";
|
||||||
|
|
|
@ -536,22 +536,18 @@ public class MiBandSupport extends AbstractBTLEDeviceSupport {
|
||||||
public void onNotification(NotificationSpec notificationSpec) {
|
public void onNotification(NotificationSpec notificationSpec) {
|
||||||
String origin = notificationSpec.type.getFixedValue();
|
String origin = notificationSpec.type.getFixedValue();
|
||||||
switch (notificationSpec.type) {
|
switch (notificationSpec.type) {
|
||||||
case SMS:
|
case GENERIC_SMS:
|
||||||
performPreferredNotification("sms received", origin, null);
|
performPreferredNotification("sms received", origin, null);
|
||||||
break;
|
break;
|
||||||
case EMAIL:
|
case GENERIC_EMAIL:
|
||||||
performPreferredNotification("email received", origin, null);
|
performPreferredNotification("email received", origin, null);
|
||||||
break;
|
break;
|
||||||
case CHAT:
|
case CONVERSATIONS:
|
||||||
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 FACEBOOK:
|
case FACEBOOK:
|
||||||
|
case FACEBOOK_MESSENGER:
|
||||||
|
case SIGNAL:
|
||||||
|
case TELEGRAM:
|
||||||
|
case TWITTER:
|
||||||
performPreferredNotification("chat message received", origin, null);
|
performPreferredNotification("chat message received", origin, null);
|
||||||
break;
|
break;
|
||||||
case UNKNOWN:
|
case UNKNOWN:
|
||||||
|
|
|
@ -464,7 +464,7 @@ public class PebbleProtocol extends GBDeviceProtocol {
|
||||||
if (mFwMajor >= 3) {
|
if (mFwMajor >= 3) {
|
||||||
// 3.x notification
|
// 3.x notification
|
||||||
return encodeBlobdbNotification(id, (int) (ts & 0xffffffffL), title, subtitle, notificationSpec.body, notificationSpec.sourceName, hasHandle, notificationSpec.type, notificationSpec.cannedReplies);
|
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
|
// 2.x notification
|
||||||
return encodeExtensibleNotification(id, (int) (ts & 0xffffffffL), title, subtitle, notificationSpec.body, notificationSpec.sourceName, hasHandle, notificationSpec.cannedReplies);
|
return encodeExtensibleNotification(id, (int) (ts & 0xffffffffL), title, subtitle, notificationSpec.body, notificationSpec.sourceName, hasHandle, notificationSpec.cannedReplies);
|
||||||
} else {
|
} else {
|
||||||
|
@ -834,11 +834,19 @@ public class PebbleProtocol extends GBDeviceProtocol {
|
||||||
int icon_id;
|
int icon_id;
|
||||||
byte color_id;
|
byte color_id;
|
||||||
switch (notificationType) {
|
switch (notificationType) {
|
||||||
case EMAIL:
|
case CONVERSATIONS:
|
||||||
|
icon_id = PebbleIconID.NOTIFICATION_HIPCHAT;
|
||||||
|
color_id = PebbleColor.Inchworm;
|
||||||
|
break;
|
||||||
|
case GENERIC_EMAIL:
|
||||||
icon_id = PebbleIconID.GENERIC_EMAIL;
|
icon_id = PebbleIconID.GENERIC_EMAIL;
|
||||||
color_id = PebbleColor.JaegerGreen;
|
color_id = PebbleColor.JaegerGreen;
|
||||||
break;
|
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;
|
icon_id = PebbleIconID.GENERIC_SMS;
|
||||||
color_id = PebbleColor.VividViolet;
|
color_id = PebbleColor.VividViolet;
|
||||||
break;
|
break;
|
||||||
|
@ -848,16 +856,20 @@ public class PebbleProtocol extends GBDeviceProtocol {
|
||||||
break;
|
break;
|
||||||
case FACEBOOK:
|
case FACEBOOK:
|
||||||
icon_id = PebbleIconID.NOTIFICATION_FACEBOOK;
|
icon_id = PebbleIconID.NOTIFICATION_FACEBOOK;
|
||||||
color_id = PebbleColor.VeryLightBlue;
|
color_id = PebbleColor.Liberty;
|
||||||
break;
|
break;
|
||||||
case CHAT:
|
case FACEBOOK_MESSENGER:
|
||||||
icon_id = PebbleIconID.NOTIFICATION_HIPCHAT;
|
icon_id = PebbleIconID.NOTIFICATION_FACEBOOK_MESSENGER;
|
||||||
color_id = PebbleColor.Inchworm;
|
color_id = PebbleColor.VeryLightBlue;
|
||||||
break;
|
break;
|
||||||
case TELEGRAM:
|
case TELEGRAM:
|
||||||
icon_id = PebbleIconID.NOTIFICATION_TELEGRAM;
|
icon_id = PebbleIconID.NOTIFICATION_TELEGRAM;
|
||||||
color_id = PebbleColor.PictonBlue;
|
color_id = PebbleColor.PictonBlue;
|
||||||
break;
|
break;
|
||||||
|
case SIGNAL:
|
||||||
|
icon_id = PebbleIconID.NOTIFICATION_HIPCHAT;
|
||||||
|
color_id = PebbleColor.BlueMoon;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
icon_id = PebbleIconID.NOTIFICATION_GENERIC;
|
icon_id = PebbleIconID.NOTIFICATION_GENERIC;
|
||||||
color_id = PebbleColor.Red;
|
color_id = PebbleColor.Red;
|
||||||
|
|
Loading…
Reference in New Issue