mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-09-01 03:55:47 +02:00
fix reserved Reminder slots for non-Huami Devices
This commit is contained in:
parent
21aff699a7
commit
e5438a856e
@ -55,6 +55,7 @@ import nodomain.freeyourgadget.gadgetbridge.entities.User;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.DeviceService;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.GBPrefs;
|
||||
|
||||
|
||||
public class ConfigureReminders extends AbstractGBActivity {
|
||||
@ -100,10 +101,9 @@ public class ConfigureReminders extends AbstractGBActivity {
|
||||
public void onClick(View v) {
|
||||
final DeviceCoordinator coordinator = gbDevice.getDeviceCoordinator();
|
||||
|
||||
final Prefs prefs = new Prefs(GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress()));
|
||||
int reservedSlots = prefs.getInt(DeviceSettingsPreferenceConst.PREF_RESERVER_REMINDERS_CALENDAR, coordinator.supportsCalendarEvents() ? 0 : 9);
|
||||
final GBPrefs prefs = new GBPrefs(new Prefs(GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress())));
|
||||
|
||||
int deviceSlots = coordinator.getReminderSlotCount(gbDevice) - reservedSlots;
|
||||
int deviceSlots = coordinator.getReminderSlotCount(gbDevice) - prefs.getReservedReminderCalendarSlots(gbDevice);
|
||||
|
||||
if (mGBReminderListAdapter.getItemCount() >= deviceSlots) {
|
||||
// No more free slots
|
||||
|
@ -79,7 +79,7 @@ public class DeviceSettingsPreferenceConst {
|
||||
public static final String PREF_SCREEN_ORIENTATION = "screen_orientation";
|
||||
public static final String PREF_SCREEN_TIMEOUT = "screen_timeout";
|
||||
public static final String PREF_RESERVER_ALARMS_CALENDAR = "reserve_alarms_calendar";
|
||||
public static final String PREF_RESERVER_REMINDERS_CALENDAR = "reserve_reminders_calendar";
|
||||
public static final String PREF_RESERVE_REMINDERS_CALENDAR = "reserve_reminders_calendar";
|
||||
public static final String PREF_ALLOW_HIGH_MTU = "allow_high_mtu";
|
||||
public static final String PREF_SYNC_CALENDAR = "sync_calendar";
|
||||
public static final String PREF_TIME_SYNC = "time_sync";
|
||||
|
@ -1123,7 +1123,7 @@ public class DeviceSpecificSettingsFragment extends AbstractPreferenceFragment i
|
||||
setInputTypeFor(MiBandConst.PREF_MIBAND_DEVICE_TIME_OFFSET_HOURS, InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED);
|
||||
setInputTypeFor(DeviceSettingsPreferenceConst.PREF_FIND_PHONE_DURATION, InputType.TYPE_CLASS_NUMBER);
|
||||
setInputTypeFor(DeviceSettingsPreferenceConst.PREF_RESERVER_ALARMS_CALENDAR, InputType.TYPE_CLASS_NUMBER);
|
||||
setInputTypeFor(DeviceSettingsPreferenceConst.PREF_RESERVER_REMINDERS_CALENDAR, InputType.TYPE_CLASS_NUMBER);
|
||||
setInputTypeFor(DeviceSettingsPreferenceConst.PREF_RESERVE_REMINDERS_CALENDAR, InputType.TYPE_CLASS_NUMBER);
|
||||
setInputTypeFor(DeviceSettingsPreferenceConst.PREF_INACTIVITY_THRESHOLD, InputType.TYPE_CLASS_NUMBER);
|
||||
setInputTypeFor(DeviceSettingsPreferenceConst.PREF_DEVICE_GPS_UPDATE_INTERVAL, InputType.TYPE_CLASS_NUMBER);
|
||||
setInputTypeFor(DeviceSettingsPreferenceConst.PREF_BANGLEJS_TEXT_BITMAP_SIZE, InputType.TYPE_CLASS_NUMBER);
|
||||
|
@ -74,6 +74,7 @@ import nodomain.freeyourgadget.gadgetbridge.util.DateTimeUtils;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.DeviceHelper;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.FileUtils;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.GBPrefs;
|
||||
|
||||
|
||||
/**
|
||||
@ -594,7 +595,7 @@ public class DBHelper {
|
||||
@NonNull
|
||||
public static List<Alarm> getAlarms(@NonNull GBDevice gbDevice) {
|
||||
DeviceCoordinator coordinator = gbDevice.getDeviceCoordinator();
|
||||
Prefs prefs = new Prefs(GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress()));
|
||||
GBPrefs prefs = new GBPrefs(new Prefs(GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress())));
|
||||
|
||||
int reservedSlots = prefs.getInt(DeviceSettingsPreferenceConst.PREF_RESERVER_ALARMS_CALENDAR, 0);
|
||||
int alarmSlots = coordinator.getAlarmSlotCount(gbDevice);
|
||||
@ -637,10 +638,9 @@ public class DBHelper {
|
||||
@NonNull
|
||||
public static List<Reminder> getReminders(@NonNull GBDevice gbDevice) {
|
||||
final DeviceCoordinator coordinator = gbDevice.getDeviceCoordinator();
|
||||
final Prefs prefs = new Prefs(GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress()));
|
||||
|
||||
int reservedSlots = prefs.getInt(DeviceSettingsPreferenceConst.PREF_RESERVER_REMINDERS_CALENDAR, coordinator.supportsCalendarEvents() ? 0 : 9);
|
||||
final GBPrefs prefs = new GBPrefs(new Prefs(GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress())));
|
||||
|
||||
final int reservedSlots = prefs.getReservedReminderCalendarSlots(gbDevice);
|
||||
final int reminderSlots = coordinator.getReminderSlotCount(gbDevice);
|
||||
|
||||
try (DBHandler db = GBApplication.acquireDB()) {
|
||||
|
@ -1,7 +1,7 @@
|
||||
/* Copyright (C) 2015-2024 akasaka / Genjitsu Labs, Alicia Hormann, Andreas
|
||||
Shimokawa, Arjan Schrijver, Carsten Pfeiffer, Daniel Dakhno, Daniele Gobbetti,
|
||||
Davis Mosenkovs, Dmitry Markin, José Rebelo, Matthieu Baerts, Nephiel,
|
||||
Petr Vaněk, Taavi Eomäe
|
||||
Petr Vaněk, Taavi Eomäe, Johannes Krude
|
||||
|
||||
This file is part of Gadgetbridge.
|
||||
|
||||
@ -566,6 +566,11 @@ public abstract class AbstractDeviceCoordinator implements DeviceCoordinator {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getReserveReminderSlotsForCalendar() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCannedRepliesSlotCount(final GBDevice device) {
|
||||
return 0;
|
||||
|
@ -1,7 +1,7 @@
|
||||
/* Copyright (C) 2015-2024 akasaka / Genjitsu Labs, Alicia Hormann, Andreas
|
||||
Böhler, Andreas Shimokawa, Arjan Schrijver, Carsten Pfeiffer, Damien Gaignon,
|
||||
Daniel Dakhno, Daniele Gobbetti, Dmitry Markin, JohnnySun, José Rebelo,
|
||||
Matthieu Baerts, Nephiel, Petr Vaněk, Uwe Hermann
|
||||
Matthieu Baerts, Nephiel, Petr Vaněk, Uwe Hermann, Johannes Krude
|
||||
|
||||
This file is part of Gadgetbridge.
|
||||
|
||||
@ -586,6 +586,11 @@ public interface DeviceCoordinator {
|
||||
*/
|
||||
int getReminderSlotCount(GBDevice device);
|
||||
|
||||
/**
|
||||
* Indicates whether some reminder slots are used for calendar events.
|
||||
*/
|
||||
boolean getReserveReminderSlotsForCalendar();
|
||||
|
||||
/**
|
||||
* Indicates the maximum number of canned replies available in the device.
|
||||
*/
|
||||
|
@ -550,6 +550,11 @@ public abstract class HuamiCoordinator extends AbstractBLEDeviceCoordinator {
|
||||
return 22; // At least, Mi Fit still allows more
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getReserveReminderSlotsForCalendar() {
|
||||
return !supportsCalendarEvents();
|
||||
}
|
||||
|
||||
public boolean supportsDebugLogs() {
|
||||
return true;
|
||||
}
|
||||
|
@ -222,7 +222,6 @@ import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.Dev
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_INACTIVITY_DND_END;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_LANGUAGE;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_RESERVER_ALARMS_CALENDAR;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_RESERVER_REMINDERS_CALENDAR;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SOUNDS;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SYNC_CALENDAR;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_TIMEFORMAT;
|
||||
@ -1030,8 +1029,8 @@ public abstract class HuamiSupport extends AbstractBTLEDeviceSupport implements
|
||||
private void sendReminders(final TransactionBuilder builder, final List<? extends Reminder> reminders) {
|
||||
final DeviceCoordinator coordinator = gbDevice.getDeviceCoordinator();
|
||||
|
||||
final Prefs prefs = new Prefs(GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress()));
|
||||
int reservedSlots = prefs.getInt(PREF_RESERVER_REMINDERS_CALENDAR, coordinator.supportsCalendarEvents() ? 0 : 9);
|
||||
final GBPrefs prefs = new GBPrefs(new Prefs(GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress())));
|
||||
int reservedSlots = prefs.getReservedReminderCalendarSlots(gbDevice);
|
||||
LOG.info("On Set Reminders. Reminders: {}, Reserved slots: {}", reminders.size(), reservedSlots);
|
||||
|
||||
// Send the reminders, skipping the reserved slots for calendar events
|
||||
@ -2757,8 +2756,8 @@ public abstract class HuamiSupport extends AbstractBTLEDeviceSupport implements
|
||||
}
|
||||
final DeviceCoordinator coordinator = gbDevice.getDeviceCoordinator();
|
||||
|
||||
final Prefs prefs = new Prefs(GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress()));
|
||||
int availableSlots = prefs.getInt(PREF_RESERVER_REMINDERS_CALENDAR, coordinator.supportsCalendarEvents() ? 0 : 9);
|
||||
final GBPrefs prefs = new GBPrefs(new Prefs(GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress())));
|
||||
int availableSlots = prefs.getReservedReminderCalendarSlots(gbDevice);
|
||||
|
||||
CalendarManager upcomingEvents = new CalendarManager(getContext(), getDevice().getAddress());
|
||||
List<CalendarEvent> calendarEvents = upcomingEvents.getCalendarEventList();
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* Copyright (C) 2016-2024 Andreas Shimokawa, Anemograph, Carsten Pfeiffer,
|
||||
Daniel Dakhno, Daniele Gobbetti, Davis Mosenkovs, Dikay900, Felix Konstantin
|
||||
Maurer, José Rebelo, Petr Vaněk
|
||||
Maurer, José Rebelo, Petr Vaněk, Johannes Krude
|
||||
|
||||
This file is part of Gadgetbridge.
|
||||
|
||||
@ -187,6 +187,14 @@ public class GBPrefs extends Prefs {
|
||||
return getLocalTime("notification_times_end", "22:00");
|
||||
}
|
||||
|
||||
public int getReservedReminderCalendarSlots(GBDevice gbDevice) {
|
||||
if (!gbDevice.getDeviceCoordinator().getReserveReminderSlotsForCalendar())
|
||||
return 0;
|
||||
if (!getBoolean(DeviceSettingsPreferenceConst.PREF_SYNC_CALENDAR, false))
|
||||
return 0;
|
||||
return getInt(DeviceSettingsPreferenceConst.PREF_RESERVE_REMINDERS_CALENDAR, 9);
|
||||
}
|
||||
|
||||
public boolean isMetricUnits() {
|
||||
return getString(SettingsActivity.PREF_MEASUREMENT_SYSTEM, "metric").equals("metric");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user