Loading src/com/android/deskclock/DeskClock.java +12 −3 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.stopwatch.StopwatchService; import com.android.deskclock.timer.TimerService; import com.android.deskclock.uidata.TabListener; import com.android.deskclock.uidata.UiDataModel; Loading Loading @@ -295,10 +296,18 @@ public class DeskClock extends BaseActivity final Intent intent = getIntent(); if (intent != null) { final String action = intent.getAction(); if (action != null && action.equals(TimerService.ACTION_SHOW_TIMER)) { if (action != null ) { int label = intent.getIntExtra(Events.EXTRA_EVENT_LABEL, R.string.label_intent); switch (action) { case TimerService.ACTION_SHOW_TIMER: Events.sendTimerEvent(R.string.action_show, label); UiDataModel.getUiDataModel().setSelectedTab(UiDataModel.Tab.TIMERS); break; case StopwatchService.ACTION_SHOW_STOPWATCH: Events.sendStopwatchEvent(R.string.action_show, label); UiDataModel.getUiDataModel().setSelectedTab(UiDataModel.Tab.STOPWATCH); break; } } } Loading src/com/android/deskclock/Utils.java +3 −1 Original line number Diff line number Diff line Loading @@ -219,7 +219,9 @@ public class Utils { * @return a PendingIntent that will start an activity */ public static PendingIntent pendingActivityIntent(Context context, Intent intent) { return PendingIntent.getActivity(context, 0, intent, FLAG_UPDATE_CURRENT | FLAG_IMMUTABLE); // explicitly set the flag here, as getActivity() documentation states we must do so return PendingIntent.getActivity(context, 0, intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK), FLAG_UPDATE_CURRENT | FLAG_IMMUTABLE); } /** Loading src/com/android/deskclock/data/StopwatchNotificationBuilder.java +3 −4 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ import androidx.core.app.NotificationCompat.Action; import androidx.core.app.NotificationCompat.Builder; 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 @@ -52,13 +53,11 @@ class StopwatchNotificationBuilder { @StringRes final int eventLabel = R.string.label_notification; // Intent to load the app when the notification is tapped. final Intent showApp = new Intent(context, StopwatchService.class) final Intent showApp = new Intent(context, DeskClock.class) .setAction(StopwatchService.ACTION_SHOW_STOPWATCH) .putExtra(Events.EXTRA_EVENT_LABEL, eventLabel); final PendingIntent pendingShowApp = PendingIntent.getService(context, 0, showApp, PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE); final PendingIntent pendingShowApp = Utils.pendingActivityIntent(context, showApp); // Compute some values required below. final boolean running = stopwatch.isRunning(); Loading src/com/android/deskclock/stopwatch/StopwatchService.java +0 −10 Original line number Diff line number Diff line Loading @@ -60,16 +60,6 @@ public final class StopwatchService extends Service { final String action = intent.getAction(); final int label = intent.getIntExtra(Events.EXTRA_EVENT_LABEL, R.string.label_intent); switch (action) { case ACTION_SHOW_STOPWATCH: { Events.sendStopwatchEvent(R.string.action_show, label); // Open DeskClock positioned on the stopwatch tab. UiDataModel.getUiDataModel().setSelectedTab(STOPWATCH); final Intent showStopwatch = new Intent(this, DeskClock.class) .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(showStopwatch); break; } case ACTION_START_STOPWATCH: { Events.sendStopwatchEvent(R.string.action_start, label); DataModel.getDataModel().startStopwatch(); Loading Loading
src/com/android/deskclock/DeskClock.java +12 −3 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.stopwatch.StopwatchService; import com.android.deskclock.timer.TimerService; import com.android.deskclock.uidata.TabListener; import com.android.deskclock.uidata.UiDataModel; Loading Loading @@ -295,10 +296,18 @@ public class DeskClock extends BaseActivity final Intent intent = getIntent(); if (intent != null) { final String action = intent.getAction(); if (action != null && action.equals(TimerService.ACTION_SHOW_TIMER)) { if (action != null ) { int label = intent.getIntExtra(Events.EXTRA_EVENT_LABEL, R.string.label_intent); switch (action) { case TimerService.ACTION_SHOW_TIMER: Events.sendTimerEvent(R.string.action_show, label); UiDataModel.getUiDataModel().setSelectedTab(UiDataModel.Tab.TIMERS); break; case StopwatchService.ACTION_SHOW_STOPWATCH: Events.sendStopwatchEvent(R.string.action_show, label); UiDataModel.getUiDataModel().setSelectedTab(UiDataModel.Tab.STOPWATCH); break; } } } Loading
src/com/android/deskclock/Utils.java +3 −1 Original line number Diff line number Diff line Loading @@ -219,7 +219,9 @@ public class Utils { * @return a PendingIntent that will start an activity */ public static PendingIntent pendingActivityIntent(Context context, Intent intent) { return PendingIntent.getActivity(context, 0, intent, FLAG_UPDATE_CURRENT | FLAG_IMMUTABLE); // explicitly set the flag here, as getActivity() documentation states we must do so return PendingIntent.getActivity(context, 0, intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK), FLAG_UPDATE_CURRENT | FLAG_IMMUTABLE); } /** Loading
src/com/android/deskclock/data/StopwatchNotificationBuilder.java +3 −4 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ import androidx.core.app.NotificationCompat.Action; import androidx.core.app.NotificationCompat.Builder; 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 @@ -52,13 +53,11 @@ class StopwatchNotificationBuilder { @StringRes final int eventLabel = R.string.label_notification; // Intent to load the app when the notification is tapped. final Intent showApp = new Intent(context, StopwatchService.class) final Intent showApp = new Intent(context, DeskClock.class) .setAction(StopwatchService.ACTION_SHOW_STOPWATCH) .putExtra(Events.EXTRA_EVENT_LABEL, eventLabel); final PendingIntent pendingShowApp = PendingIntent.getService(context, 0, showApp, PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE); final PendingIntent pendingShowApp = Utils.pendingActivityIntent(context, showApp); // Compute some values required below. final boolean running = stopwatch.isRunning(); Loading
src/com/android/deskclock/stopwatch/StopwatchService.java +0 −10 Original line number Diff line number Diff line Loading @@ -60,16 +60,6 @@ public final class StopwatchService extends Service { final String action = intent.getAction(); final int label = intent.getIntExtra(Events.EXTRA_EVENT_LABEL, R.string.label_intent); switch (action) { case ACTION_SHOW_STOPWATCH: { Events.sendStopwatchEvent(R.string.action_show, label); // Open DeskClock positioned on the stopwatch tab. UiDataModel.getUiDataModel().setSelectedTab(STOPWATCH); final Intent showStopwatch = new Intent(this, DeskClock.class) .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(showStopwatch); break; } case ACTION_START_STOPWATCH: { Events.sendStopwatchEvent(R.string.action_start, label); DataModel.getDataModel().startStopwatch(); Loading