1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-24 10:56:50 +01:00

Bangle.js: Fix calendar sync setting

This commit is contained in:
José Rebelo 2024-08-29 12:07:02 +01:00
parent 7eb1fcdb52
commit d75ae6b54d

View File

@ -999,7 +999,10 @@ public class BangleJSDeviceSupport extends AbstractBTLEDeviceSupport {
* Handle "force_calendar_sync" packet
*/
private void handleCalendarSync(JSONObject json) throws JSONException {
if (!GBApplication.getPrefs().getBoolean("enable_calendar_sync", false)) return;
if (!getDevicePrefs().getBoolean("sync_calendar", false)) {
LOG.debug("Ignoring calendar sync request, sync is disabled");
return;
}
//pretty much like the updateEvents in CalendarReceiver, but would need a lot of libraries here
JSONArray ids = json.getJSONArray("ids");
ArrayList<Long> idsList = new ArrayList<>(ids.length());
@ -1790,7 +1793,10 @@ public class BangleJSDeviceSupport extends AbstractBTLEDeviceSupport {
@Override
public void onAddCalendarEvent(CalendarEventSpec calendarEventSpec) {
if (!GBApplication.getPrefs().getBoolean("enable_calendar_sync", false)) return;
if (!getDevicePrefs().getBoolean("sync_calendar", false)) {
LOG.debug("Ignoring add calendar event {}, sync is disabled", calendarEventSpec.id);
return;
}
String description = calendarEventSpec.description;
if (description != null) {
// remove any HTML formatting
@ -1825,7 +1831,10 @@ public class BangleJSDeviceSupport extends AbstractBTLEDeviceSupport {
@Override
public void onDeleteCalendarEvent(byte type, long id) {
// FIXME: CalenderReceiver will call this directly - can we somehow batch up delete calls and use deleteCalendarEvents?
if (!GBApplication.getPrefs().getBoolean("enable_calendar_sync", false)) return;
if (!getDevicePrefs().getBoolean("sync_calendar", false)) {
LOG.debug("Ignoring delete calendar event {}, sync is disabled", id);
return;
}
try {
JSONObject o = new JSONObject();
o.put("t", "calendar-");
@ -1838,8 +1847,11 @@ public class BangleJSDeviceSupport extends AbstractBTLEDeviceSupport {
/* Called when we need to get rid of multiple calendar events */
public void deleteCalendarEvents(ArrayList<Long> ids) {
if (!GBApplication.getPrefs().getBoolean("enable_calendar_sync", false)) return;
if (ids.size() > 0)
if (!getDevicePrefs().getBoolean("sync_calendar", false)) {
LOG.debug("Ignoring delete calendar events {}, sync is disabled", ids);
return;
}
if (!ids.isEmpty())
try {
JSONObject o = new JSONObject();
o.put("t", "calendar-");