mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-26 10:35:50 +01:00
Huami: Make experimental calendar sync feature optional
This commit is contained in:
parent
1b416e18b9
commit
9a114f640b
@ -23,4 +23,5 @@ public class DeviceSettingsPreferenceConst {
|
|||||||
public static final String PREF_SCREEN_ORIENTATION = "screen_orientation";
|
public static final String PREF_SCREEN_ORIENTATION = "screen_orientation";
|
||||||
public static final String PREF_RESERVER_ALARMS_CALENDAR = "reserve_alarms_calendar";
|
public static final String PREF_RESERVER_ALARMS_CALENDAR = "reserve_alarms_calendar";
|
||||||
public static final String PREF_ALLOW_HIGH_MTU = "allow_high_mtu";
|
public static final String PREF_ALLOW_HIGH_MTU = "allow_high_mtu";
|
||||||
|
public static final String PREF_SYNC_CALENDAR = "sync_calendar";
|
||||||
}
|
}
|
@ -86,6 +86,7 @@ public class AmazfitBipCoordinator extends HuamiCoordinator {
|
|||||||
R.xml.devicesettings_custom_emoji_font,
|
R.xml.devicesettings_custom_emoji_font,
|
||||||
R.xml.devicesettings_liftwrist_display,
|
R.xml.devicesettings_liftwrist_display,
|
||||||
R.xml.devicesettings_disconnectnotification,
|
R.xml.devicesettings_disconnectnotification,
|
||||||
|
R.xml.devicesettings_sync_calendar,
|
||||||
R.xml.devicesettings_expose_hr_thirdparty,
|
R.xml.devicesettings_expose_hr_thirdparty,
|
||||||
R.xml.devicesettings_buttonactions_with_longpress,
|
R.xml.devicesettings_buttonactions_with_longpress,
|
||||||
R.xml.devicesettings_pairingkey
|
R.xml.devicesettings_pairingkey
|
||||||
|
@ -89,6 +89,7 @@ public class AmazfitCorCoordinator extends HuamiCoordinator {
|
|||||||
R.xml.devicesettings_custom_emoji_font,
|
R.xml.devicesettings_custom_emoji_font,
|
||||||
R.xml.devicesettings_liftwrist_display,
|
R.xml.devicesettings_liftwrist_display,
|
||||||
R.xml.devicesettings_disconnectnotification,
|
R.xml.devicesettings_disconnectnotification,
|
||||||
|
R.xml.devicesettings_sync_calendar,
|
||||||
R.xml.devicesettings_expose_hr_thirdparty,
|
R.xml.devicesettings_expose_hr_thirdparty,
|
||||||
R.xml.devicesettings_pairingkey
|
R.xml.devicesettings_pairingkey
|
||||||
};
|
};
|
||||||
|
@ -91,6 +91,7 @@ public class AmazfitCor2Coordinator extends HuamiCoordinator {
|
|||||||
R.xml.devicesettings_custom_emoji_font,
|
R.xml.devicesettings_custom_emoji_font,
|
||||||
R.xml.devicesettings_liftwrist_display,
|
R.xml.devicesettings_liftwrist_display,
|
||||||
R.xml.devicesettings_disconnectnotification,
|
R.xml.devicesettings_disconnectnotification,
|
||||||
|
R.xml.devicesettings_sync_calendar,
|
||||||
R.xml.devicesettings_expose_hr_thirdparty,
|
R.xml.devicesettings_expose_hr_thirdparty,
|
||||||
R.xml.devicesettings_pairingkey
|
R.xml.devicesettings_pairingkey
|
||||||
};
|
};
|
||||||
|
@ -93,6 +93,7 @@ public class AmazfitGTRCoordinator extends HuamiCoordinator {
|
|||||||
R.xml.devicesettings_timeformat,
|
R.xml.devicesettings_timeformat,
|
||||||
R.xml.devicesettings_liftwrist_display,
|
R.xml.devicesettings_liftwrist_display,
|
||||||
R.xml.devicesettings_disconnectnotification,
|
R.xml.devicesettings_disconnectnotification,
|
||||||
|
R.xml.devicesettings_sync_calendar,
|
||||||
R.xml.devicesettings_expose_hr_thirdparty,
|
R.xml.devicesettings_expose_hr_thirdparty,
|
||||||
R.xml.devicesettings_pairingkey
|
R.xml.devicesettings_pairingkey
|
||||||
};
|
};
|
||||||
|
@ -93,6 +93,7 @@ public class AmazfitGTSCoordinator extends HuamiCoordinator {
|
|||||||
R.xml.devicesettings_timeformat,
|
R.xml.devicesettings_timeformat,
|
||||||
R.xml.devicesettings_liftwrist_display,
|
R.xml.devicesettings_liftwrist_display,
|
||||||
R.xml.devicesettings_disconnectnotification,
|
R.xml.devicesettings_disconnectnotification,
|
||||||
|
R.xml.devicesettings_sync_calendar,
|
||||||
R.xml.devicesettings_expose_hr_thirdparty,
|
R.xml.devicesettings_expose_hr_thirdparty,
|
||||||
R.xml.devicesettings_pairingkey
|
R.xml.devicesettings_pairingkey
|
||||||
};
|
};
|
||||||
|
@ -110,6 +110,7 @@ public class MiBand3Coordinator extends HuamiCoordinator {
|
|||||||
R.xml.devicesettings_donotdisturb_withauto,
|
R.xml.devicesettings_donotdisturb_withauto,
|
||||||
R.xml.devicesettings_liftwrist_display,
|
R.xml.devicesettings_liftwrist_display,
|
||||||
R.xml.devicesettings_swipeunlock,
|
R.xml.devicesettings_swipeunlock,
|
||||||
|
R.xml.devicesettings_sync_calendar,
|
||||||
R.xml.devicesettings_expose_hr_thirdparty,
|
R.xml.devicesettings_expose_hr_thirdparty,
|
||||||
R.xml.devicesettings_pairingkey
|
R.xml.devicesettings_pairingkey
|
||||||
};
|
};
|
||||||
|
@ -96,6 +96,7 @@ public class MiBand4Coordinator extends HuamiCoordinator {
|
|||||||
R.xml.devicesettings_nightmode,
|
R.xml.devicesettings_nightmode,
|
||||||
R.xml.devicesettings_liftwrist_display,
|
R.xml.devicesettings_liftwrist_display,
|
||||||
R.xml.devicesettings_swipeunlock,
|
R.xml.devicesettings_swipeunlock,
|
||||||
|
R.xml.devicesettings_sync_calendar,
|
||||||
R.xml.devicesettings_expose_hr_thirdparty,
|
R.xml.devicesettings_expose_hr_thirdparty,
|
||||||
R.xml.devicesettings_pairingkey,
|
R.xml.devicesettings_pairingkey,
|
||||||
R.xml.devicesettings_high_mtu
|
R.xml.devicesettings_high_mtu
|
||||||
|
@ -137,6 +137,7 @@ import nodomain.freeyourgadget.gadgetbridge.util.Version;
|
|||||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_ALLOW_HIGH_MTU;
|
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_ALLOW_HIGH_MTU;
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_DATEFORMAT;
|
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_DATEFORMAT;
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_RESERVER_ALARMS_CALENDAR;
|
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_RESERVER_ALARMS_CALENDAR;
|
||||||
|
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SYNC_CALENDAR;
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_TIMEFORMAT;
|
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_TIMEFORMAT;
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_WEARLOCATION;
|
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_WEARLOCATION;
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.DEFAULT_VALUE_VIBRATION_COUNT;
|
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.DEFAULT_VALUE_VIBRATION_COUNT;
|
||||||
@ -738,11 +739,10 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport {
|
|||||||
setCurrentTimeWithService(builder);
|
setCurrentTimeWithService(builder);
|
||||||
//TODO: once we have a common strategy for sending events (e.g. EventHandler), remove this call from here. Meanwhile it does no harm.
|
//TODO: once we have a common strategy for sending events (e.g. EventHandler), remove this call from here. Meanwhile it does no harm.
|
||||||
// = we should genaralize the pebble calender code
|
// = we should genaralize the pebble calender code
|
||||||
if (characteristicChunked == null) {
|
if (characteristicChunked == null) { // all except Mi Band 2
|
||||||
sendCalendarEvents(builder);
|
sendCalendarEvents(builder);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// TODO: make this configurable
|
|
||||||
sendCalendarEventsAsReminder(builder);
|
sendCalendarEventsAsReminder(builder);
|
||||||
}
|
}
|
||||||
builder.queue(getQueue());
|
builder.queue(getQueue());
|
||||||
@ -1707,6 +1707,11 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private HuamiSupport sendCalendarEventsAsReminder(TransactionBuilder builder) {
|
private HuamiSupport sendCalendarEventsAsReminder(TransactionBuilder builder) {
|
||||||
|
boolean syncCalendar = GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress()).getBoolean(PREF_SYNC_CALENDAR, false);
|
||||||
|
if (!syncCalendar) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
CalendarEvents upcomingEvents = new CalendarEvents();
|
CalendarEvents upcomingEvents = new CalendarEvents();
|
||||||
List<CalendarEvents.CalendarEvent> calendarEvents = upcomingEvents.getCalendarEventList(getContext());
|
List<CalendarEvents.CalendarEvent> calendarEvents = upcomingEvents.getCalendarEventList(getContext());
|
||||||
Calendar calendar = Calendar.getInstance();
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
@ -182,6 +182,8 @@
|
|||||||
<string name="pref_summary_use_custom_font">Enable this if your device has a custom font firmware for emoji support</string>
|
<string name="pref_summary_use_custom_font">Enable this if your device has a custom font firmware for emoji support</string>
|
||||||
<string name="pref_title_allow_high_mtu">Allow high MTU</string>
|
<string name="pref_title_allow_high_mtu">Allow high MTU</string>
|
||||||
<string name="pref_summary_allow_high_mtu">Increases transfer speed, but might not work on some Android devices.</string>
|
<string name="pref_summary_allow_high_mtu">Increases transfer speed, but might not work on some Android devices.</string>
|
||||||
|
<string name="pref_summary_sync_calendar">Enables calendar alerts, even when disconnected</string>
|
||||||
|
<string name="pref_title_sync_caldendar">Sync calendar events</string>
|
||||||
<string name="pref_display_add_device_fab">Connect new device button</string>
|
<string name="pref_display_add_device_fab">Connect new device button</string>
|
||||||
<string name="pref_display_add_device_fab_on">Always visible</string>
|
<string name="pref_display_add_device_fab_on">Always visible</string>
|
||||||
<string name="pref_display_add_device_fab_off">Visible only if no device is added</string>
|
<string name="pref_display_add_device_fab_off">Visible only if no device is added</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user