Search in sources :

Example 6 with UserNotification

use of com.eveningoutpost.dexdrip.Models.UserNotification in project xDrip-plus by jamorham.

the class Notifications method clearExtraCalibrationRequest.

private void clearExtraCalibrationRequest() {
    UserNotification userNotification = UserNotification.lastExtraCalibrationAlert();
    if (userNotification != null) {
        userNotification.delete();
        notificationDismiss(extraCalibrationNotificationId);
    }
}
Also used : UserNotification(com.eveningoutpost.dexdrip.Models.UserNotification)

Example 7 with UserNotification

use of com.eveningoutpost.dexdrip.Models.UserNotification in project xDrip by NightscoutFoundation.

the class MissedReadingService method checkBackAfterSnoozeTime.

private void checkBackAfterSnoozeTime(Context context, long now) {
    // This is not 100% acurate, need to take in account also the time of when this alert was snoozed.
    UserNotification userNotification = UserNotification.GetNotificationByType("bg_missed_alerts");
    if (userNotification == null) {
        // No active alert exists, should not happen, we have just created it.
        Log.wtf(TAG, "No active alert exists.");
        setAlarm(getOtherAlertReraiseSec(context, "bg_missed_alerts") * 1000, false);
    } else {
        // we have an alert that should be re-raised on userNotification.timestamp
        long alarmIn = (long) userNotification.timestamp - now;
        if (alarmIn < 0) {
            alarmIn = 0;
        }
        setAlarm(alarmIn, true);
    }
}
Also used : UserNotification(com.eveningoutpost.dexdrip.Models.UserNotification)

Example 8 with UserNotification

use of com.eveningoutpost.dexdrip.Models.UserNotification in project xDrip by NightscoutFoundation.

the class Notifications method clearCalibrationRequest.

private void clearCalibrationRequest() {
    UserNotification userNotification = UserNotification.lastCalibrationAlert();
    if (userNotification != null) {
        userNotification.delete();
        notificationDismiss(calibrationNotificationId);
    }
}
Also used : UserNotification(com.eveningoutpost.dexdrip.Models.UserNotification)

Example 9 with UserNotification

use of com.eveningoutpost.dexdrip.Models.UserNotification in project xDrip by NightscoutFoundation.

the class Notifications method calcuatleArmTimeUnclearalert.

// This is the absolute time, not time from now.
private long calcuatleArmTimeUnclearalert(Context ctx, long now, boolean unclearAlert) {
    if (!unclearAlert) {
        return Long.MAX_VALUE;
    }
    Long wakeTimeUnclear = Long.MAX_VALUE;
    UserNotification userNotification = UserNotification.GetNotificationByType("bg_unclear_readings_alert");
    if (userNotification == null) {
        // This is the case, that we are in unclear sensor reading, but for small time, so there is no call
        Log.i(TAG, "No active alert exists. returning Long.MAX_VALUE");
        return Long.MAX_VALUE;
    } else {
        // This alert is snoozed
        // reminder - userNotification.timestamp is the time that the alert should be played again
        wakeTimeUnclear = (long) userNotification.timestamp;
    }
    if (wakeTimeUnclear < now) {
        // we should alert now,
        wakeTimeUnclear = now;
    }
    if (wakeTimeUnclear == Long.MAX_VALUE) {
        // Should not happen
        Log.e(TAG, "calcuatleArmTimeUnclearalert wakeTimeUnclear bad value setting it to one minute from now " + new Date(wakeTimeUnclear) + " in " + ((wakeTimeUnclear - now) / 60000d) + " minutes");
        return now + 60 * 1000;
    }
    Log.w(TAG, "calcuatleArmTimeUnclearalert returning " + new Date(wakeTimeUnclear) + " in " + ((wakeTimeUnclear - now) / 60000d) + " minutes");
    return wakeTimeUnclear;
}
Also used : UserNotification(com.eveningoutpost.dexdrip.Models.UserNotification) Date(java.util.Date)

Example 10 with UserNotification

use of com.eveningoutpost.dexdrip.Models.UserNotification in project xDrip by NightscoutFoundation.

the class Notifications method calibrationRequest.

private void calibrationRequest() {
    UserNotification userNotification = UserNotification.lastCalibrationAlert();
    if ((userNotification == null) || (userNotification.timestamp <= ((new Date().getTime()) - (60000 * calibration_snooze)))) {
        if (userNotification != null) {
            userNotification.delete();
        }
        UserNotification.create("12 hours since last Calibration  (@" + JoH.hourMinuteString() + ")", "calibration_alert", new Date().getTime());
        String title = "Calibration Needed";
        String content = "12 hours since last calibration";
    // KS Intent intent = new Intent(mContext, AddCalibration.class);
    // KS calibrationNotificationCreate(title, content, intent, calibrationNotificationId);
    }
}
Also used : UserNotification(com.eveningoutpost.dexdrip.Models.UserNotification) Date(java.util.Date)

Aggregations

UserNotification (com.eveningoutpost.dexdrip.Models.UserNotification)18 Date (java.util.Date)10 NotificationManager (android.app.NotificationManager)2 PendingIntent (android.app.PendingIntent)2 Intent (android.content.Intent)2 SharedPreferences (android.content.SharedPreferences)2 NotificationCompat (android.support.v4.app.NotificationCompat)2