Ejemplo n.º 1
0
 /** Disable the snooze alert if the given id matches the snooze id. */
 static void disableSnoozeAlert(final Context context, final int id) {
   SharedPreferences prefs = context.getSharedPreferences(PREFERENCES, 0);
   if (hasAlarmBeenSnoozed(prefs, id)) {
     // This is the same id so clear the shared prefs.
     clearSnoozePreference(context, prefs, id);
   }
 }
Ejemplo n.º 2
0
 private static void clearSnoozeIfNeeded(Context context, long alarmTime) {
   // If this alarm fires before the next snooze, clear the snooze to
   // enable this alarm.
   SharedPreferences prefs = context.getSharedPreferences(AlarmClock.PREFERENCES, 0);
   long snoozeTime = prefs.getLong(PREF_SNOOZE_TIME, 0);
   if (alarmTime < snoozeTime) {
     clearSnoozePreference(context, prefs);
   }
 }
Ejemplo n.º 3
0
 /** Disable the snooze alert if the given id matches the snooze id. */
 static void disableSnoozeAlert(final Context context, final int id) {
   SharedPreferences prefs = context.getSharedPreferences(AlarmClock.PREFERENCES, 0);
   int snoozeId = prefs.getInt(PREF_SNOOZE_ID, -1);
   if (snoozeId == -1) {
     // No snooze set, do nothing.
     return;
   } else if (snoozeId == id) {
     // This is the same id so clear the shared prefs.
     clearSnoozePreference(context, prefs);
   }
 }
Ejemplo n.º 4
0
 static void saveSnoozeAlert(final Context context, final int id, final long time) {
   SharedPreferences prefs = context.getSharedPreferences(AlarmClock.PREFERENCES, 0);
   if (id == -1) {
     clearSnoozePreference(context, prefs);
   } else {
     SharedPreferences.Editor ed = prefs.edit();
     ed.putInt(PREF_SNOOZE_ID, id);
     ed.putLong(PREF_SNOOZE_TIME, time);
     ed.apply();
   }
   // Set the next alert after updating the snooze.
   setNextAlert(context);
 }
Ejemplo n.º 5
0
  private static void clearSnoozeIfNeeded(Context context, long alarmTime) {
    // If this alarm fires before the next snooze, clear the snooze to
    // enable this alarm.
    SharedPreferences prefs = context.getSharedPreferences(PREFERENCES, 0);

    // Get the list of snoozed alarms
    final Set<String> snoozedIds = prefs.getStringSet(PREF_SNOOZE_IDS, new HashSet<String>());
    final Set<String> snoozedIdsForCopy = new HashSet<String>();
    snoozedIdsForCopy.addAll(snoozedIds);
    for (String snoozedAlarm : snoozedIdsForCopy) {
      final long snoozeTime = prefs.getLong(getAlarmPrefSnoozeTimeKey(snoozedAlarm), 0);
      if (alarmTime < snoozeTime) {
        final int alarmId = Integer.parseInt(snoozedAlarm);
        clearSnoozePreference(context, prefs, alarmId);
      }
    }
  }