diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/calendar/alerts/AlertReceiver.java | 101 |
1 files changed, 65 insertions, 36 deletions
diff --git a/src/com/android/calendar/alerts/AlertReceiver.java b/src/com/android/calendar/alerts/AlertReceiver.java index 757f0ed4..68c3a514 100644 --- a/src/com/android/calendar/alerts/AlertReceiver.java +++ b/src/com/android/calendar/alerts/AlertReceiver.java @@ -254,10 +254,21 @@ public class AlertReceiver extends BroadcastReceiver { notificationBuilder.setFullScreenIntent(createAlertActivityIntent(context), true); } - // Turn off timestamp. - notificationBuilder.setWhen(0); + PendingIntent snoozeIntent = null; + PendingIntent emailIntent = null; + if (addActionButtons) { + // Create snooze intent. TODO: change snooze to 10 minutes. + snoozeIntent = createSnoozeIntent(context, eventId, startMillis, endMillis, + notificationId); + + // Create email intent for emailing attendees. + emailIntent = createBroadcastMailIntent(context, eventId, title); + } if (Utils.isJellybeanOrLater()) { + // Turn off timestamp. + notificationBuilder.setWhen(0); + // Setting to a higher priority will encourage notification manager to expand the // notification. if (highPriority) { @@ -265,46 +276,47 @@ public class AlertReceiver extends BroadcastReceiver { } else { notificationBuilder.setPriority(Notification.PRIORITY_DEFAULT); } - } - if (addActionButtons) { - // Create snooze intent. TODO: change snooze to 10 minutes. - PendingIntent snoozeIntent = createSnoozeIntent(context, eventId, startMillis, - endMillis, notificationId); - - // Create email intent for emailing attendees. - PendingIntent emailIntent = createBroadcastMailIntent(context, eventId, title); - - if (Utils.isJellybeanOrLater()) { + // Add action buttons. + if (snoozeIntent != null) { notificationBuilder.addAction(R.drawable.ic_alarm_holo_dark, resources.getString(R.string.snooze_label), snoozeIntent); - if (emailIntent != null) { - notificationBuilder.addAction(R.drawable.ic_menu_email_holo_dark, - resources.getString(R.string.email_guests_label), emailIntent); - } + } + if (emailIntent != null) { + notificationBuilder.addAction(R.drawable.ic_menu_email_holo_dark, + resources.getString(R.string.email_guests_label), emailIntent); + } + return notificationBuilder.getNotification(); + + } else { + // Old-style notification (pre-JB). Use custom view with buttons to provide + // JB-like functionality (snooze/email). + Notification n = notificationBuilder.getNotification(); + + // Use custom view with buttons to provide JB-like functionality (snooze/email). + RemoteViews contentView = new RemoteViews(context.getPackageName(), + R.layout.notification); + contentView.setImageViewResource(R.id.image, R.drawable.stat_notify_calendar); + contentView.setTextViewText(R.id.title, title); + contentView.setTextViewText(R.id.text, summaryText); + if (snoozeIntent == null) { + contentView.setViewVisibility(R.id.email_button, View.GONE); } else { - // Old-style notification (pre-JB). Use custom view with buttons to provide - // JB-like functionality (snooze/email). - Notification n = notificationBuilder.getNotification(); - - // Use custom view with buttons to provide JB-like functionality (snooze/email). - RemoteViews contentView = new RemoteViews(context.getPackageName(), - R.layout.notification); - contentView.setTextViewText(R.id.title, title); - contentView.setTextViewText(R.id.text, summaryText); contentView.setViewVisibility(R.id.snooze_button, View.VISIBLE); contentView.setOnClickPendingIntent(R.id.snooze_button, snoozeIntent); - if (emailIntent == null) { - contentView.setViewVisibility(R.id.email_button, View.GONE); - } else { - contentView.setViewVisibility(R.id.email_button, View.VISIBLE); - contentView.setOnClickPendingIntent(R.id.email_button, emailIntent); - } - n.contentView = contentView; - return n; + contentView.setViewVisibility(R.id.end_padding, View.GONE); } + if (emailIntent == null) { + contentView.setViewVisibility(R.id.email_button, View.GONE); + } else { + contentView.setViewVisibility(R.id.email_button, View.VISIBLE); + contentView.setOnClickPendingIntent(R.id.email_button, emailIntent); + contentView.setViewVisibility(R.id.end_padding, View.GONE); + } + n.contentView = contentView; + + return n; } - return notificationBuilder.getNotification(); } /** @@ -447,8 +459,25 @@ public class AlertReceiver extends BroadcastReceiver { n = notificationBuilder.build(); } } else { - // Old style notification (pre-JB) - n = notificationBuilder.getNotification(); + // Old-style notification (pre-JB). We only need a standard notification (no + // buttons) but use a custom view so it is consistent with the others. + n = notificationBuilder.getNotification(); + + // Use custom view with buttons to provide JB-like functionality (snooze/email). + RemoteViews contentView = new RemoteViews(context.getPackageName(), + R.layout.notification); + contentView.setImageViewResource(R.id.image, R.drawable.stat_notify_calendar_multiple); + contentView.setTextViewText(R.id.title, nEventsStr); + contentView.setTextViewText(R.id.text, digestTitle); + contentView.setViewVisibility(R.id.time, View.VISIBLE); + contentView.setViewVisibility(R.id.email_button, View.GONE); + contentView.setViewVisibility(R.id.snooze_button, View.GONE); + contentView.setViewVisibility(R.id.end_padding, View.VISIBLE); + n.contentView = contentView; + + // Use timestamp to force expired digest notification to the bottom (there is no + // priority setting before JB release). This is hidden by the custom view. + n.when = 1; } NotificationWrapper nw = new NotificationWrapper(n); |