From 004355f69f52dccec0698d335e273dab8b6414d9 Mon Sep 17 00:00:00 2001 From: Gabriele Monaco Date: Tue, 23 Aug 2022 17:05:38 +0200 Subject: [PATCH] Added calendar color and name to CalendarEventSpec Tested on banglejs --- .../gadgetbridge/externalevents/CalendarReceiver.java | 2 ++ .../freeyourgadget/gadgetbridge/impl/GBDeviceService.java | 2 ++ .../freeyourgadget/gadgetbridge/model/CalendarEventSpec.java | 2 ++ .../freeyourgadget/gadgetbridge/model/DeviceService.java | 2 ++ .../gadgetbridge/service/DeviceCommunicationService.java | 4 ++++ .../service/devices/banglejs/BangleJSDeviceSupport.java | 2 ++ 6 files changed, 14 insertions(+) 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 adb7e21f0..b92d40e47 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/CalendarReceiver.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/CalendarReceiver.java @@ -203,6 +203,8 @@ public class CalendarReceiver extends BroadcastReceiver { calendarEventSpec.description = calendarEvent.getDescription(); calendarEventSpec.location = calendarEvent.getLocation(); calendarEventSpec.type = CalendarEventSpec.TYPE_UNKNOWN; + calendarEventSpec.calName = calendarEvent.getUniqueCalName(); + calendarEventSpec.color = calendarEvent.getColor(); if (syncState == EventState.NEEDS_UPDATE) { GBApplication.deviceService(mGBDevice).onDeleteCalendarEvent(CalendarEventSpec.TYPE_UNKNOWN, i); } 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 af21055e4..69e7ed257 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/impl/GBDeviceService.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/impl/GBDeviceService.java @@ -404,6 +404,8 @@ public class GBDeviceService implements DeviceService { .putExtra(EXTRA_CALENDAREVENT_ALLDAY, calendarEventSpec.allDay) .putExtra(EXTRA_CALENDAREVENT_TITLE, calendarEventSpec.title) .putExtra(EXTRA_CALENDAREVENT_DESCRIPTION, calendarEventSpec.description) + .putExtra(EXTRA_CALENDAREVENT_CALNAME, calendarEventSpec.calName) + .putExtra(EXTRA_CALENDAREVENT_COLOR, calendarEventSpec.color) .putExtra(EXTRA_CALENDAREVENT_LOCATION, calendarEventSpec.location); invokeService(intent); } 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 fbaf1db3a..13fed4e2e 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/CalendarEventSpec.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/CalendarEventSpec.java @@ -28,5 +28,7 @@ public class CalendarEventSpec { public String title; public String description; public String location; + public String calName; + public int color; public boolean allDay; } 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 659e43c64..3502c0b4c 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/DeviceService.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/DeviceService.java @@ -147,6 +147,8 @@ public interface DeviceService extends EventHandler { String EXTRA_CALENDAREVENT_TITLE = "calendarevent_title"; String EXTRA_CALENDAREVENT_DESCRIPTION = "calendarevent_description"; String EXTRA_CALENDAREVENT_LOCATION = "calendarevent_location"; + String EXTRA_CALENDAREVENT_CALNAME = "calendarevent_calname"; + String EXTRA_CALENDAREVENT_COLOR = "calendarevent_color"; void start(); 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 9a410026f..0a11ece79 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/DeviceCommunicationService.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/DeviceCommunicationService.java @@ -149,6 +149,8 @@ import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_CAL import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_CALENDAREVENT_ALLDAY; import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_CALENDAREVENT_TITLE; import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_CALENDAREVENT_TYPE; +import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_CALENDAREVENT_CALNAME; +import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_CALENDAREVENT_COLOR; import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_CALL_COMMAND; import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_CALL_DISPLAYNAME; import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_CALL_DNDSUPPRESSED; @@ -728,6 +730,8 @@ public class DeviceCommunicationService extends Service implements SharedPrefere calendarEventSpec.title = sanitizeNotifText(intent.getStringExtra(EXTRA_CALENDAREVENT_TITLE), device); calendarEventSpec.description = sanitizeNotifText(intent.getStringExtra(EXTRA_CALENDAREVENT_DESCRIPTION), device); calendarEventSpec.location = sanitizeNotifText(intent.getStringExtra(EXTRA_CALENDAREVENT_LOCATION), device); + calendarEventSpec.calName = sanitizeNotifText(intent.getStringExtra(EXTRA_CALENDAREVENT_CALNAME), device); + calendarEventSpec.color = intent.getIntExtra(EXTRA_CALENDAREVENT_COLOR, 0); deviceSupport.onAddCalendarEvent(calendarEventSpec); break; } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/banglejs/BangleJSDeviceSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/banglejs/BangleJSDeviceSupport.java index 599429595..2067d2f4a 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/banglejs/BangleJSDeviceSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/banglejs/BangleJSDeviceSupport.java @@ -1142,6 +1142,8 @@ public class BangleJSDeviceSupport extends AbstractBTLEDeviceSupport { o.put("title", calendarEventSpec.title); o.put("description", calendarEventSpec.description); o.put("location", calendarEventSpec.location); + o.put("calName", calendarEventSpec.calName); + o.put("color", calendarEventSpec.color); o.put("allDay", calendarEventSpec.allDay); uartTxJSON("onAddCalendarEvent", o); } catch (JSONException e) {