Pebble: use SMS/EMAIL icons for notifications on FW 3.X

This commit is contained in:
Andreas Shimokawa 2015-08-17 13:57:01 +02:00
parent e704357728
commit 8fee88a1ba
1 changed files with 18 additions and 5 deletions

View File

@ -269,8 +269,7 @@ public class PebbleProtocol extends GBDeviceProtocol {
if (isFw3x) { if (isFw3x) {
// 3.x notification // 3.x notification
String[] parts = {title, subtitle, body}; return encodeBlobdbNotification((int) (ts & 0xffffffff), title, subtitle, body, type);
return encodeBlobdbNotification((int) (ts & 0xffffffff), parts);
} else if (mForceProtocol || type != NOTIFICATION_EMAIL) { } else if (mForceProtocol || type != NOTIFICATION_EMAIL) {
// 2.x notification // 2.x notification
return encodeExtensibleNotification(id, (int) (ts & 0xffffffff), title, subtitle, body, type); return encodeExtensibleNotification(id, (int) (ts & 0xffffffff), title, subtitle, body, type);
@ -381,15 +380,25 @@ public class PebbleProtocol extends GBDeviceProtocol {
return buf.array(); 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 // Calculate length first
final short BLOBDB_LENGTH = 23; final short BLOBDB_LENGTH = 23;
final short NOTIFICATION_PIN_LENGTH = 46; final short NOTIFICATION_PIN_LENGTH = 46;
final short ACTIONS_LENGTH = 17; 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) { if (parts != null) {
for (String s : parts) { for (String s : parts) {
if (s == null || s.equals("")) { 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) { if (mForceProtocol) {
// ACTION // ACTION
buf.put((byte) 0x01); // id buf.put((byte) 0x01); // id