Exemplo n.º 1
0
 public synchronized void PreSnooze(Context ctx, String uuid, int repeatTime) {
   Log.i(TAG, "PreSnooze called repeatTime = " + repeatTime);
   stopAlert(ctx, true, false);
   ActiveBgAlert.Create(uuid, true, new Date().getTime() + repeatTime * 60000);
   ActiveBgAlert activeBgAlert = ActiveBgAlert.getOnly();
   if (activeBgAlert == null) {
     Log.wtf(TAG, "Just created the alert, where did it go...");
     return;
   }
   activeBgAlert.snooze(repeatTime);
 }
Exemplo n.º 2
0
 public synchronized void Snooze(Context ctx, int repeatTime) {
   Log.i(TAG, "Snooze called repeatTime = " + repeatTime);
   stopAlert(ctx, false, false);
   ActiveBgAlert activeBgAlert = ActiveBgAlert.getOnly();
   if (activeBgAlert == null) {
     Log.w(
         TAG,
         "Error, snooze was called but no alert is active. alert was probably removed in ui ");
     return;
   }
   activeBgAlert.snooze(repeatTime);
 }
Exemplo n.º 3
0
  void displayStatus() {
    ActiveBgAlert aba = ActiveBgAlert.getOnly();
    AlertType activeBgAlert = ActiveBgAlert.alertTypegetOnly();

    // aba and activeBgAlert should both either exist ot not exist. all other cases are a bug in
    // another place
    if (aba == null && activeBgAlert != null) {
      UserError.Log.wtf(
          TAG, "ERRRO displayStatus: aba == null, but activeBgAlert != null exiting...");
      return;
    }
    if (aba != null && activeBgAlert == null) {
      UserError.Log.wtf(
          TAG, "ERRRO displayStatus: aba != null, but activeBgAlert == null exiting...");
      return;
    }
    String status;
    if (activeBgAlert == null) {
      status = "No active alert exists";
      alertStatus.setText(status);
      buttonSnooze.setVisibility(View.GONE);
      snoozeValue.setVisibility(View.GONE);
    } else {
      if (!aba.ready_to_alarm()) {
        status =
            "Active alert exists named \""
                + activeBgAlert.name
                + "\" Alert snoozed until "
                + DateFormat.getTimeInstance(DateFormat.MEDIUM).format(new Date(aba.next_alert_at))
                + " ("
                + (aba.next_alert_at - new Date().getTime()) / 60000
                + " minutes left)";
      } else {
        status = "Active alert exists named \"" + activeBgAlert.name + "\" (not snoozed)";
      }
      SetSnoozePickerValues(snoozeValue, activeBgAlert.above, activeBgAlert.default_snooze);
      alertStatus.setText(status);
    }
  }
Exemplo n.º 4
0
  // Check the state and alrarm if needed
  public void ClockTick(Context ctx, boolean trendingToAlertEnd, String bgValue) {
    if (trendingToAlertEnd) {
      Log.d(TAG, "ClockTick: This alert is trending to it's end will not do anything");
      return;
    }
    ActiveBgAlert activeBgAlert = ActiveBgAlert.getOnly();
    if (activeBgAlert == null) {
      // Nothing to do ...
      return;
    }
    if (activeBgAlert.ready_to_alarm()) {
      stopAlert(ctx, false, false);

      int timeFromStartPlaying = activeBgAlert.getUpdatePlayTime();
      AlertType alert = AlertType.get_alert(activeBgAlert.alert_uuid);
      if (alert == null) {
        Log.w(TAG, "ClockTick: The alert was already deleted... will not play");
        ActiveBgAlert.ClearData();
        return;
      }
      Log.d(TAG, "ClockTick: Playing the alert again");
      Vibrate(ctx, alert, bgValue, alert.override_silent_mode, timeFromStartPlaying);
    }
  }