Skip to content

Commit

Permalink
Take snooze time from the correct place, for missed-readings and nois…
Browse files Browse the repository at this point in the history
…y-sensor alerts.

Signed-off-by: Tzachi Dar <[email protected]>
  • Loading branch information
tzachi-dar committed Nov 4, 2016
1 parent 3329f93 commit 0b4a41b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ protected void onCreate(Bundle savedInstanceState) {
endHour = AlertType.time2Hours(endMinutes);
endMinute = AlertType.time2Minutes(endMinutes);
bgMissedMinutes.setText(prefs.getString("bg_missed_minutes", "30"));
int defaultSnooze = MissedReadingService.readPerfsInt(prefs, "other_alerts_snooze", 20);
bgMissedSnoozeMin.setText(prefs.getString("bg_missed_alerts_snooze", "" + defaultSnooze));
bgMissedSnoozeMin.setText("" + MissedReadingService.getOtherAlertSnoozeMinutes(prefs, "bg_missed_alerts"));
bgMissedReraiseSec.setText(prefs.getString("bg_missed_alerts_reraise_sec", "60"));

addListenerOnButtons();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,14 @@ static public long getOtherAlertReraiseSec(Context context, String alertName) {
if(enableAlertsReraise) {
return readPerfsInt(prefs, alertName + "_reraise_sec", 60);
} else {
int defaultSnooze = readPerfsInt(prefs, "other_alerts_snooze", 20);
return 60 * readPerfsInt(prefs, alertName + "_snooze", defaultSnooze);
return 60 * getOtherAlertSnoozeMinutes(prefs, alertName);
}

}

static public long getOtherAlertSnoozeMinutes(SharedPreferences prefs, String alertName) {
int defaultSnooze = readPerfsInt(prefs, "other_alerts_snooze", 20);
return readPerfsInt(prefs, alertName + "_snooze", defaultSnooze);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ private void snoozeBgAlert() {

private void snoozeOtherAlert(String alertType) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
int snoozeMinutes = MissedReadingService.readPerfsInt(prefs, "other_alerts_snooze", 20);
long snoozeMinutes = MissedReadingService.getOtherAlertSnoozeMinutes(prefs, alertType);
Log.i(TAG, "snoozeOtherAlert calling snooze alert alert = " + alertType + " snoozeMinutes = " + snoozeMinutes);
UserNotification.snoozeAlert(alertType, snoozeMinutes);
}
}

0 comments on commit 0b4a41b

Please sign in to comment.