Example #1
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);
    }
  }
Example #2
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);
    }
  }