Create NS-anouncements for error dialogs and local alerts.
This commit is contained in:
parent
d92a7e8ef1
commit
0df796d3f4
5 changed files with 12 additions and 2 deletions
|
@ -600,7 +600,8 @@ public class DataService extends IntentService {
|
||||||
if (trJson.has("eventType") && trJson.getString("eventType").equals(CareportalEvent.ANNOUNCEMENT)) {
|
if (trJson.has("eventType") && trJson.getString("eventType").equals(CareportalEvent.ANNOUNCEMENT)) {
|
||||||
long date = trJson.getLong("mills");
|
long date = trJson.getLong("mills");
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
if (date > now - 15 * 60 * 1000L && trJson.has("notes")) {
|
if (date > now - 15 * 60 * 1000L && trJson.has("notes")
|
||||||
|
&& !(trJson.has("enteredBy") && trJson.getString("enteredBy").equals(SP.getString("careportal_enteredby", "AndroidAPS")))) {
|
||||||
Notification announcement = new Notification(Notification.NSANNOUNCEMENT, trJson.getString("notes"), Notification.ANNOUNCEMENT, 60);
|
Notification announcement = new Notification(Notification.NSANNOUNCEMENT, trJson.getString("notes"), Notification.ANNOUNCEMENT, 60);
|
||||||
MainApp.bus().post(new EventNewNotification(announcement));
|
MainApp.bus().post(new EventNewNotification(announcement));
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import android.graphics.Color;
|
||||||
import com.j256.ormlite.field.DatabaseField;
|
import com.j256.ormlite.field.DatabaseField;
|
||||||
import com.j256.ormlite.table.DatabaseTable;
|
import com.j256.ormlite.table.DatabaseTable;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -184,7 +185,7 @@ public class CareportalEvent implements DataPointWithLabelInterface {
|
||||||
try {
|
try {
|
||||||
JSONObject object = new JSONObject(json);
|
JSONObject object = new JSONObject(json);
|
||||||
if (object.has("notes"))
|
if (object.has("notes"))
|
||||||
return object.getString("notes");
|
return StringUtils.abbreviate(object.getString("notes"), 40);
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
log.error("Unhandled exception", e);
|
log.error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,8 @@ package info.nightscout.androidaps.plugins.Overview.Dialogs;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
|
|
||||||
|
import info.nightscout.utils.NSUpload;
|
||||||
|
|
||||||
public class ErrorHelperActivity extends AppCompatActivity {
|
public class ErrorHelperActivity extends AppCompatActivity {
|
||||||
public ErrorHelperActivity() {
|
public ErrorHelperActivity() {
|
||||||
super();
|
super();
|
||||||
|
@ -17,5 +19,7 @@ public class ErrorHelperActivity extends AppCompatActivity {
|
||||||
errorDialog.setSound(getIntent().getIntExtra("soundid", 0));
|
errorDialog.setSound(getIntent().getIntExtra("soundid", 0));
|
||||||
errorDialog.setTitle(getIntent().getStringExtra("title"));
|
errorDialog.setTitle(getIntent().getStringExtra("title"));
|
||||||
errorDialog.show(this.getSupportFragmentManager(), "Error");
|
errorDialog.show(this.getSupportFragmentManager(), "Error");
|
||||||
|
|
||||||
|
NSUpload.uploadError(getIntent().getStringExtra("status"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
||||||
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
|
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
|
||||||
import info.nightscout.androidaps.receivers.KeepAliveReceiver;
|
import info.nightscout.androidaps.receivers.KeepAliveReceiver;
|
||||||
|
import info.nightscout.utils.NSUpload;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by adrian on 17/12/17.
|
* Created by adrian on 17/12/17.
|
||||||
|
@ -42,6 +43,7 @@ public class LocalAlertUtils {
|
||||||
n.soundId = R.raw.alarm;
|
n.soundId = R.raw.alarm;
|
||||||
SP.putLong("nextPumpDisconnectedAlarm", System.currentTimeMillis() + pumpUnreachableThreshold());
|
SP.putLong("nextPumpDisconnectedAlarm", System.currentTimeMillis() + pumpUnreachableThreshold());
|
||||||
MainApp.bus().post(new EventNewNotification(n));
|
MainApp.bus().post(new EventNewNotification(n));
|
||||||
|
NSUpload.uploadError(n.text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,6 +93,7 @@ public class LocalAlertUtils {
|
||||||
n.soundId = R.raw.alarm;
|
n.soundId = R.raw.alarm;
|
||||||
SP.putLong("nextMissedReadingsAlarm", System.currentTimeMillis() + missedReadingsThreshold());
|
SP.putLong("nextMissedReadingsAlarm", System.currentTimeMillis() + missedReadingsThreshold());
|
||||||
MainApp.bus().post(new EventNewNotification(n));
|
MainApp.bus().post(new EventNewNotification(n));
|
||||||
|
NSUpload.uploadError(n.text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -399,6 +399,7 @@ public class NSUpload {
|
||||||
try {
|
try {
|
||||||
data.put("eventType", "Announcement");
|
data.put("eventType", "Announcement");
|
||||||
data.put("created_at", DateUtil.toISOString(new Date()));
|
data.put("created_at", DateUtil.toISOString(new Date()));
|
||||||
|
data.put("enteredBy", SP.getString("careportal_enteredby", MainApp.gs(R.string.app_name)));
|
||||||
data.put("notes", error);
|
data.put("notes", error);
|
||||||
data.put("isAnnouncement", true);
|
data.put("isAnnouncement", true);
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
|
|
Loading…
Reference in a new issue