Merge pull request #1016 from MilosKozak/pump-notifications
Pump notifications
This commit is contained in:
commit
8d7df64050
6 changed files with 47 additions and 15 deletions
|
@ -59,6 +59,8 @@ public class Notification {
|
|||
public static final int ZERO_VALUE_IN_PROFILE = 31;
|
||||
public static final int PROFILE_SWITCH_MISSING = 32;
|
||||
public static final int NOT_ENG_MODE_OR_RELEASE = 33;
|
||||
public static final int WRONG_PUMP_PASSWORD = 34;
|
||||
|
||||
|
||||
public int id;
|
||||
public Date date;
|
||||
|
|
|
@ -65,6 +65,11 @@ public abstract class AbstractDanaRExecutionService extends Service {
|
|||
|
||||
protected final UUID SPP_UUID = UUID.fromString("00001101-0000-1000-8000-00805f9b34fb");
|
||||
|
||||
protected long lastWrongPumpPassword = 0;
|
||||
|
||||
protected long lastApproachingDailyLimit = 0;
|
||||
|
||||
|
||||
public abstract boolean updateBasalsInPump(final Profile profile);
|
||||
|
||||
public abstract void connect();
|
||||
|
|
|
@ -97,7 +97,11 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService{
|
|||
|
||||
public void connect() {
|
||||
if (mDanaRPump.password != -1 && mDanaRPump.password != SP.getInt(R.string.key_danar_password, -1)) {
|
||||
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.gs(R.string.wrongpumppassword), R.raw.error);
|
||||
if(System.currentTimeMillis() > lastWrongPumpPassword + 30 * 1000) {
|
||||
Notification notification = new Notification(Notification.WRONG_PUMP_PASSWORD, MainApp.gs(R.string.wrongpumppassword), Notification.URGENT);
|
||||
notification.soundId = R.raw.error;
|
||||
lastWrongPumpPassword = System.currentTimeMillis();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -192,9 +196,12 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService{
|
|||
NSUpload.uploadDeviceStatus();
|
||||
if (mDanaRPump.dailyTotalUnits > mDanaRPump.maxDailyTotalUnits * Constants.dailyLimitWarning) {
|
||||
log.debug("Approaching daily limit: " + mDanaRPump.dailyTotalUnits + "/" + mDanaRPump.maxDailyTotalUnits);
|
||||
Notification reportFail = new Notification(Notification.APPROACHING_DAILY_LIMIT, MainApp.gs(R.string.approachingdailylimit), Notification.URGENT);
|
||||
MainApp.bus().post(new EventNewNotification(reportFail));
|
||||
NSUpload.uploadError(MainApp.gs(R.string.approachingdailylimit) + ": " + mDanaRPump.dailyTotalUnits + "/" + mDanaRPump.maxDailyTotalUnits + "U");
|
||||
if(System.currentTimeMillis() > lastApproachingDailyLimit + 30 * 60 * 1000) {
|
||||
Notification reportFail = new Notification(Notification.APPROACHING_DAILY_LIMIT, MainApp.gs(R.string.approachingdailylimit), Notification.URGENT);
|
||||
MainApp.bus().post(new EventNewNotification(reportFail));
|
||||
NSUpload.uploadError(MainApp.gs(R.string.approachingdailylimit) + ": " + mDanaRPump.dailyTotalUnits + "/" + mDanaRPump.maxDailyTotalUnits + "U");
|
||||
lastApproachingDailyLimit = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("Unhandled exception", e);
|
||||
|
|
|
@ -105,7 +105,11 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
|
|||
|
||||
public void connect() {
|
||||
if (mDanaRPump.password != -1 && mDanaRPump.password != SP.getInt(R.string.key_danar_password, -1)) {
|
||||
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.gs(R.string.wrongpumppassword), R.raw.error);
|
||||
if(System.currentTimeMillis() > lastWrongPumpPassword + 30 * 1000) {
|
||||
Notification notification = new Notification(Notification.WRONG_PUMP_PASSWORD, MainApp.gs(R.string.wrongpumppassword), Notification.URGENT);
|
||||
notification.soundId = R.raw.error;
|
||||
lastWrongPumpPassword = System.currentTimeMillis();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -197,9 +201,12 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
|
|||
NSUpload.uploadDeviceStatus();
|
||||
if (mDanaRPump.dailyTotalUnits > mDanaRPump.maxDailyTotalUnits * Constants.dailyLimitWarning) {
|
||||
log.debug("Approaching daily limit: " + mDanaRPump.dailyTotalUnits + "/" + mDanaRPump.maxDailyTotalUnits);
|
||||
Notification reportFail = new Notification(Notification.APPROACHING_DAILY_LIMIT, MainApp.gs(R.string.approachingdailylimit), Notification.URGENT);
|
||||
MainApp.bus().post(new EventNewNotification(reportFail));
|
||||
NSUpload.uploadError(MainApp.gs(R.string.approachingdailylimit) + ": " + mDanaRPump.dailyTotalUnits + "/" + mDanaRPump.maxDailyTotalUnits + "U");
|
||||
if(System.currentTimeMillis() > lastApproachingDailyLimit + 30 * 60 * 1000) {
|
||||
Notification reportFail = new Notification(Notification.APPROACHING_DAILY_LIMIT, MainApp.gs(R.string.approachingdailylimit), Notification.URGENT);
|
||||
MainApp.bus().post(new EventNewNotification(reportFail));
|
||||
NSUpload.uploadError(MainApp.gs(R.string.approachingdailylimit) + ": " + mDanaRPump.dailyTotalUnits + "/" + mDanaRPump.maxDailyTotalUnits + "U");
|
||||
lastApproachingDailyLimit = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("Unhandled exception", e);
|
||||
|
|
|
@ -87,6 +87,7 @@ public class DanaRSService extends Service {
|
|||
private Treatment bolusingTreatment = null;
|
||||
|
||||
private long lastHistoryFetched = 0;
|
||||
private long lastApproachingDailyLimit = 0;
|
||||
|
||||
public DanaRSService() {
|
||||
try {
|
||||
|
@ -165,9 +166,12 @@ public class DanaRSService extends Service {
|
|||
NSUpload.uploadDeviceStatus();
|
||||
if (danaRPump.dailyTotalUnits > danaRPump.maxDailyTotalUnits * Constants.dailyLimitWarning) {
|
||||
log.debug("Approaching daily limit: " + danaRPump.dailyTotalUnits + "/" + danaRPump.maxDailyTotalUnits);
|
||||
Notification reportFail = new Notification(Notification.APPROACHING_DAILY_LIMIT, MainApp.gs(R.string.approachingdailylimit), Notification.URGENT);
|
||||
MainApp.bus().post(new EventNewNotification(reportFail));
|
||||
NSUpload.uploadError(MainApp.gs(R.string.approachingdailylimit) + ": " + danaRPump.dailyTotalUnits + "/" + danaRPump.maxDailyTotalUnits + "U");
|
||||
if(System.currentTimeMillis() > lastApproachingDailyLimit + 30 * 60 * 1000) {
|
||||
Notification reportFail = new Notification(Notification.APPROACHING_DAILY_LIMIT, MainApp.gs(R.string.approachingdailylimit), Notification.URGENT);
|
||||
MainApp.bus().post(new EventNewNotification(reportFail));
|
||||
NSUpload.uploadError(MainApp.gs(R.string.approachingdailylimit) + ": " + danaRPump.dailyTotalUnits + "/" + danaRPump.maxDailyTotalUnits + "U");
|
||||
lastApproachingDailyLimit = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("Unhandled exception", e);
|
||||
|
|
|
@ -120,7 +120,11 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
|||
|
||||
public void connect() {
|
||||
if (mDanaRPump.password != -1 && mDanaRPump.password != SP.getInt(R.string.key_danar_password, -1)) {
|
||||
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.gs(R.string.wrongpumppassword), R.raw.error);
|
||||
if(System.currentTimeMillis() > lastWrongPumpPassword + 30 * 1000) {
|
||||
Notification notification = new Notification(Notification.WRONG_PUMP_PASSWORD, MainApp.gs(R.string.wrongpumppassword), Notification.URGENT);
|
||||
notification.soundId = R.raw.error;
|
||||
lastWrongPumpPassword = System.currentTimeMillis();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -218,9 +222,12 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
|||
NSUpload.uploadDeviceStatus();
|
||||
if (mDanaRPump.dailyTotalUnits > mDanaRPump.maxDailyTotalUnits * Constants.dailyLimitWarning) {
|
||||
log.debug("Approaching daily limit: " + mDanaRPump.dailyTotalUnits + "/" + mDanaRPump.maxDailyTotalUnits);
|
||||
Notification reportFail = new Notification(Notification.APPROACHING_DAILY_LIMIT, MainApp.gs(R.string.approachingdailylimit), Notification.URGENT);
|
||||
MainApp.bus().post(new EventNewNotification(reportFail));
|
||||
NSUpload.uploadError(MainApp.gs(R.string.approachingdailylimit) + ": " + mDanaRPump.dailyTotalUnits + "/" + mDanaRPump.maxDailyTotalUnits + "U");
|
||||
if(System.currentTimeMillis() > lastApproachingDailyLimit + 30 * 60 * 1000) {
|
||||
Notification reportFail = new Notification(Notification.APPROACHING_DAILY_LIMIT, MainApp.gs(R.string.approachingdailylimit), Notification.URGENT);
|
||||
MainApp.bus().post(new EventNewNotification(reportFail));
|
||||
NSUpload.uploadError(MainApp.gs(R.string.approachingdailylimit) + ": " + mDanaRPump.dailyTotalUnits + "/" + mDanaRPump.maxDailyTotalUnits + "U");
|
||||
lastApproachingDailyLimit = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("Unhandled exception", e);
|
||||
|
|
Loading…
Reference in a new issue