Pebble: support the new element icon on firmware 4.9.x and add contants for all recently added ones

Also remove RIOT (previously ELEMENT, no longer works), unify ELEMENT and ELEMENTX which do not deserve its own Type.
This commit is contained in:
Andreas Shimokawa
2025-12-07 00:07:40 +01:00
parent 96fe3509f1
commit 9183714880
11 changed files with 39 additions and 20 deletions
@@ -115,11 +115,27 @@ public final class PebbleIconID {
public static final int REWARD_AVERAGE = 104;
public static final int NOTIFICATION_FACETIME = 110;
// 4.x only from here
// >=4.0 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;
// >=4.9 only from here (core devices)
public static final int NOTIFICATION_BEEPER = 120;
public static final int NOTIFICATION_DISCORD = 121;
public static final int NOTIFICATION_BLUESKY = 122;
public static final int NOTIFICATION_DUOLINGO = 123;
public static final int NOTIFICATION_ELEMENT = 124;
public static final int NOTIFICATION_GOOGLE_CHAT = 125;
public static final int NOTIFICATION_GOOGLE_TASKS = 126;
public static final int NOTIFICATION_HOME_ASSISTANT = 127;
public static final int NOTIFICATION_STEAM = 128;
public static final int NOTIFICATION_TEAMS = 129;
public static final int NOTIFICATION_THREADS = 130;
public static final int NOTIFICATION_UNIFI_PROTECT = 131;
public static final int NOTIFICATION_ZOOM = 132;
public static final int NOTIFICATION_EBAY = 133;
}
@@ -23,9 +23,11 @@ public class PebbleNotification {
private final int icon;
private final byte color;
private final NotificationType notificationType;
private final boolean isCoreDevice;
public PebbleNotification(NotificationSpec notificationSpec) {
public PebbleNotification(NotificationSpec notificationSpec, boolean isCoreDevice) {
this.notificationType = notificationSpec.type;
this.isCoreDevice = isCoreDevice;
this.icon = setIcon(notificationSpec.type);
this.color = setColor(notificationSpec);
}
@@ -56,13 +58,13 @@ public class PebbleNotification {
case KAKAO_TALK -> PebbleColor.Yellow;
case KIK, LINE, WHATSAPP, COL_REMINDER -> PebbleColor.IslamicGreen;
case LIGHTHOUSE -> PebbleColor.PictonBlue;
case RIOT, MOLLY -> PebbleColor.LavenderIndigo;
case MOLLY -> PebbleColor.LavenderIndigo;
case SLACK -> PebbleColor.Folly;
case SNAPCHAT -> PebbleColor.Icterine;
case DISCORD -> PebbleColor.Purpureus;
case WECHAT -> PebbleColor.KellyGreen;
case YAHOO_MAIL -> PebbleColor.Indigo;
case ELEMENT, ELEMENTX -> PebbleColor.Malachite;
case ELEMENT -> PebbleColor.MediumAquamarine;
default -> PebbleColor.DarkCandyAppleRed;
};
}
@@ -71,9 +73,10 @@ public class PebbleNotification {
return switch (notificationType) {
case AMAZON -> PebbleIconID.NOTIFICATION_AMAZON;
case BBM -> PebbleIconID.NOTIFICATION_BLACKBERRY_MESSENGER;
case CONVERSATIONS, HIPCHAT, RIOT, SIGNAL, WIRE, THREEMA, KONTALK,
ANTOX, DISCORD, DELTACHAT, ELEMENT, ELEMENTX, MOLLY ->
case CONVERSATIONS, HIPCHAT, SIGNAL, WIRE, THREEMA, KONTALK,
ANTOX, DISCORD, DELTACHAT, MOLLY ->
PebbleIconID.NOTIFICATION_HIPCHAT;
case ELEMENT -> isCoreDevice ? PebbleIconID.NOTIFICATION_ELEMENT : PebbleIconID.NOTIFICATION_HIPCHAT;
case FACEBOOK -> PebbleIconID.NOTIFICATION_FACEBOOK;
case FACEBOOK_MESSENGER -> PebbleIconID.NOTIFICATION_FACEBOOK_MESSENGER;
case GENERIC_ALARM_CLOCK -> PebbleIconID.ALARM_CLOCK;
@@ -68,10 +68,12 @@ public class AppNotificationType extends HashMap<String, NotificationType> {
put("eu.siacs.conversations", NotificationType.CONVERSATIONS);
put("de.pixart.messenger", NotificationType.CONVERSATIONS);
// Riot, Element, ElementX
put("im.vector.alpha", NotificationType.RIOT);
// Element, ElementX, SchildiChat, FluffyChat
// (making the last two an extra Notification Type to give them distinct colors is debatable)
put("im.vector.app", NotificationType.ELEMENT);
put("io.element.android.x", NotificationType.ELEMENTX);
put("io.element.android.x", NotificationType.ELEMENT);
put("chat.fluffy.fluffychat", NotificationType.ELEMENT);
put("chat.schildi.android", NotificationType.ELEMENT);
// Signal
put("org.thoughtcrime.securesms", NotificationType.SIGNAL);
@@ -33,7 +33,6 @@ public enum NotificationType {
MAILBOX,
OUTLOOK,
BUSINESS_CALENDAR,
RIOT,
SIGNAL,
WIRE,
SKYPE,
@@ -53,7 +52,6 @@ public enum NotificationType {
COL_REMINDER,
DELTACHAT,
ELEMENT,
ELEMENTX,
MOLLY,
VK,
QQ,
@@ -90,7 +88,6 @@ public enum NotificationType {
return "generic_social";
case CONVERSATIONS:
case FACEBOOK_MESSENGER:
case RIOT:
case SIGNAL:
case WIRE:
case TELEGRAM:
@@ -111,7 +108,6 @@ public enum NotificationType {
case DISCORD:
case DELTACHAT:
case ELEMENT:
case ELEMENTX:
case MOLLY:
return "generic_chat";
case GMAIL:
@@ -436,7 +436,6 @@ public class BLETypeConversions {
case HIPCHAT:
case KAKAO_TALK:
case LINE:
case RIOT:
case SIGNAL:
case WIRE:
case SKYPE:
@@ -50,7 +50,7 @@ enum class GloryFitNotificationType(val code: Byte) {
companion object {
fun fromNotificationType(type: NotificationType): GloryFitNotificationType {
when (type) {
NotificationType.CONVERSATIONS, NotificationType.RIOT, NotificationType.HIPCHAT, NotificationType.KONTALK,
NotificationType.CONVERSATIONS, NotificationType.HIPCHAT, NotificationType.KONTALK,
NotificationType.ANTOX, NotificationType.GENERIC_SMS, NotificationType.WECHAT,
NotificationType.SIGNAL-> return WECHAT
@@ -67,7 +67,6 @@ public class HuamiIcon {
case GENERIC_NAVIGATION:
return APP_11;
case CONVERSATIONS:
case RIOT:
case HIPCHAT:
case KONTALK:
case ANTOX:
@@ -305,6 +305,7 @@ public class PebbleProtocol extends GBDeviceProtocol {
private static final Random mRandom = new Random();
int mFwMajor = 3;
boolean isNewEraPebble = false;
boolean mEnablePebbleKit = false;
boolean mAlwaysACKPebbleKit = false;
private byte[] screenshotData = null;
@@ -523,7 +524,7 @@ public class PebbleProtocol extends GBDeviceProtocol {
@Override
public byte[] encodeNotification(NotificationSpec notificationSpec) {
final PebbleNotification pebbleNotification = new PebbleNotification(notificationSpec);
final PebbleNotification pebbleNotification = new PebbleNotification(notificationSpec, isNewEraPebble);
int id = notificationSpec.getId() != -1 ? notificationSpec.getId() : mRandom.nextInt();
String title;
String subtitle = null;
@@ -2399,7 +2400,13 @@ public class PebbleProtocol extends GBDeviceProtocol {
versionCmd.fwVersion = getFixedString(buf, 32);
mFwMajor = versionCmd.fwVersion.charAt(1) - 48;
String[] parsedVersion = versionCmd.fwVersion.split("\\.");
LOG.info("Pebble firmware major detected as {}", mFwMajor);
LOG.info("Pebble firmware minor detected as {}", parsedVersion[1]);
if (mFwMajor >= 5 || (mFwMajor == 4 && Integer.parseInt(parsedVersion[1]) >= 9)) {
isNewEraPebble = true;
}
String gitHash = getFixedString(buf, 8);
int fwFlags = buf.get();
LOG.info("git hash: {}, flags: {}", gitHash, fwFlags);
@@ -150,7 +150,6 @@ public class NotificationProvider {
case MAILBOX:
return AncsConstants.CATEGORY_ID_MISSED_CALL;
case LINE:
case RIOT:
case SIGNAL:
case WIRE:
case SKYPE:
@@ -755,7 +755,6 @@ public class ZeTimeDeviceSupport extends AbstractBTLESingleDeviceSupport {
notification[5] = ZeTimeConstants.NOTIFICATION_SKYPE;
break;
case CONVERSATIONS:
case RIOT:
case SIGNAL:
case WIRE:
case TELEGRAM:
@@ -62,7 +62,6 @@ public class NotificationUtils {
case HIPCHAT:
case KAKAO_TALK:
case LINE:
case RIOT:
case SIGNAL:
case WIRE:
case SKYPE: