Search in sources :

Example 16 with UserNotification

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

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 17 with UserNotification

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

the class Notifications method doubleCalibrationRequest.

private void doubleCalibrationRequest() {
    UserNotification userNotification = UserNotification.lastDoubleCalibrationAlert();
    if ((userNotification == null) || (userNotification.timestamp <= ((new Date().getTime()) - (60000 * calibration_snooze)))) {
        if (userNotification != null) {
            userNotification.delete();
        }
        UserNotification.create("Double Calibration", "double_calibration_alert", new Date().getTime());
        String title = "Sensor is ready";
    // KS String content = getString(R.string.sensor_is_ready_please_enter_double_calibration) + "  (@" + JoH.hourMinuteString() + ")";
    // KS Intent intent = new Intent(mContext, DoubleCalibrationActivity.class);
    // KS calibrationNotificationCreate(title, content, intent, calibrationNotificationId);
    }
}
Also used : UserNotification(com.eveningoutpost.dexdrip.Models.UserNotification) Date(java.util.Date)

Example 18 with UserNotification

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

the class Notifications method extraCalibrationRequest.

private void extraCalibrationRequest() {
    UserNotification userNotification = UserNotification.lastExtraCalibrationAlert();
    if ((userNotification == null) || (userNotification.timestamp <= ((new Date().getTime()) - (60000 * calibration_snooze)))) {
        if (userNotification != null) {
            userNotification.delete();
        }
        UserNotification.create("Extra Calibration Requested", "extra_calibration_alert", new Date().getTime());
        String title = "Calibration Requested";
        String content = "Increase performance by calibrating now" + "  (@" + JoH.hourMinuteString() + ")";
    // KS Intent intent = new Intent(mContext, AddCalibration.class);
    // KS calibrationNotificationCreate(title, content, intent, extraCalibrationNotificationId);
    }
}
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