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.R;
|
||||
import info.nightscout.androidaps.Services.AlarmSoundService;
|
||||
import info.nightscout.androidaps.plugins.Wear.WearPlugin;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
/**
|
||||
|
@ -58,8 +57,7 @@ public class NotificationStore {
|
|||
|
||||
store.add(n);
|
||||
|
||||
if (SP.getBoolean(MainApp.sResources.getString(R.string.key_raise_urgent_alarms_as_android_notification), false)
|
||||
&& n.level == Notification.URGENT) {
|
||||
if (SP.getBoolean(MainApp.sResources.getString(R.string.key_raise_notifications_as_android_notifications), false)) {
|
||||
raiseSystemNotification(n);
|
||||
} else {
|
||||
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)
|
||||
WearPlugin wearPlugin = MainApp.getSpecificPlugin(WearPlugin.class);
|
||||
/*WearPlugin wearPlugin = MainApp.getSpecificPlugin(WearPlugin.class);
|
||||
if(wearPlugin!= null && wearPlugin.isEnabled()) {
|
||||
wearPlugin.overviewNotification(n.id, "OverviewNotification:\n" + n.text);
|
||||
}
|
||||
|
||||
}*/
|
||||
}
|
||||
|
||||
Collections.sort(store, new NotificationComparator());
|
||||
|
@ -91,9 +88,13 @@ public class NotificationStore {
|
|||
.setContentTitle("Urgent alarm")
|
||||
.setContentText(n.text)
|
||||
.setPriority(NotificationCompat.PRIORITY_HIGH)
|
||||
.setVibrate(new long[] { 1000, 1000, 1000, 1000})
|
||||
.setSound(sound, AudioAttributes.USAGE_ALARM)
|
||||
.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());
|
||||
}
|
||||
|
||||
|
|
|
@ -82,11 +82,10 @@ public class KeepAliveReceiver extends BroadcastReceiver {
|
|||
boolean alarmTimeoutExpired = lastConnection.getTime() + pumpUnreachableThreshold() < 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) {
|
||||
Notification n = new Notification(Notification.PUMP_UNREACHABLE, MainApp.sResources.getString(R.string.pump_unreachable), Notification.URGENT);
|
||||
n.soundId = R.raw.alarm;
|
||||
SP.putLong("nextMissedReadingsAlarm", System.currentTimeMillis() + missedReadingsThreshold());
|
||||
SP.putLong("nextPumpDisconnectedAlarm", System.currentTimeMillis() + pumpUnreachableThreshold());
|
||||
MainApp.bus().post(new EventNewNotification(n));
|
||||
} else if (SP.getBoolean("syncprofiletopump", false) && !pump.isThisProfileSet(profile)) {
|
||||
|
|
|
@ -759,8 +759,8 @@
|
|||
<string name="startingbolus">Starting bolus delivery</string>
|
||||
<string name="pump_unreachable">Pump unreachable</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="raise_urgent_alarms_as_android_notification">Use system notifications for alerts</string>
|
||||
<string name="key_raise_notifications_as_android_notifications" translatable="false">raise_urgent_alarms_as_android_notification</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_missed_bg_readings_alert" translatable="false">enable_missed_bg_readings</string>
|
||||
<string name="localalertsettings_title">Local alerts</string>
|
||||
|
|
|
@ -72,8 +72,7 @@
|
|||
android:key="short_tabtitles"
|
||||
android:title="@string/short_tabtitles"/>
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory
|
||||
android:key="others"
|
||||
<PreferenceScreen
|
||||
android:title="@string/localalertsettings_title">
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
|
@ -87,7 +86,7 @@
|
|||
android:inputType="number">
|
||||
</EditTextPreference>
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:defaultValue="true"
|
||||
android:key="@string/key_enable_pump_unreachable_alert"
|
||||
android:title="@string/enable_pump_unreachable_alert"/>
|
||||
<EditTextPreference
|
||||
|
@ -97,9 +96,9 @@
|
|||
android:defaultValue="30"
|
||||
android:inputType="number">
|
||||
</EditTextPreference>
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="raise_urgent_alarms_as_android_notification"
|
||||
android:title="@string/raise_urgent_alarms_as_android_notification"/>
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="@string/key_raise_notifications_as_android_notifications"
|
||||
android:title="@string/raise_notifications_as_android_notifications"/>
|
||||
</PreferenceScreen>
|
||||
|
|
Loading…
Reference in a new issue