mirror of
https://github.com/moparisthebest/Conversations
synced 2024-12-02 13:42:18 -05:00
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_CRYPTO_TARGETS = "crypto_targets";
|
||||||
public static final String ATTRIBUTE_LAST_CLEAR_HISTORY = "last_clear_history";
|
public static final String ATTRIBUTE_LAST_CLEAR_HISTORY = "last_clear_history";
|
||||||
|
|
||||||
|
private String draftMessage;
|
||||||
private String name;
|
private String name;
|
||||||
private String contactUuid;
|
private String contactUuid;
|
||||||
private String accountUuid;
|
private String accountUuid;
|
||||||
@ -357,9 +358,8 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean setCorrectingMessage(Message correctingMessage) {
|
public boolean setCorrectingMessage(Message correctingMessage) {
|
||||||
boolean corrected = this.correctingMessage != null && correctingMessage == null;
|
|
||||||
this.correctingMessage = correctingMessage;
|
this.correctingMessage = correctingMessage;
|
||||||
return corrected;
|
return correctingMessage == null && draftMessage != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Message getCorrectingMessage() {
|
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 {
|
public interface OnMessageFound {
|
||||||
void onMessageFound(final Message message);
|
void onMessageFound(final Message message);
|
||||||
}
|
}
|
||||||
|
@ -344,11 +344,11 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
|
|||||||
break;
|
break;
|
||||||
case CANCEL:
|
case CANCEL:
|
||||||
if (conversation != null) {
|
if (conversation != null) {
|
||||||
if (conversation.getCorrectingMessage() != null) {
|
if(conversation.setCorrectingMessage(null)) {
|
||||||
conversation.setCorrectingMessage(null);
|
|
||||||
mEditMessage.getEditableText().clear();
|
mEditMessage.getEditableText().clear();
|
||||||
}
|
mEditMessage.getEditableText().append(conversation.getDraftMessage());
|
||||||
if (conversation.getMode() == Conversation.MODE_MULTI) {
|
conversation.setDraftMessage(null);
|
||||||
|
} else if (conversation.getMode() == Conversation.MODE_MULTI) {
|
||||||
conversation.setNextCounterpart(null);
|
conversation.setNextCounterpart(null);
|
||||||
}
|
}
|
||||||
updateChatMsgHint();
|
updateChatMsgHint();
|
||||||
@ -839,6 +839,8 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
|
|||||||
message = message.next();
|
message = message.next();
|
||||||
}
|
}
|
||||||
this.conversation.setCorrectingMessage(message);
|
this.conversation.setCorrectingMessage(message);
|
||||||
|
final Editable editable = mEditMessage.getText();
|
||||||
|
this.conversation.setDraftMessage(editable.toString());
|
||||||
this.mEditMessage.getEditableText().clear();
|
this.mEditMessage.getEditableText().clear();
|
||||||
this.mEditMessage.getEditableText().append(message.getBody());
|
this.mEditMessage.getEditableText().append(message.getBody());
|
||||||
|
|
||||||
@ -1072,8 +1074,12 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
|
|||||||
|
|
||||||
protected void messageSent() {
|
protected void messageSent() {
|
||||||
mSendingPgpMessage.set(false);
|
mSendingPgpMessage.set(false);
|
||||||
mEditMessage.getEditableText().clear();
|
Editable editable = mEditMessage.getEditableText();
|
||||||
conversation.setCorrectingMessage(null);
|
editable.clear();
|
||||||
|
if (conversation.setCorrectingMessage(null)) {
|
||||||
|
editable.append(conversation.getDraftMessage());
|
||||||
|
conversation.setDraftMessage(null);
|
||||||
|
}
|
||||||
updateChatMsgHint();
|
updateChatMsgHint();
|
||||||
new Handler().post(new Runnable() {
|
new Handler().post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user