diff --git a/src/main/java/eu/siacs/conversations/entities/Conversation.java b/src/main/java/eu/siacs/conversations/entities/Conversation.java index eaf01dd0..2f3989dd 100644 --- a/src/main/java/eu/siacs/conversations/entities/Conversation.java +++ b/src/main/java/eu/siacs/conversations/entities/Conversation.java @@ -58,6 +58,7 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl public static final String ATTRIBUTE_CRYPTO_TARGETS = "crypto_targets"; public static final String ATTRIBUTE_LAST_CLEAR_HISTORY = "last_clear_history"; + private String draftMessage; private String name; private String contactUuid; private String accountUuid; @@ -357,9 +358,8 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl } public boolean setCorrectingMessage(Message correctingMessage) { - boolean corrected = this.correctingMessage != null && correctingMessage == null; this.correctingMessage = correctingMessage; - return corrected; + return correctingMessage == null && draftMessage != null; } public Message getCorrectingMessage() { @@ -383,6 +383,14 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl } } + public void setDraftMessage(String draftMessage) { + this.draftMessage = draftMessage; + } + + public String getDraftMessage() { + return draftMessage; + } + public interface OnMessageFound { void onMessageFound(final Message message); } diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java index a8a1d0ba..3ac2447e 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java @@ -344,11 +344,11 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa break; case CANCEL: if (conversation != null) { - if (conversation.getCorrectingMessage() != null) { - conversation.setCorrectingMessage(null); + if(conversation.setCorrectingMessage(null)) { mEditMessage.getEditableText().clear(); - } - if (conversation.getMode() == Conversation.MODE_MULTI) { + mEditMessage.getEditableText().append(conversation.getDraftMessage()); + conversation.setDraftMessage(null); + } else if (conversation.getMode() == Conversation.MODE_MULTI) { conversation.setNextCounterpart(null); } updateChatMsgHint(); @@ -839,6 +839,8 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa message = message.next(); } this.conversation.setCorrectingMessage(message); + final Editable editable = mEditMessage.getText(); + this.conversation.setDraftMessage(editable.toString()); this.mEditMessage.getEditableText().clear(); this.mEditMessage.getEditableText().append(message.getBody()); @@ -1072,8 +1074,12 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa protected void messageSent() { mSendingPgpMessage.set(false); - mEditMessage.getEditableText().clear(); - conversation.setCorrectingMessage(null); + Editable editable = mEditMessage.getEditableText(); + editable.clear(); + if (conversation.setCorrectingMessage(null)) { + editable.append(conversation.getDraftMessage()); + conversation.setDraftMessage(null); + } updateChatMsgHint(); new Handler().post(new Runnable() { @Override