Show auto silence view

This commit is contained in:
Phillip Hsu
2016-08-06 02:52:49 -07:00
parent d845f241e9
commit 29194f241f
7 changed files with 86 additions and 24 deletions
@@ -1,7 +1,6 @@
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;
@@ -51,14 +50,6 @@ public class TimerRingtoneService extends RingtoneService<Timer> {
@Override
protected void onAutoSilenced() {
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
@@ -1,8 +1,11 @@
package com.philliphsu.clock2.timers;
import android.app.Notification;
import android.app.NotificationManager;
import android.content.Intent;
import android.os.Bundle;
import android.os.SystemClock;
import android.support.v4.app.NotificationCompat;
import android.view.ViewGroup;
import com.philliphsu.clock2.R;
@@ -11,12 +14,22 @@ import com.philliphsu.clock2.ringtone.RingtoneActivity;
import com.philliphsu.clock2.ringtone.RingtoneService;
public class TimesUpActivity extends RingtoneActivity<Timer> {
private static final String TAG = "TimesUpActivity";
private NotificationManager mNotificationManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
stopService(new Intent(this, TimerNotificationService.class));
TimerNotificationService.cancelNotification(this, getRingingObject().getId());
mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
}
@Override
public void finish() {
super.finish();
mNotificationManager.cancel(TAG, getRingingObject().getIntId());
}
@Override
@@ -75,4 +88,17 @@ public class TimesUpActivity extends RingtoneActivity<Timer> {
protected void onRightButtonClick() {
}
// TODO: Consider changing the return type to Notification, and move the actual
// task of notifying to the base class.
@Override
protected void showAutoSilenced() {
super.showAutoSilenced();
Notification note = new NotificationCompat.Builder(this)
.setContentTitle(getString(R.string.timer_expired))
.setContentText(getRingingObject().label())
.setSmallIcon(R.mipmap.ic_launcher) // TODO: correct icon
.build();
mNotificationManager.notify(TAG, getRingingObject().getIntId(), note);
}
}