diff options
author | Christian Schneppe <christian@pix-art.de> | 2017-04-16 12:16:42 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2017-04-16 12:16:42 +0200 |
commit | ed539ec46ce4608b4f2d17f59d956e6272f0e599 (patch) | |
tree | 780139477078de90bcd75f8df1e4df272e9941a0 /src/main/java | |
parent | 45e4c115d66804d53275d9885fc2b5e64114d134 (diff) |
show 'try again' button when remote server wasn't found in previously active muc
Diffstat (limited to 'src/main/java')
3 files changed, 19 insertions, 1 deletions
diff --git a/src/main/java/de/pixart/messenger/entities/Conversation.java b/src/main/java/de/pixart/messenger/entities/Conversation.java index 52525e481..922ba614f 100644 --- a/src/main/java/de/pixart/messenger/entities/Conversation.java +++ b/src/main/java/de/pixart/messenger/entities/Conversation.java @@ -1057,6 +1057,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/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java index 2a0aa62dd..02f9273c7 100644 --- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java +++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java @@ -2450,6 +2450,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/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java index d8eb6eac2..5976bde02 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java @@ -1072,7 +1072,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); @@ -1094,6 +1098,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)) { |