HPlus: Clear alarms if no alarm is enabled
This commit is contained in:
parent
cc917e97a6
commit
644c06df68
|
@ -355,9 +355,17 @@ public class HPlusSupport extends AbstractBTLEDeviceSupport {
|
||||||
|
|
||||||
private HPlusSupport setAlarm(TransactionBuilder transaction, Calendar t) {
|
private HPlusSupport setAlarm(TransactionBuilder transaction, Calendar t) {
|
||||||
|
|
||||||
|
byte hour = HPlusConstants.ARG_ALARM_DISABLE;
|
||||||
|
byte minute = HPlusConstants.ARG_ALARM_DISABLE;
|
||||||
|
|
||||||
|
if(t != null){
|
||||||
|
hour = (byte) t.get(Calendar.HOUR_OF_DAY);
|
||||||
|
minute = (byte) t.get(Calendar.MINUTE);
|
||||||
|
}
|
||||||
|
|
||||||
transaction.write(ctrlCharacteristic, new byte[]{HPlusConstants.CMD_SET_ALARM,
|
transaction.write(ctrlCharacteristic, new byte[]{HPlusConstants.CMD_SET_ALARM,
|
||||||
(byte) t.get(Calendar.HOUR_OF_DAY),
|
hour,
|
||||||
(byte) t.get(Calendar.MINUTE)});
|
minute});
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -429,8 +437,8 @@ public class HPlusSupport extends AbstractBTLEDeviceSupport {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSetAlarms(ArrayList<? extends Alarm> alarms) {
|
public void onSetAlarms(ArrayList<? extends Alarm> alarms) {
|
||||||
if (alarms.size() == 0)
|
|
||||||
return;
|
TransactionBuilder builder = new TransactionBuilder("alarm");
|
||||||
|
|
||||||
for (Alarm alarm : alarms) {
|
for (Alarm alarm : alarms) {
|
||||||
|
|
||||||
|
@ -441,7 +449,6 @@ public class HPlusSupport extends AbstractBTLEDeviceSupport {
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Calendar t = alarm.getAlarmCal();
|
Calendar t = alarm.getAlarmCal();
|
||||||
TransactionBuilder builder = new TransactionBuilder("alarm");
|
|
||||||
setAlarm(builder, t);
|
setAlarm(builder, t);
|
||||||
builder.queue(getQueue());
|
builder.queue(getQueue());
|
||||||
|
|
||||||
|
@ -449,6 +456,10 @@ public class HPlusSupport extends AbstractBTLEDeviceSupport {
|
||||||
|
|
||||||
return; //Only first alarm
|
return; //Only first alarm
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setAlarm(builder, null);
|
||||||
|
builder.queue(getQueue());
|
||||||
|
|
||||||
GB.toast(getContext(), getContext().getString(R.string.user_feedback_all_alarms_disabled), Toast.LENGTH_SHORT, GB.INFO);
|
GB.toast(getContext(), getContext().getString(R.string.user_feedback_all_alarms_disabled), Toast.LENGTH_SHORT, GB.INFO);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue