mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-01-10 17:11:56 +01:00
Xiaomi: Fetch alarm and reminder slots from watch
This commit is contained in:
parent
5f9fda4f07
commit
95d3ff81fd
@ -33,6 +33,7 @@ import java.util.UUID;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.BuildConfig;
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBException;
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.appmanager.AppManagerActivity;
|
||||
@ -56,8 +57,10 @@ import nodomain.freeyourgadget.gadgetbridge.model.Spo2Sample;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.StressSample;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.xiaomi.XiaomiBleUuids;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.xiaomi.XiaomiPreferences;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.xiaomi.XiaomiSupport;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.xiaomi.activity.impl.WorkoutSummaryParser;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
|
||||
|
||||
public abstract class XiaomiCoordinator extends AbstractBLEDeviceCoordinator {
|
||||
// On plaintext devices, user id is used as auth key - numeric
|
||||
@ -158,8 +161,7 @@ public abstract class XiaomiCoordinator extends AbstractBLEDeviceCoordinator {
|
||||
|
||||
@Override
|
||||
public int getAlarmSlotCount(final GBDevice device) {
|
||||
// TODO the watch returns the slot count
|
||||
return 10;
|
||||
return getPrefs(device).getInt(XiaomiPreferences.PREF_ALARM_SLOTS, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -255,11 +257,6 @@ public abstract class XiaomiCoordinator extends AbstractBLEDeviceCoordinator {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsAlarmSnoozing() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsAlarmDescription(final GBDevice device) {
|
||||
// TODO does it?
|
||||
@ -279,8 +276,7 @@ public abstract class XiaomiCoordinator extends AbstractBLEDeviceCoordinator {
|
||||
|
||||
@Override
|
||||
public int getReminderSlotCount(final GBDevice device) {
|
||||
// TODO fetch from watch
|
||||
return 50;
|
||||
return getPrefs(device).getInt(XiaomiPreferences.PREF_REMINDER_SLOTS, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -513,6 +509,10 @@ public abstract class XiaomiCoordinator extends AbstractBLEDeviceCoordinator {
|
||||
return new AbstractNotificationPattern[0];
|
||||
}
|
||||
|
||||
protected static Prefs getPrefs(final GBDevice device) {
|
||||
return new Prefs(GBApplication.getDeviceSpecificSharedPrefs(device.getAddress()));
|
||||
}
|
||||
|
||||
public boolean supportsMultipleWeatherLocations() {
|
||||
return false;
|
||||
}
|
||||
|
@ -81,14 +81,4 @@ public class MiWatchLiteCoordinator extends XiaomiCoordinator {
|
||||
public boolean supportsRealtimeData() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAlarmSlotCount(final GBDevice device) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getReminderSlotCount(final GBDevice device) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -28,6 +28,9 @@ import nodomain.freeyourgadget.gadgetbridge.proto.xiaomi.XiaomiProto;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
|
||||
|
||||
public final class XiaomiPreferences {
|
||||
public static final String PREF_ALARM_SLOTS = "alarm_slots";
|
||||
public static final String PREF_REMINDER_SLOTS = "reminder_slots";
|
||||
|
||||
private XiaomiPreferences() {
|
||||
// util class
|
||||
}
|
||||
|
@ -48,7 +48,6 @@ import nodomain.freeyourgadget.gadgetbridge.model.DeviceService;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.Reminder;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.WorldClock;
|
||||
import nodomain.freeyourgadget.gadgetbridge.proto.xiaomi.XiaomiProto;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.xiaomi.XiaomiPreferences;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.xiaomi.XiaomiSupport;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
|
||||
@ -165,6 +164,11 @@ public class XiaomiScheduleService extends AbstractXiaomiService {
|
||||
public void handleReminders(final XiaomiProto.Reminders reminders) {
|
||||
LOG.debug("Got {} reminders from the watch", reminders.getReminderCount());
|
||||
|
||||
final GBDeviceEventUpdatePreferences eventUpdatePreferences = new GBDeviceEventUpdatePreferences()
|
||||
.withPreference(XiaomiPreferences.PREF_REMINDER_SLOTS, reminders.getMaxReminders());
|
||||
|
||||
getSupport().evaluateGBDeviceEvent(eventUpdatePreferences);
|
||||
|
||||
watchReminders.clear();
|
||||
for (final XiaomiProto.Reminder reminder : reminders.getReminderList()) {
|
||||
final nodomain.freeyourgadget.gadgetbridge.entities.Reminder gbReminder = new nodomain.freeyourgadget.gadgetbridge.entities.Reminder();
|
||||
@ -499,6 +503,11 @@ public class XiaomiScheduleService extends AbstractXiaomiService {
|
||||
public void handleAlarms(final XiaomiProto.Alarms alarms) {
|
||||
LOG.debug("Got {} alarms from the watch", alarms.getAlarmCount());
|
||||
|
||||
final GBDeviceEventUpdatePreferences eventUpdatePreferences = new GBDeviceEventUpdatePreferences()
|
||||
.withPreference(XiaomiPreferences.PREF_ALARM_SLOTS, alarms.getMaxAlarms());
|
||||
|
||||
getSupport().evaluateGBDeviceEvent(eventUpdatePreferences);
|
||||
|
||||
watchAlarms.clear();
|
||||
for (final XiaomiProto.Alarm alarm : alarms.getAlarmList()) {
|
||||
final nodomain.freeyourgadget.gadgetbridge.entities.Alarm gbAlarm = new nodomain.freeyourgadget.gadgetbridge.entities.Alarm();
|
||||
|
@ -825,7 +825,7 @@ message SleepModeSchedule {
|
||||
|
||||
message Reminders {
|
||||
repeated Reminder reminder = 1;
|
||||
optional uint32 unknown2 = 2; // 50, max reminder?
|
||||
optional uint32 maxReminders = 2;
|
||||
}
|
||||
|
||||
message Reminder {
|
||||
|
Loading…
Reference in New Issue
Block a user