diff options
author | Sara Ting <sarating@google.com> | 2012-09-20 14:18:32 -0700 |
---|---|---|
committer | Sara Ting <sarating@google.com> | 2012-09-20 14:18:32 -0700 |
commit | af589fb93e05051f026a41cd4b87b5b74636b05f (patch) | |
tree | dc4ab7487d8e3ecb27b8b7bae242b4872287fd30 | |
parent | 21049d25dcf8f055dc046a889b0a514833ad599a (diff) | |
download | android_packages_apps_Calendar-af589fb93e05051f026a41cd4b87b5b74636b05f.tar.gz android_packages_apps_Calendar-af589fb93e05051f026a41cd4b87b5b74636b05f.tar.bz2 android_packages_apps_Calendar-af589fb93e05051f026a41cd4b87b5b74636b05f.zip |
ICS notifications fix: de-prioritize expired digest, and use the same custom view for all our notifications.
Bug:7188074,7185828
Change-Id: Ib70b8530532e314a8088cb207f8910f01d3f16ad
-rw-r--r-- | res/layout/notification.xml | 20 | ||||
-rw-r--r-- | src/com/android/calendar/alerts/AlertReceiver.java | 103 |
2 files changed, 77 insertions, 46 deletions
diff --git a/res/layout/notification.xml b/res/layout/notification.xml index acb18ef3..4a723c75 100644 --- a/res/layout/notification.xml +++ b/res/layout/notification.xml @@ -34,7 +34,7 @@ <LinearLayout android:orientation="vertical" - android:paddingLeft="12dip" + android:paddingLeft="12dp" android:layout_width="0dp" android:layout_weight="1" android:layout_height="wrap_content"> @@ -42,17 +42,17 @@ <TextView android:id="@+id/title" android:textAppearance="@android:style/TextAppearance.StatusBar.EventContent.Title" - android:layout_width="wrap_content" + android:layout_width="match_parent" android:layout_height="wrap_content" android:singleLine="true" - android:ellipsize="marquee" /> + android:ellipsize="end" /> <TextView android:id="@+id/text" android:textAppearance="@android:style/TextAppearance.StatusBar.EventContent" - android:layout_width="wrap_content" + android:layout_width="match_parent" android:layout_height="wrap_content" android:singleLine="true" - android:ellipsize="marquee" /> + android:ellipsize="end" /> </LinearLayout> <ImageButton @@ -73,4 +73,14 @@ android:background="?android:attr/selectableItemBackground" android:padding="8dip" android:contentDescription="@string/acessibility_snooze_notification" /> + + <!-- Add right padding if no buttons so notification text does not run too + close to edge. + --> + <TextView + android:id="@+id/end_padding" + android:layout_width="12dp" + android:layout_height="match_parent" + android:paddingRight="12dp" /> + </LinearLayout> diff --git a/src/com/android/calendar/alerts/AlertReceiver.java b/src/com/android/calendar/alerts/AlertReceiver.java index 757f0ed4..4c99122e 100644 --- a/src/com/android/calendar/alerts/AlertReceiver.java +++ b/src/com/android/calendar/alerts/AlertReceiver.java @@ -254,57 +254,61 @@ public class AlertReceiver extends BroadcastReceiver { notificationBuilder.setFullScreenIntent(createAlertActivityIntent(context), true); } - // Turn off timestamp. - notificationBuilder.setWhen(0); - - if (Utils.isJellybeanOrLater()) { - // Setting to a higher priority will encourage notification manager to expand the - // notification. - if (highPriority) { - notificationBuilder.setPriority(Notification.PRIORITY_HIGH); - } else { - notificationBuilder.setPriority(Notification.PRIORITY_DEFAULT); - } - } - + PendingIntent snoozeIntent = null; + PendingIntent emailIntent = null; if (addActionButtons) { // Create snooze intent. TODO: change snooze to 10 minutes. - PendingIntent snoozeIntent = createSnoozeIntent(context, eventId, startMillis, - endMillis, notificationId); + snoozeIntent = createSnoozeIntent(context, eventId, startMillis, endMillis, + notificationId); // Create email intent for emailing attendees. - PendingIntent emailIntent = createBroadcastMailIntent(context, eventId, title); + emailIntent = createBroadcastMailIntent(context, eventId, title); + } + + if (Utils.isJellybeanOrLater()) { + // Turn off timestamp. + notificationBuilder.setWhen(0); - 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 +451,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); |