Change timer notification icons
This commit is contained in:
parent
2f202467bb
commit
34930fa2b3
@ -74,6 +74,7 @@ public class TimerNotificationService extends Service {
|
|||||||
// TODO: Verify the notification countdown is extended by one minute.
|
// TODO: Verify the notification countdown is extended by one minute.
|
||||||
} else if (ACTION_START_PAUSE.equals(action)) {
|
} else if (ACTION_START_PAUSE.equals(action)) {
|
||||||
mController.startPause();
|
mController.startPause();
|
||||||
|
showNotification(); // Update the notification
|
||||||
} else if (ACTION_STOP.equals(action)) {
|
} else if (ACTION_STOP.equals(action)) {
|
||||||
mController.stop();
|
mController.stop();
|
||||||
stopSelf();
|
stopSelf();
|
||||||
@ -93,7 +94,7 @@ public class TimerNotificationService extends Service {
|
|||||||
private void showNotification() {
|
private void showNotification() {
|
||||||
// Base note
|
// Base note
|
||||||
NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
|
NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
|
||||||
.setSmallIcon(R.drawable.ic_half_day_1_24dp) // TODO: correct icon
|
.setSmallIcon(R.drawable.ic_timer_24dp)
|
||||||
.setShowWhen(false)
|
.setShowWhen(false)
|
||||||
.setOngoing(true);
|
.setOngoing(true);
|
||||||
// TODO: Set content intent so that when clicked, we launch
|
// TODO: Set content intent so that when clicked, we launch
|
||||||
@ -118,12 +119,13 @@ public class TimerNotificationService extends Service {
|
|||||||
}
|
}
|
||||||
builder.setContentTitle(title);
|
builder.setContentTitle(title);
|
||||||
|
|
||||||
addAction(builder, ACTION_ADD_ONE_MINUTE,
|
addAction(builder, ACTION_ADD_ONE_MINUTE, R.drawable.ic_add_24dp, getString(R.string.minute));
|
||||||
R.drawable.ic_add_circle_24dp/*TODO: correct icon*/);
|
|
||||||
|
boolean running = mTimer.isRunning();
|
||||||
addAction(builder, ACTION_START_PAUSE,
|
addAction(builder, ACTION_START_PAUSE,
|
||||||
R.drawable.ic_add_circle_24dp/*TODO: correct icon*/);
|
running ? R.drawable.ic_pause_24dp : R.drawable.ic_start_24dp,
|
||||||
addAction(builder, ACTION_STOP,
|
getString(running ? R.string.pause : R.string.resume));
|
||||||
R.drawable.ic_add_circle_24dp/*TODO: correct icon*/);
|
addAction(builder, ACTION_STOP, R.drawable.ic_stop_24dp, getString(R.string.stop));
|
||||||
|
|
||||||
NotificationManager nm = (NotificationManager)
|
NotificationManager nm = (NotificationManager)
|
||||||
getSystemService(Context.NOTIFICATION_SERVICE);
|
getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
@ -133,12 +135,13 @@ public class TimerNotificationService extends Service {
|
|||||||
/**
|
/**
|
||||||
* Builds and adds the specified action to the notification's builder.
|
* Builds and adds the specified action to the notification's builder.
|
||||||
*/
|
*/
|
||||||
private void addAction(NotificationCompat.Builder noteBuilder, String action, @DrawableRes int icon) {
|
private void addAction(NotificationCompat.Builder noteBuilder, String action,
|
||||||
|
@DrawableRes int icon, String actionTitle) {
|
||||||
Intent intent = new Intent(this, TimerNotificationService.class)
|
Intent intent = new Intent(this, TimerNotificationService.class)
|
||||||
.setAction(action);
|
.setAction(action);
|
||||||
// .putExtra(EXTRA_TIMER, mTimer);
|
// .putExtra(EXTRA_TIMER, mTimer);
|
||||||
PendingIntent pi = PendingIntent.getService(this,
|
PendingIntent pi = PendingIntent.getService(this,
|
||||||
mTimer.getIntId(), intent, 0/*no flags*/);
|
mTimer.getIntId(), intent, 0/*no flags*/);
|
||||||
noteBuilder.addAction(icon, ""/*no action title*/, pi);
|
noteBuilder.addAction(icon, actionTitle, pi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -69,13 +69,13 @@ public class TimerRingtoneService extends RingtoneService<Timer> {
|
|||||||
return new NotificationCompat.Builder(this)
|
return new NotificationCompat.Builder(this)
|
||||||
.setContentTitle(title)
|
.setContentTitle(title)
|
||||||
.setContentText(getString(R.string.times_up))
|
.setContentText(getString(R.string.times_up))
|
||||||
.setSmallIcon(R.drawable.ic_half_day_1_24dp) // TODO: correct icon
|
.setSmallIcon(R.drawable.ic_timer_24dp)
|
||||||
.setShowWhen(false) // TODO: Should we show this?
|
.setShowWhen(false) // TODO: Should we show this?
|
||||||
// .setOngoing(true) // foreground notes are ongoing by default
|
// .setOngoing(true) // foreground notes are ongoing by default
|
||||||
.addAction(R.drawable.ic_add_circle_24dp, // TODO: correct icon
|
.addAction(R.drawable.ic_add_24dp,
|
||||||
getString(R.string.add_one_minute),
|
getString(R.string.add_one_minute),
|
||||||
getPendingIntent(ACTION_ADD_ONE_MINUTE, getRingingObject().getIntId()))
|
getPendingIntent(ACTION_ADD_ONE_MINUTE, getRingingObject().getIntId()))
|
||||||
.addAction(R.drawable.ic_add_circle_24dp, // TODO: correct icon
|
.addAction(R.drawable.ic_stop_24dp,
|
||||||
getString(R.string.stop),
|
getString(R.string.stop),
|
||||||
getPendingIntent(ACTION_STOP, getRingingObject().getIntId()))
|
getPendingIntent(ACTION_STOP, getRingingObject().getIntId()))
|
||||||
.build();
|
.build();
|
||||||
|
|||||||
@ -197,4 +197,7 @@
|
|||||||
|
|
||||||
<string name="label">Label</string>
|
<string name="label">Label</string>
|
||||||
<string name="ringtones">Ringtones</string>
|
<string name="ringtones">Ringtones</string>
|
||||||
|
|
||||||
|
<string name="pause">Pause</string>
|
||||||
|
<string name="resume">Resume</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user