save message drafts across restarts. fixes #2642
This commit is contained in:
parent
50d436fd81
commit
48baf56622
|
@ -54,6 +54,7 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
|
||||||
public static final String ATTRIBUTE_MUTED_TILL = "muted_till";
|
public static final String ATTRIBUTE_MUTED_TILL = "muted_till";
|
||||||
public static final String ATTRIBUTE_ALWAYS_NOTIFY = "always_notify";
|
public static final String ATTRIBUTE_ALWAYS_NOTIFY = "always_notify";
|
||||||
public static final String ATTRIBUTE_LAST_CLEAR_HISTORY = "last_clear_history";
|
public static final String ATTRIBUTE_LAST_CLEAR_HISTORY = "last_clear_history";
|
||||||
|
public static final String ATTRIBUTE_NEXT_MESSAGE = "next_message";
|
||||||
|
|
||||||
private static final String ATTRIBUTE_CRYPTO_TARGETS = "crypto_targets";
|
private static final String ATTRIBUTE_CRYPTO_TARGETS = "crypto_targets";
|
||||||
|
|
||||||
|
@ -81,8 +82,6 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
|
||||||
private transient String otrFingerprint = null;
|
private transient String otrFingerprint = null;
|
||||||
private Smp mSmp = new Smp();
|
private Smp mSmp = new Smp();
|
||||||
|
|
||||||
private String nextMessage;
|
|
||||||
|
|
||||||
private transient MucOptions mucOptions = null;
|
private transient MucOptions mucOptions = null;
|
||||||
|
|
||||||
private byte[] symmetricKey;
|
private byte[] symmetricKey;
|
||||||
|
@ -753,19 +752,18 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getNextMessage() {
|
public String getNextMessage() {
|
||||||
if (this.nextMessage == null) {
|
final String nextMessage = getAttribute(ATTRIBUTE_NEXT_MESSAGE);
|
||||||
return "";
|
return nextMessage == null ? "" : nextMessage;
|
||||||
} else {
|
|
||||||
return this.nextMessage;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean smpRequested() {
|
public boolean smpRequested() {
|
||||||
return smp().status == Smp.STATUS_CONTACT_REQUESTED;
|
return smp().status == Smp.STATUS_CONTACT_REQUESTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNextMessage(String message) {
|
public boolean setNextMessage(String message) {
|
||||||
this.nextMessage = message;
|
boolean changed = !getNextMessage().equals(message);
|
||||||
|
this.setAttribute(ATTRIBUTE_NEXT_MESSAGE,message);
|
||||||
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSymmetricKey(byte[] key) {
|
public void setSymmetricKey(byte[] key) {
|
||||||
|
|
|
@ -889,7 +889,9 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
|
||||||
}
|
}
|
||||||
if (this.conversation != null) {
|
if (this.conversation != null) {
|
||||||
final String msg = mEditMessage.getText().toString();
|
final String msg = mEditMessage.getText().toString();
|
||||||
this.conversation.setNextMessage(msg);
|
if (this.conversation.setNextMessage(msg)) {
|
||||||
|
activity.xmppConnectionService.updateConversation(this.conversation);
|
||||||
|
}
|
||||||
updateChatState(this.conversation, msg);
|
updateChatState(this.conversation, msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -910,7 +912,9 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
|
||||||
setupIme();
|
setupIme();
|
||||||
if (this.conversation != null) {
|
if (this.conversation != null) {
|
||||||
final String msg = mEditMessage.getText().toString();
|
final String msg = mEditMessage.getText().toString();
|
||||||
this.conversation.setNextMessage(msg);
|
if (this.conversation.setNextMessage(msg)) {
|
||||||
|
activity.xmppConnectionService.updateConversation(conversation);
|
||||||
|
}
|
||||||
if (this.conversation != conversation) {
|
if (this.conversation != conversation) {
|
||||||
updateChatState(this.conversation, msg);
|
updateChatState(this.conversation, msg);
|
||||||
messageListAdapter.stopAudioPlayer();
|
messageListAdapter.stopAudioPlayer();
|
||||||
|
@ -1154,7 +1158,9 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
|
||||||
mEditMessage.append(conversation.getDraftMessage());
|
mEditMessage.append(conversation.getDraftMessage());
|
||||||
conversation.setDraftMessage(null);
|
conversation.setDraftMessage(null);
|
||||||
}
|
}
|
||||||
conversation.setNextMessage(mEditMessage.getText().toString());
|
if (conversation.setNextMessage(mEditMessage.getText().toString())) {
|
||||||
|
activity.xmppConnectionService.updateConversation(conversation);
|
||||||
|
}
|
||||||
updateChatMsgHint();
|
updateChatMsgHint();
|
||||||
new Handler().post(new Runnable() {
|
new Handler().post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue