Use notification builder

pull/253/head
Alex Baker 9 years ago
parent f1818afbf2
commit c7c2586bb7

@ -50,13 +50,14 @@ public class ShowNotificationReceiver extends InjectingBroadcastReceiver {
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
super.onReceive(context, intent); super.onReceive(context, intent);
int notificationId = intent.getIntExtra(Notifications.EXTRAS_NOTIF_ID, 0); showNotification(
Intent customIntent = intent.getParcelableExtra(Notifications.EXTRAS_CUSTOM_INTENT); context,
int type = intent.getIntExtra(Notifications.EXTRAS_TYPE, 0); intent.getIntExtra(Notifications.EXTRAS_NOTIF_ID, 0),
String title = intent.getStringExtra(Notifications.EXTRAS_TITLE); intent.<Intent>getParcelableExtra(Notifications.EXTRAS_CUSTOM_INTENT),
String text = intent.getStringExtra(Notifications.EXTRAS_TEXT); intent.getIntExtra(Notifications.EXTRAS_TYPE, 0),
int ringTimes = intent.getIntExtra(Notifications.EXTRAS_RING_TIMES, 1); intent.getStringExtra(Notifications.EXTRAS_TITLE),
showNotification(context, notificationId, customIntent, type, title, text, ringTimes); intent.getStringExtra(Notifications.EXTRAS_TEXT),
intent.getIntExtra(Notifications.EXTRAS_RING_TIMES, 1));
} }
/** /**
@ -107,22 +108,21 @@ public class ShowNotificationReceiver extends InjectingBroadcastReceiver {
} }
// quiet hours? unless alarm clock // quiet hours? unless alarm clock
boolean quietHours = (type == ReminderService.TYPE_ALARM || type == ReminderService.TYPE_DUE) ? false : isQuietHours(preferences); boolean quietHours = !(type == ReminderService.TYPE_ALARM || type == ReminderService.TYPE_DUE) && isQuietHours(preferences);
PendingIntent pendingIntent = PendingIntent.getActivity(context, PendingIntent pendingIntent = PendingIntent.getActivity(context, notificationId, intent, PendingIntent.FLAG_UPDATE_CURRENT);
notificationId, intent, PendingIntent.FLAG_UPDATE_CURRENT);
// create notification object Notification notification = new Notification.Builder(context)
final Notification notification = new Notification( .setSmallIcon(R.drawable.notif_astrid)
R.drawable.notif_astrid, text, System.currentTimeMillis()); .setTicker(text)
notification.setLatestEventInfo(context, .setWhen(System.currentTimeMillis())
title, .setContentTitle(title)
text, .setContentText(text)
pendingIntent); .setContentIntent(pendingIntent)
.build();
notification.flags |= Notification.FLAG_AUTO_CANCEL; notification.flags |= Notification.FLAG_AUTO_CANCEL;
if (preferences.getBoolean(R.string.p_rmd_persistent, true)) { if (preferences.getBoolean(R.string.p_rmd_persistent, true)) {
notification.flags |= Notification.FLAG_NO_CLEAR | notification.flags |= Notification.FLAG_NO_CLEAR | Notification.FLAG_SHOW_LIGHTS;
Notification.FLAG_SHOW_LIGHTS;
notification.ledOffMS = 5000; notification.ledOffMS = 5000;
notification.ledOnMS = 700; notification.ledOnMS = 700;
notification.ledARGB = Color.YELLOW; notification.ledARGB = Color.YELLOW;
@ -130,8 +130,7 @@ public class ShowNotificationReceiver extends InjectingBroadcastReceiver {
notification.defaults = Notification.DEFAULT_LIGHTS; notification.defaults = Notification.DEFAULT_LIGHTS;
} }
AudioManager audioManager = (AudioManager) context.getSystemService( AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
Context.AUDIO_SERVICE);
// detect call state // detect call state
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);

Loading…
Cancel
Save