Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit faebc818 authored by Annie Chin's avatar Annie Chin
Browse files

Never remove Timer times up notification.

Bug: 23709019
Bug: 23707132
Bug: 23478562

Timer times up notification used to hide/show depending on app
open state. Now firing timer notifications are never hidden.
This is consistent with firing Alarm notifications.

Add call to re-sync UI on timer stop action in case the HUN stop is
clicked while on TimerFragment.

Change-Id: I69276246ed2c6136f5424a0db28c882d1d625d30
parent f83cd4ec
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -222,7 +222,6 @@ public class DeskClock extends BaseActivity
        SharedPreferences.Editor editor = prefs.edit();
        editor.putBoolean(Timers.NOTIF_APP_OPEN, true);
        editor.apply();
        Utils.cancelTimesUpNotifications(this);
        Utils.updateTimesUpNotification(this);
        sendBroadcast(new Intent(Timers.NOTIF_IN_USE_CANCEL));
        mActivityResumed = true;
@@ -241,7 +240,6 @@ public class DeskClock extends BaseActivity
        editor.apply();
        Utils.showInUseNotifications(this);
        Utils.updateTimesUpNotification(this);

        super.onPause();
    }

+0 −18
Original line number Diff line number Diff line
@@ -305,24 +305,6 @@ public class Utils {
        context.sendBroadcast(timerHUNIntent);
    }

    /**
     * Broadcast a message to show the in-use timers in the notifications
     */
    public static void showTimesUpNotifications(Context context) {
        Intent timerIntent = new Intent();
        timerIntent.setAction(Timers.NOTIF_TIMES_UP_SHOW);
        context.sendBroadcast(timerIntent);
    }

    /**
     * Broadcast a message to cancel the in-use timers in the notifications
     */
    public static void cancelTimesUpNotifications(Context context) {
        Intent timerIntent = new Intent();
        timerIntent.setAction(Timers.NOTIF_TIMES_UP_CANCEL);
        context.sendBroadcast(timerIntent);
    }

    /** Runnable for use with screensaver and dream, to move the clock every minute.
     *  registerViews() must be called prior to posting.
     */
+0 −5
Original line number Diff line number Diff line
@@ -77,16 +77,11 @@ public class TimerAlertFullScreen extends BaseActivity implements OnEmptyListLis
    protected void onResume() {
        super.onResume();

        // Only show notifications for times-up when this activity closed.
        Utils.cancelTimesUpNotifications(this);

        overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
    }

    @Override
    public void onPause() {
        Utils.showTimesUpNotifications(this);

        super.onPause();
    }

+5 −11
Original line number Diff line number Diff line
@@ -74,13 +74,9 @@ public class TimerReceiver extends BroadcastReceiver {
            case Timers.NOTIF_IN_USE_SHOW:
                showInUseNotification(context);
                return;
            case Timers.NOTIF_TIMES_UP_SHOW:
            case Timers.NOTIF_UPDATE:
                updateTimesUpNotification(context);
                return;
            case Timers.NOTIF_TIMES_UP_CANCEL:
                cancelTimesUpNotification(context);
                return;
            case Timers.NOTIF_RESET_ALL_TIMERS:
                resetAllTimers(context, prefs);
                return;
@@ -172,6 +168,9 @@ public class TimerReceiver extends BroadcastReceiver {
                stopTimer(prefs, t);
            }
            stopRingtoneIfNoTimesup(context);
            // Flag to tell DeskClock to re-sync with the database. Important if the HUN stop is
            // clicked while TimerFragment is open.
            prefs.edit().putBoolean(Timers.REFRESH_UI_WITH_LATEST_DATA, true).apply();
        } else if (Timers.NOTIF_TIMES_UP_PLUS_ONE.equals(actionType)) {
            // Find the timer (if it doesn't exists, it was probably deleted).
            if (t == null) {
@@ -606,12 +605,6 @@ public class TimerReceiver extends BroadcastReceiver {
    private void updateTimesUpNotification(final Context context) {
        final ArrayList<TimerObj> timesUpTimers =  Timers.timersInTimesUp(mTimers);

        if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean(
                Timers.NOTIF_APP_OPEN, false)) {
            cancelTimesUpNotification(context);
            return;
        }

        if (timesUpTimers.isEmpty()) {
            LogUtils.i("No more timers are firing.");
            cancelTimesUpNotification(context);
@@ -628,7 +621,8 @@ public class TimerReceiver extends BroadcastReceiver {
     * @param context
     * @param timesUpTimers list of Timers in TIMES_UP state
     */
    private void updateTimesUpNotification(final Context context, ArrayList<TimerObj> timesUpTimers) {
    private void updateTimesUpNotification(final Context context,
            ArrayList<TimerObj> timesUpTimers) {
        NotificationManagerCompat nm = NotificationManagerCompat.from(context);

        final TimerObj timerObj = timesUpTimers.get(0);
+0 −2
Original line number Diff line number Diff line
@@ -50,8 +50,6 @@ public class Timers {
    public static final String NOTIF_STOP_ALL_TIMERS = "notif_stop_all_timers";
    public static final String NOTIF_TIMES_UP_STOP = "notif_times_up_stop";
    public static final String NOTIF_TIMES_UP_PLUS_ONE = "notif_times_up_plus_one";
    public static final String NOTIF_TIMES_UP_SHOW = "notif_times_up_show";
    public static final String NOTIF_TIMES_UP_CANCEL = "notif_times_up_cancel";
    public static final String FIRST_LAUNCH_FROM_API_CALL = "first_launch_from_api_call";
    public static final String SCROLL_TO_TIMER_ID = "scroll_to_timer_id";