Loading QKSMS/src/main/java/com/moez/QKSMS/enums/QKPreference.java +4 −1 Original line number Diff line number Diff line Loading @@ -93,7 +93,10 @@ public enum QKPreference { QK_COMPOSE("pref_key_quickcompose", false), // LiveViews CONVERSATION_THEME("conversation_theme"); CONVERSATION_THEME("conversation_theme"), // Storage COMPOSE_DRAFT("compose_draft", ""); private String mKey; private Object mDefaultValue; Loading QKSMS/src/main/java/com/moez/QKSMS/ui/compose/ComposeFragment.java +17 −0 Original line number Diff line number Diff line Loading @@ -104,6 +104,7 @@ public class ComposeFragment extends QKContentFragment implements ActivityLaunch view.findViewById(R.id.compose_view_stub).setVisibility(View.VISIBLE); mComposeView = (ComposeView) view.findViewById(R.id.compose_view); mComposeView.onOpenConversation(null, null); mComposeView.setActivityLauncher(this); mComposeView.setRecipientProvider(this); mComposeView.setOnSendListener(this); Loading Loading @@ -168,6 +169,22 @@ public class ComposeFragment extends QKContentFragment implements ActivityLaunch } } @Override public void onContentClosed() { super.onContentClosed(); if (mComposeView != null) { mComposeView.saveDraft(); } } @Override public void onDestroy() { super.onDestroy(); if (mComposeView != null) { mComposeView.saveDraft(); } } @Override public void onMenuChanging(float percentOpen) { Loading QKSMS/src/main/java/com/moez/QKSMS/ui/view/ComposeView.java +23 −7 Original line number Diff line number Diff line Loading @@ -715,7 +715,7 @@ public class ComposeView extends LinearLayout implements View.OnClickListener { mConversationLegacy = conversationLegacy; // If the conversation was different, set up the draft here. if (threadId != newThreadId) { if (threadId != newThreadId || newThreadId == -1) { setupDraft(); } } Loading @@ -735,9 +735,10 @@ public class ComposeView extends LinearLayout implements View.OnClickListener { public void saveDraft() { // If the conversation_reply view is null, then we won't worry about saving drafts at all. We also don't save // drafts if a message is about to be sent (delayed) if (mReplyText != null && mConversation != null && mButtonState != SendButtonState.CANCEL) { if (mReplyText != null && mButtonState != SendButtonState.CANCEL) { String draft = mReplyText.getText().toString(); if (mConversation != null) { if (mConversationLegacy.hasDraft() && TextUtils.isEmpty(draft)) { mConversationLegacy.clearDrafts(); Loading @@ -745,6 +746,17 @@ public class ComposeView extends LinearLayout implements View.OnClickListener { (!mConversationLegacy.hasDraft() || !draft.equals(mConversationLegacy.getDraft()))) { mConversationLegacy.saveDraft(draft); } } else { String oldDraft = mPrefs.getString(QKPreference.COMPOSE_DRAFT.getKey(), ""); if (!draft.equals(oldDraft)) { mPrefs.edit().putString(QKPreference.COMPOSE_DRAFT.getKey(), draft).apply(); // Only show the draft if we saved text, not if we just cleared some if (!TextUtils.isEmpty(draft)) { Toast.makeText(mContext, R.string.toast_draft, Toast.LENGTH_SHORT).show(); } } } } } Loading @@ -767,6 +779,10 @@ public class ComposeView extends LinearLayout implements View.OnClickListener { mReplyText.setText(""); clearAttachment(); } } else { String draft = mPrefs.getString(QKPreference.COMPOSE_DRAFT.getKey(), ""); mReplyText.setText(draft); mReplyText.setSelection(draft.length()); } } Loading Loading
QKSMS/src/main/java/com/moez/QKSMS/enums/QKPreference.java +4 −1 Original line number Diff line number Diff line Loading @@ -93,7 +93,10 @@ public enum QKPreference { QK_COMPOSE("pref_key_quickcompose", false), // LiveViews CONVERSATION_THEME("conversation_theme"); CONVERSATION_THEME("conversation_theme"), // Storage COMPOSE_DRAFT("compose_draft", ""); private String mKey; private Object mDefaultValue; Loading
QKSMS/src/main/java/com/moez/QKSMS/ui/compose/ComposeFragment.java +17 −0 Original line number Diff line number Diff line Loading @@ -104,6 +104,7 @@ public class ComposeFragment extends QKContentFragment implements ActivityLaunch view.findViewById(R.id.compose_view_stub).setVisibility(View.VISIBLE); mComposeView = (ComposeView) view.findViewById(R.id.compose_view); mComposeView.onOpenConversation(null, null); mComposeView.setActivityLauncher(this); mComposeView.setRecipientProvider(this); mComposeView.setOnSendListener(this); Loading Loading @@ -168,6 +169,22 @@ public class ComposeFragment extends QKContentFragment implements ActivityLaunch } } @Override public void onContentClosed() { super.onContentClosed(); if (mComposeView != null) { mComposeView.saveDraft(); } } @Override public void onDestroy() { super.onDestroy(); if (mComposeView != null) { mComposeView.saveDraft(); } } @Override public void onMenuChanging(float percentOpen) { Loading
QKSMS/src/main/java/com/moez/QKSMS/ui/view/ComposeView.java +23 −7 Original line number Diff line number Diff line Loading @@ -715,7 +715,7 @@ public class ComposeView extends LinearLayout implements View.OnClickListener { mConversationLegacy = conversationLegacy; // If the conversation was different, set up the draft here. if (threadId != newThreadId) { if (threadId != newThreadId || newThreadId == -1) { setupDraft(); } } Loading @@ -735,9 +735,10 @@ public class ComposeView extends LinearLayout implements View.OnClickListener { public void saveDraft() { // If the conversation_reply view is null, then we won't worry about saving drafts at all. We also don't save // drafts if a message is about to be sent (delayed) if (mReplyText != null && mConversation != null && mButtonState != SendButtonState.CANCEL) { if (mReplyText != null && mButtonState != SendButtonState.CANCEL) { String draft = mReplyText.getText().toString(); if (mConversation != null) { if (mConversationLegacy.hasDraft() && TextUtils.isEmpty(draft)) { mConversationLegacy.clearDrafts(); Loading @@ -745,6 +746,17 @@ public class ComposeView extends LinearLayout implements View.OnClickListener { (!mConversationLegacy.hasDraft() || !draft.equals(mConversationLegacy.getDraft()))) { mConversationLegacy.saveDraft(draft); } } else { String oldDraft = mPrefs.getString(QKPreference.COMPOSE_DRAFT.getKey(), ""); if (!draft.equals(oldDraft)) { mPrefs.edit().putString(QKPreference.COMPOSE_DRAFT.getKey(), draft).apply(); // Only show the draft if we saved text, not if we just cleared some if (!TextUtils.isEmpty(draft)) { Toast.makeText(mContext, R.string.toast_draft, Toast.LENGTH_SHORT).show(); } } } } } Loading @@ -767,6 +779,10 @@ public class ComposeView extends LinearLayout implements View.OnClickListener { mReplyText.setText(""); clearAttachment(); } } else { String draft = mPrefs.getString(QKPreference.COMPOSE_DRAFT.getKey(), ""); mReplyText.setText(draft); mReplyText.setSelection(draft.length()); } } Loading