1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-15 06:29:24 +01:00

Treat Conversations messagess as chat messages, even if arrived via Pebble Intents (which is the default)

This commit is contained in:
Andreas Shimokawa 2015-09-17 23:08:05 +02:00
parent a5ef952e37
commit 041bd1a7f4
2 changed files with 12 additions and 5 deletions

View File

@ -13,6 +13,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import nodomain.freeyourgadget.gadgetbridge.GBApplication; import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.model.NotificationKind;
public class PebbleReceiver extends BroadcastReceiver { public class PebbleReceiver extends BroadcastReceiver {
@ -46,6 +47,7 @@ public class PebbleReceiver extends BroadcastReceiver {
return; return;
} }
String notificationData = intent.getStringExtra("notificationData"); String notificationData = intent.getStringExtra("notificationData");
try { try {
JSONArray notificationJSON = new JSONArray(notificationData); JSONArray notificationJSON = new JSONArray(notificationData);
@ -57,7 +59,12 @@ public class PebbleReceiver extends BroadcastReceiver {
} }
if (title != null && body != null) { if (title != null && body != null) {
GBApplication.deviceService().onSMS(title, body); NotificationKind notificationKind = NotificationKind.UNDEFINED;
String sender = intent.getStringExtra("sender");
if ("Conversations".equals(sender)) {
notificationKind = NotificationKind.CHAT;
}
GBApplication.deviceService().onGenericNotification(title, body, -1, notificationKind);
} }
} }
} }

View File

@ -383,11 +383,11 @@ public class PebbleProtocol extends GBDeviceProtocol {
if (isFw3x) { if (isFw3x) {
// 3.x notification // 3.x notification
//return encodeTimelinePin(id, (int) (ts + 600 & 0xffffffff), (short) 90, ICON_TIMELINE_CALENDAR, title); // really, this is just for testing //return encodeTimelinePin(id, (int) ((ts + 600) & 0xffffffffL), (short) 90, PebbleIconID.TIMELINE_CALENDAR, title); // really, this is just for testing
return encodeBlobdbNotification(id, (int) (ts & 0xffffffff), title, subtitle, body, type, hasHandle, notificationKind); return encodeBlobdbNotification(id, (int) (ts & 0xffffffffL), title, subtitle, body, type, hasHandle, notificationKind);
} 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, hasHandle); return encodeExtensibleNotification(id, (int) (ts & 0xffffffffL), title, subtitle, body, type, hasHandle);
} else { } else {
// 1.x notification on FW 2.X // 1.x notification on FW 2.X
String[] parts = {title, body, ts.toString(), subtitle}; String[] parts = {title, body, ts.toString(), subtitle};
@ -408,7 +408,7 @@ public class PebbleProtocol extends GBDeviceProtocol {
@Override @Override
public byte[] encodeGenericNotification(String title, String details, int handle, NotificationKind notificationKind) { public byte[] encodeGenericNotification(String title, String details, int handle, NotificationKind notificationKind) {
return encodeNotification(handle, title, null, details, NOTIFICATION_UNDEFINED, true, notificationKind); return encodeNotification(handle, title, null, details, NOTIFICATION_UNDEFINED, handle != -1, notificationKind);
} }
@Override @Override