refresh contacts when opening StartConversationsActivity

This commit is contained in:
Christian Schneppe 2018-11-23 12:32:34 +01:00
parent 7d584fbee0
commit f7fea5a35a
5 changed files with 18 additions and 1 deletions

View file

@ -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

View file

@ -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() {

View file

@ -929,9 +929,10 @@ public class NotificationService {
cancel(ERROR_NOTIFICATION_ID);
return;
}
final boolean showAllErrors = QuickConversationsService.isConversations();
final List<Account> 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);
}
}

View file

@ -4041,6 +4041,10 @@ public class XmppConnectionService extends Service {
return this.mMessageArchiveService;
}
public QuickConversationsService getQuickConversationsService() {
return this.mQuickConversationsService;
}
public List<Contact> findContacts(Jid jid, String accountJid) {
ArrayList<Contact> contacts = new ArrayList<>();
for (Account account : getAccounts()) {

View file

@ -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;