From f7fea5a35adae306326de57da22420c52bfc4517 Mon Sep 17 00:00:00 2001 From: Christian Schneppe Date: Fri, 23 Nov 2018 12:32:34 +0100 Subject: refresh contacts when opening StartConversationsActivity --- src/main/java/de/pixart/messenger/Config.java | 3 +++ src/main/java/de/pixart/messenger/entities/Account.java | 8 ++++++++ .../java/de/pixart/messenger/services/NotificationService.java | 3 ++- .../java/de/pixart/messenger/services/XmppConnectionService.java | 4 ++++ .../java/de/pixart/messenger/ui/StartConversationActivity.java | 1 + 5 files changed, 18 insertions(+), 1 deletion(-) (limited to 'src/main/java/de/pixart/messenger') diff --git a/src/main/java/de/pixart/messenger/Config.java b/src/main/java/de/pixart/messenger/Config.java index 5181b24b1..13c86e6a1 100644 --- a/src/main/java/de/pixart/messenger/Config.java +++ b/src/main/java/de/pixart/messenger/Config.java @@ -59,6 +59,9 @@ public final class Config { public static final boolean ALLOW_NON_TLS_CONNECTIONS = false; //very dangerous. you should have a good reason to set this to true public static final boolean FORCE_ORBOT = false; // always use TOR + + public static final long CONTACT_SYNC_RETRY_INTERVAL = 1000L * 60 * 5; + public static final boolean HIDE_MESSAGE_TEXT_IN_NOTIFICATION = false; public static final boolean SHOW_CONNECTED_ACCOUNTS = false; //show number of connected accounts in foreground notification diff --git a/src/main/java/de/pixart/messenger/entities/Account.java b/src/main/java/de/pixart/messenger/entities/Account.java index 9e3711535..412960e48 100644 --- a/src/main/java/de/pixart/messenger/entities/Account.java +++ b/src/main/java/de/pixart/messenger/entities/Account.java @@ -73,6 +73,7 @@ public class Account extends AbstractEntity { protected String password; protected int options = 0; protected State status = State.OFFLINE; + private State lastErrorStatus = State.OFFLINE; protected String resource; protected String avatar; protected String hostname = null; @@ -271,8 +272,15 @@ public class Account extends AbstractEntity { } } + public State getLastErrorStatus() { + return this.lastErrorStatus; + } + public void setStatus(final State status) { this.status = status; + if (status.isError) { + this.lastErrorStatus = status; + } } public State getTrueStatus() { diff --git a/src/main/java/de/pixart/messenger/services/NotificationService.java b/src/main/java/de/pixart/messenger/services/NotificationService.java index 053685fc6..91501f623 100644 --- a/src/main/java/de/pixart/messenger/services/NotificationService.java +++ b/src/main/java/de/pixart/messenger/services/NotificationService.java @@ -929,9 +929,10 @@ public class NotificationService { cancel(ERROR_NOTIFICATION_ID); return; } + final boolean showAllErrors = QuickConversationsService.isConversations(); final List errors = new ArrayList<>(); for (final Account account : mXmppConnectionService.getAccounts()) { - if (account.hasErrorStatus() && account.showErrorNotification()) { + if (account.hasErrorStatus() && account.showErrorNotification() && (showAllErrors || account.getLastErrorStatus() == Account.State.UNAUTHORIZED)) { errors.add(account); } } diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java index e9f77b33b..174785fb8 100644 --- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java +++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java @@ -4041,6 +4041,10 @@ public class XmppConnectionService extends Service { return this.mMessageArchiveService; } + public QuickConversationsService getQuickConversationsService() { + return this.mQuickConversationsService; + } + public List findContacts(Jid jid, String accountJid) { ArrayList contacts = new ArrayList<>(); for (Account account : getAccounts()) { diff --git a/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java b/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java index 1edbafd67..171db1bda 100644 --- a/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java +++ b/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java @@ -735,6 +735,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne @Override protected void onBackendConnected() { + xmppConnectionService.getQuickConversationsService().considerSync(); if (mPostponedActivityResult != null) { onActivityResult(mPostponedActivityResult.first, RESULT_OK, mPostponedActivityResult.second); this.mPostponedActivityResult = null; -- cgit v1.2.3