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

Commit 692ccc4a authored by James Lemieux's avatar James Lemieux
Browse files

Do not attempt to display deleted timer

TimerIntentsTest actually caught this bug. The intent to show
the timer tab requested that a freshly deleted timer be displayed.
This can produce exceptions if it was the last timer.

When a timer is deleted, the timer tab can be shown but no
specific timer should be requested for display.

Change-Id: I7024fbe5a154d5ecb8d563c80c09044d3917ab50
parent 197051b0
Loading
Loading
Loading
Loading
+9 −5
Original line number Diff line number Diff line
@@ -210,11 +210,14 @@ public class HandleDeskClockApiCalls extends Activity {
            if (timer == null) {
                Voice.notifyFailure(this, reason);
            } else {
                timerId = timer.getId();

                // Otherwise the control command can be honored.
                switch (action) {
                    case ACTION_RESET_TIMER: {
                        DataModel.getDataModel().resetOrDeleteTimer(timer, eventLabel);
                        if (timer.isExpired() && timer.getDeleteAfterUse()) {
                            timerId = -1;
                            reason = getString(R.string.timer_deleted);
                        } else {
                            reason = getString(R.string.timer_was_reset);
@@ -237,7 +240,6 @@ public class HandleDeskClockApiCalls extends Activity {
                        throw new IllegalArgumentException("unknown timer action: " + action);
                }

                timerId = timer.getId();
                Voice.notifySuccess(this, reason);
            }

@@ -245,10 +247,12 @@ public class HandleDeskClockApiCalls extends Activity {
        }

        // Open the UI to the timers.
        final Intent timerIntent = new Intent(mAppContext, DeskClock.class)
                .putExtra(DeskClock.SELECT_TAB_INTENT_EXTRA, DeskClock.TIMER_TAB_INDEX)
                .putExtra(EXTRA_TIMER_ID, timerId);
        startActivity(timerIntent);
        final Intent showTimers = new Intent(mAppContext, DeskClock.class)
                .putExtra(DeskClock.SELECT_TAB_INTENT_EXTRA, DeskClock.TIMER_TAB_INDEX);
        if (timerId != -1) {
            showTimers.putExtra(EXTRA_TIMER_ID, timerId);
        }
        startActivity(showTimers);
    }

    private void handleClockIntent(Intent intent) {