show notification on toast alarm

This commit is contained in:
AdrianLxM 2017-08-16 21:37:33 +02:00
parent 63793ed358
commit e61d7a4442
2 changed files with 12 additions and 0 deletions

View file

@ -48,6 +48,7 @@ public class Notification {
public static final int NSALARM = 19;
public static final int NSURGENTALARM = 20;
public static final int SHORT_DIA = 21;
public static final int TOAST_ALARM = 22;
public int id;

View file

@ -6,6 +6,10 @@ import android.os.Handler;
import android.os.Looper;
import android.widget.Toast;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.plugins.Overview.Notification;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
public class ToastUtils {
public static void showToastInUiThread(final Context ctx,
@ -25,6 +29,13 @@ public class ToastUtils {
showToastInUiThread(ctx, string);
playSound(ctx, soundID);
new Thread(new Runnable() {
@Override
public void run() {
Notification notification = new Notification(Notification.TOAST_ALARM, string, Notification.URGENT);
MainApp.bus().post(new EventNewNotification(notification));
}
}).start();
}
private static void playSound(final Context ctx, final int soundID) {