diff options
author | Daniel Gultsch <daniel@gultsch.de> | 2016-10-04 11:16:59 +0200 |
---|---|---|
committer | Daniel Gultsch <daniel@gultsch.de> | 2016-10-04 11:16:59 +0200 |
commit | 082c06a486fe4cdb8870680a33836f40d570d1fd (patch) | |
tree | c7655284bae8cef2523968c7585aaca926d005a7 /src/main/java/eu/siacs/conversations/services/XmppConnectionService.java | |
parent | 5ac0e9267d8ff98dcb6a28d1837e81b4572e8b03 (diff) |
make error notification dismissable. fixes #1815
Diffstat (limited to 'src/main/java/eu/siacs/conversations/services/XmppConnectionService.java')
-rw-r--r-- | src/main/java/eu/siacs/conversations/services/XmppConnectionService.java | 39 |
1 files changed, 26 insertions, 13 deletions
diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index 39e28f93..215d2c09 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -132,8 +132,8 @@ public class XmppConnectionService extends Service { public static final String ACTION_REPLY_TO_CONVERSATION = "reply_to_conversations"; public static final String ACTION_CLEAR_NOTIFICATION = "clear_notification"; public static final String ACTION_DISABLE_FOREGROUND = "disable_foreground"; + public static final String ACTION_DISMISS_ERROR_NOTIFICATIONS = "dismiss_error"; public static final String ACTION_TRY_AGAIN = "try_again"; - public static final String ACTION_DISABLE_ACCOUNT = "disable_account"; public static final String ACTION_IDLE_PING = "idle_ping"; private static final String ACTION_MERGE_PHONE_CONTACTS = "merge_phone_contacts"; public static final String ACTION_GCM_TOKEN_REFRESH = "gcm_token_refresh"; @@ -294,6 +294,9 @@ public class XmppConnectionService extends Service { mOnAccountUpdate.onAccountUpdate(); } if (account.getStatus() == Account.State.ONLINE) { + if (account.setShowErrorNotification(true)) { + databaseBackend.updateAccount(account); + } mMessageArchiveService.executePendingQueries(account); if (connection != null && connection.getFeatures().csi()) { if (checkListeners()) { @@ -554,22 +557,13 @@ public class XmppConnectionService extends Service { getPreferences().edit().putBoolean("keep_foreground_service", false).commit(); toggleForegroundService(); break; + case ACTION_DISMISS_ERROR_NOTIFICATIONS: + dismissErrorNotifications(); + break; case ACTION_TRY_AGAIN: resetAllAttemptCounts(false); interactive = true; break; - case ACTION_DISABLE_ACCOUNT: - try { - String jid = intent.getStringExtra("account"); - Account account = jid == null ? null : findAccountByJid(Jid.fromString(jid)); - if (account != null) { - account.setOption(Account.OPTION_DISABLED, true); - updateAccount(account); - } - } catch (final InvalidJidException ignored) { - break; - } - break; case ACTION_REPLY_TO_CONVERSATION: Bundle remoteInput = RemoteInput.getResultsFromIntent(intent); if (remoteInput != null && c != null) { @@ -811,6 +805,20 @@ public class XmppConnectionService extends Service { connection.resetAttemptCount(); } } + if (account.setShowErrorNotification(true)) { + databaseBackend.updateAccount(account); + } + } + } + + private void dismissErrorNotifications() { + for (final Account account : this.accounts) { + if (account.hasErrorStatus()) { + Log.d(Config.LOGTAG,account.getJid().toBareJid()+": dismissing error notification"); + if (account.setShowErrorNotification(false)) { + databaseBackend.updateAccount(account); + } + } } } @@ -1027,6 +1035,10 @@ public class XmppConnectionService extends Service { private void sendMessage(final Message message, final boolean resend, final boolean delay) { final Account account = message.getConversation().getAccount(); + if (account.setShowErrorNotification(true)) { + databaseBackend.updateAccount(account); + mNotificationService.updateErrorNotification(); + } final Conversation conversation = message.getConversation(); account.deactivateGracePeriod(); MessagePacket packet = null; @@ -1651,6 +1663,7 @@ public class XmppConnectionService extends Service { public boolean updateAccount(final Account account) { if (databaseBackend.updateAccount(account)) { + account.setShowErrorNotification(true); this.statusListener.onStatusChanged(account); databaseBackend.updateAccount(account); reconnectAccountInBackground(account); |