commit next message (draft) when input box gets emptied. causes tablet view to update

This commit is contained in:
Daniel Gultsch 2018-09-16 15:26:33 +02:00
parent 3624d11824
commit 6a6287bbd7

View file

@ -1847,10 +1847,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
} }
if (this.conversation != null) { if (this.conversation != null) {
final String msg = this.binding.textinput.getText().toString(); final String msg = this.binding.textinput.getText().toString();
final boolean participating = conversation.getMode() == Conversational.MODE_SINGLE || conversation.getMucOptions().participating(); storeNextMessage(msg);
if (this.conversation.getStatus() != Conversation.STATUS_ARCHIVED && participating && this.conversation.setNextMessage(msg)) {
this.activity.xmppConnectionService.updateConversation(this.conversation);
}
updateChatState(this.conversation, msg); updateChatState(this.conversation, msg);
this.activity.xmppConnectionService.getNotificationService().setOpenConversation(null); this.activity.xmppConnectionService.getNotificationService().setOpenConversation(null);
} }
@ -1872,10 +1869,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
} }
Log.d(Config.LOGTAG, "ConversationFragment.saveMessageDraftStopAudioPlayer()"); Log.d(Config.LOGTAG, "ConversationFragment.saveMessageDraftStopAudioPlayer()");
final String msg = this.binding.textinput.getText().toString(); final String msg = this.binding.textinput.getText().toString();
final boolean participating = previousConversation.getMode() == Conversational.MODE_SINGLE || previousConversation.getMucOptions().participating(); storeNextMessage(msg);
if (participating && previousConversation.setNextMessage(msg)) {
activity.xmppConnectionService.updateConversation(previousConversation);
}
updateChatState(this.conversation, msg); updateChatState(this.conversation, msg);
messageListAdapter.stopAudioPlayer(); messageListAdapter.stopAudioPlayer();
mediaPreviewAdapter.clearPreviews(); mediaPreviewAdapter.clearPreviews();
@ -2191,10 +2185,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
this.binding.textinput.append(conversation.getDraftMessage()); this.binding.textinput.append(conversation.getDraftMessage());
conversation.setDraftMessage(null); conversation.setDraftMessage(null);
} }
final boolean participating = conversation.getMode() == Conversational.MODE_SINGLE || conversation.getMucOptions().participating(); storeNextMessage();
if (participating && conversation.setNextMessage(this.binding.textinput.getText().toString())) {
activity.xmppConnectionService.databaseBackend.updateConversation(conversation);
}
updateChatMsgHint(); updateChatMsgHint();
SharedPreferences p = PreferenceManager.getDefaultSharedPreferences(activity); SharedPreferences p = PreferenceManager.getDefaultSharedPreferences(activity);
final boolean prefScrollToBottom = p.getBoolean("scroll_to_bottom", activity.getResources().getBoolean(R.bool.scroll_to_bottom)); final boolean prefScrollToBottom = p.getBoolean("scroll_to_bottom", activity.getResources().getBoolean(R.bool.scroll_to_bottom));
@ -2206,6 +2197,19 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
} }
} }
private boolean storeNextMessage() {
return storeNextMessage(this.binding.textinput.getText().toString());
}
private boolean storeNextMessage(String msg) {
final boolean participating = conversation.getMode() == Conversational.MODE_SINGLE || conversation.getMucOptions().participating();
if (this.conversation.getStatus() != Conversation.STATUS_ARCHIVED && participating && this.conversation.setNextMessage(msg)) {
this.activity.xmppConnectionService.updateConversation(this.conversation);
return true;
}
return false;
}
public void doneSendingPgpMessage() { public void doneSendingPgpMessage() {
mSendingPgpMessage.set(false); mSendingPgpMessage.set(false);
} }
@ -2577,6 +2581,9 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
if (status == Account.State.ONLINE && conversation.setOutgoingChatState(Config.DEFAULT_CHATSTATE)) { if (status == Account.State.ONLINE && conversation.setOutgoingChatState(Config.DEFAULT_CHATSTATE)) {
service.sendChatState(conversation); service.sendChatState(conversation);
} }
if (storeNextMessage()) {
activity.onConversationsListItemUpdated();
}
updateSendButton(); updateSendButton();
} }