From d2cfac222ef7c144047eb7518a32f7cf9b39144f Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sun, 21 Feb 2016 17:32:46 +0100 Subject: show load more messages when auto loading is disabled and messages are still left on server --- .../eu/siacs/conversations/ui/ConversationFragment.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src/main/java/eu/siacs/conversations/ui') diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java index a39b6feef..ac06452a5 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java @@ -53,6 +53,7 @@ import eu.siacs.conversations.entities.MucOptions; import eu.siacs.conversations.entities.Presence; import eu.siacs.conversations.entities.Transferable; import eu.siacs.conversations.entities.TransferablePlaceholder; +import eu.siacs.conversations.services.MessageArchiveService; import eu.siacs.conversations.services.XmppConnectionService; import eu.siacs.conversations.ui.XmppActivity.OnPresenceSelected; import eu.siacs.conversations.ui.XmppActivity.OnValueEdited; @@ -1052,10 +1053,7 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa protected void updateStatusMessages() { synchronized (this.messageList) { - final XmppConnection connection = conversation.getAccount().getXmppConnection(); - if (conversation.getLastClearHistory() != 0 - && connection != null - && connection.getFeatures().mam()) { + if (showLoadMoreMessages(conversation)) { this.messageList.add(0, Message.createLoadMoreMessage(conversation)); } if (conversation.getMode() == Conversation.MODE_SINGLE) { @@ -1081,8 +1079,14 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa } } - protected void showSnackbar(final int message, final int action, - final OnClickListener clickListener) { + private boolean showLoadMoreMessages(final Conversation c) { + final XmppConnection connection = c.getAccount().getXmppConnection(); + final boolean mam = connection != null && connection.getFeatures().mam(); + final MessageArchiveService service = activity.xmppConnectionService.getMessageArchiveService(); + return mam && (c.getLastClearHistory() != 0 || (c.countMessages() == 0 && c.hasMessagesLeftOnServer() && !service.queryInProgress(c))); + } + + protected void showSnackbar(final int message, final int action, final OnClickListener clickListener) { snackbar.setVisibility(View.VISIBLE); snackbar.setOnClickListener(null); snackbarMessage.setText(message); -- cgit v1.2.3 From a0d0ed34ae38f2377fdb3ad2c661b74b85f2df28 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Mon, 22 Feb 2016 20:19:58 +0100 Subject: turned muc errors into enum. added error codes for service shutdown --- .../conversations/ui/ConversationFragment.java | 27 +++++++++++++--------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'src/main/java/eu/siacs/conversations/ui') diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java index ac06452a5..c652c3c0a 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java @@ -809,26 +809,29 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa && !conversation.getMucOptions().online() && account.getStatus() == Account.State.ONLINE) { switch (conversation.getMucOptions().getError()) { - case MucOptions.ERROR_NICK_IN_USE: + case NICK_IN_USE: showSnackbar(R.string.nick_in_use, R.string.edit, clickToMuc); break; - case MucOptions.ERROR_NO_RESPONSE: - showSnackbar(R.string.conference_not_found, R.string.leave, leaveMuc); + case NO_RESPONSE: + showSnackbar(R.string.joining_conference, 0, null); break; - case MucOptions.ERROR_PASSWORD_REQUIRED: + case PASSWORD_REQUIRED: showSnackbar(R.string.conference_requires_password, R.string.enter_password, enterPassword); break; - case MucOptions.ERROR_BANNED: + case BANNED: showSnackbar(R.string.conference_banned, R.string.leave, leaveMuc); break; - case MucOptions.ERROR_MEMBERS_ONLY: + case MEMBERS_ONLY: showSnackbar(R.string.conference_members_only, R.string.leave, leaveMuc); break; - case MucOptions.KICKED_FROM_ROOM: + case KICKED: showSnackbar(R.string.conference_kicked, R.string.join, joinMuc); break; - case MucOptions.ERROR_UNKNOWN: - showSnackbar(R.string.conference_unknown_error, R.string.try_again, joinMuc); + case UNKNOWN: + showSnackbar(R.string.conference_unknown_error, R.string.join, joinMuc); + break; + case SHUTDOWN: + showSnackbar(R.string.conference_shutdown, R.string.join, joinMuc); break; default: break; @@ -1091,8 +1094,10 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa snackbar.setOnClickListener(null); snackbarMessage.setText(message); snackbarMessage.setOnClickListener(null); - snackbarAction.setVisibility(View.VISIBLE); - snackbarAction.setText(action); + snackbarAction.setVisibility(clickListener == null ? View.GONE : View.VISIBLE); + if (action != 0) { + snackbarAction.setText(action); + } snackbarAction.setOnClickListener(clickListener); } -- cgit v1.2.3 From 689ded160718b5c73e118abe531530082b322636 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Mon, 22 Feb 2016 20:28:58 +0100 Subject: properly trigger show load more messages in mucs --- .../java/eu/siacs/conversations/ui/ConversationFragment.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/main/java/eu/siacs/conversations/ui') diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java index c652c3c0a..d5c77490a 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java @@ -1083,12 +1083,20 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa } private boolean showLoadMoreMessages(final Conversation c) { - final XmppConnection connection = c.getAccount().getXmppConnection(); - final boolean mam = connection != null && connection.getFeatures().mam(); + final boolean mam = hasMamSupport(c); final MessageArchiveService service = activity.xmppConnectionService.getMessageArchiveService(); return mam && (c.getLastClearHistory() != 0 || (c.countMessages() == 0 && c.hasMessagesLeftOnServer() && !service.queryInProgress(c))); } + private boolean hasMamSupport(final Conversation c) { + if (c.getMode() == Conversation.MODE_SINGLE) { + final XmppConnection connection = c.getAccount().getXmppConnection(); + return connection != null && connection.getFeatures().mam(); + } else { + return c.getMucOptions().mamSupport(); + } + } + protected void showSnackbar(final int message, final int action, final OnClickListener clickListener) { snackbar.setVisibility(View.VISIBLE); snackbar.setOnClickListener(null); -- cgit v1.2.3 From 17b1fcc3eafa078a902c662a6e774bcd7f2927b3 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Tue, 23 Feb 2016 16:15:55 +0100 Subject: set noMessagesLeftOnServer before conference configuration fetch --- src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java | 1 - 1 file changed, 1 deletion(-) (limited to 'src/main/java/eu/siacs/conversations/ui') diff --git a/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java b/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java index f8d1c97f7..d50e0661f 100644 --- a/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java @@ -14,7 +14,6 @@ import android.provider.ContactsContract; import android.provider.ContactsContract.CommonDataKinds; import android.provider.ContactsContract.Contacts; import android.provider.ContactsContract.Intents; -import android.util.Log; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; -- cgit v1.2.3