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 7ea876559..a7a0ffef9 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/CalendarReceiver.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/CalendarReceiver.java @@ -26,6 +26,7 @@ import android.widget.Toast; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.ArrayList; import java.util.Calendar; import java.util.Enumeration; import java.util.GregorianCalendar; @@ -188,6 +189,7 @@ public class CalendarReceiver extends BroadcastReceiver { calendarEventSpec.id = i; calendarEventSpec.title = calendarEvent.getTitle(); calendarEventSpec.allDay = calendarEvent.isAllDay(); + calendarEventSpec.reminders = new ArrayList<>(calendarEvent.getRemindersAbsoluteTs()); calendarEventSpec.timestamp = calendarEvent.getBeginSeconds(); calendarEventSpec.durationInSeconds = calendarEvent.getDurationSeconds(); //FIXME: leads to problems right now if (calendarEvent.isAllDay()) { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/impl/GBDeviceService.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/impl/GBDeviceService.java index cdf79dfda..9fbf2d02e 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/impl/GBDeviceService.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/impl/GBDeviceService.java @@ -451,6 +451,7 @@ public class GBDeviceService implements DeviceService { .putExtra(EXTRA_CALENDAREVENT_TIMESTAMP, calendarEventSpec.timestamp) .putExtra(EXTRA_CALENDAREVENT_DURATION, calendarEventSpec.durationInSeconds) .putExtra(EXTRA_CALENDAREVENT_ALLDAY, calendarEventSpec.allDay) + .putExtra(EXTRA_CALENDAREVENT_REMINDERS, calendarEventSpec.reminders) .putExtra(EXTRA_CALENDAREVENT_TITLE, calendarEventSpec.title) .putExtra(EXTRA_CALENDAREVENT_DESCRIPTION, calendarEventSpec.description) .putExtra(EXTRA_CALENDAREVENT_CALNAME, calendarEventSpec.calName) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/CalendarEventSpec.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/CalendarEventSpec.java index 198f132a5..553c63aab 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/CalendarEventSpec.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/CalendarEventSpec.java @@ -17,6 +17,8 @@ along with this program. If not, see . */ package nodomain.freeyourgadget.gadgetbridge.model; +import java.util.ArrayList; + public class CalendarEventSpec { public static final byte TYPE_UNKNOWN = 0; public static final byte TYPE_SUNRISE = 1; @@ -32,4 +34,5 @@ public class CalendarEventSpec { public String calName; public int color; public boolean allDay; + public ArrayList reminders; // unix epoch millis } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/DeviceService.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/DeviceService.java index 8b5018662..af7c031fe 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/DeviceService.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/DeviceService.java @@ -162,6 +162,7 @@ public interface DeviceService extends EventHandler { String EXTRA_CALENDAREVENT_TIMESTAMP = "calendarevent_timestamp"; String EXTRA_CALENDAREVENT_DURATION = "calendarevent_duration"; String EXTRA_CALENDAREVENT_ALLDAY = "calendarevent_allday"; + String EXTRA_CALENDAREVENT_REMINDERS = "calendarevent_reminders"; String EXTRA_CALENDAREVENT_TITLE = "calendarevent_title"; String EXTRA_CALENDAREVENT_DESCRIPTION = "calendarevent_description"; String EXTRA_CALENDAREVENT_LOCATION = "calendarevent_location"; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/DeviceCommunicationService.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/DeviceCommunicationService.java index a2f9117b5..11f5ae326 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/DeviceCommunicationService.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/DeviceCommunicationService.java @@ -860,6 +860,7 @@ public class DeviceCommunicationService extends Service implements SharedPrefere calendarEventSpec.timestamp = intent.getIntExtra(EXTRA_CALENDAREVENT_TIMESTAMP, -1); calendarEventSpec.durationInSeconds = intent.getIntExtra(EXTRA_CALENDAREVENT_DURATION, -1); calendarEventSpec.allDay = intent.getBooleanExtra(EXTRA_CALENDAREVENT_ALLDAY, false); + calendarEventSpec.reminders = (ArrayList) intent.getSerializableExtra(EXTRA_CALENDAREVENT_REMINDERS); calendarEventSpec.title = intent.getStringExtra(EXTRA_CALENDAREVENT_TITLE); calendarEventSpec.description = intent.getStringExtra(EXTRA_CALENDAREVENT_DESCRIPTION); calendarEventSpec.location = intent.getStringExtra(EXTRA_CALENDAREVENT_LOCATION); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/services/ZeppOsCalendarService.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/services/ZeppOsCalendarService.java index 3b03779c4..84d104a18 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/services/ZeppOsCalendarService.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/services/ZeppOsCalendarService.java @@ -143,10 +143,12 @@ public class ZeppOsCalendarService extends AbstractZeppOsService { buf.putInt(calendarEventSpec.timestamp + calendarEventSpec.durationInSeconds); // Remind - buf.put((byte) 0x00); // ? - buf.put((byte) 0x00); // ? - buf.put((byte) 0x00); // ? - buf.put((byte) 0x00); // ? + if (calendarEventSpec.reminders != null && !calendarEventSpec.reminders.isEmpty()) { + buf.putInt((int) (calendarEventSpec.reminders.get(0) / 1000L)); + } else { + buf.putInt(0); + } + // Repeat buf.put((byte) 0x00); // ? buf.put((byte) 0x00); // ? @@ -231,7 +233,10 @@ public class ZeppOsCalendarService extends AbstractZeppOsService { final int endTime = BLETypeConversions.toUint32(payload, i); i += 4; - // ? 00 00 00 00 00 00 00 00 ff ff ff ff + final int reminderTime = BLETypeConversions.toUint32(payload, i); + i += 4; + + // ? 00 00 00 00 ff ff ff ff i += 12; boolean allDay = (payload[i] == 0x01);