Expired timer notification

This commit is contained in:
Phillip Hsu 2016-08-05 01:58:43 -07:00
parent 8dea6301aa
commit 6ae9c3511c
4 changed files with 15 additions and 3 deletions

View File

@ -59,7 +59,7 @@ public class AlarmRingtoneService extends RingtoneService<Alarm> {
.setContentText(mNormalRingTime)
.setSmallIcon(R.mipmap.ic_launcher)
.build();
nm.notify(TAG, getRingingObject().intId(), note);
nm.notify(TAG, getRingingObject().getIntId(), note);
}
@Override

View File

@ -1,6 +1,7 @@
package com.philliphsu.clock2.timers;
import android.app.Notification;
import android.app.NotificationManager;
import android.content.Intent;
import android.net.Uri;
import android.provider.Settings;
@ -12,6 +13,7 @@ import com.philliphsu.clock2.Timer;
import com.philliphsu.clock2.ringtone.RingtoneService;
public class TimerRingtoneService extends RingtoneService<Timer> {
private static final String TAG = "TimerRingtoneService";
// private because they refer to our foreground notification's actions.
// we reuse these from TimerNotificationService because they're just constants, the values
@ -48,8 +50,15 @@ public class TimerRingtoneService extends RingtoneService<Timer> {
@Override
protected void onAutoSilenced() {
// TODO: We probably have relevant code to copy over from the old project.
// TODO: Stop the Timer and update the table
mController.stop();
// Post notification that alarm was missed
NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
Notification note = new NotificationCompat.Builder(this)
.setContentTitle(getString(R.string.timer_expired))
.setContentText(getRingingObject().label())
.setSmallIcon(R.mipmap.ic_launcher) // TODO: correct icon
.build();
nm.notify(TAG, getRingingObject().getIntId(), note);
}
@Override

View File

@ -18,6 +18,8 @@
android:layout_height="wrap_content"
app:cardElevation="2dp"
app:cardCornerRadius="0dp"
android:foreground="?selectableItemBackground"
android:clickable="true"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp">

View File

@ -196,4 +196,5 @@
<string name="times_up">Time\'s up</string>
<string name="add_one_minute">Add 1 minute</string>
<string name="stop">Stop</string>
<string name="timer_expired">Timer expired</string>
</resources>