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