Merge branch 'notification_fixes'

This commit is contained in:
cketti 2015-12-29 15:50:44 +01:00
commit 69590af824
4 changed files with 40 additions and 23 deletions

View file

@ -106,11 +106,22 @@ class NotificationActionCreator {
public PendingIntent createMarkAllAsReadPendingIntent(Account account,
ArrayList<MessageReference> messageReferences, int notificationId) {
return getMarkAsReadPendingIntent(account, messageReferences, notificationId, context,
PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_ONE_SHOT);
}
public PendingIntent getMarkAllAsReadPendingIntent(Account account, ArrayList<MessageReference> messageReferences,
int notificationId) {
return getMarkAsReadPendingIntent(account, messageReferences, notificationId, context,
PendingIntent.FLAG_NO_CREATE);
}
private PendingIntent getMarkAsReadPendingIntent(Account account, ArrayList<MessageReference> messageReferences,
int notificationId, Context context, int flags) {
String accountUuid = account.getUuid();
Intent intent = NotificationActionService.createMarkAllAsReadIntent(context, accountUuid, messageReferences);
return PendingIntent.getService(context, notificationId, intent,
PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_ONE_SHOT);
return PendingIntent.getService(context, notificationId, intent, flags);
}
public PendingIntent createDeleteMessagePendingIntent(MessageReference messageReference, int notificationId) {
@ -137,27 +148,39 @@ class NotificationActionCreator {
public PendingIntent createDeleteAllPendingIntent(Account account, ArrayList<MessageReference> messageReferences,
int notificationId) {
if (K9.confirmDeleteFromNotification()) {
return createDeleteAllConfirmationPendingIntent(messageReferences, notificationId);
return getDeleteAllConfirmationPendingIntent(messageReferences, notificationId,
PendingIntent.FLAG_CANCEL_CURRENT);
} else {
return createDeleteAllServicePendingIntent(account, messageReferences, notificationId);
return getDeleteAllServicePendingIntent(account, messageReferences, notificationId,
PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_ONE_SHOT);
}
}
private PendingIntent createDeleteAllConfirmationPendingIntent(ArrayList<MessageReference> messageReferences,
public PendingIntent getDeleteAllPendingIntent(Account account, ArrayList<MessageReference> messageReferences,
int notificationId) {
Intent intent = NotificationDeleteConfirmation.getIntent(context, messageReferences);
return PendingIntent.getActivity(context, notificationId, intent, PendingIntent.FLAG_CANCEL_CURRENT);
if (K9.confirmDeleteFromNotification()) {
return getDeleteAllConfirmationPendingIntent(messageReferences, notificationId,
PendingIntent.FLAG_NO_CREATE);
} else {
return getDeleteAllServicePendingIntent(account, messageReferences, notificationId,
PendingIntent.FLAG_NO_CREATE);
}
}
private PendingIntent createDeleteAllServicePendingIntent(Account account,
ArrayList<MessageReference> messageReferences, int notificationId) {
private PendingIntent getDeleteAllConfirmationPendingIntent(ArrayList<MessageReference> messageReferences,
int notificationId, int flags) {
Intent intent = NotificationDeleteConfirmation.getIntent(context, messageReferences);
return PendingIntent.getActivity(context, notificationId, intent, flags);
}
private PendingIntent getDeleteAllServicePendingIntent(Account account,
ArrayList<MessageReference> messageReferences, int notificationId, int flags) {
String accountUuid = account.getUuid();
Intent intent = NotificationActionService.createDeleteAllMessagesIntent(
context, accountUuid, messageReferences);
return PendingIntent.getService(context, notificationId, intent,
PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_ONE_SHOT);
return PendingIntent.getService(context, notificationId, intent, flags);
}
public PendingIntent createArchiveMessagePendingIntent(MessageReference messageReference, int notificationId) {

View file

@ -61,8 +61,7 @@ class WearNotifications extends BaseNotifications {
Account account = notificationData.getAccount();
ArrayList<MessageReference> messageReferences = notificationData.getAllMessageReferences();
int notificationId = NotificationIds.getNewMailSummaryNotificationId(account);
PendingIntent action = actionCreator.createMarkAllAsReadPendingIntent(
account, messageReferences, notificationId);
PendingIntent action = actionCreator.getMarkAllAsReadPendingIntent(account, messageReferences, notificationId);
NotificationCompat.Action markAsReadAction = new NotificationCompat.Action.Builder(icon, title, action).build();
wearableExtender.addAction(markAsReadAction);
@ -75,7 +74,7 @@ class WearNotifications extends BaseNotifications {
Account account = notificationData.getAccount();
ArrayList<MessageReference> messageReferences = notificationData.getAllMessageReferences();
int notificationId = NotificationIds.getNewMailSummaryNotificationId(account);
PendingIntent action = actionCreator.createDeleteAllPendingIntent(account, messageReferences, notificationId);
PendingIntent action = actionCreator.getDeleteAllPendingIntent(account, messageReferences, notificationId);
NotificationCompat.Action deleteAction = new NotificationCompat.Action.Builder(icon, title, action).build();
wearableExtender.addAction(deleteAction);

View file

@ -1,11 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- On Lollipop, notifications are on white rather than on dark grey, making
the title too light. When using targetSdk 17, #ffffffff (which should be
white) is being used as a mask or inverted (not sure which). The net
effect is that specifying #ffffffff is resulting in black text. This
needs to change once we go to targetSdk 21. -->
<style name="TextAppearance.StatusBar.EventContent.Emphasized" parent="@android:style/TextAppearance.StatusBar.EventContent">
<item name="android:textColor">#ffffffff</item>
<item name="android:textColor">#000000</item>
</style>
</resources>

View file

@ -146,7 +146,7 @@ public class WearNotificationsTest {
ArrayList<MessageReference> messageReferences = createMessageReferenceList();
NotificationData notificationData = createNotificationData(messageReferences);
PendingIntent markAllAsReadPendingIntent = createFakePendingIntent(1);
when(actionCreator.createMarkAllAsReadPendingIntent(account, messageReferences, notificationId))
when(actionCreator.getMarkAllAsReadPendingIntent(account, messageReferences, notificationId))
.thenReturn(markAllAsReadPendingIntent);
wearNotifications.addSummaryActions(builder, notificationData);
@ -163,7 +163,7 @@ public class WearNotificationsTest {
ArrayList<MessageReference> messageReferences = createMessageReferenceList();
NotificationData notificationData = createNotificationData(messageReferences);
PendingIntent deletePendingIntent = createFakePendingIntent(1);
when(actionCreator.createDeleteAllPendingIntent(account, messageReferences, notificationId))
when(actionCreator.getDeleteAllPendingIntent(account, messageReferences, notificationId))
.thenReturn(deletePendingIntent);
wearNotifications.addSummaryActions(builder, notificationData);