Loading AndroidManifest.xml +1 −21 Original line number Diff line number Diff line Loading @@ -104,24 +104,9 @@ android:taskAffinity="" android:theme="@android:style/Theme.NoDisplay"> <intent-filter> <action android:name="android.intent.action.DISMISS_ALARM" /> <action android:name="android.intent.action.SHOW_ALARMS" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.VOICE" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.SHOW_TIMERS" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.VOICE" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.DISMISS_ALARM" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.VOICE" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.SNOOZE_ALARM" /> <category android:name="android.intent.category.DEFAULT" /> Loading @@ -135,11 +120,6 @@ android:targetActivity=".HandleApiCalls"> <intent-filter> <action android:name="android.intent.action.SET_ALARM" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.VOICE" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.SET_TIMER" /> <category android:name="android.intent.category.DEFAULT" /> Loading src/com/android/deskclock/HandleApiCalls.java +42 −32 Original line number Diff line number Diff line Loading @@ -61,20 +61,26 @@ import static com.android.deskclock.uidata.UiDataModel.Tab.TIMERS; */ public class HandleApiCalls extends Activity { private Context mAppContext; private static final LogUtils.Logger LOGGER = new LogUtils.Logger("HandleApiCalls"); static final String ACTION_SHOW_TIMERS = "android.intent.action.SHOW_TIMERS"; public static final String ACTION_SHOW_TIMERS = "android.intent.action.SHOW_TIMERS"; private Context mAppContext; @Override protected void onCreate(Bundle icicle) { try { super.onCreate(icicle); mAppContext = getApplicationContext(); try { final Intent intent = getIntent(); final String action = intent == null ? null : intent.getAction(); if (action == null) { return; } LOGGER.i("onCreate: " + intent); switch (action) { case AlarmClock.ACTION_SET_ALARM: handleSetAlarm(intent); Loading @@ -95,6 +101,8 @@ public class HandleApiCalls extends Activity { handleSnoozeAlarm(intent); break; } } catch (Exception e) { LOGGER.wtf(e); } finally { finish(); } Loading @@ -118,7 +126,7 @@ public class HandleApiCalls extends Activity { if (instance == null) { final String reason = context.getString(R.string.no_alarm_scheduled_for_this_time); Voice.notifyFailure(activity, reason); LogUtils.i(reason); LOGGER.i("No alarm instance to dismiss"); return; } Loading @@ -143,13 +151,13 @@ public class HandleApiCalls extends Activity { final String reason = context.getString( R.string.alarm_cant_be_dismissed_still_more_than_24_hours_away, time); Voice.notifyFailure(activity, reason); LogUtils.i(reason); LOGGER.i("Can't dismiss alarm more than 24 hours in advance"); } // Log the successful dismissal. final String reason = context.getString(R.string.alarm_is_dismissed, time); LogUtils.i(reason); Voice.notifySuccess(activity, reason); LOGGER.i("Alarm dismissed: " + instance); Events.sendAlarmEvent(R.string.action_dismiss, R.string.label_intent); } Loading @@ -172,8 +180,8 @@ public class HandleApiCalls extends Activity { final List<Alarm> alarms = getEnabledAlarms(mContext); if (alarms.isEmpty()) { final String reason = mContext.getString(R.string.no_scheduled_alarms); LogUtils.i(reason); Voice.notifyFailure(mActivity, reason); LOGGER.i("No scheduled alarms"); return null; } Loading Loading @@ -221,7 +229,7 @@ public class HandleApiCalls extends Activity { // Apply the action to the matching alarms for (Alarm alarm : matchingAlarms) { dismissAlarm(alarm, mActivity); LogUtils.i("Alarm %s is dismissed", alarm); LOGGER.i("Alarm dismissed: " + alarm); } return null; } Loading Loading @@ -256,8 +264,8 @@ public class HandleApiCalls extends Activity { cr, FIRED_STATE); if (alarmInstances.isEmpty()) { final String reason = mContext.getString(R.string.no_firing_alarms); LogUtils.i(reason); Voice.notifyFailure(mActivity, reason); LOGGER.i("No firing alarms"); return null; } Loading @@ -274,10 +282,10 @@ public class HandleApiCalls extends Activity { final String time = DateFormat.getTimeFormat(context).format( alarmInstance.getAlarmTime().getTime()); final String reason = context.getString(R.string.alarm_is_snoozed, time); LogUtils.i(reason); Voice.notifySuccess(activity, reason); AlarmStateManager.setSnoozeState(context, alarmInstance, true); LogUtils.i("Snooze %d:%d", alarmInstance.mHour, alarmInstance.mMinute); Voice.notifySuccess(activity, reason); LOGGER.i("Alarm snoozed: " + alarmInstance); Events.sendAlarmEvent(R.string.action_snooze, R.string.label_intent); } Loading @@ -293,7 +301,7 @@ public class HandleApiCalls extends Activity { if (hour < 0 || hour > 23) { final int mins = intent.getIntExtra(AlarmClock.EXTRA_MINUTES, 0); Voice.notifyFailure(this, getString(R.string.invalid_time, hour, mins, " ")); LogUtils.i("HandleApiCalls given illegal hour: " + hour); LOGGER.i("Illegal hour: " + hour); return; } } Loading @@ -302,7 +310,7 @@ public class HandleApiCalls extends Activity { final int minutes = intent.getIntExtra(AlarmClock.EXTRA_MINUTES, 0); if (minutes < 0 || minutes > 59) { Voice.notifyFailure(this, getString(R.string.invalid_time, hour, minutes, " ")); LogUtils.i("HandleApiCalls given illegal minute: " + minutes); LOGGER.i("Illegal minute: " + minutes); return; } Loading @@ -323,7 +331,7 @@ public class HandleApiCalls extends Activity { // Open DeskClock which is now positioned on the alarms tab. startActivity(createAlarm); Voice.notifyFailure(this, getString(R.string.invalid_time, hour, minutes, " ")); LogUtils.i("HandleApiCalls not given time information; opening UI"); LOGGER.i("Missing alarm time; opening UI"); return; } Loading @@ -344,7 +352,7 @@ public class HandleApiCalls extends Activity { AlarmStateManager.deleteAllInstances(this, alarm.id); setupInstance(alarm.createInstanceAfter(Calendar.getInstance()), skipUi); Events.sendAlarmEvent(R.string.action_update, R.string.label_intent); LogUtils.i("HandleApiCalls deleted old, created new alarm: %s", alarm); LOGGER.i("Deleted old instances, created new alarm: " + alarm); return; } Loading @@ -364,29 +372,31 @@ public class HandleApiCalls extends Activity { final String time = DateFormat.getTimeFormat(this).format( alarmInstance.getAlarmTime().getTime()); Voice.notifySuccess(this, getString(R.string.alarm_is_set, time)); LogUtils.i("HandleApiCalls created alarm: %s", alarm); LOGGER.i("Created new alarm: " + alarm); } private void handleShowAlarms(Intent intent) { // Change to the alarms tab. UiDataModel.getUiDataModel().setSelectedTab(ALARMS); Events.sendAlarmEvent(R.string.action_show, R.string.label_intent); // Open DeskClock which is now positioned on the alarms tab. // Open DeskClock positioned on the alarms tab. UiDataModel.getUiDataModel().setSelectedTab(ALARMS); startActivity(new Intent(this, DeskClock.class)); Events.sendAlarmEvent(R.string.action_show, R.string.label_intent); LogUtils.i("HandleApiCalls show alarms"); } private void handleShowTimers(Intent intent) { // Change to the timers tab. UiDataModel.getUiDataModel().setSelectedTab(TIMERS); Events.sendTimerEvent(R.string.action_show, R.string.label_intent); // Open DeskClock which is now positioned on the timers tab. startActivity(new Intent(this, DeskClock.class)); final Intent showTimersIntent = new Intent(this, DeskClock.class); Events.sendTimerEvent(R.string.action_show, R.string.label_intent); LogUtils.i("HandleApiCalls show timers"); final List<Timer> timers = DataModel.getDataModel().getTimers(); if (!timers.isEmpty()) { final Timer newestTimer = timers.get(timers.size() - 1); showTimersIntent.putExtra(TimerService.EXTRA_TIMER_ID, newestTimer.getId()); } // Open DeskClock positioned on the timers tab. UiDataModel.getUiDataModel().setSelectedTab(TIMERS); startActivity(showTimersIntent); } private void handleSetTimer(Intent intent) { Loading @@ -397,7 +407,7 @@ public class HandleApiCalls extends Activity { // Open DeskClock which is now positioned on the timers tab and show the timer setup. startActivity(TimerFragment.createTimerSetupIntent(this)); LogUtils.i("HandleApiCalls showing timer setup"); LOGGER.i("Showing timer setup"); return; } Loading @@ -405,7 +415,7 @@ public class HandleApiCalls extends Activity { final long lengthMillis = SECOND_IN_MILLIS * intent.getIntExtra(AlarmClock.EXTRA_LENGTH, 0); if (lengthMillis < Timer.MIN_LENGTH || lengthMillis > Timer.MAX_LENGTH) { Voice.notifyFailure(this, getString(R.string.invalid_timer_length)); LogUtils.i("Invalid timer length requested: " + lengthMillis); LOGGER.i("Invalid timer length requested: " + lengthMillis); return; } Loading Loading
AndroidManifest.xml +1 −21 Original line number Diff line number Diff line Loading @@ -104,24 +104,9 @@ android:taskAffinity="" android:theme="@android:style/Theme.NoDisplay"> <intent-filter> <action android:name="android.intent.action.DISMISS_ALARM" /> <action android:name="android.intent.action.SHOW_ALARMS" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.VOICE" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.SHOW_TIMERS" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.VOICE" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.DISMISS_ALARM" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.VOICE" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.SNOOZE_ALARM" /> <category android:name="android.intent.category.DEFAULT" /> Loading @@ -135,11 +120,6 @@ android:targetActivity=".HandleApiCalls"> <intent-filter> <action android:name="android.intent.action.SET_ALARM" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.VOICE" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.SET_TIMER" /> <category android:name="android.intent.category.DEFAULT" /> Loading
src/com/android/deskclock/HandleApiCalls.java +42 −32 Original line number Diff line number Diff line Loading @@ -61,20 +61,26 @@ import static com.android.deskclock.uidata.UiDataModel.Tab.TIMERS; */ public class HandleApiCalls extends Activity { private Context mAppContext; private static final LogUtils.Logger LOGGER = new LogUtils.Logger("HandleApiCalls"); static final String ACTION_SHOW_TIMERS = "android.intent.action.SHOW_TIMERS"; public static final String ACTION_SHOW_TIMERS = "android.intent.action.SHOW_TIMERS"; private Context mAppContext; @Override protected void onCreate(Bundle icicle) { try { super.onCreate(icicle); mAppContext = getApplicationContext(); try { final Intent intent = getIntent(); final String action = intent == null ? null : intent.getAction(); if (action == null) { return; } LOGGER.i("onCreate: " + intent); switch (action) { case AlarmClock.ACTION_SET_ALARM: handleSetAlarm(intent); Loading @@ -95,6 +101,8 @@ public class HandleApiCalls extends Activity { handleSnoozeAlarm(intent); break; } } catch (Exception e) { LOGGER.wtf(e); } finally { finish(); } Loading @@ -118,7 +126,7 @@ public class HandleApiCalls extends Activity { if (instance == null) { final String reason = context.getString(R.string.no_alarm_scheduled_for_this_time); Voice.notifyFailure(activity, reason); LogUtils.i(reason); LOGGER.i("No alarm instance to dismiss"); return; } Loading @@ -143,13 +151,13 @@ public class HandleApiCalls extends Activity { final String reason = context.getString( R.string.alarm_cant_be_dismissed_still_more_than_24_hours_away, time); Voice.notifyFailure(activity, reason); LogUtils.i(reason); LOGGER.i("Can't dismiss alarm more than 24 hours in advance"); } // Log the successful dismissal. final String reason = context.getString(R.string.alarm_is_dismissed, time); LogUtils.i(reason); Voice.notifySuccess(activity, reason); LOGGER.i("Alarm dismissed: " + instance); Events.sendAlarmEvent(R.string.action_dismiss, R.string.label_intent); } Loading @@ -172,8 +180,8 @@ public class HandleApiCalls extends Activity { final List<Alarm> alarms = getEnabledAlarms(mContext); if (alarms.isEmpty()) { final String reason = mContext.getString(R.string.no_scheduled_alarms); LogUtils.i(reason); Voice.notifyFailure(mActivity, reason); LOGGER.i("No scheduled alarms"); return null; } Loading Loading @@ -221,7 +229,7 @@ public class HandleApiCalls extends Activity { // Apply the action to the matching alarms for (Alarm alarm : matchingAlarms) { dismissAlarm(alarm, mActivity); LogUtils.i("Alarm %s is dismissed", alarm); LOGGER.i("Alarm dismissed: " + alarm); } return null; } Loading Loading @@ -256,8 +264,8 @@ public class HandleApiCalls extends Activity { cr, FIRED_STATE); if (alarmInstances.isEmpty()) { final String reason = mContext.getString(R.string.no_firing_alarms); LogUtils.i(reason); Voice.notifyFailure(mActivity, reason); LOGGER.i("No firing alarms"); return null; } Loading @@ -274,10 +282,10 @@ public class HandleApiCalls extends Activity { final String time = DateFormat.getTimeFormat(context).format( alarmInstance.getAlarmTime().getTime()); final String reason = context.getString(R.string.alarm_is_snoozed, time); LogUtils.i(reason); Voice.notifySuccess(activity, reason); AlarmStateManager.setSnoozeState(context, alarmInstance, true); LogUtils.i("Snooze %d:%d", alarmInstance.mHour, alarmInstance.mMinute); Voice.notifySuccess(activity, reason); LOGGER.i("Alarm snoozed: " + alarmInstance); Events.sendAlarmEvent(R.string.action_snooze, R.string.label_intent); } Loading @@ -293,7 +301,7 @@ public class HandleApiCalls extends Activity { if (hour < 0 || hour > 23) { final int mins = intent.getIntExtra(AlarmClock.EXTRA_MINUTES, 0); Voice.notifyFailure(this, getString(R.string.invalid_time, hour, mins, " ")); LogUtils.i("HandleApiCalls given illegal hour: " + hour); LOGGER.i("Illegal hour: " + hour); return; } } Loading @@ -302,7 +310,7 @@ public class HandleApiCalls extends Activity { final int minutes = intent.getIntExtra(AlarmClock.EXTRA_MINUTES, 0); if (minutes < 0 || minutes > 59) { Voice.notifyFailure(this, getString(R.string.invalid_time, hour, minutes, " ")); LogUtils.i("HandleApiCalls given illegal minute: " + minutes); LOGGER.i("Illegal minute: " + minutes); return; } Loading @@ -323,7 +331,7 @@ public class HandleApiCalls extends Activity { // Open DeskClock which is now positioned on the alarms tab. startActivity(createAlarm); Voice.notifyFailure(this, getString(R.string.invalid_time, hour, minutes, " ")); LogUtils.i("HandleApiCalls not given time information; opening UI"); LOGGER.i("Missing alarm time; opening UI"); return; } Loading @@ -344,7 +352,7 @@ public class HandleApiCalls extends Activity { AlarmStateManager.deleteAllInstances(this, alarm.id); setupInstance(alarm.createInstanceAfter(Calendar.getInstance()), skipUi); Events.sendAlarmEvent(R.string.action_update, R.string.label_intent); LogUtils.i("HandleApiCalls deleted old, created new alarm: %s", alarm); LOGGER.i("Deleted old instances, created new alarm: " + alarm); return; } Loading @@ -364,29 +372,31 @@ public class HandleApiCalls extends Activity { final String time = DateFormat.getTimeFormat(this).format( alarmInstance.getAlarmTime().getTime()); Voice.notifySuccess(this, getString(R.string.alarm_is_set, time)); LogUtils.i("HandleApiCalls created alarm: %s", alarm); LOGGER.i("Created new alarm: " + alarm); } private void handleShowAlarms(Intent intent) { // Change to the alarms tab. UiDataModel.getUiDataModel().setSelectedTab(ALARMS); Events.sendAlarmEvent(R.string.action_show, R.string.label_intent); // Open DeskClock which is now positioned on the alarms tab. // Open DeskClock positioned on the alarms tab. UiDataModel.getUiDataModel().setSelectedTab(ALARMS); startActivity(new Intent(this, DeskClock.class)); Events.sendAlarmEvent(R.string.action_show, R.string.label_intent); LogUtils.i("HandleApiCalls show alarms"); } private void handleShowTimers(Intent intent) { // Change to the timers tab. UiDataModel.getUiDataModel().setSelectedTab(TIMERS); Events.sendTimerEvent(R.string.action_show, R.string.label_intent); // Open DeskClock which is now positioned on the timers tab. startActivity(new Intent(this, DeskClock.class)); final Intent showTimersIntent = new Intent(this, DeskClock.class); Events.sendTimerEvent(R.string.action_show, R.string.label_intent); LogUtils.i("HandleApiCalls show timers"); final List<Timer> timers = DataModel.getDataModel().getTimers(); if (!timers.isEmpty()) { final Timer newestTimer = timers.get(timers.size() - 1); showTimersIntent.putExtra(TimerService.EXTRA_TIMER_ID, newestTimer.getId()); } // Open DeskClock positioned on the timers tab. UiDataModel.getUiDataModel().setSelectedTab(TIMERS); startActivity(showTimersIntent); } private void handleSetTimer(Intent intent) { Loading @@ -397,7 +407,7 @@ public class HandleApiCalls extends Activity { // Open DeskClock which is now positioned on the timers tab and show the timer setup. startActivity(TimerFragment.createTimerSetupIntent(this)); LogUtils.i("HandleApiCalls showing timer setup"); LOGGER.i("Showing timer setup"); return; } Loading @@ -405,7 +415,7 @@ public class HandleApiCalls extends Activity { final long lengthMillis = SECOND_IN_MILLIS * intent.getIntExtra(AlarmClock.EXTRA_LENGTH, 0); if (lengthMillis < Timer.MIN_LENGTH || lengthMillis > Timer.MAX_LENGTH) { Voice.notifyFailure(this, getString(R.string.invalid_timer_length)); LogUtils.i("Invalid timer length requested: " + lengthMillis); LOGGER.i("Invalid timer length requested: " + lengthMillis); return; } Loading