Add extra handler for generic notifications

(instead of misusing onSMS handler). Pebble still does that,
but not everybody has to.

Small step for #53
This commit is contained in:
cpfeiffer 2015-05-13 21:55:22 +02:00
parent c81e28c030
commit 27d725853f
5 changed files with 22 additions and 0 deletions

View File

@ -63,6 +63,12 @@ public abstract class AbstractBTDeviceSupport extends AbstractDeviceSupport {
sendToDevice(bytes);
}
@Override
public void onGenericNotification(String title, String details) {
byte[] bytes = gbDeviceProtocol.encodeGenericNotification(title, details);
sendToDevice(bytes);
}
@Override
public void onSetTime(long ts) {
byte[] bytes = gbDeviceProtocol.encodeSetTime(ts);

View File

@ -5,6 +5,8 @@ public interface EventHandler {
void onEmail(String from, String subject, String body);
void onGenericNotification(String title, String details);
void onSetTime(long ts);
void onSetCallState(String number, String name, GBCommand command);

View File

@ -126,6 +126,11 @@ public class MiBandSupport extends AbstractBTLEDeviceSupport {
performDefaultNotification("email received");
}
@Override
public void onGenericNotification(String title, String details) {
performDefaultNotification("generic notification received");
}
@Override
public void onSetTime(long ts) {
try {

View File

@ -224,6 +224,11 @@ public class PebbleProtocol extends GBDeviceProtocol {
return encodeMessage(ENDPOINT_NOTIFICATION, NOTIFICATION_EMAIL, 0, parts);
}
@Override
public byte[] encodeGenericNotification(String title, String details) {
return encodeSMS(title, details);
}
@Override
public byte[] encodeSetTime(long ts) {
if (ts == -1) {

View File

@ -12,6 +12,10 @@ public abstract class GBDeviceProtocol {
return null;
}
public byte[] encodeGenericNotification(String title, String details) {
return null;
}
public byte[] encodeSetTime(long ts) {
return null;
}