diff options
author | Christian Schneppe <christian@pix-art.de> | 2016-10-05 21:56:32 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2016-10-05 21:56:32 +0200 |
commit | 4aa2eb0be27cfc3a35d50b5616a33f60dc414bd7 (patch) | |
tree | bb85cfd44120da0b8415040b3affc30507d0bf27 /src/main/java/de/pixart/messenger/services/NotificationService.java | |
parent | 11bddfe2b1fbb3dd02ebe0290e58f842ec28ef16 (diff) |
make error notification dismissable
Diffstat (limited to 'src/main/java/de/pixart/messenger/services/NotificationService.java')
-rw-r--r-- | src/main/java/de/pixart/messenger/services/NotificationService.java | 39 |
1 files changed, 11 insertions, 28 deletions
diff --git a/src/main/java/de/pixart/messenger/services/NotificationService.java b/src/main/java/de/pixart/messenger/services/NotificationService.java index 293442662..13ac34cc0 100644 --- a/src/main/java/de/pixart/messenger/services/NotificationService.java +++ b/src/main/java/de/pixart/messenger/services/NotificationService.java @@ -504,11 +504,10 @@ public class NotificationService { return PendingIntent.getService(mXmppConnectionService, 45, intent, 0); } - private PendingIntent createDisableAccountIntent(final Account account) { + private PendingIntent createDismissErrorIntent() { final Intent intent = new Intent(mXmppConnectionService, XmppConnectionService.class); - intent.setAction(XmppConnectionService.ACTION_DISABLE_ACCOUNT); - intent.putExtra("account", account.getJid().toBareJid().toString()); - return PendingIntent.getService(mXmppConnectionService, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); + intent.setAction(XmppConnectionService.ACTION_DISMISS_ERROR_NOTIFICATIONS); + return PendingIntent.getService(mXmppConnectionService, 69, intent, 0); } private boolean wasHighlightedOrPrivate(final Message message) { @@ -611,7 +610,7 @@ public class NotificationService { final NotificationManagerCompat notificationManager = NotificationManagerCompat.from(mXmppConnectionService); final List<Account> errors = new ArrayList<>(); for (final Account account : mXmppConnectionService.getAccounts()) { - if (account.hasErrorStatus()) { + if (account.hasErrorStatus() && account.showErrorNotification()) { errors.add(account); } } @@ -632,29 +631,13 @@ public class NotificationService { mBuilder.addAction(R.drawable.ic_autorenew_white_24dp, mXmppConnectionService.getString(R.string.try_again), createTryAgainIntent()); - if (errors.size() == 1) { - if (Config.SHOW_DISABLE_FOREGROUND && !Config.USE_ALWAYS_FOREGROUND) { - mBuilder.addAction(R.drawable.ic_block_white_24dp, - mXmppConnectionService.getString(R.string.disable_account), - createDisableAccountIntent(errors.get(0))); - } - } - mBuilder.setOngoing(true); - //mBuilder.setLights(0xffffffff, 2000, 4000); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - mBuilder.setSmallIcon(R.drawable.ic_warning_white_24dp); - } else { - mBuilder.setSmallIcon(R.drawable.ic_stat_alert_warning); - } - final TaskStackBuilder stackBuilder = TaskStackBuilder.create(mXmppConnectionService); - stackBuilder.addParentStack(ConversationActivity.class); - - final Intent manageAccountsIntent = new Intent(mXmppConnectionService, ManageAccountActivity.class); - stackBuilder.addNextIntent(manageAccountsIntent); - - final PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); - - mBuilder.setContentIntent(resultPendingIntent); + mBuilder.setDeleteIntent(createDismissErrorIntent()); + mBuilder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC); + mBuilder.setSmallIcon(R.drawable.ic_warning_white_24dp); + mBuilder.setContentIntent(PendingIntent.getActivity(mXmppConnectionService, + 145, + new Intent(mXmppConnectionService,ManageAccountActivity.class), + PendingIntent.FLAG_UPDATE_CURRENT)); notificationManager.notify(ERROR_NOTIFICATION_ID, mBuilder.build()); } } |