1
0
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:
Damien 'Psolyca' Gaignon 2023-06-13 23:02:26 +02:00
parent be575af314
commit a3c0e10330
No known key found for this signature in database
GPG Key ID: 9E9404E5D9E11843
51 changed files with 52 additions and 52 deletions

View File

@ -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();

View File

@ -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));
}

View File

@ -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()
{

View File

@ -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();

View File

@ -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

View File

@ -146,7 +146,7 @@ public class UnknownDeviceCoordinator extends AbstractDeviceCoordinator {
}
@Override
public int getAlarmSlotCount() {
public int getAlarmSlotCount(GBDevice device) {
return 0;
}

View File

@ -138,7 +138,7 @@ public class AsteroidOSDeviceCoordinator extends AbstractDeviceCoordinator {
}
@Override
public int getAlarmSlotCount() {
public int getAlarmSlotCount(GBDevice device) {
return 0;
}

View File

@ -151,7 +151,7 @@ public class BangleJSCoordinator extends AbstractBLEDeviceCoordinator {
}
@Override
public int getAlarmSlotCount() {
public int getAlarmSlotCount(GBDevice device) {
return 10;
}

View File

@ -101,7 +101,7 @@ public class BinarySensorCoordinator extends AbstractBLEDeviceCoordinator {
}
@Override
public int getAlarmSlotCount() {
public int getAlarmSlotCount(GBDevice device) {
return 0;
}

View File

@ -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
}

View File

@ -122,7 +122,7 @@ public class CasioGBX100DeviceCoordinator extends AbstractBLEDeviceCoordinator {
}
@Override
public int getAlarmSlotCount() {
public int getAlarmSlotCount(GBDevice device) {
return 4;
}

View File

@ -80,7 +80,7 @@ public class DomyosT540Coordinator extends AbstractBLEDeviceCoordinator {
}
@Override
public int getAlarmSlotCount() {
public int getAlarmSlotCount(GBDevice device) {
return 0;
}

View File

@ -123,7 +123,7 @@ public class FitProDeviceCoordinator extends AbstractBLEDeviceCoordinator {
}
@Override
public int getAlarmSlotCount() {
public int getAlarmSlotCount(GBDevice device) {
return 8;
}

View File

@ -72,7 +72,7 @@ public class FlipperZeroCoordinator extends AbstractBLEDeviceCoordinator {
}
@Override
public int getAlarmSlotCount() {
public int getAlarmSlotCount(GBDevice device) {
return 0;
}

View File

@ -56,7 +56,7 @@ public abstract class GalaxyBudsGenericCoordinator extends AbstractBLClassicDevi
}
@Override
public int getAlarmSlotCount() {
public int getAlarmSlotCount(GBDevice device) {
return 0;
}

View File

@ -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
}

View File

@ -116,7 +116,7 @@ public abstract class HuamiCoordinator extends AbstractBLEDeviceCoordinator {
}
@Override
public int getAlarmSlotCount() {
public int getAlarmSlotCount(GBDevice device) {
return 10;
}

View File

@ -106,7 +106,7 @@ public class ID115Coordinator extends AbstractBLEDeviceCoordinator {
}
@Override
public int getAlarmSlotCount() {
public int getAlarmSlotCount(GBDevice device) {
return 0;
}

View File

@ -106,7 +106,7 @@ public class ITagCoordinator extends AbstractBLEDeviceCoordinator {
}
@Override
public int getAlarmSlotCount() {
public int getAlarmSlotCount(GBDevice device) {
return 0;
}

View File

@ -122,7 +122,7 @@ public class BFH16DeviceCoordinator extends AbstractBLEDeviceCoordinator
//Supported ________________________________________________________
@Override
public int getAlarmSlotCount()
public int getAlarmSlotCount(GBDevice device)
{
return 3;
}

View File

@ -142,7 +142,7 @@ public class TeclastH30Coordinator extends AbstractBLEDeviceCoordinator {
}
@Override
public int getAlarmSlotCount() {
public int getAlarmSlotCount(GBDevice device) {
return 3;
}

View File

@ -98,7 +98,7 @@ public class Y5Coordinator extends AbstractBLEDeviceCoordinator {
}
@Override
public int getAlarmSlotCount() {
public int getAlarmSlotCount(GBDevice device) {
return 3;
}

View File

@ -109,7 +109,7 @@ public class LefunDeviceCoordinator extends AbstractBLEDeviceCoordinator {
}
@Override
public int getAlarmSlotCount() {
public int getAlarmSlotCount(GBDevice device) {
return NUM_ALARM_SLOTS;
}

View File

@ -141,7 +141,7 @@ public class WatchXPlusDeviceCoordinator extends AbstractBLEDeviceCoordinator {
}
@Override
public int getAlarmSlotCount() {
public int getAlarmSlotCount(GBDevice device) {
return 3;
}

View File

@ -80,7 +80,7 @@ public class LiveviewCoordinator extends AbstractBLClassicDeviceCoordinator {
}
@Override
public int getAlarmSlotCount() {
public int getAlarmSlotCount(GBDevice device) {
return 0;
}

View File

@ -236,7 +236,7 @@ public class MakibesHR3Coordinator extends AbstractBLEDeviceCoordinator {
}
@Override
public int getAlarmSlotCount() {
public int getAlarmSlotCount(GBDevice device) {
return 8;
}

View File

@ -134,7 +134,7 @@ public class MiBandCoordinator extends AbstractBLEDeviceCoordinator {
}
@Override
public int getAlarmSlotCount() {
public int getAlarmSlotCount(GBDevice device) {
return 3;
}

View File

@ -85,7 +85,7 @@ public class MijiaLywsd02Coordinator extends AbstractBLEDeviceCoordinator {
}
@Override
public int getAlarmSlotCount() {
public int getAlarmSlotCount(GBDevice device) {
return 0;
}

View File

@ -125,7 +125,7 @@ public class MiScale2DeviceCoordinator extends AbstractBLEDeviceCoordinator {
}
@Override
public int getAlarmSlotCount() {
public int getAlarmSlotCount(GBDevice device) {
return 0;
}

View File

@ -106,7 +106,7 @@ public class No1F1Coordinator extends AbstractBLEDeviceCoordinator {
}
@Override
public int getAlarmSlotCount() {
public int getAlarmSlotCount(GBDevice device) {
return 3;
}

View File

@ -67,7 +67,7 @@ public class Ear1Coordinator extends AbstractBLClassicDeviceCoordinator {
}
@Override
public int getAlarmSlotCount() {
public int getAlarmSlotCount(GBDevice device) {
return 0;
}

View File

@ -108,7 +108,7 @@ public class NutCoordinator extends AbstractBLEDeviceCoordinator {
}
@Override
public int getAlarmSlotCount() {
public int getAlarmSlotCount(GBDevice device) {
return 0;
}

View File

@ -126,7 +126,7 @@ public class PebbleCoordinator extends AbstractBLClassicDeviceCoordinator {
}
@Override
public int getAlarmSlotCount() {
public int getAlarmSlotCount(GBDevice device) {
return 0;
}

View File

@ -85,7 +85,7 @@ public class PineTimeJFCoordinator extends AbstractBLEDeviceCoordinator {
}
@Override
public int getAlarmSlotCount() {
public int getAlarmSlotCount(GBDevice device) {
return 0;
}

View File

@ -94,7 +94,7 @@ public class QC35Coordinator extends AbstractBLClassicDeviceCoordinator {
}
@Override
public int getAlarmSlotCount() {
public int getAlarmSlotCount(GBDevice device) {
return 0;
}

View File

@ -149,7 +149,7 @@ public class QHybridCoordinator extends AbstractBLEDeviceCoordinator {
}
@Override
public int getAlarmSlotCount() {
public int getAlarmSlotCount(GBDevice device) {
return this.supportsAlarmConfiguration() ? 5 : 0;
}

View File

@ -84,7 +84,7 @@ public abstract class RoidmiCoordinator extends AbstractBLClassicDeviceCoordinat
}
@Override
public int getAlarmSlotCount() {
public int getAlarmSlotCount(GBDevice device) {
return 0;
}

View File

@ -102,7 +102,7 @@ public class SMAQ2OSSCoordinator extends AbstractBLEDeviceCoordinator {
}
@Override
public int getAlarmSlotCount() {
public int getAlarmSlotCount(GBDevice device) {
return 0;
}

View File

@ -80,7 +80,7 @@ public class SoFlowCoordinator extends AbstractBLEDeviceCoordinator {
}
@Override
public int getAlarmSlotCount() {
public int getAlarmSlotCount(GBDevice device) {
return 0;
}

View File

@ -91,7 +91,7 @@ public abstract class SonyHeadphonesCoordinator extends AbstractBLClassicDeviceC
}
@Override
public int getAlarmSlotCount() {
public int getAlarmSlotCount(GBDevice device) {
return 0;
}

View File

@ -96,7 +96,7 @@ public class SonySWR12DeviceCoordinator extends AbstractBLEDeviceCoordinator {
}
@Override
public int getAlarmSlotCount() {
public int getAlarmSlotCount(GBDevice device) {
return 5;
}

View File

@ -100,7 +100,7 @@ public class SuperCarsCoordinator extends AbstractDeviceCoordinator {
}
@Override
public int getAlarmSlotCount() {
public int getAlarmSlotCount(GBDevice device) {
return 0;
}

View File

@ -91,7 +91,7 @@ public class TLW64Coordinator extends AbstractBLEDeviceCoordinator {
}
@Override
public int getAlarmSlotCount() {
public int getAlarmSlotCount(GBDevice device) {
return 3;
}

View File

@ -101,7 +101,7 @@ public class UM25Coordinator extends AbstractBLEDeviceCoordinator {
}
@Override
public int getAlarmSlotCount() {
public int getAlarmSlotCount(GBDevice device) {
return 0;
}

View File

@ -116,7 +116,7 @@ public class VescCoordinator extends AbstractBLEDeviceCoordinator {
}
@Override
public int getAlarmSlotCount() {
public int getAlarmSlotCount(GBDevice device) {
return 0;
}

View File

@ -80,7 +80,7 @@ public class VibratissimoCoordinator extends AbstractBLEDeviceCoordinator {
}
@Override
public int getAlarmSlotCount() {
public int getAlarmSlotCount(GBDevice device) {
return 0;
}

View File

@ -136,7 +136,7 @@ public class WaspOSCoordinator extends AbstractBLEDeviceCoordinator {
}
@Override
public int getAlarmSlotCount() {
public int getAlarmSlotCount(GBDevice device) {
return 0;
}

View File

@ -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
}

View File

@ -87,7 +87,7 @@ public class XWatchCoordinator extends AbstractBLEDeviceCoordinator {
}
@Override
public int getAlarmSlotCount() {
public int getAlarmSlotCount(GBDevice device) {
return 0;
}

View File

@ -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
}

View File

@ -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) {