From 5717379aec22de8d22135ad9863e7abee2dc1bb2 Mon Sep 17 00:00:00 2001 From: Andreas Shimokawa Date: Thu, 20 Apr 2017 10:40:28 +0200 Subject: [PATCH] Pebble: change timeline layout to "calendar" for calendaar events and display end time --- .../gadgetbridge/externalevents/CalendarReceiver.java | 4 ++-- .../service/devices/pebble/PebbleProtocol.java | 10 +++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/CalendarReceiver.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/CalendarReceiver.java index 9c4cac6a..2a30556b 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/CalendarReceiver.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/CalendarReceiver.java @@ -177,14 +177,14 @@ public class CalendarReceiver extends BroadcastReceiver { calendarEventSpec.title = calendarEvent.getTitle(); calendarEventSpec.allDay = calendarEvent.isAllDay(); calendarEventSpec.timestamp = calendarEvent.getBeginSeconds(); - //calendarEventSpec.durationInSeconds = calendarEvent.getDurationSeconds(); //FIXME: leads to problems right now + calendarEventSpec.durationInSeconds = calendarEvent.getDurationSeconds(); //FIXME: leads to problems right now if (calendarEvent.isAllDay()) { //force the all day events to begin at midnight and last a whole day Calendar c = GregorianCalendar.getInstance(); c.setTimeInMillis(calendarEvent.getBegin()); c.set(Calendar.HOUR, 0); calendarEventSpec.timestamp = (int) (c.getTimeInMillis() / 1000); - //calendarEventSpec.durationInSeconds = 24 * 60 *60; //TODO: commented because it is commented above + calendarEventSpec.durationInSeconds = 24 * 60 * 60; //TODO: commented because it is commented above } calendarEventSpec.description = calendarEvent.getDescription(); calendarEventSpec.location = calendarEvent.getLocation(); 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 582e3878..c37b9b45 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 @@ -525,7 +525,7 @@ public class PebbleProtocol extends GBDeviceProtocol { iconId = PebbleIconID.TIMELINE_CALENDAR; } - return encodeTimelinePin(new UUID(GB_UUID_MASK | calendarEventSpec.type, id), calendarEventSpec.timestamp, (short) calendarEventSpec.durationInSeconds, iconId, calendarEventSpec.title, calendarEventSpec.description); + return encodeTimelinePin(new UUID(GB_UUID_MASK | calendarEventSpec.type, id), calendarEventSpec.timestamp, (short) (calendarEventSpec.durationInSeconds / 60), iconId, calendarEventSpec.title, calendarEventSpec.description); } @Override @@ -841,6 +841,11 @@ public class PebbleProtocol extends GBDeviceProtocol { private byte[] encodeTimelinePin(UUID uuid, int timestamp, short duration, int icon_id, String title, String subtitle) { final short TIMELINE_PIN_LENGTH = 46; + //FIXME: dont depend layout on icon :P + byte layout_id = 0x01; + if (icon_id == PebbleIconID.TIMELINE_CALENDAR) { + layout_id = 0x02; + } icon_id |= 0x80000000; byte attributes_count = 2; byte actions_count = 0; @@ -865,8 +870,7 @@ public class PebbleProtocol extends GBDeviceProtocol { buf.putShort(duration); buf.put((byte) 0x02); // type (0x02 = pin) buf.putShort((short) 0x0001); // flags 0x0001 = ? - buf.put((byte) 0x01); // layout was (0x02 = pin?), 0x01 needed for subtitle but seems to do no harm if there isn't one - + buf.put(layout_id); // layout was (0x02 = pin?), 0x01 needed for subtitle but seems to do no harm if there isn't one buf.putShort((short) attributes_length); // total length of all attributes and actions in bytes buf.put(attributes_count); buf.put(actions_count);