mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-17 19:38:52 +01:00
Improved draft support
This commit is contained in:
@@ -162,41 +162,29 @@ public class ConversationLegacy {
|
||||
|
||||
public void saveDraft(final String draft) {
|
||||
|
||||
new AsyncTask<Void, Void, Void>() {
|
||||
clearDrafts();
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
clearDrafts();
|
||||
if (draft.length() > 0) {
|
||||
try {
|
||||
DraftCache.getInstance().setSavingDraft(true);
|
||||
DraftCache.getInstance().setDraftState(threadId, true);
|
||||
ConversationLegacy.this.draft = draft;
|
||||
|
||||
if (draft.length() > 0) {
|
||||
try {
|
||||
DraftCache.getInstance().setSavingDraft(true);
|
||||
DraftCache.getInstance().setDraftState(threadId, true);
|
||||
ConversationLegacy.this.draft = draft;
|
||||
ContentResolver contentResolver = context.getContentResolver();
|
||||
ContentValues cv = new ContentValues();
|
||||
|
||||
ContentResolver contentResolver = context.getContentResolver();
|
||||
ContentValues cv = new ContentValues();
|
||||
cv.put("address", getAddress());
|
||||
cv.put("body", draft);
|
||||
|
||||
cv.put("address", getAddress());
|
||||
cv.put("body", draft);
|
||||
|
||||
contentResolver.insert(SmsHelper.DRAFTS_CONTENT_PROVIDER, cv);
|
||||
} finally {
|
||||
DraftCache.getInstance().setSavingDraft(false);
|
||||
}
|
||||
} else {
|
||||
ConversationLegacy.this.draft = null;
|
||||
}
|
||||
|
||||
return null;
|
||||
contentResolver.insert(SmsHelper.DRAFTS_CONTENT_PROVIDER, cv);
|
||||
} finally {
|
||||
DraftCache.getInstance().setSavingDraft(false);
|
||||
}
|
||||
} else {
|
||||
ConversationLegacy.this.draft = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Void aVoid) {
|
||||
super.onPostExecute(aVoid);
|
||||
Toast.makeText(context, R.string.toast_draft, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}.execute((Void[]) null);
|
||||
Toast.makeText(context, R.string.toast_draft, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
|
||||
@@ -268,6 +268,12 @@ public class MessageListFragment extends QKContentFragment implements ActivityLa
|
||||
onOpenConversation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
mComposeView.saveDraft();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(Bundle outState) {
|
||||
outState.putLong(ARG_THREAD_ID, mThreadId);
|
||||
@@ -511,14 +517,6 @@ public class MessageListFragment extends QKContentFragment implements ActivityLa
|
||||
v.vibrate(vibrateTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
|
||||
// Save the draft. This should also clear the EditText.
|
||||
mComposeView.saveDraft();
|
||||
}
|
||||
|
||||
/**
|
||||
* Photo Selection result
|
||||
*/
|
||||
|
||||
@@ -742,8 +742,7 @@ public class ComposeView extends LinearLayout implements View.OnClickListener {
|
||||
mConversationLegacy.clearDrafts();
|
||||
|
||||
} else if (!TextUtils.isEmpty(draft) &&
|
||||
(!mConversationLegacy.hasDraft() ||
|
||||
!draft.equals(mConversationLegacy.getDraft()))) {
|
||||
(!mConversationLegacy.hasDraft() || !draft.equals(mConversationLegacy.getDraft()))) {
|
||||
mConversationLegacy.saveDraft(draft);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user