From 1ac0c2f453d639f3332eec5f6a8894264b43adb7 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sat, 15 Apr 2017 17:18:15 +0200 Subject: [PATCH] show 'try again' button when remote server wasn't found in previously active muc --- .../siacs/conversations/entities/Conversation.java | 12 ++++++++++++ .../services/XmppConnectionService.java | 1 + .../siacs/conversations/ui/ConversationFragment.java | 7 ++++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/main/java/eu/siacs/conversations/entities/Conversation.java b/src/main/java/eu/siacs/conversations/entities/Conversation.java index 517221504..c3da6977f 100644 --- a/src/main/java/eu/siacs/conversations/entities/Conversation.java +++ b/src/main/java/eu/siacs/conversations/entities/Conversation.java @@ -1007,6 +1007,18 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl } } + public int receivedMessagesCount() { + int count = 0; + synchronized (this.messages) { + for(Message message : messages) { + if (message.getStatus() == Message.STATUS_RECEIVED) { + ++count; + } + } + } + return count; + } + private int sentMessagesCount() { int count = 0; synchronized (this.messages) { diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index 5c6baf9d2..994870fd7 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -2267,6 +2267,7 @@ public class XmppConnectionService extends Service { public void onFetchFailed(final Conversation conversation, Element error) { if (error != null && "remote-server-not-found".equals(error.getName())) { conversation.getMucOptions().setError(MucOptions.Error.SERVER_NOT_FOUND); + updateConversationUi(); } else { join(conversation); fetchConferenceConfiguration(conversation); diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java index 75fab618d..9b96fa18a 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java @@ -1038,7 +1038,11 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa showSnackbar(R.string.joining_conference, 0, null); break; case SERVER_NOT_FOUND: - showSnackbar(R.string.remote_server_not_found,R.string.leave, leaveMuc); + if (conversation.receivedMessagesCount() > 0) { + showSnackbar(R.string.remote_server_not_found,R.string.try_again, joinMuc); + } else { + showSnackbar(R.string.remote_server_not_found, R.string.leave, leaveMuc); + } break; case PASSWORD_REQUIRED: showSnackbar(R.string.conference_requires_password, R.string.enter_password, enterPassword); @@ -1059,6 +1063,7 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa showSnackbar(R.string.conference_shutdown, R.string.join, joinMuc); break; default: + hideSnackbar(); break; } } else if (account.hasPendingPgpIntent(conversation)) {