From 8fee88a1baae0be1579bd36fb4bba216ab8c52fa Mon Sep 17 00:00:00 2001 From: Andreas Shimokawa Date: Mon, 17 Aug 2015 13:57:01 +0200 Subject: [PATCH] Pebble: use SMS/EMAIL icons for notifications on FW 3.X --- .../devices/pebble/PebbleProtocol.java | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleProtocol.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleProtocol.java index 8ba3d6e3..2c5fc6ed 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleProtocol.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleProtocol.java @@ -269,8 +269,7 @@ public class PebbleProtocol extends GBDeviceProtocol { if (isFw3x) { // 3.x notification - String[] parts = {title, subtitle, body}; - return encodeBlobdbNotification((int) (ts & 0xffffffff), parts); + return encodeBlobdbNotification((int) (ts & 0xffffffff), title, subtitle, body, type); } else if (mForceProtocol || type != NOTIFICATION_EMAIL) { // 2.x notification return encodeExtensibleNotification(id, (int) (ts & 0xffffffff), title, subtitle, body, type); @@ -381,15 +380,25 @@ public class PebbleProtocol extends GBDeviceProtocol { return buf.array(); } - private byte[] encodeBlobdbNotification(int timestamp, String[] parts) { + private byte[] encodeBlobdbNotification(int timestamp, String title, String subtitle, String body, byte type) { + String[] parts = {title, subtitle, body}; + + int icon_id = 1; + switch (type) { + case NOTIFICATION_EMAIL: + icon_id = 19; + break; + case NOTIFICATION_SMS: + icon_id = 45; + } // Calculate length first final short BLOBDB_LENGTH = 23; final short NOTIFICATION_PIN_LENGTH = 46; final short ACTIONS_LENGTH = 17; - byte attributes_count = 0; + byte attributes_count = 1; // icon - short attributes_length = 0; + short attributes_length = 7; // icon if (parts != null) { for (String s : parts) { if (s == null || s.equals("")) { @@ -458,6 +467,10 @@ public class PebbleProtocol extends GBDeviceProtocol { } } + buf.put((byte) 4); // icon + buf.putShort((short) 4); // length of int + buf.putInt(icon_id); + if (mForceProtocol) { // ACTION buf.put((byte) 0x01); // id