mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-18 22:57:48 +01:00
Zepp OS: Sync calendar event reminders
This commit is contained in:
parent
13d6c49bb5
commit
3799ffb72c
@ -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()) {
|
||||
|
@ -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)
|
||||
|
@ -17,6 +17,8 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
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<Long> reminders; // unix epoch millis
|
||||
}
|
||||
|
@ -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";
|
||||
|
@ -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<Long>) 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);
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user