system notifications for non-urgent
This commit is contained in:
parent
2b06e9e63e
commit
2f56687e82
4 changed files with 19 additions and 20 deletions
|
@ -21,7 +21,6 @@ import java.util.List;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.Services.AlarmSoundService;
|
import info.nightscout.androidaps.Services.AlarmSoundService;
|
||||||
import info.nightscout.androidaps.plugins.Wear.WearPlugin;
|
|
||||||
import info.nightscout.utils.SP;
|
import info.nightscout.utils.SP;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -58,8 +57,7 @@ public class NotificationStore {
|
||||||
|
|
||||||
store.add(n);
|
store.add(n);
|
||||||
|
|
||||||
if (SP.getBoolean(MainApp.sResources.getString(R.string.key_raise_urgent_alarms_as_android_notification), false)
|
if (SP.getBoolean(MainApp.sResources.getString(R.string.key_raise_notifications_as_android_notifications), false)) {
|
||||||
&& n.level == Notification.URGENT) {
|
|
||||||
raiseSystemNotification(n);
|
raiseSystemNotification(n);
|
||||||
} else {
|
} else {
|
||||||
if (n.soundId != null) {
|
if (n.soundId != null) {
|
||||||
|
@ -69,11 +67,10 @@ public class NotificationStore {
|
||||||
}
|
}
|
||||||
|
|
||||||
//Only pipe through to wear if no system notification is raised (should show on wear anyways)
|
//Only pipe through to wear if no system notification is raised (should show on wear anyways)
|
||||||
WearPlugin wearPlugin = MainApp.getSpecificPlugin(WearPlugin.class);
|
/*WearPlugin wearPlugin = MainApp.getSpecificPlugin(WearPlugin.class);
|
||||||
if(wearPlugin!= null && wearPlugin.isEnabled()) {
|
if(wearPlugin!= null && wearPlugin.isEnabled()) {
|
||||||
wearPlugin.overviewNotification(n.id, "OverviewNotification:\n" + n.text);
|
wearPlugin.overviewNotification(n.id, "OverviewNotification:\n" + n.text);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Collections.sort(store, new NotificationComparator());
|
Collections.sort(store, new NotificationComparator());
|
||||||
|
@ -91,9 +88,13 @@ public class NotificationStore {
|
||||||
.setContentTitle("Urgent alarm")
|
.setContentTitle("Urgent alarm")
|
||||||
.setContentText(n.text)
|
.setContentText(n.text)
|
||||||
.setPriority(NotificationCompat.PRIORITY_HIGH)
|
.setPriority(NotificationCompat.PRIORITY_HIGH)
|
||||||
.setVibrate(new long[] { 1000, 1000, 1000, 1000})
|
|
||||||
.setSound(sound, AudioAttributes.USAGE_ALARM)
|
|
||||||
.setDeleteIntent(DismissNotificationService.deleteIntent(n.id));
|
.setDeleteIntent(DismissNotificationService.deleteIntent(n.id));
|
||||||
|
if (n.level == Notification.URGENT) {
|
||||||
|
notificationBuilder.setVibrate(new long[]{1000, 1000, 1000, 1000})
|
||||||
|
.setSound(sound, AudioAttributes.USAGE_ALARM);
|
||||||
|
} else {
|
||||||
|
notificationBuilder.setVibrate(new long[]{0, 100, 50, 100, 50});
|
||||||
|
}
|
||||||
mgr.notify(n.id, notificationBuilder.build());
|
mgr.notify(n.id, notificationBuilder.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,11 +82,10 @@ public class KeepAliveReceiver extends BroadcastReceiver {
|
||||||
boolean alarmTimeoutExpired = lastConnection.getTime() + pumpUnreachableThreshold() < System.currentTimeMillis();
|
boolean alarmTimeoutExpired = lastConnection.getTime() + pumpUnreachableThreshold() < System.currentTimeMillis();
|
||||||
boolean nextAlarmOccurrenceReached = SP.getLong("nextPumpDisconnectedAlarm", 0l) < System.currentTimeMillis();
|
boolean nextAlarmOccurrenceReached = SP.getLong("nextPumpDisconnectedAlarm", 0l) < System.currentTimeMillis();
|
||||||
|
|
||||||
if (SP.getBoolean(MainApp.sResources.getString(R.string.key_enable_pump_unreachable_alert), false)
|
if (SP.getBoolean(MainApp.sResources.getString(R.string.key_enable_pump_unreachable_alert), true)
|
||||||
&& isStatusOutdated && alarmTimeoutExpired && nextAlarmOccurrenceReached) {
|
&& isStatusOutdated && alarmTimeoutExpired && nextAlarmOccurrenceReached) {
|
||||||
Notification n = new Notification(Notification.PUMP_UNREACHABLE, MainApp.sResources.getString(R.string.pump_unreachable), Notification.URGENT);
|
Notification n = new Notification(Notification.PUMP_UNREACHABLE, MainApp.sResources.getString(R.string.pump_unreachable), Notification.URGENT);
|
||||||
n.soundId = R.raw.alarm;
|
n.soundId = R.raw.alarm;
|
||||||
SP.putLong("nextMissedReadingsAlarm", System.currentTimeMillis() + missedReadingsThreshold());
|
|
||||||
SP.putLong("nextPumpDisconnectedAlarm", System.currentTimeMillis() + pumpUnreachableThreshold());
|
SP.putLong("nextPumpDisconnectedAlarm", System.currentTimeMillis() + pumpUnreachableThreshold());
|
||||||
MainApp.bus().post(new EventNewNotification(n));
|
MainApp.bus().post(new EventNewNotification(n));
|
||||||
} else if (SP.getBoolean("syncprofiletopump", false) && !pump.isThisProfileSet(profile)) {
|
} else if (SP.getBoolean("syncprofiletopump", false) && !pump.isThisProfileSet(profile)) {
|
||||||
|
|
|
@ -759,8 +759,8 @@
|
||||||
<string name="startingbolus">Starting bolus delivery</string>
|
<string name="startingbolus">Starting bolus delivery</string>
|
||||||
<string name="pump_unreachable">Pump unreachable</string>
|
<string name="pump_unreachable">Pump unreachable</string>
|
||||||
<string name="missed_bg_readings">Missed BG readings</string>
|
<string name="missed_bg_readings">Missed BG readings</string>
|
||||||
<string name="key_raise_urgent_alarms_as_android_notification" translatable="false">raise_urgent_alarms_as_android_notification</string>
|
<string name="key_raise_notifications_as_android_notifications" translatable="false">raise_urgent_alarms_as_android_notification</string>
|
||||||
<string name="raise_urgent_alarms_as_android_notification">Use system notifications for alerts</string>
|
<string name="raise_notifications_as_android_notifications">Use system notifications for alerts and notifications</string>
|
||||||
<string name="key_enable_pump_unreachable_alert" translatable="false">enable_pump_unreachable_alert</string>
|
<string name="key_enable_pump_unreachable_alert" translatable="false">enable_pump_unreachable_alert</string>
|
||||||
<string name="key_enable_missed_bg_readings_alert" translatable="false">enable_missed_bg_readings</string>
|
<string name="key_enable_missed_bg_readings_alert" translatable="false">enable_missed_bg_readings</string>
|
||||||
<string name="localalertsettings_title">Local alerts</string>
|
<string name="localalertsettings_title">Local alerts</string>
|
||||||
|
|
|
@ -72,8 +72,7 @@
|
||||||
android:key="short_tabtitles"
|
android:key="short_tabtitles"
|
||||||
android:title="@string/short_tabtitles"/>
|
android:title="@string/short_tabtitles"/>
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
<PreferenceCategory
|
<PreferenceScreen
|
||||||
android:key="others"
|
|
||||||
android:title="@string/localalertsettings_title">
|
android:title="@string/localalertsettings_title">
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
|
@ -87,7 +86,7 @@
|
||||||
android:inputType="number">
|
android:inputType="number">
|
||||||
</EditTextPreference>
|
</EditTextPreference>
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:defaultValue="false"
|
android:defaultValue="true"
|
||||||
android:key="@string/key_enable_pump_unreachable_alert"
|
android:key="@string/key_enable_pump_unreachable_alert"
|
||||||
android:title="@string/enable_pump_unreachable_alert"/>
|
android:title="@string/enable_pump_unreachable_alert"/>
|
||||||
<EditTextPreference
|
<EditTextPreference
|
||||||
|
@ -97,9 +96,9 @@
|
||||||
android:defaultValue="30"
|
android:defaultValue="30"
|
||||||
android:inputType="number">
|
android:inputType="number">
|
||||||
</EditTextPreference>
|
</EditTextPreference>
|
||||||
<SwitchPreference
|
</PreferenceScreen>
|
||||||
android:defaultValue="false"
|
<SwitchPreference
|
||||||
android:key="raise_urgent_alarms_as_android_notification"
|
android:defaultValue="false"
|
||||||
android:title="@string/raise_urgent_alarms_as_android_notification"/>
|
android:key="@string/key_raise_notifications_as_android_notifications"
|
||||||
</PreferenceCategory>
|
android:title="@string/raise_notifications_as_android_notifications"/>
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
|
Loading…
Reference in a new issue