List of usage examples for android.content.res Resources getText
@NonNull public CharSequence getText(@StringRes int id) throws NotFoundException
From source file:org.jonblack.bluetrack.activities.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main_activity); // Load default preference values. // The defaults are only loaded if they haven't been done before. It will // not overwrite changes. // @see PreferenceManager.setDefaultValues PreferenceManager.setDefaultValues(this, R.xml.preferences, false); // Get the local bluetooth adapter and check if bluetooth is supported. BluetoothAdapter localBtAdapter = BluetoothAdapter.getDefaultAdapter(); if (localBtAdapter == null) { Log.w(TAG, "Bluetooth isn't supported on device."); AlertDialog ad = new AlertDialog.Builder(this).create(); ad.setCancelable(false);/* ww w .j a va2 s . c om*/ Resources r = getResources(); String msg = r.getString(R.string.error_bluetooth_not_supported, r.getString(R.string.app_name)); ad.setMessage(msg); ad.setButton(AlertDialog.BUTTON_POSITIVE, r.getString(R.string.button_exit), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { finish(); dialog.dismiss(); } }); ad.show(); return; } Resources r = getResources(); ActionBar actionBar = getSupportActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); ActionBar.Tab tab1 = actionBar.newTab().setText(r.getText(R.string.ab_tab_live_tracking)); tab1.setTag("tracking"); tab1.setTabListener(new TabListener<LiveTrackingFragment>(this, "tracking", LiveTrackingFragment.class)); actionBar.addTab(tab1); ActionBar.Tab tab2 = actionBar.newTab().setText(r.getText(R.string.ab_tab_sessions)); tab2.setTag("session"); tab2.setTabListener(new TabListener<SessionFragment>(this, "session", SessionFragment.class)); actionBar.addTab(tab2); ActionBar.Tab tab3 = actionBar.newTab().setText(r.getText(R.string.ab_tab_devices)); tab3.setTag("devices"); tab3.setTabListener(new TabListener<DevicesFragment>(this, "devices", DevicesFragment.class)); actionBar.addTab(tab3); }
From source file:com.androidinspain.deskclock.data.StopwatchNotificationBuilder.java
public Notification build(Context context, NotificationModel nm, Stopwatch stopwatch) { @StringRes//from ww w . ja va2 s. c o m final int eventLabel = com.androidinspain.deskclock.R.string.label_notification; // Intent to load the app when the notification is tapped. final Intent showApp = new Intent(context, StopwatchService.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); // Compute some values required below. final boolean running = stopwatch.isRunning(); final String pname = context.getPackageName(); final Resources res = context.getResources(); final long base = SystemClock.elapsedRealtime() - stopwatch.getTotalTime(); final RemoteViews content = new RemoteViews(pname, com.androidinspain.deskclock.R.layout.chronometer_notif_content); content.setChronometer(com.androidinspain.deskclock.R.id.chronometer, base, null, running); final List<Action> actions = new ArrayList<>(2); if (running) { // Left button: Pause final Intent pause = new Intent(context, StopwatchService.class) .setAction(StopwatchService.ACTION_PAUSE_STOPWATCH) .putExtra(Events.EXTRA_EVENT_LABEL, eventLabel); @DrawableRes final int icon1 = com.androidinspain.deskclock.R.drawable.ic_pause_24dp; final CharSequence title1 = res.getText(com.androidinspain.deskclock.R.string.sw_pause_button); final PendingIntent intent1 = Utils.pendingServiceIntent(context, pause); actions.add(new Action.Builder(icon1, title1, intent1).build()); // Right button: Add Lap if (DataModel.getDataModel().canAddMoreLaps()) { final Intent lap = new Intent(context, StopwatchService.class) .setAction(StopwatchService.ACTION_LAP_STOPWATCH) .putExtra(Events.EXTRA_EVENT_LABEL, eventLabel); @DrawableRes final int icon2 = com.androidinspain.deskclock.R.drawable.ic_sw_lap_24dp; final CharSequence title2 = res.getText(com.androidinspain.deskclock.R.string.sw_lap_button); final PendingIntent intent2 = Utils.pendingServiceIntent(context, lap); actions.add(new Action.Builder(icon2, title2, intent2).build()); } // Show the current lap number if any laps have been recorded. final int lapCount = DataModel.getDataModel().getLaps().size(); if (lapCount > 0) { final int lapNumber = lapCount + 1; final String lap = res.getString(com.androidinspain.deskclock.R.string.sw_notification_lap_number, lapNumber); content.setTextViewText(com.androidinspain.deskclock.R.id.state, lap); content.setViewVisibility(com.androidinspain.deskclock.R.id.state, VISIBLE); } else { content.setViewVisibility(com.androidinspain.deskclock.R.id.state, GONE); } } else { // Left button: Start final Intent start = new Intent(context, StopwatchService.class) .setAction(StopwatchService.ACTION_START_STOPWATCH) .putExtra(Events.EXTRA_EVENT_LABEL, eventLabel); @DrawableRes final int icon1 = com.androidinspain.deskclock.R.drawable.ic_start_24dp; final CharSequence title1 = res.getText(com.androidinspain.deskclock.R.string.sw_start_button); final PendingIntent intent1 = Utils.pendingServiceIntent(context, start); actions.add(new Action.Builder(icon1, title1, intent1).build()); // Right button: Reset (dismisses notification and resets stopwatch) final Intent reset = new Intent(context, StopwatchService.class) .setAction(StopwatchService.ACTION_RESET_STOPWATCH) .putExtra(Events.EXTRA_EVENT_LABEL, eventLabel); @DrawableRes final int icon2 = com.androidinspain.deskclock.R.drawable.ic_reset_24dp; final CharSequence title2 = res.getText(com.androidinspain.deskclock.R.string.sw_reset_button); final PendingIntent intent2 = Utils.pendingServiceIntent(context, reset); actions.add(new Action.Builder(icon2, title2, intent2).build()); // Indicate the stopwatch is paused. content.setTextViewText(com.androidinspain.deskclock.R.id.state, res.getString(com.androidinspain.deskclock.R.string.swn_paused)); content.setViewVisibility(com.androidinspain.deskclock.R.id.state, VISIBLE); } final Builder notification = new NotificationCompat.Builder(context).setLocalOnly(true).setOngoing(running) .setCustomContentView(content).setContentIntent(pendingShowApp).setAutoCancel(stopwatch.isPaused()) .setPriority(Notification.PRIORITY_MAX) .setSmallIcon(com.androidinspain.deskclock.R.drawable.stat_notify_stopwatch) .setStyle(new NotificationCompat.DecoratedCustomViewStyle()) .setColor(ContextCompat.getColor(context, com.androidinspain.deskclock.R.color.default_background)); if (Utils.isNOrLater()) { notification.setGroup(nm.getStopwatchNotificationGroupKey()); } for (Action action : actions) { notification.addAction(action); } return notification.build(); }
From source file:com.wizardsofm.deskclock.data.StopwatchNotificationBuilderN.java
@Override public Notification build(Context context, NotificationModel nm, Stopwatch stopwatch) { @StringRes/*from ww w . j a v a 2 s. c om*/ final int eventLabel = com.wizardsofm.deskclock.R.string.label_notification; // Intent to load the app when the notification is tapped. final Intent showApp = new Intent(context, HandleDeskClockApiCalls.class) .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK).setAction(HandleDeskClockApiCalls.ACTION_SHOW_STOPWATCH) .putExtra(HandleDeskClockApiCalls.EXTRA_EVENT_LABEL, eventLabel); final PendingIntent pendingShowApp = PendingIntent.getActivity(context, 0, showApp, PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_UPDATE_CURRENT); // Compute some values required below. final boolean running = stopwatch.isRunning(); final String pname = context.getPackageName(); final Resources res = context.getResources(); final long base = SystemClock.elapsedRealtime() - stopwatch.getTotalTime(); final RemoteViews content = new RemoteViews(pname, com.wizardsofm.deskclock.R.layout.chronometer_notif_content); content.setChronometer(com.wizardsofm.deskclock.R.id.chronometer, base, null, running); final List<Notification.Action> actions = new ArrayList<>(2); if (running) { // Left button: Pause final Intent pause = new Intent(context, StopwatchService.class) .setAction(HandleDeskClockApiCalls.ACTION_PAUSE_STOPWATCH) .putExtra(HandleDeskClockApiCalls.EXTRA_EVENT_LABEL, eventLabel); final Icon icon1 = Icon.createWithResource(context, com.wizardsofm.deskclock.R.drawable.ic_pause_24dp); final CharSequence title1 = res.getText(com.wizardsofm.deskclock.R.string.sw_pause_button); final PendingIntent intent1 = Utils.pendingServiceIntent(context, pause); actions.add(new Notification.Action.Builder(icon1, title1, intent1).build()); // Right button: Add Lap if (DataModel.getDataModel().canAddMoreLaps()) { final Intent lap = new Intent(context, StopwatchService.class) .setAction(HandleDeskClockApiCalls.ACTION_LAP_STOPWATCH) .putExtra(HandleDeskClockApiCalls.EXTRA_EVENT_LABEL, eventLabel); final Icon icon2 = Icon.createWithResource(context, com.wizardsofm.deskclock.R.drawable.ic_sw_lap_24dp); final CharSequence title2 = res.getText(com.wizardsofm.deskclock.R.string.sw_lap_button); final PendingIntent intent2 = Utils.pendingServiceIntent(context, lap); actions.add(new Notification.Action.Builder(icon2, title2, intent2).build()); } // Show the current lap number if any laps have been recorded. final int lapCount = DataModel.getDataModel().getLaps().size(); if (lapCount > 0) { final int lapNumber = lapCount + 1; final String lap = res.getString(com.wizardsofm.deskclock.R.string.sw_notification_lap_number, lapNumber); content.setTextViewText(com.wizardsofm.deskclock.R.id.state, lap); content.setViewVisibility(com.wizardsofm.deskclock.R.id.state, VISIBLE); } else { content.setViewVisibility(com.wizardsofm.deskclock.R.id.state, GONE); } } else { // Left button: Start final Intent start = new Intent(context, StopwatchService.class) .setAction(HandleDeskClockApiCalls.ACTION_START_STOPWATCH) .putExtra(HandleDeskClockApiCalls.EXTRA_EVENT_LABEL, eventLabel); final Icon icon1 = Icon.createWithResource(context, com.wizardsofm.deskclock.R.drawable.ic_start_24dp); final CharSequence title1 = res.getText(com.wizardsofm.deskclock.R.string.sw_start_button); final PendingIntent intent1 = Utils.pendingServiceIntent(context, start); actions.add(new Notification.Action.Builder(icon1, title1, intent1).build()); // Right button: Reset (dismisses notification and resets stopwatch) final Intent reset = new Intent(context, StopwatchService.class) .setAction(HandleDeskClockApiCalls.ACTION_RESET_STOPWATCH) .putExtra(HandleDeskClockApiCalls.EXTRA_EVENT_LABEL, eventLabel); final Icon icon2 = Icon.createWithResource(context, com.wizardsofm.deskclock.R.drawable.ic_reset_24dp); final CharSequence title2 = res.getText(com.wizardsofm.deskclock.R.string.sw_reset_button); final PendingIntent intent2 = Utils.pendingServiceIntent(context, reset); actions.add(new Notification.Action.Builder(icon2, title2, intent2).build()); // Indicate the stopwatch is paused. content.setTextViewText(com.wizardsofm.deskclock.R.id.state, res.getString(com.wizardsofm.deskclock.R.string.swn_paused)); content.setViewVisibility(com.wizardsofm.deskclock.R.id.state, VISIBLE); } // Swipe away will reset the stopwatch without bringing forward the app. final Intent reset = new Intent(context, StopwatchService.class) .setAction(HandleDeskClockApiCalls.ACTION_RESET_STOPWATCH) .putExtra(HandleDeskClockApiCalls.EXTRA_EVENT_LABEL, eventLabel); return new Notification.Builder(context).setLocalOnly(true).setOngoing(running) .setCustomContentView(content).setContentIntent(pendingShowApp).setAutoCancel(stopwatch.isPaused()) .setPriority(Notification.PRIORITY_MAX) .setSmallIcon(com.wizardsofm.deskclock.R.drawable.stat_notify_stopwatch) .setGroup(nm.getStopwatchNotificationGroupKey()) .setStyle(new Notification.DecoratedCustomViewStyle()) .setDeleteIntent(Utils.pendingServiceIntent(context, reset)) .setActions(actions.toArray(new Notification.Action[actions.size()])) .setColor(ContextCompat.getColor(context, com.wizardsofm.deskclock.R.color.default_background)) .build(); }
From source file:at.alladin.rmbt.android.test.RMBTLoopService.java
private NotificationCompat.Builder createNotificationBuilder() { final Resources res = getResources(); Intent notificationIntent = new Intent(getApplicationContext(), RMBTMainActivity.class); notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent openAppIntent = PendingIntent.getActivity(getApplicationContext(), 0, notificationIntent, 0); final NotificationCompat.Builder builder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.stat_icon_loop) .setContentTitle(res.getText(R.string.loop_notification_title)) .setTicker(res.getText(R.string.loop_notification_ticker)).setContentIntent(openAppIntent); setNotificationText(builder);/*from ww w .j a v a 2 s . co m*/ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { if (SHOW_DEV_BUTTONS) { final Intent stopIntent = new Intent(ACTION_STOP, null, getApplicationContext(), getClass()); final PendingIntent stopPIntent = PendingIntent.getService(getApplicationContext(), 0, stopIntent, 0); final Intent forceIntent = new Intent(ACTION_FORCE, null, getApplicationContext(), getClass()); final PendingIntent forcePIntent = PendingIntent.getService(getApplicationContext(), 0, forceIntent, 0); addActionToNotificationBuilder(builder, stopPIntent, forcePIntent); } } return builder; }
From source file:com.android.deskclock.data.StopwatchNotificationBuilderPreN.java
@Override public Notification build(Context context, NotificationModel nm, Stopwatch stopwatch) { @StringRes//from w w w . j a v a2 s . com final int eventLabel = R.string.label_notification; // Intent to load the app when the notification is tapped. final Intent showApp = new Intent(context, HandleDeskClockApiCalls.class) .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK).setAction(HandleDeskClockApiCalls.ACTION_SHOW_STOPWATCH) .putExtra(HandleDeskClockApiCalls.EXTRA_EVENT_LABEL, eventLabel); final PendingIntent pendingShowApp = PendingIntent.getActivity(context, 0, showApp, PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_UPDATE_CURRENT); // Compute some values required below. final boolean running = stopwatch.isRunning(); final String pname = context.getPackageName(); final Resources res = context.getResources(); final long base = SystemClock.elapsedRealtime() - stopwatch.getTotalTime(); final RemoteViews collapsed = new RemoteViews(pname, R.layout.stopwatch_notif_collapsed); collapsed.setChronometer(R.id.swn_collapsed_chronometer, base, null, running); collapsed.setOnClickPendingIntent(R.id.swn_collapsed_hitspace, pendingShowApp); collapsed.setImageViewResource(R.id.notification_icon, R.drawable.stat_notify_stopwatch); final RemoteViews expanded = new RemoteViews(pname, R.layout.stopwatch_notif_expanded); expanded.setChronometer(R.id.swn_expanded_chronometer, base, null, running); expanded.setOnClickPendingIntent(R.id.swn_expanded_hitspace, pendingShowApp); expanded.setImageViewResource(R.id.notification_icon, R.drawable.stat_notify_stopwatch); @IdRes final int leftButtonId = R.id.swn_left_button; @IdRes final int rightButtonId = R.id.swn_right_button; if (running) { // Left button: Pause expanded.setTextViewText(leftButtonId, res.getText(R.string.sw_pause_button)); setTextViewDrawable(expanded, leftButtonId, R.drawable.ic_pause_24dp); final Intent pause = new Intent(context, StopwatchService.class) .setAction(HandleDeskClockApiCalls.ACTION_PAUSE_STOPWATCH) .putExtra(HandleDeskClockApiCalls.EXTRA_EVENT_LABEL, eventLabel); final PendingIntent pendingPause = Utils.pendingServiceIntent(context, pause); expanded.setOnClickPendingIntent(leftButtonId, pendingPause); // Right button: Add Lap if (DataModel.getDataModel().canAddMoreLaps()) { expanded.setTextViewText(rightButtonId, res.getText(R.string.sw_lap_button)); setTextViewDrawable(expanded, rightButtonId, R.drawable.ic_sw_lap_24dp); final Intent lap = new Intent(context, StopwatchService.class) .setAction(HandleDeskClockApiCalls.ACTION_LAP_STOPWATCH) .putExtra(HandleDeskClockApiCalls.EXTRA_EVENT_LABEL, eventLabel); final PendingIntent pendingLap = Utils.pendingServiceIntent(context, lap); expanded.setOnClickPendingIntent(rightButtonId, pendingLap); expanded.setViewVisibility(rightButtonId, VISIBLE); } else { expanded.setViewVisibility(rightButtonId, INVISIBLE); } // Show the current lap number if any laps have been recorded. final int lapCount = DataModel.getDataModel().getLaps().size(); if (lapCount > 0) { final int lapNumber = lapCount + 1; final String lap = res.getString(R.string.sw_notification_lap_number, lapNumber); collapsed.setTextViewText(R.id.swn_collapsed_laps, lap); collapsed.setViewVisibility(R.id.swn_collapsed_laps, VISIBLE); expanded.setTextViewText(R.id.swn_expanded_laps, lap); expanded.setViewVisibility(R.id.swn_expanded_laps, VISIBLE); } else { collapsed.setViewVisibility(R.id.swn_collapsed_laps, GONE); expanded.setViewVisibility(R.id.swn_expanded_laps, GONE); } } else { // Left button: Start expanded.setTextViewText(leftButtonId, res.getText(R.string.sw_start_button)); setTextViewDrawable(expanded, leftButtonId, R.drawable.ic_start_24dp); final Intent start = new Intent(context, StopwatchService.class) .setAction(HandleDeskClockApiCalls.ACTION_START_STOPWATCH) .putExtra(HandleDeskClockApiCalls.EXTRA_EVENT_LABEL, eventLabel); final PendingIntent pendingStart = Utils.pendingServiceIntent(context, start); expanded.setOnClickPendingIntent(leftButtonId, pendingStart); // Right button: Reset (dismisses notification and resets stopwatch) expanded.setViewVisibility(rightButtonId, VISIBLE); expanded.setTextViewText(rightButtonId, res.getText(R.string.sw_reset_button)); setTextViewDrawable(expanded, rightButtonId, R.drawable.ic_reset_24dp); final Intent reset = new Intent(context, StopwatchService.class) .setAction(HandleDeskClockApiCalls.ACTION_RESET_STOPWATCH) .putExtra(HandleDeskClockApiCalls.EXTRA_EVENT_LABEL, eventLabel); final PendingIntent pendingReset = Utils.pendingServiceIntent(context, reset); expanded.setOnClickPendingIntent(rightButtonId, pendingReset); // Indicate the stopwatch is paused. collapsed.setTextViewText(R.id.swn_collapsed_laps, res.getString(R.string.swn_paused)); collapsed.setViewVisibility(R.id.swn_collapsed_laps, VISIBLE); expanded.setTextViewText(R.id.swn_expanded_laps, res.getString(R.string.swn_paused)); expanded.setViewVisibility(R.id.swn_expanded_laps, VISIBLE); } // Swipe away will reset the stopwatch without bringing forward the app. final Intent reset = new Intent(context, StopwatchService.class) .setAction(HandleDeskClockApiCalls.ACTION_RESET_STOPWATCH) .putExtra(HandleDeskClockApiCalls.EXTRA_EVENT_LABEL, eventLabel); final Notification notification = new NotificationCompat.Builder(context).setLocalOnly(true) .setOngoing(running).setContent(collapsed).setAutoCancel(stopwatch.isPaused()) .setPriority(NotificationCompat.PRIORITY_MAX).setSmallIcon(R.drawable.stat_notify_stopwatch) .setDeleteIntent(Utils.pendingServiceIntent(context, reset)) .setColor(ContextCompat.getColor(context, R.color.default_background)).build(); notification.bigContentView = expanded; return notification; }
From source file:com.androidinspain.deskclock.data.TimerNotificationBuilder.java
Notification buildMissed(Context context, NotificationModel nm, List<Timer> missedTimers) { final Timer timer = missedTimers.get(0); final int count = missedTimers.size(); // Compute some values required below. final long base = getChronometerBase(timer); final String pname = context.getPackageName(); final Resources res = context.getResources(); final Action action; final CharSequence stateText; if (count == 1) { // Single timer is missed. if (TextUtils.isEmpty(timer.getLabel())) { stateText = res.getString(com.androidinspain.deskclock.R.string.missed_timer_notification_label); } else {/*from ww w . ja v a 2 s . c o m*/ stateText = res.getString( com.androidinspain.deskclock.R.string.missed_named_timer_notification_label, timer.getLabel()); } // Reset button final Intent reset = new Intent(context, TimerService.class).setAction(TimerService.ACTION_RESET_TIMER) .putExtra(TimerService.EXTRA_TIMER_ID, timer.getId()); @DrawableRes final int icon1 = com.androidinspain.deskclock.R.drawable.ic_reset_24dp; final CharSequence title1 = res.getText(com.androidinspain.deskclock.R.string.timer_reset); final PendingIntent intent1 = Utils.pendingServiceIntent(context, reset); action = new Action.Builder(icon1, title1, intent1).build(); } else { // Multiple missed timers. stateText = res.getString(com.androidinspain.deskclock.R.string.timer_multi_missed, count); final Intent reset = TimerService.createResetMissedTimersIntent(context); @DrawableRes final int icon1 = com.androidinspain.deskclock.R.drawable.ic_reset_24dp; final CharSequence title1 = res.getText(com.androidinspain.deskclock.R.string.timer_reset_all); final PendingIntent intent1 = Utils.pendingServiceIntent(context, reset); action = new Action.Builder(icon1, title1, intent1).build(); } // Intent to load the app and show the timer when the notification is tapped. final Intent showApp = new Intent(context, TimerService.class).setAction(TimerService.ACTION_SHOW_TIMER) .putExtra(TimerService.EXTRA_TIMER_ID, timer.getId()) .putExtra(Events.EXTRA_EVENT_LABEL, com.androidinspain.deskclock.R.string.label_notification); final PendingIntent pendingShowApp = PendingIntent.getService(context, REQUEST_CODE_MISSING, showApp, PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_UPDATE_CURRENT); final Builder notification = new NotificationCompat.Builder(context).setLocalOnly(true).setShowWhen(false) .setAutoCancel(false).setContentIntent(pendingShowApp).setPriority(Notification.PRIORITY_HIGH) .setCategory(NotificationCompat.CATEGORY_ALARM) .setSmallIcon(com.androidinspain.deskclock.R.drawable.stat_notify_timer) .setVisibility(NotificationCompat.VISIBILITY_PUBLIC) .setSortKey(nm.getTimerNotificationMissedSortKey()) .setStyle(new NotificationCompat.DecoratedCustomViewStyle()).addAction(action) .setColor(ContextCompat.getColor(context, com.androidinspain.deskclock.R.color.default_background)); if (Utils.isNOrLater()) { notification.setCustomContentView(buildChronometer(pname, base, true, stateText)) .setGroup(nm.getTimerNotificationGroupKey()); } else { final CharSequence contentText = AlarmUtils.getFormattedTime(context, timer.getWallClockExpirationTime()); notification.setContentText(contentText).setContentTitle(stateText); } return notification.build(); }
From source file:com.android.deskclock.data.StopwatchModel.java
/** * Updates the notification to reflect the latest state of the stopwatch and recorded laps. *//*from w ww.j a v a2s .co m*/ void updateNotification() { final Stopwatch stopwatch = getStopwatch(); // Notification should be hidden if the stopwatch has no time or the app is open. if (stopwatch.isReset() || mNotificationModel.isApplicationInForeground()) { mNotificationManager.cancel(mNotificationModel.getStopwatchNotificationId()); return; } @StringRes final int eventLabel = R.string.label_notification; // Intent to load the app when the notification is tapped. final Intent showApp = new Intent(mContext, HandleDeskClockApiCalls.class) .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK).setAction(HandleDeskClockApiCalls.ACTION_SHOW_STOPWATCH) .putExtra(HandleDeskClockApiCalls.EXTRA_EVENT_LABEL, eventLabel); final PendingIntent pendingShowApp = PendingIntent.getActivity(mContext, 0, showApp, PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_UPDATE_CURRENT); // Compute some values required below. final boolean running = stopwatch.isRunning(); final String pname = mContext.getPackageName(); final Resources res = mContext.getResources(); final long base = SystemClock.elapsedRealtime() - stopwatch.getTotalTime(); final RemoteViews collapsed = new RemoteViews(pname, R.layout.stopwatch_notif_collapsed); collapsed.setChronometer(R.id.swn_collapsed_chronometer, base, null, running); collapsed.setOnClickPendingIntent(R.id.swn_collapsed_hitspace, pendingShowApp); collapsed.setImageViewResource(R.id.notification_icon, R.drawable.stat_notify_stopwatch); final RemoteViews expanded = new RemoteViews(pname, R.layout.stopwatch_notif_expanded); expanded.setChronometer(R.id.swn_expanded_chronometer, base, null, running); expanded.setOnClickPendingIntent(R.id.swn_expanded_hitspace, pendingShowApp); expanded.setImageViewResource(R.id.notification_icon, R.drawable.stat_notify_stopwatch); @IdRes final int leftButtonId = R.id.swn_left_button; @IdRes final int rightButtonId = R.id.swn_right_button; if (running) { // Left button: Pause expanded.setTextViewText(leftButtonId, res.getText(R.string.sw_pause_button)); setTextViewDrawable(expanded, leftButtonId, R.drawable.ic_pause_24dp); final Intent pause = new Intent(mContext, StopwatchService.class) .setAction(HandleDeskClockApiCalls.ACTION_PAUSE_STOPWATCH) .putExtra(HandleDeskClockApiCalls.EXTRA_EVENT_LABEL, eventLabel); expanded.setOnClickPendingIntent(leftButtonId, pendingServiceIntent(pause)); // Right button: Add Lap if (canAddMoreLaps()) { expanded.setTextViewText(rightButtonId, res.getText(R.string.sw_lap_button)); setTextViewDrawable(expanded, rightButtonId, R.drawable.ic_sw_lap_24dp); final Intent lap = new Intent(mContext, StopwatchService.class) .setAction(HandleDeskClockApiCalls.ACTION_LAP_STOPWATCH) .putExtra(HandleDeskClockApiCalls.EXTRA_EVENT_LABEL, eventLabel); expanded.setOnClickPendingIntent(rightButtonId, pendingServiceIntent(lap)); expanded.setViewVisibility(rightButtonId, VISIBLE); } else { expanded.setViewVisibility(rightButtonId, INVISIBLE); } // Show the current lap number if any laps have been recorded. final int lapCount = getLaps().size(); if (lapCount > 0) { final int lapNumber = lapCount + 1; final String lap = res.getString(R.string.sw_notification_lap_number, lapNumber); collapsed.setTextViewText(R.id.swn_collapsed_laps, lap); collapsed.setViewVisibility(R.id.swn_collapsed_laps, VISIBLE); expanded.setTextViewText(R.id.swn_expanded_laps, lap); expanded.setViewVisibility(R.id.swn_expanded_laps, VISIBLE); } else { collapsed.setViewVisibility(R.id.swn_collapsed_laps, GONE); expanded.setViewVisibility(R.id.swn_expanded_laps, GONE); } } else { // Left button: Start expanded.setTextViewText(leftButtonId, res.getText(R.string.sw_start_button)); setTextViewDrawable(expanded, leftButtonId, R.drawable.ic_start_24dp); final Intent start = new Intent(mContext, StopwatchService.class) .setAction(HandleDeskClockApiCalls.ACTION_START_STOPWATCH) .putExtra(HandleDeskClockApiCalls.EXTRA_EVENT_LABEL, eventLabel); expanded.setOnClickPendingIntent(leftButtonId, pendingServiceIntent(start)); // Right button: Reset (HandleDeskClockApiCalls will also bring forward the app) expanded.setViewVisibility(rightButtonId, VISIBLE); expanded.setTextViewText(rightButtonId, res.getText(R.string.sw_reset_button)); setTextViewDrawable(expanded, rightButtonId, R.drawable.ic_reset_24dp); final Intent reset = new Intent(mContext, HandleDeskClockApiCalls.class) .setAction(HandleDeskClockApiCalls.ACTION_RESET_STOPWATCH) .putExtra(HandleDeskClockApiCalls.EXTRA_EVENT_LABEL, eventLabel); expanded.setOnClickPendingIntent(rightButtonId, pendingActivityIntent(reset)); // Indicate the stopwatch is paused. collapsed.setTextViewText(R.id.swn_collapsed_laps, res.getString(R.string.swn_paused)); collapsed.setViewVisibility(R.id.swn_collapsed_laps, VISIBLE); expanded.setTextViewText(R.id.swn_expanded_laps, res.getString(R.string.swn_paused)); expanded.setViewVisibility(R.id.swn_expanded_laps, VISIBLE); } // Swipe away will reset the stopwatch without bringing forward the app. final Intent reset = new Intent(mContext, StopwatchService.class) .setAction(HandleDeskClockApiCalls.ACTION_RESET_STOPWATCH) .putExtra(HandleDeskClockApiCalls.EXTRA_EVENT_LABEL, eventLabel); final Notification notification = new NotificationCompat.Builder(mContext).setLocalOnly(true) .setOngoing(running).setContent(collapsed).setAutoCancel(stopwatch.isPaused()) .setPriority(Notification.PRIORITY_MAX).setDeleteIntent(pendingServiceIntent(reset)) .setSmallIcon(R.drawable.ic_tab_stopwatch_activated).build(); notification.bigContentView = expanded; mNotificationManager.notify(mNotificationModel.getStopwatchNotificationId(), notification); }
From source file:com.androidinspain.deskclock.data.TimerNotificationBuilder.java
public Notification build(Context context, NotificationModel nm, List<Timer> unexpired) { final Timer timer = unexpired.get(0); final int count = unexpired.size(); // Compute some values required below. final boolean running = timer.isRunning(); final Resources res = context.getResources(); final long base = getChronometerBase(timer); final String pname = context.getPackageName(); final List<Action> actions = new ArrayList<>(2); final CharSequence stateText; if (count == 1) { if (running) { // Single timer is running. if (TextUtils.isEmpty(timer.getLabel())) { stateText = res.getString(com.androidinspain.deskclock.R.string.timer_notification_label); } else { stateText = timer.getLabel(); }//from ww w . ja v a 2 s . c om // Left button: Pause final Intent pause = new Intent(context, TimerService.class) .setAction(TimerService.ACTION_PAUSE_TIMER) .putExtra(TimerService.EXTRA_TIMER_ID, timer.getId()); @DrawableRes final int icon1 = com.androidinspain.deskclock.R.drawable.ic_pause_24dp; final CharSequence title1 = res.getText(com.androidinspain.deskclock.R.string.timer_pause); final PendingIntent intent1 = Utils.pendingServiceIntent(context, pause); actions.add(new Action.Builder(icon1, title1, intent1).build()); // Right Button: +1 Minute final Intent addMinute = new Intent(context, TimerService.class) .setAction(TimerService.ACTION_ADD_MINUTE_TIMER) .putExtra(TimerService.EXTRA_TIMER_ID, timer.getId()); @DrawableRes final int icon2 = com.androidinspain.deskclock.R.drawable.ic_add_24dp; final CharSequence title2 = res.getText(com.androidinspain.deskclock.R.string.timer_plus_1_min); final PendingIntent intent2 = Utils.pendingServiceIntent(context, addMinute); actions.add(new Action.Builder(icon2, title2, intent2).build()); } else { // Single timer is paused. stateText = res.getString(com.androidinspain.deskclock.R.string.timer_paused); // Left button: Start final Intent start = new Intent(context, TimerService.class) .setAction(TimerService.ACTION_START_TIMER) .putExtra(TimerService.EXTRA_TIMER_ID, timer.getId()); @DrawableRes final int icon1 = com.androidinspain.deskclock.R.drawable.ic_start_24dp; final CharSequence title1 = res.getText(com.androidinspain.deskclock.R.string.sw_resume_button); final PendingIntent intent1 = Utils.pendingServiceIntent(context, start); actions.add(new Action.Builder(icon1, title1, intent1).build()); // Right Button: Reset final Intent reset = new Intent(context, TimerService.class) .setAction(TimerService.ACTION_RESET_TIMER) .putExtra(TimerService.EXTRA_TIMER_ID, timer.getId()); @DrawableRes final int icon2 = com.androidinspain.deskclock.R.drawable.ic_reset_24dp; final CharSequence title2 = res.getText(com.androidinspain.deskclock.R.string.sw_reset_button); final PendingIntent intent2 = Utils.pendingServiceIntent(context, reset); actions.add(new Action.Builder(icon2, title2, intent2).build()); } } else { if (running) { // At least one timer is running. stateText = res.getString(com.androidinspain.deskclock.R.string.timers_in_use, count); } else { // All timers are paused. stateText = res.getString(com.androidinspain.deskclock.R.string.timers_stopped, count); } final Intent reset = TimerService.createResetUnexpiredTimersIntent(context); @DrawableRes final int icon1 = com.androidinspain.deskclock.R.drawable.ic_reset_24dp; final CharSequence title1 = res.getText(com.androidinspain.deskclock.R.string.timer_reset_all); final PendingIntent intent1 = Utils.pendingServiceIntent(context, reset); actions.add(new Action.Builder(icon1, title1, intent1).build()); } // Intent to load the app and show the timer when the notification is tapped. final Intent showApp = new Intent(context, TimerService.class).setAction(TimerService.ACTION_SHOW_TIMER) .putExtra(TimerService.EXTRA_TIMER_ID, timer.getId()) .putExtra(Events.EXTRA_EVENT_LABEL, com.androidinspain.deskclock.R.string.label_notification); final PendingIntent pendingShowApp = PendingIntent.getService(context, REQUEST_CODE_UPCOMING, showApp, PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_UPDATE_CURRENT); final Builder notification = new NotificationCompat.Builder(context).setOngoing(true).setLocalOnly(true) .setShowWhen(false).setAutoCancel(false).setContentIntent(pendingShowApp) .setPriority(Notification.PRIORITY_HIGH).setCategory(NotificationCompat.CATEGORY_ALARM) .setSmallIcon(com.androidinspain.deskclock.R.drawable.stat_notify_timer) .setSortKey(nm.getTimerNotificationSortKey()).setVisibility(NotificationCompat.VISIBILITY_PUBLIC) .setStyle(new NotificationCompat.DecoratedCustomViewStyle()) .setColor(ContextCompat.getColor(context, com.androidinspain.deskclock.R.color.default_background)); for (Action action : actions) { notification.addAction(action); } if (Utils.isNOrLater()) { notification.setCustomContentView(buildChronometer(pname, base, running, stateText)) .setGroup(nm.getTimerNotificationGroupKey()); } else { final CharSequence contentTextPreN; if (count == 1) { contentTextPreN = TimerStringFormatter.formatTimeRemaining(context, timer.getRemainingTime(), false); } else if (running) { final String timeRemaining = TimerStringFormatter.formatTimeRemaining(context, timer.getRemainingTime(), false); contentTextPreN = context.getString(com.androidinspain.deskclock.R.string.next_timer_notif, timeRemaining); } else { contentTextPreN = context.getString(com.androidinspain.deskclock.R.string.all_timers_stopped_notif); } notification.setContentTitle(stateText).setContentText(contentTextPreN); final AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); final Intent updateNotification = TimerService.createUpdateNotificationIntent(context); final long remainingTime = timer.getRemainingTime(); if (timer.isRunning() && remainingTime > MINUTE_IN_MILLIS) { // Schedule a callback to update the time-sensitive information of the running timer final PendingIntent pi = PendingIntent.getService(context, REQUEST_CODE_UPCOMING, updateNotification, PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_UPDATE_CURRENT); final long nextMinuteChange = remainingTime % MINUTE_IN_MILLIS; final long triggerTime = SystemClock.elapsedRealtime() + nextMinuteChange; TimerModel.schedulePendingIntent(am, triggerTime, pi); } else { // Cancel the update notification callback. final PendingIntent pi = PendingIntent.getService(context, 0, updateNotification, PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_NO_CREATE); if (pi != null) { am.cancel(pi); pi.cancel(); } } } return notification.build(); }
From source file:com.onyx.deskclock.deskclock.data.StopwatchModel.java
/** * Updates the notification to reflect the latest state of the stopwatch and recorded laps. *///ww w . j ava 2 s . c o m void updateNotification() { final Stopwatch stopwatch = getStopwatch(); // Notification should be hidden if the stopwatch has no time or the app is open. if (stopwatch.isReset() || mNotificationModel.isApplicationInForeground()) { mNotificationManager.cancel(mNotificationModel.getStopwatchNotificationId()); return; } @StringRes final int eventLabel = R.string.label_notification; // Intent to load the app when the notification is tapped. final Intent showApp = new Intent(mContext, HandleDeskClockApiCalls.class) .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK).setAction(HandleDeskClockApiCalls.ACTION_SHOW_STOPWATCH) .putExtra(HandleDeskClockApiCalls.EXTRA_EVENT_LABEL, eventLabel); final PendingIntent pendingShowApp = PendingIntent.getActivity(mContext, 0, showApp, PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_UPDATE_CURRENT); // Compute some values required below. final boolean running = stopwatch.isRunning(); final String pname = mContext.getPackageName(); final Resources res = mContext.getResources(); final long base = SystemClock.elapsedRealtime() - stopwatch.getTotalTime(); final RemoteViews collapsed = new RemoteViews(pname, R.layout.stopwatch_notif_collapsed); collapsed.setChronometer(R.id.swn_collapsed_chronometer, base, null, running); collapsed.setOnClickPendingIntent(R.id.swn_collapsed_hitspace, pendingShowApp); collapsed.setImageViewResource(R.id.notification_icon, R.drawable.stat_notify_stopwatch); final RemoteViews expanded = new RemoteViews(pname, R.layout.stopwatch_notif_expanded); expanded.setChronometer(R.id.swn_expanded_chronometer, base, null, running); expanded.setOnClickPendingIntent(R.id.swn_expanded_hitspace, pendingShowApp); expanded.setImageViewResource(R.id.notification_icon, R.drawable.stat_notify_stopwatch); @IdRes final int leftButtonId = R.id.swn_left_button; @IdRes final int rightButtonId = R.id.swn_right_button; if (running) { // Left button: Pause expanded.setTextViewText(leftButtonId, res.getText(R.string.sw_pause_button)); // setTextViewDrawable(expanded, leftButtonId, R.drawable.ic_pause_24dp); final Intent pause = new Intent(mContext, StopwatchService.class) .setAction(HandleDeskClockApiCalls.ACTION_PAUSE_STOPWATCH) .putExtra(HandleDeskClockApiCalls.EXTRA_EVENT_LABEL, eventLabel); expanded.setOnClickPendingIntent(leftButtonId, pendingServiceIntent(pause)); // Right button: Add Lap if (canAddMoreLaps()) { expanded.setTextViewText(rightButtonId, res.getText(R.string.sw_lap_button)); // setTextViewDrawable(expanded, rightButtonId, R.drawable.ic_sw_lap_24dp); final Intent lap = new Intent(mContext, StopwatchService.class) .setAction(HandleDeskClockApiCalls.ACTION_LAP_STOPWATCH) .putExtra(HandleDeskClockApiCalls.EXTRA_EVENT_LABEL, eventLabel); expanded.setOnClickPendingIntent(rightButtonId, pendingServiceIntent(lap)); expanded.setViewVisibility(rightButtonId, VISIBLE); } else { expanded.setViewVisibility(rightButtonId, INVISIBLE); } // Show the current lap number if any laps have been recorded. final int lapCount = getLaps().size(); if (lapCount > 0) { final int lapNumber = lapCount + 1; final String lap = res.getString(R.string.sw_notification_lap_number, lapNumber); collapsed.setTextViewText(R.id.swn_collapsed_laps, lap); collapsed.setViewVisibility(R.id.swn_collapsed_laps, VISIBLE); expanded.setTextViewText(R.id.swn_expanded_laps, lap); expanded.setViewVisibility(R.id.swn_expanded_laps, VISIBLE); } else { collapsed.setViewVisibility(R.id.swn_collapsed_laps, GONE); expanded.setViewVisibility(R.id.swn_expanded_laps, GONE); } } else { // Left button: Start expanded.setTextViewText(leftButtonId, res.getText(R.string.sw_start_button)); // setTextViewDrawable(expanded, leftButtonId, R.drawable.ic_start_24dp); final Intent start = new Intent(mContext, StopwatchService.class) .setAction(HandleDeskClockApiCalls.ACTION_START_STOPWATCH) .putExtra(HandleDeskClockApiCalls.EXTRA_EVENT_LABEL, eventLabel); expanded.setOnClickPendingIntent(leftButtonId, pendingServiceIntent(start)); // Right button: Reset (HandleDeskClockApiCalls will also bring forward the app) expanded.setViewVisibility(rightButtonId, VISIBLE); expanded.setTextViewText(rightButtonId, res.getText(R.string.sw_reset_button)); // setTextViewDrawable(expanded, rightButtonId, R.drawable.ic_reset_24dp); final Intent reset = new Intent(mContext, HandleDeskClockApiCalls.class) .setAction(HandleDeskClockApiCalls.ACTION_RESET_STOPWATCH) .putExtra(HandleDeskClockApiCalls.EXTRA_EVENT_LABEL, eventLabel); expanded.setOnClickPendingIntent(rightButtonId, pendingActivityIntent(reset)); // Indicate the stopwatch is paused. collapsed.setTextViewText(R.id.swn_collapsed_laps, res.getString(R.string.swn_paused)); collapsed.setViewVisibility(R.id.swn_collapsed_laps, VISIBLE); expanded.setTextViewText(R.id.swn_expanded_laps, res.getString(R.string.swn_paused)); expanded.setViewVisibility(R.id.swn_expanded_laps, VISIBLE); } // Swipe away will reset the stopwatch without bringing forward the app. final Intent reset = new Intent(mContext, StopwatchService.class) .setAction(HandleDeskClockApiCalls.ACTION_RESET_STOPWATCH) .putExtra(HandleDeskClockApiCalls.EXTRA_EVENT_LABEL, eventLabel); final Notification notification = new NotificationCompat.Builder(mContext).setLocalOnly(true) .setOngoing(running).setContent(collapsed).setAutoCancel(stopwatch.isPaused()) .setPriority(Notification.PRIORITY_MAX).setDeleteIntent(pendingServiceIntent(reset)) .setSmallIcon(R.drawable.ic_tab_stopwatch_activated).build(); if (Build.VERSION.SDK_INT >= 16) { notification.bigContentView = expanded; } mNotificationManager.notify(mNotificationModel.getStopwatchNotificationId(), notification); }
From source file:com.android.deskclock.data.TimerNotificationBuilderN.java
@Override public Notification build(Context context, NotificationModel nm, List<Timer> unexpired) { final Timer timer = unexpired.get(0); final int count = unexpired.size(); // Compute some values required below. final boolean running = timer.isRunning(); final Resources res = context.getResources(); final long base = getChronometerBase(timer); final String pname = context.getPackageName(); final RemoteViews content = new RemoteViews(pname, R.layout.chronometer_notif_content); content.setChronometerCountDown(R.id.chronometer, true); content.setChronometer(R.id.chronometer, base, null, running); final List<Notification.Action> actions = new ArrayList<>(2); final CharSequence stateText; if (count == 1) { if (running) { // Single timer is running. if (TextUtils.isEmpty(timer.getLabel())) { stateText = res.getString(R.string.timer_notification_label); } else { stateText = timer.getLabel(); }/*from w ww . java 2s .c o m*/ // Left button: Pause final Intent pause = new Intent(context, TimerService.class) .setAction(HandleDeskClockApiCalls.ACTION_PAUSE_TIMER) .putExtra(HandleDeskClockApiCalls.EXTRA_TIMER_ID, timer.getId()); final Icon icon1 = Icon.createWithResource(context, R.drawable.ic_pause_24dp); final CharSequence title1 = res.getText(R.string.timer_pause); final PendingIntent intent1 = Utils.pendingServiceIntent(context, pause); actions.add(new Notification.Action.Builder(icon1, title1, intent1).build()); // Right Button: +1 Minute final Intent addMinute = new Intent(context, TimerService.class) .setAction(HandleDeskClockApiCalls.ACTION_ADD_MINUTE_TIMER) .putExtra(HandleDeskClockApiCalls.EXTRA_TIMER_ID, timer.getId()); final Icon icon2 = Icon.createWithResource(context, R.drawable.ic_add_24dp); final CharSequence title2 = res.getText(R.string.timer_plus_1_min); final PendingIntent intent2 = Utils.pendingServiceIntent(context, addMinute); actions.add(new Notification.Action.Builder(icon2, title2, intent2).build()); } else { // Single timer is paused. stateText = res.getString(R.string.timer_paused); // Left button: Start final Intent start = new Intent(context, TimerService.class) .setAction(HandleDeskClockApiCalls.ACTION_START_TIMER) .putExtra(HandleDeskClockApiCalls.EXTRA_TIMER_ID, timer.getId()); final Icon icon1 = Icon.createWithResource(context, R.drawable.ic_start_24dp); final CharSequence title1 = res.getText(R.string.sw_resume_button); final PendingIntent intent1 = Utils.pendingServiceIntent(context, start); actions.add(new Notification.Action.Builder(icon1, title1, intent1).build()); // Right Button: Reset final Intent reset = new Intent(context, TimerService.class) .setAction(HandleDeskClockApiCalls.ACTION_RESET_TIMER) .putExtra(HandleDeskClockApiCalls.EXTRA_TIMER_ID, timer.getId()); final Icon icon2 = Icon.createWithResource(context, R.drawable.ic_reset_24dp); final CharSequence title2 = res.getText(R.string.sw_reset_button); final PendingIntent intent2 = Utils.pendingServiceIntent(context, reset); actions.add(new Notification.Action.Builder(icon2, title2, intent2).build()); } } else { if (running) { // At least one timer is running. stateText = res.getString(R.string.timers_in_use, count); } else { // All timers are paused. stateText = res.getString(R.string.timers_stopped, count); } final Intent reset = TimerService.createResetUnexpiredTimersIntent(context); final Icon icon1 = Icon.createWithResource(context, R.drawable.ic_reset_24dp); final CharSequence title1 = res.getText(R.string.timer_reset_all); final PendingIntent intent1 = Utils.pendingServiceIntent(context, reset); actions.add(new Notification.Action.Builder(icon1, title1, intent1).build()); } content.setTextViewText(R.id.state, stateText); // Intent to load the app and show the timer when the notification is tapped. final Intent showApp = new Intent(context, HandleDeskClockApiCalls.class) .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK).setAction(HandleDeskClockApiCalls.ACTION_SHOW_TIMERS) .putExtra(HandleDeskClockApiCalls.EXTRA_TIMER_ID, timer.getId()) .putExtra(HandleDeskClockApiCalls.EXTRA_EVENT_LABEL, R.string.label_notification); final PendingIntent pendingShowApp = PendingIntent.getActivity(context, 0, showApp, PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_UPDATE_CURRENT); return new Notification.Builder(context).setOngoing(true).setLocalOnly(true).setShowWhen(false) .setAutoCancel(false).setCustomContentView(content).setContentIntent(pendingShowApp) .setPriority(Notification.PRIORITY_HIGH).setCategory(Notification.CATEGORY_ALARM) .setSmallIcon(R.drawable.stat_notify_timer).setGroup(nm.getTimerNotificationGroupKey()) .setVisibility(Notification.VISIBILITY_PUBLIC).setStyle(new Notification.DecoratedCustomViewStyle()) .setActions(actions.toArray(new Notification.Action[actions.size()])) .setColor(ContextCompat.getColor(context, R.color.default_background)).build(); }