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

Commit b15c46b5 authored by Christine Franks's avatar Christine Franks Committed by Android (Google) Code Review
Browse files

Merge "Handle ACTION_DISMISS_TIMER intent"

parents d27e407c 2cfca779
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -109,6 +109,7 @@
            android:theme="@android:style/Theme.NoDisplay">
            <intent-filter>
                <action android:name="android.intent.action.DISMISS_ALARM" />
                <action android:name="android.intent.action.DISMISS_TIMER" />
                <action android:name="android.intent.action.SHOW_ALARMS" />
                <action android:name="android.intent.action.SHOW_TIMERS" />
                <action android:name="android.intent.action.SNOOZE_ALARM" />
+5 −3
Original line number Diff line number Diff line
@@ -1007,9 +1007,11 @@
    -->
    <string name="timer_created">Timer created</string>

    <!-- String that represents that the user has successfully reset a timer through a voice action
    that was marked as deleteAfterUse and was thus deleted instead.
    [CHAR LIMIT=NONE]
    <!-- String that represents that the user has successfully dismissed a timer. [CHAR_LIMIT=NONE]
    -->
    <string name="timer_dismissed">Timer dismissed</string>

    <!-- String that represents that the user has successfully deleted a timer. [CHAR LIMIT=NONE]
    -->
    <string name="timer_deleted">Timer deleted</string>

+12 −5
Original line number Diff line number Diff line
@@ -64,8 +64,6 @@ public class HandleApiCalls extends Activity {

    private static final LogUtils.Logger LOGGER = new LogUtils.Logger("HandleApiCalls");

    static final String ACTION_SHOW_TIMERS = "android.intent.action.SHOW_TIMERS";

    private Context mAppContext;

    @Override
@@ -83,16 +81,17 @@ public class HandleApiCalls extends Activity {
            LOGGER.i("onCreate: " + intent);

            switch (action) {

                case AlarmClock.ACTION_SET_ALARM:
                    handleSetAlarm(intent);
                    break;
                case AlarmClock.ACTION_SHOW_ALARMS:
                    handleShowAlarms(intent);
                    handleShowAlarms();
                    break;
                case AlarmClock.ACTION_SET_TIMER:
                    handleSetTimer(intent);
                    break;
                case ACTION_SHOW_TIMERS:
                case AlarmClock.ACTION_SHOW_TIMERS:
                    handleShowTimers(intent);
                    break;
                case AlarmClock.ACTION_DISMISS_ALARM:
@@ -101,6 +100,9 @@ public class HandleApiCalls extends Activity {
                case AlarmClock.ACTION_SNOOZE_ALARM:
                    handleSnoozeAlarm(intent);
                    break;
                case AlarmClock.ACTION_DISMISS_TIMER:
                    handleDismissTimer();
                    break;
            }
        } catch (Exception e) {
            LOGGER.wtf(e);
@@ -383,7 +385,12 @@ public class HandleApiCalls extends Activity {
        Controller.getController().notifyVoiceSuccess(this, getString(R.string.alarm_is_set, time));
    }

    private void handleShowAlarms(Intent intent) {
    private void handleDismissTimer() {
        DataModel.getDataModel().resetOrDeleteExpiredTimers(R.string.label_intent);
        Controller.getController().notifyVoiceSuccess(this, getString(R.string.timer_dismissed));
    }

    private void handleShowAlarms() {
        Events.sendAlarmEvent(R.string.action_show, R.string.label_intent);

        // Open DeskClock positioned on the alarms tab.
+2 −2
Original line number Diff line number Diff line
@@ -546,9 +546,9 @@ public final class DataModel {
     *
     * @param eventLabelId the label of the timer event to send; 0 if no event should be sent
     */
    public void resetExpiredTimers(@StringRes int eventLabelId) {
    public void resetOrDeleteExpiredTimers(@StringRes int eventLabelId) {
        enforceMainLooper();
        mTimerModel.resetExpiredTimers(eventLabelId);
        mTimerModel.resetOrDeleteExpiredTimers(eventLabelId);
    }

    /**
+3 −2
Original line number Diff line number Diff line
@@ -340,11 +340,12 @@ final class TimerModel {
    }

    /**
     * Reset all expired timers.
     * Reset all expired timers. Exactly one parameter should be filled, with preference given to
     * eventLabelId.
     *
     * @param eventLabelId the label of the timer event to send; 0 if no event should be sent
     */
    void resetExpiredTimers(@StringRes int eventLabelId) {
    void resetOrDeleteExpiredTimers(@StringRes int eventLabelId) {
        final List<Timer> timers = new ArrayList<>(getTimers());
        for (Timer timer : timers) {
            if (timer.isExpired()) {
Loading