mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-28 19:45:50 +01:00
Fill function to to add a calendar event at the day view.
This commit is contained in:
parent
7c65fa4fc0
commit
fec1f1afc6
@ -57,6 +57,7 @@ public class ZeTimeConstants {
|
|||||||
public static final byte CMD_GET_HEARTRATE_EXDATA = (byte) 0x61;
|
public static final byte CMD_GET_HEARTRATE_EXDATA = (byte) 0x61;
|
||||||
public static final byte CMD_PUSH_EX_MSG = (byte) 0x76;
|
public static final byte CMD_PUSH_EX_MSG = (byte) 0x76;
|
||||||
public static final byte CMD_PUSH_WEATHER_DATA = (byte) 0x77;
|
public static final byte CMD_PUSH_WEATHER_DATA = (byte) 0x77;
|
||||||
|
public static final byte CMD_PUSH_CALENDAR_DAY = (byte) 0x99;
|
||||||
public static final byte CMD_MUSIC_CONTROL = (byte) 0xD0;
|
public static final byte CMD_MUSIC_CONTROL = (byte) 0xD0;
|
||||||
// here are the action commands
|
// here are the action commands
|
||||||
public static final byte CMD_REQUEST = (byte) 0x70;
|
public static final byte CMD_REQUEST = (byte) 0x70;
|
||||||
|
@ -324,7 +324,36 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAddCalendarEvent(CalendarEventSpec calendarEventSpec) {
|
public void onAddCalendarEvent(CalendarEventSpec calendarEventSpec) {
|
||||||
|
Calendar time = GregorianCalendar.getInstance();
|
||||||
|
byte[] CalendarEvent = new byte[calendarEventSpec.title.getBytes(StandardCharsets.UTF_8).length + 16]; // 26 bytes for calendar and overhead
|
||||||
|
time.setTimeInMillis(calendarEventSpec.timestamp);
|
||||||
|
CalendarEvent[0] = ZeTimeConstants.CMD_PREAMBLE;
|
||||||
|
CalendarEvent[1] = ZeTimeConstants.CMD_PUSH_CALENDAR_DAY;
|
||||||
|
CalendarEvent[2] = ZeTimeConstants.CMD_SEND;
|
||||||
|
CalendarEvent[3] = (byte)((calendarEventSpec.title.getBytes(StandardCharsets.UTF_8).length + 10) & 0xff);
|
||||||
|
CalendarEvent[4] = (byte)((calendarEventSpec.title.getBytes(StandardCharsets.UTF_8).length + 10) >> 8);
|
||||||
|
CalendarEvent[5] = (byte)(calendarEventSpec.type + 0x1);
|
||||||
|
CalendarEvent[6] = (byte)(time.get(Calendar.YEAR) & 0xff);
|
||||||
|
CalendarEvent[7] = (byte)(time.get(Calendar.YEAR) >> 8);
|
||||||
|
CalendarEvent[8] = (byte)(time.get(Calendar.MONTH)+1);
|
||||||
|
CalendarEvent[9] = (byte)time.get(Calendar.DAY_OF_MONTH);
|
||||||
|
CalendarEvent[10] = (byte) ((time.get(Calendar.HOUR_OF_DAY)/10) + '0');
|
||||||
|
CalendarEvent[11] = (byte) ((time.get(Calendar.HOUR_OF_DAY)%10) + '0');
|
||||||
|
CalendarEvent[12] = (byte) ((time.get(Calendar.MINUTE)/10) + '0');
|
||||||
|
CalendarEvent[13] = (byte) ((time.get(Calendar.MINUTE)%10) + '0');
|
||||||
|
CalendarEvent[14] = (byte) calendarEventSpec.title.getBytes(StandardCharsets.UTF_8).length;
|
||||||
|
System.arraycopy(calendarEventSpec.title.getBytes(StandardCharsets.UTF_8), 0, CalendarEvent, 15, calendarEventSpec.title.getBytes(StandardCharsets.UTF_8).length);
|
||||||
|
CalendarEvent[CalendarEvent.length-1] = ZeTimeConstants.CMD_END;
|
||||||
|
if(CalendarEvent != null)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
TransactionBuilder builder = performInitialized("sendCalendarEvenr");
|
||||||
|
sendMsgToWatch(builder, CalendarEvent);
|
||||||
|
performConnected(builder.getTransaction());
|
||||||
|
} catch (IOException e) {
|
||||||
|
GB.toast(getContext(), "Error sending calendar event: " + e.getLocalizedMessage(), Toast.LENGTH_LONG, GB.ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user