Loading src/com/android/deskclock/DeskClock.java +11 −0 Original line number Diff line number Diff line Loading @@ -54,6 +54,7 @@ import com.android.deskclock.data.DataModel.SilentSetting; import com.android.deskclock.data.OnSilentSettingsListener; import com.android.deskclock.events.Events; import com.android.deskclock.provider.Alarm; import com.android.deskclock.timer.TimerService; import com.android.deskclock.uidata.TabListener; import com.android.deskclock.uidata.UiDataModel; import com.android.deskclock.widget.toast.SnackbarManager; Loading Loading @@ -291,6 +292,16 @@ public class DeskClock extends BaseActivity protected void onResume() { super.onResume(); final Intent intent = getIntent(); if (intent != null) { final String action = intent.getAction(); if (action != null && action.equals(TimerService.ACTION_SHOW_TIMER)) { int label = intent.getIntExtra(Events.EXTRA_EVENT_LABEL, R.string.label_intent); Events.sendTimerEvent(R.string.action_show, label); UiDataModel.getUiDataModel().setSelectedTab(UiDataModel.Tab.TIMERS); } } // ViewPager does not save state; this honors the selected tab in the user interface. updateCurrentTab(); } Loading src/com/android/deskclock/data/TimerNotificationBuilder.java +5 −13 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ import android.widget.RemoteViews; import androidx.core.app.NotificationCompat; import androidx.core.content.ContextCompat; import com.android.deskclock.DeskClock; import com.android.deskclock.NotificationUtils; import com.android.deskclock.R; import com.android.deskclock.Utils; Loading @@ -49,9 +50,6 @@ import java.util.List; */ class TimerNotificationBuilder { private static final int REQUEST_CODE_UPCOMING = 0; private static final int REQUEST_CODE_MISSING = 1; public Notification build(Context context, NotificationModel nm, List<Timer> unexpired) { final Timer timer = unexpired.get(0); final int count = unexpired.size(); Loading Loading @@ -132,15 +130,12 @@ class TimerNotificationBuilder { } // Intent to load the app and show the timer when the notification is tapped. final Intent showApp = new Intent(context, TimerService.class) final Intent showApp = new Intent(context, DeskClock.class) .setAction(TimerService.ACTION_SHOW_TIMER) .putExtra(TimerService.EXTRA_TIMER_ID, timer.getId()) .putExtra(Events.EXTRA_EVENT_LABEL, R.string.label_notification); final PendingIntent pendingShowApp = PendingIntent.getService(context, REQUEST_CODE_UPCOMING, showApp, PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE); final PendingIntent pendingShowApp = Utils.pendingActivityIntent(context, showApp); final Builder notification = new NotificationCompat.Builder( context, TIMER_MODEL_NOTIFICATION_CHANNEL_ID) Loading Loading @@ -281,15 +276,12 @@ class TimerNotificationBuilder { } // Intent to load the app and show the timer when the notification is tapped. final Intent showApp = new Intent(context, TimerService.class) final Intent showApp = new Intent(context, DeskClock.class) .setAction(TimerService.ACTION_SHOW_TIMER) .putExtra(TimerService.EXTRA_TIMER_ID, timer.getId()) .putExtra(Events.EXTRA_EVENT_LABEL, R.string.label_notification); final PendingIntent pendingShowApp = PendingIntent.getService(context, REQUEST_CODE_MISSING, showApp, PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE); final PendingIntent pendingShowApp = Utils.pendingActivityIntent(context, showApp); final Builder notification = new NotificationCompat.Builder( context, TIMER_MODEL_NOTIFICATION_CHANNEL_ID) Loading src/com/android/deskclock/timer/TimerService.java +1 −14 Original line number Diff line number Diff line Loading @@ -143,20 +143,7 @@ public final class TimerService extends Service { // Perform the action on the timer. if (action != null) { switch (action) { case ACTION_SHOW_TIMER: { Events.sendTimerEvent(R.string.action_show, label); // Change to the timers tab. UiDataModel.getUiDataModel().setSelectedTab(TIMERS); // Open DeskClock which is now positioned on the timers tab and show // the timer in question. final Intent showTimers = new Intent(this, DeskClock.class) .putExtra(EXTRA_TIMER_ID, timerId) .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(showTimers); break; } case ACTION_START_TIMER: { case ACTION_START_TIMER: { Events.sendTimerEvent(R.string.action_start, label); DataModel.getDataModel().startTimer(this, timer); break; Loading Loading
src/com/android/deskclock/DeskClock.java +11 −0 Original line number Diff line number Diff line Loading @@ -54,6 +54,7 @@ import com.android.deskclock.data.DataModel.SilentSetting; import com.android.deskclock.data.OnSilentSettingsListener; import com.android.deskclock.events.Events; import com.android.deskclock.provider.Alarm; import com.android.deskclock.timer.TimerService; import com.android.deskclock.uidata.TabListener; import com.android.deskclock.uidata.UiDataModel; import com.android.deskclock.widget.toast.SnackbarManager; Loading Loading @@ -291,6 +292,16 @@ public class DeskClock extends BaseActivity protected void onResume() { super.onResume(); final Intent intent = getIntent(); if (intent != null) { final String action = intent.getAction(); if (action != null && action.equals(TimerService.ACTION_SHOW_TIMER)) { int label = intent.getIntExtra(Events.EXTRA_EVENT_LABEL, R.string.label_intent); Events.sendTimerEvent(R.string.action_show, label); UiDataModel.getUiDataModel().setSelectedTab(UiDataModel.Tab.TIMERS); } } // ViewPager does not save state; this honors the selected tab in the user interface. updateCurrentTab(); } Loading
src/com/android/deskclock/data/TimerNotificationBuilder.java +5 −13 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ import android.widget.RemoteViews; import androidx.core.app.NotificationCompat; import androidx.core.content.ContextCompat; import com.android.deskclock.DeskClock; import com.android.deskclock.NotificationUtils; import com.android.deskclock.R; import com.android.deskclock.Utils; Loading @@ -49,9 +50,6 @@ import java.util.List; */ class TimerNotificationBuilder { private static final int REQUEST_CODE_UPCOMING = 0; private static final int REQUEST_CODE_MISSING = 1; public Notification build(Context context, NotificationModel nm, List<Timer> unexpired) { final Timer timer = unexpired.get(0); final int count = unexpired.size(); Loading Loading @@ -132,15 +130,12 @@ class TimerNotificationBuilder { } // Intent to load the app and show the timer when the notification is tapped. final Intent showApp = new Intent(context, TimerService.class) final Intent showApp = new Intent(context, DeskClock.class) .setAction(TimerService.ACTION_SHOW_TIMER) .putExtra(TimerService.EXTRA_TIMER_ID, timer.getId()) .putExtra(Events.EXTRA_EVENT_LABEL, R.string.label_notification); final PendingIntent pendingShowApp = PendingIntent.getService(context, REQUEST_CODE_UPCOMING, showApp, PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE); final PendingIntent pendingShowApp = Utils.pendingActivityIntent(context, showApp); final Builder notification = new NotificationCompat.Builder( context, TIMER_MODEL_NOTIFICATION_CHANNEL_ID) Loading Loading @@ -281,15 +276,12 @@ class TimerNotificationBuilder { } // Intent to load the app and show the timer when the notification is tapped. final Intent showApp = new Intent(context, TimerService.class) final Intent showApp = new Intent(context, DeskClock.class) .setAction(TimerService.ACTION_SHOW_TIMER) .putExtra(TimerService.EXTRA_TIMER_ID, timer.getId()) .putExtra(Events.EXTRA_EVENT_LABEL, R.string.label_notification); final PendingIntent pendingShowApp = PendingIntent.getService(context, REQUEST_CODE_MISSING, showApp, PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE); final PendingIntent pendingShowApp = Utils.pendingActivityIntent(context, showApp); final Builder notification = new NotificationCompat.Builder( context, TIMER_MODEL_NOTIFICATION_CHANNEL_ID) Loading
src/com/android/deskclock/timer/TimerService.java +1 −14 Original line number Diff line number Diff line Loading @@ -143,20 +143,7 @@ public final class TimerService extends Service { // Perform the action on the timer. if (action != null) { switch (action) { case ACTION_SHOW_TIMER: { Events.sendTimerEvent(R.string.action_show, label); // Change to the timers tab. UiDataModel.getUiDataModel().setSelectedTab(TIMERS); // Open DeskClock which is now positioned on the timers tab and show // the timer in question. final Intent showTimers = new Intent(this, DeskClock.class) .putExtra(EXTRA_TIMER_ID, timerId) .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(showTimers); break; } case ACTION_START_TIMER: { case ACTION_START_TIMER: { Events.sendTimerEvent(R.string.action_start, label); DataModel.getDataModel().startTimer(this, timer); break; Loading