show load more messages when auto loading is disabled and messages are still left on server

This commit is contained in:
Daniel Gultsch 2016-02-21 17:32:46 +01:00
parent b00c561f81
commit d2cfac222e
2 changed files with 14 additions and 6 deletions

View file

@ -189,6 +189,10 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded {
} }
} }
public boolean queryInProgress(Conversation conversation) {
return queryInProgress(conversation, null);
}
public void processFin(Element fin, Jid from) { public void processFin(Element fin, Jid from) {
if (fin == null) { if (fin == null) {
return; return;

View file

@ -53,6 +53,7 @@ import eu.siacs.conversations.entities.MucOptions;
import eu.siacs.conversations.entities.Presence; import eu.siacs.conversations.entities.Presence;
import eu.siacs.conversations.entities.Transferable; import eu.siacs.conversations.entities.Transferable;
import eu.siacs.conversations.entities.TransferablePlaceholder; import eu.siacs.conversations.entities.TransferablePlaceholder;
import eu.siacs.conversations.services.MessageArchiveService;
import eu.siacs.conversations.services.XmppConnectionService; import eu.siacs.conversations.services.XmppConnectionService;
import eu.siacs.conversations.ui.XmppActivity.OnPresenceSelected; import eu.siacs.conversations.ui.XmppActivity.OnPresenceSelected;
import eu.siacs.conversations.ui.XmppActivity.OnValueEdited; import eu.siacs.conversations.ui.XmppActivity.OnValueEdited;
@ -1052,10 +1053,7 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
protected void updateStatusMessages() { protected void updateStatusMessages() {
synchronized (this.messageList) { synchronized (this.messageList) {
final XmppConnection connection = conversation.getAccount().getXmppConnection(); if (showLoadMoreMessages(conversation)) {
if (conversation.getLastClearHistory() != 0
&& connection != null
&& connection.getFeatures().mam()) {
this.messageList.add(0, Message.createLoadMoreMessage(conversation)); this.messageList.add(0, Message.createLoadMoreMessage(conversation));
} }
if (conversation.getMode() == Conversation.MODE_SINGLE) { 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, private boolean showLoadMoreMessages(final Conversation c) {
final OnClickListener clickListener) { 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.setVisibility(View.VISIBLE);
snackbar.setOnClickListener(null); snackbar.setOnClickListener(null);
snackbarMessage.setText(message); snackbarMessage.setText(message);