mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-28 11:35:48 +01:00
Add GBDevice argument to getAlarmSlotCount
This commit is contained in:
parent
be575af314
commit
a3c0e10330
@ -120,7 +120,7 @@ public class ConfigureAlarms extends AbstractGBActivity {
|
||||
|
||||
private void addMissingAlarms(List<Alarm> alarms) {
|
||||
DeviceCoordinator coordinator = DeviceHelper.getInstance().getCoordinator(getGbDevice());
|
||||
int supportedNumAlarms = coordinator.getAlarmSlotCount();
|
||||
int supportedNumAlarms = coordinator.getAlarmSlotCount(getGbDevice());
|
||||
if (supportedNumAlarms > alarms.size()) {
|
||||
try (DBHandler db = GBApplication.acquireDB()) {
|
||||
DaoSession daoSession = db.getDaoSession();
|
||||
|
@ -126,7 +126,7 @@ public class SleepAlarmWidgetConfigurationActivity extends Activity {
|
||||
Device dbDevice = DBHelper.findDevice(device, daoSession);
|
||||
int icon = device.isInitialized() ? device.getType().getIcon() : device.getType().getDisabledIcon();
|
||||
if (dbDevice != null && coordinator != null
|
||||
&& (coordinator.getAlarmSlotCount() > 0)
|
||||
&& (coordinator.getAlarmSlotCount(device) > 0)
|
||||
&& !newMap.containsKey(device.getAliasOrName())) {
|
||||
newMap.put(device.getAliasOrName(), new Pair(device.getAddress(), icon));
|
||||
}
|
||||
|
@ -456,7 +456,7 @@ public class GBDeviceAdapterv2 extends ListAdapter<GBDevice, GBDeviceAdapterv2.V
|
||||
);
|
||||
|
||||
//set alarms
|
||||
holder.setAlarmsView.setVisibility(coordinator.getAlarmSlotCount() > 0 ? View.VISIBLE : View.GONE);
|
||||
holder.setAlarmsView.setVisibility(coordinator.getAlarmSlotCount(device) > 0 ? View.VISIBLE : View.GONE);
|
||||
holder.setAlarmsView.setOnClickListener(new View.OnClickListener()
|
||||
|
||||
{
|
||||
|
@ -596,7 +596,7 @@ public class DBHelper {
|
||||
Prefs prefs = new Prefs(GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress()));
|
||||
|
||||
int reservedSlots = prefs.getInt(DeviceSettingsPreferenceConst.PREF_RESERVER_ALARMS_CALENDAR, 0);
|
||||
int alarmSlots = coordinator.getAlarmSlotCount();
|
||||
int alarmSlots = coordinator.getAlarmSlotCount(gbDevice);
|
||||
|
||||
try (DBHandler db = GBApplication.acquireDB()) {
|
||||
DaoSession daoSession = db.getDaoSession();
|
||||
|
@ -323,7 +323,7 @@ public interface DeviceCoordinator {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
int getAlarmSlotCount();
|
||||
int getAlarmSlotCount(GBDevice device);
|
||||
|
||||
/**
|
||||
* Returns true if this device/coordinator supports alarms with smart wakeup
|
||||
|
@ -146,7 +146,7 @@ public class UnknownDeviceCoordinator extends AbstractDeviceCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAlarmSlotCount() {
|
||||
public int getAlarmSlotCount(GBDevice device) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -138,7 +138,7 @@ public class AsteroidOSDeviceCoordinator extends AbstractDeviceCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAlarmSlotCount() {
|
||||
public int getAlarmSlotCount(GBDevice device) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -151,7 +151,7 @@ public class BangleJSCoordinator extends AbstractBLEDeviceCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAlarmSlotCount() {
|
||||
public int getAlarmSlotCount(GBDevice device) {
|
||||
return 10;
|
||||
}
|
||||
|
||||
|
@ -101,7 +101,7 @@ public class BinarySensorCoordinator extends AbstractBLEDeviceCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAlarmSlotCount() {
|
||||
public int getAlarmSlotCount(GBDevice device) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -118,7 +118,7 @@ public class CasioGB6900DeviceCoordinator extends AbstractBLEDeviceCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAlarmSlotCount() {
|
||||
public int getAlarmSlotCount(GBDevice device) {
|
||||
return 5; // 4 regular and one snooze
|
||||
}
|
||||
|
||||
|
@ -122,7 +122,7 @@ public class CasioGBX100DeviceCoordinator extends AbstractBLEDeviceCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAlarmSlotCount() {
|
||||
public int getAlarmSlotCount(GBDevice device) {
|
||||
return 4;
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,7 @@ public class DomyosT540Coordinator extends AbstractBLEDeviceCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAlarmSlotCount() {
|
||||
public int getAlarmSlotCount(GBDevice device) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -123,7 +123,7 @@ public class FitProDeviceCoordinator extends AbstractBLEDeviceCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAlarmSlotCount() {
|
||||
public int getAlarmSlotCount(GBDevice device) {
|
||||
return 8;
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ public class FlipperZeroCoordinator extends AbstractBLEDeviceCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAlarmSlotCount() {
|
||||
public int getAlarmSlotCount(GBDevice device) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@ public abstract class GalaxyBudsGenericCoordinator extends AbstractBLClassicDevi
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAlarmSlotCount() {
|
||||
public int getAlarmSlotCount(GBDevice device) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -141,7 +141,7 @@ public class HPlusCoordinator extends AbstractBLEDeviceCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAlarmSlotCount() {
|
||||
public int getAlarmSlotCount(GBDevice device) {
|
||||
return 3; // FIXME - check the real value
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,7 @@ public abstract class HuamiCoordinator extends AbstractBLEDeviceCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAlarmSlotCount() {
|
||||
public int getAlarmSlotCount(GBDevice device) {
|
||||
return 10;
|
||||
}
|
||||
|
||||
|
@ -106,7 +106,7 @@ public class ID115Coordinator extends AbstractBLEDeviceCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAlarmSlotCount() {
|
||||
public int getAlarmSlotCount(GBDevice device) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -106,7 +106,7 @@ public class ITagCoordinator extends AbstractBLEDeviceCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAlarmSlotCount() {
|
||||
public int getAlarmSlotCount(GBDevice device) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -122,7 +122,7 @@ public class BFH16DeviceCoordinator extends AbstractBLEDeviceCoordinator
|
||||
//Supported ________________________________________________________
|
||||
|
||||
@Override
|
||||
public int getAlarmSlotCount()
|
||||
public int getAlarmSlotCount(GBDevice device)
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
@ -142,7 +142,7 @@ public class TeclastH30Coordinator extends AbstractBLEDeviceCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAlarmSlotCount() {
|
||||
public int getAlarmSlotCount(GBDevice device) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
|
@ -98,7 +98,7 @@ public class Y5Coordinator extends AbstractBLEDeviceCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAlarmSlotCount() {
|
||||
public int getAlarmSlotCount(GBDevice device) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
|
@ -109,7 +109,7 @@ public class LefunDeviceCoordinator extends AbstractBLEDeviceCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAlarmSlotCount() {
|
||||
public int getAlarmSlotCount(GBDevice device) {
|
||||
return NUM_ALARM_SLOTS;
|
||||
}
|
||||
|
||||
|
@ -141,7 +141,7 @@ public class WatchXPlusDeviceCoordinator extends AbstractBLEDeviceCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAlarmSlotCount() {
|
||||
public int getAlarmSlotCount(GBDevice device) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,7 @@ public class LiveviewCoordinator extends AbstractBLClassicDeviceCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAlarmSlotCount() {
|
||||
public int getAlarmSlotCount(GBDevice device) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -236,7 +236,7 @@ public class MakibesHR3Coordinator extends AbstractBLEDeviceCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAlarmSlotCount() {
|
||||
public int getAlarmSlotCount(GBDevice device) {
|
||||
return 8;
|
||||
}
|
||||
|
||||
|
@ -134,7 +134,7 @@ public class MiBandCoordinator extends AbstractBLEDeviceCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAlarmSlotCount() {
|
||||
public int getAlarmSlotCount(GBDevice device) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,7 @@ public class MijiaLywsd02Coordinator extends AbstractBLEDeviceCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAlarmSlotCount() {
|
||||
public int getAlarmSlotCount(GBDevice device) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -125,7 +125,7 @@ public class MiScale2DeviceCoordinator extends AbstractBLEDeviceCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAlarmSlotCount() {
|
||||
public int getAlarmSlotCount(GBDevice device) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -106,7 +106,7 @@ public class No1F1Coordinator extends AbstractBLEDeviceCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAlarmSlotCount() {
|
||||
public int getAlarmSlotCount(GBDevice device) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ public class Ear1Coordinator extends AbstractBLClassicDeviceCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAlarmSlotCount() {
|
||||
public int getAlarmSlotCount(GBDevice device) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -108,7 +108,7 @@ public class NutCoordinator extends AbstractBLEDeviceCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAlarmSlotCount() {
|
||||
public int getAlarmSlotCount(GBDevice device) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -126,7 +126,7 @@ public class PebbleCoordinator extends AbstractBLClassicDeviceCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAlarmSlotCount() {
|
||||
public int getAlarmSlotCount(GBDevice device) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,7 @@ public class PineTimeJFCoordinator extends AbstractBLEDeviceCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAlarmSlotCount() {
|
||||
public int getAlarmSlotCount(GBDevice device) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,7 @@ public class QC35Coordinator extends AbstractBLClassicDeviceCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAlarmSlotCount() {
|
||||
public int getAlarmSlotCount(GBDevice device) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -149,7 +149,7 @@ public class QHybridCoordinator extends AbstractBLEDeviceCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAlarmSlotCount() {
|
||||
public int getAlarmSlotCount(GBDevice device) {
|
||||
return this.supportsAlarmConfiguration() ? 5 : 0;
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,7 @@ public abstract class RoidmiCoordinator extends AbstractBLClassicDeviceCoordinat
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAlarmSlotCount() {
|
||||
public int getAlarmSlotCount(GBDevice device) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -102,7 +102,7 @@ public class SMAQ2OSSCoordinator extends AbstractBLEDeviceCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAlarmSlotCount() {
|
||||
public int getAlarmSlotCount(GBDevice device) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,7 @@ public class SoFlowCoordinator extends AbstractBLEDeviceCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAlarmSlotCount() {
|
||||
public int getAlarmSlotCount(GBDevice device) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -91,7 +91,7 @@ public abstract class SonyHeadphonesCoordinator extends AbstractBLClassicDeviceC
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAlarmSlotCount() {
|
||||
public int getAlarmSlotCount(GBDevice device) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -96,7 +96,7 @@ public class SonySWR12DeviceCoordinator extends AbstractBLEDeviceCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAlarmSlotCount() {
|
||||
public int getAlarmSlotCount(GBDevice device) {
|
||||
return 5;
|
||||
}
|
||||
|
||||
|
@ -100,7 +100,7 @@ public class SuperCarsCoordinator extends AbstractDeviceCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAlarmSlotCount() {
|
||||
public int getAlarmSlotCount(GBDevice device) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -91,7 +91,7 @@ public class TLW64Coordinator extends AbstractBLEDeviceCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAlarmSlotCount() {
|
||||
public int getAlarmSlotCount(GBDevice device) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
|
@ -101,7 +101,7 @@ public class UM25Coordinator extends AbstractBLEDeviceCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAlarmSlotCount() {
|
||||
public int getAlarmSlotCount(GBDevice device) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,7 @@ public class VescCoordinator extends AbstractBLEDeviceCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAlarmSlotCount() {
|
||||
public int getAlarmSlotCount(GBDevice device) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,7 @@ public class VibratissimoCoordinator extends AbstractBLEDeviceCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAlarmSlotCount() {
|
||||
public int getAlarmSlotCount(GBDevice device) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -136,7 +136,7 @@ public class WaspOSCoordinator extends AbstractBLEDeviceCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAlarmSlotCount() {
|
||||
public int getAlarmSlotCount(GBDevice device) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -114,7 +114,7 @@ public class Watch9DeviceCoordinator extends AbstractBLEDeviceCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAlarmSlotCount() {
|
||||
public int getAlarmSlotCount(GBDevice device) {
|
||||
return 3; // FIXME - check the real value
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ public class XWatchCoordinator extends AbstractBLEDeviceCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAlarmSlotCount() {
|
||||
public int getAlarmSlotCount(GBDevice device) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -73,7 +73,7 @@ public class ZeTimeCoordinator extends AbstractBLEDeviceCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAlarmSlotCount() {
|
||||
public int getAlarmSlotCount(GBDevice device) {
|
||||
return 3; // FIXME - check the real value
|
||||
}
|
||||
|
||||
|
@ -843,7 +843,7 @@ public abstract class HuamiSupport extends AbstractBTLEDeviceSupport implements
|
||||
@Override
|
||||
public void onSetAlarms(ArrayList<? extends Alarm> alarms) {
|
||||
final DeviceCoordinator coordinator = DeviceHelper.getInstance().getCoordinator(gbDevice);
|
||||
int maxAlarms = coordinator.getAlarmSlotCount();
|
||||
int maxAlarms = coordinator.getAlarmSlotCount(gbDevice);
|
||||
|
||||
try {
|
||||
TransactionBuilder builder = performInitialized("Set alarm");
|
||||
@ -2674,7 +2674,7 @@ public abstract class HuamiSupport extends AbstractBTLEDeviceSupport implements
|
||||
private HuamiSupport sendCalendarEventsAsAlarms(TransactionBuilder builder) {
|
||||
DeviceCoordinator coordinator = DeviceHelper.getInstance().getCoordinator(gbDevice);
|
||||
Prefs prefs = new Prefs(GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress()));
|
||||
int maxAlarms = coordinator.getAlarmSlotCount();
|
||||
int maxAlarms = coordinator.getAlarmSlotCount(gbDevice);
|
||||
int availableSlots = Math.min(prefs.getInt(PREF_RESERVER_ALARMS_CALENDAR, 0), maxAlarms);
|
||||
|
||||
if (availableSlots <= 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user