mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-24 10:56:50 +01:00
Make calendar event type byte instead of int
Now the UUID will be constructed like this: High 64bit 0x4742474200 | type Low 64bit id
This commit is contained in:
parent
c9c9b420dc
commit
cb1ec5dccb
@ -55,5 +55,5 @@ public interface EventHandler {
|
||||
|
||||
void onAddCalendarEvent(CalendarEventSpec calendarEventSpec);
|
||||
|
||||
void onDeleteCalendarEvent(int type, long id);
|
||||
void onDeleteCalendarEvent(byte type, long id);
|
||||
}
|
||||
|
@ -238,7 +238,7 @@ public class GBDeviceService implements DeviceService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeleteCalendarEvent(int type, long id) {
|
||||
public void onDeleteCalendarEvent(byte type, long id) {
|
||||
Intent intent = createIntent().setAction(ACTION_DELETE_CALENDAREVENT)
|
||||
.putExtra(EXTRA_CALENDAREVENT_TYPE, type)
|
||||
.putExtra(EXTRA_CALENDAREVENT_ID, id);
|
||||
|
@ -1,11 +1,11 @@
|
||||
package nodomain.freeyourgadget.gadgetbridge.model;
|
||||
|
||||
public class CalendarEventSpec {
|
||||
public static final int TYPE_UNKNOWN = 0;
|
||||
public static final int TYPE_SUNRISE = 1;
|
||||
public static final int TYPE_SUNSET = 2;
|
||||
public static final byte TYPE_UNKNOWN = 0;
|
||||
public static final byte TYPE_SUNRISE = 1;
|
||||
public static final byte TYPE_SUNSET = 2;
|
||||
|
||||
public int type;
|
||||
public byte type;
|
||||
public long id;
|
||||
public int timestamp;
|
||||
public int durationInSeconds;
|
||||
|
@ -282,7 +282,7 @@ public class DeviceCommunicationService extends Service implements SharedPrefere
|
||||
case ACTION_ADD_CALENDAREVENT: {
|
||||
CalendarEventSpec calendarEventSpec = new CalendarEventSpec();
|
||||
calendarEventSpec.id = intent.getLongExtra(EXTRA_CALENDAREVENT_ID, -1);
|
||||
calendarEventSpec.type = intent.getIntExtra(EXTRA_CALENDAREVENT_TYPE, -1);
|
||||
calendarEventSpec.type = intent.getByteExtra(EXTRA_CALENDAREVENT_TYPE, (byte) -1);
|
||||
calendarEventSpec.timestamp = intent.getIntExtra(EXTRA_CALENDAREVENT_TIMESTAMP, -1);
|
||||
calendarEventSpec.durationInSeconds = intent.getIntExtra(EXTRA_CALENDAREVENT_DURATION, -1);
|
||||
calendarEventSpec.title = intent.getStringExtra(EXTRA_CALENDAREVENT_TITLE);
|
||||
@ -292,7 +292,7 @@ public class DeviceCommunicationService extends Service implements SharedPrefere
|
||||
}
|
||||
case ACTION_DELETE_CALENDAREVENT: {
|
||||
long id = intent.getLongExtra(EXTRA_CALENDAREVENT_ID, -1);
|
||||
int type = intent.getIntExtra(EXTRA_CALENDAREVENT_TYPE, -1);
|
||||
byte type = intent.getByteExtra(EXTRA_CALENDAREVENT_TYPE, (byte) -1);
|
||||
mDeviceSupport.onDeleteCalendarEvent(type, id);
|
||||
break;
|
||||
}
|
||||
|
@ -279,7 +279,7 @@ public class ServiceDeviceSupport implements DeviceSupport {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeleteCalendarEvent(int type, long id) {
|
||||
public void onDeleteCalendarEvent(byte type, long id) {
|
||||
if (checkBusy("delete calendar event")) {
|
||||
return;
|
||||
}
|
||||
|
@ -389,7 +389,7 @@ public class MiBandSupport extends AbstractBTLEDeviceSupport {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeleteCalendarEvent(int type, long id) {
|
||||
public void onDeleteCalendarEvent(byte type, long id) {
|
||||
// not supported
|
||||
}
|
||||
|
||||
|
@ -241,6 +241,8 @@ public class PebbleProtocol extends GBDeviceProtocol {
|
||||
|
||||
static final byte LENGTH_UUID = 16;
|
||||
|
||||
static final long GB_UUID_MASK = 0x4742474200L;
|
||||
|
||||
// base is -5
|
||||
private static final String[] hwRevisions = {
|
||||
// Emulator
|
||||
@ -479,12 +481,12 @@ public class PebbleProtocol extends GBDeviceProtocol {
|
||||
iconId = PebbleIconID.TIMELINE_CALENDAR;
|
||||
}
|
||||
|
||||
return encodeTimelinePin(new UUID(calendarEventSpec.type, id), calendarEventSpec.timestamp, (short) calendarEventSpec.durationInSeconds, iconId, calendarEventSpec.title, calendarEventSpec.description);
|
||||
return encodeTimelinePin(new UUID(GB_UUID_MASK | calendarEventSpec.type, id), calendarEventSpec.timestamp, (short) calendarEventSpec.durationInSeconds, iconId, calendarEventSpec.title, calendarEventSpec.description);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] encodeDeleteCalendarEvent(int type, long id) {
|
||||
return encodeBlobdb(new UUID(type, id), BLOBDB_DELETE, BLOBDB_PIN, null);
|
||||
public byte[] encodeDeleteCalendarEvent(byte type, long id) {
|
||||
return encodeBlobdb(new UUID(GB_UUID_MASK | type, id), BLOBDB_DELETE, BLOBDB_PIN, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -129,7 +129,7 @@ public class PebbleSupport extends AbstractSerialDeviceSupport {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeleteCalendarEvent(int type, long id) {
|
||||
public void onDeleteCalendarEvent(byte type, long id) {
|
||||
if (reconnect()) {
|
||||
super.onDeleteCalendarEvent(type, id);
|
||||
}
|
||||
|
@ -196,7 +196,7 @@ public abstract class AbstractSerialDeviceSupport extends AbstractDeviceSupport
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeleteCalendarEvent(int type, long id) {
|
||||
public void onDeleteCalendarEvent(byte type, long id) {
|
||||
byte[] bytes = gbDeviceProtocol.encodeDeleteCalendarEvent(type, id);
|
||||
sendToDevice(bytes);
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ public abstract class GBDeviceProtocol {
|
||||
return null;
|
||||
}
|
||||
|
||||
public byte[] encodeDeleteCalendarEvent(int type, long id) {
|
||||
public byte[] encodeDeleteCalendarEvent(byte type, long id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -137,7 +137,7 @@ public class TestDeviceSupport extends AbstractDeviceSupport {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeleteCalendarEvent(int type, long id) {
|
||||
public void onDeleteCalendarEvent(byte type, long id) {
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user