Keep draft even when correcting previously sent msg
fixes #1822. Thank you @singhalok641
This commit is contained in:
parent
d166309393
commit
cb203f5fd3
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue