nsalarm notifications fix
This commit is contained in:
parent
8e49717794
commit
8ae817cdda
|
@ -331,7 +331,7 @@ public class NSDeviceStatus {
|
|||
// test warning level
|
||||
int level = Levels.INFO;
|
||||
long now = System.currentTimeMillis();
|
||||
if (deviceStatusOpenAPSData.clockSuggested != 0 && deviceStatusOpenAPSData.clockSuggested + sp.getInt(R.string.key_nsalarm_urgent_staledatavalue, 16) * 60 * 1000L < now)
|
||||
if (deviceStatusOpenAPSData.clockSuggested != 0 && deviceStatusOpenAPSData.clockSuggested + sp.getInt(R.string.key_nsalarm_urgent_staledatavalue, 31) * 60 * 1000L < now)
|
||||
level = Levels.URGENT;
|
||||
else if (deviceStatusOpenAPSData.clockSuggested != 0 && deviceStatusOpenAPSData.clockSuggested + sp.getInt(R.string.key_nsalarm_staledatavalue, 16) * 60 * 1000L < now)
|
||||
level = Levels.WARN;
|
||||
|
|
|
@ -842,14 +842,19 @@ public class NSClientService extends DaggerService {
|
|||
}
|
||||
|
||||
private void handleAnnouncement(JSONObject announcement) {
|
||||
boolean defaultVal = config.getNSCLIENT();
|
||||
if (sp.getBoolean(R.string.key_ns_announcements, defaultVal)) {
|
||||
NSAlarm nsAlarm = new NSAlarm(announcement);
|
||||
Notification notification = new NotificationWithAction(injector, nsAlarm);
|
||||
rxBus.send(new EventNewNotification(notification));
|
||||
rxBus.send(new EventNSClientNewLog("ANNOUNCEMENT", JsonHelper.safeGetString(announcement, "message", "received")));
|
||||
aapsLogger.debug(LTag.NSCLIENT, announcement.toString());
|
||||
}
|
||||
}
|
||||
|
||||
private void handleAlarm(JSONObject alarm) {
|
||||
boolean defaultVal = config.getNSCLIENT();
|
||||
if (sp.getBoolean(R.string.key_ns_alarms, defaultVal)) {
|
||||
long snoozedTo = sp.getLong(R.string.key_snoozedTo, 0L);
|
||||
if (snoozedTo == 0L || System.currentTimeMillis() > snoozedTo) {
|
||||
NSAlarm nsAlarm = new NSAlarm(alarm);
|
||||
|
@ -859,8 +864,11 @@ public class NSClientService extends DaggerService {
|
|||
rxBus.send(new EventNSClientNewLog("ALARM", JsonHelper.safeGetString(alarm, "message", "received")));
|
||||
aapsLogger.debug(LTag.NSCLIENT, alarm.toString());
|
||||
}
|
||||
}
|
||||
|
||||
private void handleUrgentAlarm(JSONObject alarm) {
|
||||
boolean defaultVal = config.getNSCLIENT();
|
||||
if (sp.getBoolean(R.string.key_ns_alarms, defaultVal)) {
|
||||
long snoozedTo = sp.getLong(R.string.key_snoozedTo, 0L);
|
||||
if (snoozedTo == 0L || System.currentTimeMillis() > snoozedTo) {
|
||||
NSAlarm nsAlarm = new NSAlarm(alarm);
|
||||
|
@ -870,6 +878,7 @@ public class NSClientService extends DaggerService {
|
|||
rxBus.send(new EventNSClientNewLog("URGENTALARM", JsonHelper.safeGetString(alarm, "message", "received")));
|
||||
aapsLogger.debug(LTag.NSCLIENT, alarm.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public void handleNewCal(JSONArray cals, boolean isDelta) {
|
||||
Bundle bundle = new Bundle();
|
||||
|
|
|
@ -22,8 +22,6 @@ class NotificationWithAction constructor(
|
|||
@Inject lateinit var defaultValueHelper: DefaultValueHelper
|
||||
@Inject lateinit var nsClientPlugin: NSClientPlugin
|
||||
|
||||
private var nsAlarm: NSAlarm? = null
|
||||
|
||||
init {
|
||||
injector.androidInjector().inject(this)
|
||||
}
|
||||
|
@ -36,7 +34,6 @@ class NotificationWithAction constructor(
|
|||
}
|
||||
|
||||
constructor (injector: HasAndroidInjector, nsAlarm: NSAlarm) : this(injector) {
|
||||
this.nsAlarm = nsAlarm
|
||||
date = System.currentTimeMillis()
|
||||
when (nsAlarm.level()) {
|
||||
0 -> {
|
||||
|
@ -50,14 +47,14 @@ class NotificationWithAction constructor(
|
|||
id = NSALARM
|
||||
level = NORMAL
|
||||
text = nsAlarm.title()
|
||||
if (nsAlarm.low() && sp.getBoolean(R.string.key_nsalarm_low, false) || nsAlarm.high() && sp.getBoolean(R.string.key_nsalarm_high, false) || nsAlarm.timeago() && sp.getBoolean(R.string.key_nsalarm_staledata, false)) soundId = R.raw.alarm
|
||||
soundId = R.raw.alarm
|
||||
}
|
||||
|
||||
2 -> {
|
||||
id = NSURGENTALARM
|
||||
level = URGENT
|
||||
text = nsAlarm.title()
|
||||
if (nsAlarm.low() && sp.getBoolean(R.string.key_nsalarm_urgent_low, false) || nsAlarm.high() && sp.getBoolean(R.string.key_nsalarm_urgent_high, false) || nsAlarm.timeago() && sp.getBoolean(R.string.key_nsalarm_staledata, false)) soundId = R.raw.urgentalarm
|
||||
soundId = R.raw.urgentalarm
|
||||
}
|
||||
}
|
||||
buttonText = R.string.snooze
|
||||
|
|
|
@ -549,20 +549,12 @@
|
|||
<string name="doprofileswitch">Do Profile Switch</string>
|
||||
<string name="careportal_pbage_label">Pump battery age</string>
|
||||
<string name="ns_alarmoptions">Alarm options</string>
|
||||
<string name="key_nsalarm_urgent_high" translatable="false">nsalarm_urgent_high</string>
|
||||
<string name="key_nsalarm_high" translatable="false">nsalarm_high</string>
|
||||
<string name="key_nsalarm_low" translatable="false">nsalarm_low</string>
|
||||
<string name="key_nsalarm_urgent_low" translatable="false">nsalarm_urgent_low</string>
|
||||
<string name="key_nsalarm_staledata" translatable="false">nsalarm_staledata</string>
|
||||
<string name="key_nsalarm_urgent_staledata" translatable="false">nsalarm_urgent_staledata</string>
|
||||
<string name="key_ns_announcements" translatable="false">ns_announcements</string>
|
||||
<string name="key_ns_alarms" translatable="false">ns_alarms</string>
|
||||
<string name="key_nsalarm_staledatavalue" translatable="false">nsalarm_staledatavalue</string>
|
||||
<string name="key_nsalarm_urgent_staledatavalue" translatable="false">nsalarm_urgent_staledatavalue</string>
|
||||
<string name="nsalarm_urgenthigh">Urgent high</string>
|
||||
<string name="nsalarm_high">High</string>
|
||||
<string name="nsalarm_low">Low</string>
|
||||
<string name="nsalarm_urgentlow">Urgent low</string>
|
||||
<string name="nsalarm_staledata">Stale data</string>
|
||||
<string name="nsalarm_urgentstaledata">Urgent stale data</string>
|
||||
<string name="ns_alarms">Create notifications from NS alarms</string>
|
||||
<string name="ns_announcements">Create notifications from NS announcements</string>
|
||||
<string name="nsalarm_staledatavalue_label">Stale data threshold [min]</string>
|
||||
<string name="nsalarm_urgent_staledatavalue_label">Urgent stale data threshold [min]</string>
|
||||
<string name="openapsama_autosens_period">Interval for autosens [h]</string>
|
||||
|
|
|
@ -42,29 +42,12 @@
|
|||
android:title="@string/ns_alarmoptions">
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="@string/key_nsalarm_urgent_high"
|
||||
android:title="@string/nsalarm_urgenthigh" />
|
||||
android:key="@string/key_ns_alarms"
|
||||
android:title="@string/ns_alarms" />
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="@string/key_nsalarm_high"
|
||||
android:title="@string/nsalarm_high" />
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="@string/key_nsalarm_low"
|
||||
android:title="@string/nsalarm_low" />
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="@string/key_nsalarm_urgent_low"
|
||||
android:title="@string/nsalarm_urgentlow" />
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="@string/key_nsalarm_staledata"
|
||||
android:title="@string/nsalarm_staledata" />
|
||||
android:key="@string/key_ns_announcements"
|
||||
android:title="@string/ns_announcements" />
|
||||
|
||||
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
|
||||
android:defaultValue="16"
|
||||
|
@ -79,11 +62,6 @@
|
|||
validate:minNumber="15"
|
||||
validate:testType="numericRange" />
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="@string/key_nsalarm_urgent_staledata"
|
||||
android:title="@string/nsalarm_urgentstaledata" />
|
||||
|
||||
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
|
||||
android:defaultValue="31"
|
||||
android:digits="0123456789"
|
||||
|
|
Loading…
Reference in a new issue