diff options
| author | Danesh M <daneshm90@gmail.com> | 2015-07-31 13:24:57 -0700 |
|---|---|---|
| committer | doc HD <doc.divxm@gmail.com> | 2015-08-06 11:44:54 +0300 |
| commit | 2496538d51f313fd13e5de5b070538555bd96238 (patch) | |
| tree | 1fb8ac6f196b5cfdbfc90520f268611229dba54d | |
| parent | b55c814a97d90d9745df30029e32e7afa3777aef (diff) | |
Mms : Replace REQUEST_CODE_PICK with REQUEST_CODE_ADD_RECIPIENTS
This ensures the logic surrounding the old REQUEST_CODE_PICK is still
used. This fixes various draft issues when leaving the cma for picking
recipients...etc
Change-Id: I52da4626415798f971a28933c4bbd4d1454eefd9
| -rw-r--r-- | src/com/android/mms/data/WorkingMessage.java | 8 | ||||
| -rw-r--r-- | src/com/android/mms/ui/ComposeMessageActivity.java | 165 | ||||
| -rw-r--r-- | src/com/android/mms/ui/RecipientsEditor.java | 26 |
3 files changed, 44 insertions, 155 deletions
diff --git a/src/com/android/mms/data/WorkingMessage.java b/src/com/android/mms/data/WorkingMessage.java index 9dbeb7c3..40332652 100644 --- a/src/com/android/mms/data/WorkingMessage.java +++ b/src/com/android/mms/data/WorkingMessage.java @@ -1894,6 +1894,14 @@ public class WorkingMessage { }, "WorkingMessage.asyncDelete").start(); } + public void asyncDeleteDraftMessage(Conversation conv) { + if (mHasSmsDraft) { + asyncDeleteDraftSmsMessage(conv); + } else { + asyncDeleteDraftMmsMessage(conv); + } + } + public void asyncDeleteDraftSmsMessage(Conversation conv) { mHasSmsDraft = false; diff --git a/src/com/android/mms/ui/ComposeMessageActivity.java b/src/com/android/mms/ui/ComposeMessageActivity.java index 45d55823..e43780fd 100644 --- a/src/com/android/mms/ui/ComposeMessageActivity.java +++ b/src/com/android/mms/ui/ComposeMessageActivity.java @@ -169,7 +169,6 @@ import com.android.mms.ui.MessageUtils.ResizeImageResultCallback; import com.android.mms.ui.RecipientsEditor.RecipientContextMenuInfo; import com.android.mms.ui.zoom.ZoomGestureOverlayView; import com.android.mms.ui.zoom.ZoomGestureOverlayView.IZoomListener; -import com.android.mms.ui.zoom.ZoomMessageListItem; import com.android.mms.util.DraftCache; import com.android.mms.util.IntentUtils; import com.android.mms.util.PhoneNumberFormatter; @@ -211,12 +210,11 @@ public class ComposeMessageActivity extends Activity public static final int REQUEST_CODE_CREATE_SLIDESHOW = 106; public static final int REQUEST_CODE_ECM_EXIT_DIALOG = 107; public static final int REQUEST_CODE_ADD_CONTACT = 108; - public static final int REQUEST_CODE_PICK = 109; + public static final int REQUEST_CODE_ADD_RECIPIENTS = 109; public static final int REQUEST_CODE_ATTACH_ADD_CONTACT_INFO = 110; public static final int REQUEST_CODE_ATTACH_ADD_CONTACT_VCARD = 111; public static final int REQUEST_CODE_ATTACH_REPLACE_CONTACT_INFO = 112; - public static final int REQUEST_CODE_ADD_RECIPIENTS = 113; - public static final int REQUEST_CODE_ADD_CALENDAR_EVENTS = 114; + public static final int REQUEST_CODE_ADD_CALENDAR_EVENTS = 113; private static final String TAG = LogTag.TAG; @@ -503,8 +501,6 @@ public class ComposeMessageActivity extends Activity private AddNumbersTask mAddNumbersTask; - boolean isNotProcessingNumbers = true; - @SuppressWarnings("unused") public static void log(String logMsg) { Thread current = Thread.currentThread(); @@ -1081,29 +1077,27 @@ public class ComposeMessageActivity extends Activity return; } - if (isNotProcessingNumbers) { - mWorkingMessage.setWorkingRecipients(mRecipientsEditor.getNumbers()); - mWorkingMessage.setHasEmail(mRecipientsEditor.containsEmail(), true); - - checkForTooManyRecipients(); - // If pick recipients from Contacts, - // then only update title once when process finished - if (mIsProcessPickedRecipients) { - return; - } + mWorkingMessage.setWorkingRecipients(mRecipientsEditor.getNumbers()); + mWorkingMessage.setHasEmail(mRecipientsEditor.containsEmail(), true); - if (mRecipientsPickList != null) { - // Update UI with mRecipientsPickList, which is picked from - // People. - updateTitle(mRecipientsPickList); - mRecipientsPickList = null; - } else { - updateTitleForRecipientsChange(s); - } + checkForTooManyRecipients(); + // If pick recipients from Contacts, + // then only update title once when process finished + if (mIsProcessPickedRecipients) { + return; + } - // If we have gone to zero recipients, disable send button. - updateSendButtonState(); + if (mRecipientsPickList != null) { + // Update UI with mRecipientsPickList, which is picked from + // People. + updateTitle(mRecipientsPickList); + mRecipientsPickList = null; + } else { + updateTitleForRecipientsChange(s); } + + // If we have gone to zero recipients, disable send button. + updateSendButtonState(); } }; @@ -2509,7 +2503,8 @@ public class ComposeMessageActivity extends Activity mIsPickingContact = false; addRecipientsListeners(); - if (isRecipientsEditorVisible()) { + if (isRecipientsEditorVisible() && (mAddNumbersTask == null || + mAddNumbersTask.getStatus() == AsyncTask.Status.FINISHED)) { mRecipientsEditor.addTextChangedListener(mRecipientsWatcher); } @@ -3526,10 +3521,6 @@ public class ComposeMessageActivity extends Activity mWorkingMessage.removeFakeMmsForDraft(); } - if (requestCode == REQUEST_CODE_PICK) { - mWorkingMessage.asyncDeleteDraftSmsMessage(mConversation); - } - if (requestCode == REQUEST_CODE_ADD_CONTACT) { // The user might have added a new contact. When we tell contacts to add a contact // and tap "Done", we're not returned to Messaging. If we back out to return to @@ -3637,12 +3628,6 @@ public class ComposeMessageActivity extends Activity } break; - case REQUEST_CODE_PICK: - if (data != null) { - processPickResult(data); - } - break; - case REQUEST_CODE_ATTACH_REPLACE_CONTACT_INFO: // Caused by user choose to replace the attachment, so we need remove // the attachment and then add the contact info to text. @@ -3669,6 +3654,7 @@ public class ComposeMessageActivity extends Activity break; case REQUEST_CODE_ADD_RECIPIENTS: + mWorkingMessage.asyncDeleteDraftMessage(mConversation); mAddNumbersTask = new AddNumbersTask(); mAddNumbersTask.execute( data.getStringArrayListExtra(SelectRecipientsList.EXTRA_RECIPIENTS)); @@ -3725,7 +3711,7 @@ public class ComposeMessageActivity extends Activity mPD.setMessage(getString(R.string.adding_selected_recipients_dialog_text)); mPD.setCancelable(false); mPD.show(); - isNotProcessingNumbers = false; + mRecipientsEditor.removeTextChangedListener(mRecipientsWatcher); } @Override @@ -3747,44 +3733,9 @@ public class ComposeMessageActivity extends Activity if (mPD != null && mPD.isShowing()) { mPD.dismiss(); } - isNotProcessingNumbers = true; - } - } - - private void processPickResult(final Intent data) { - // The EXTRA_PHONE_URIS stores the phone's urls that were selected by user in the - // multiple phone picker. - Bundle bundle = data.getExtras().getBundle("result"); - final Set<String> keySet = bundle.keySet(); - final int recipientCount = (keySet != null) ? keySet.size() : 0; - - // If total recipients count > recipientLimit, - // then forbid add reipients to RecipientsEditor - final int recipientLimit = MmsConfig.getRecipientLimit(); - int totalRecipientsCount = mExistsRecipientsCount + recipientCount; - if (recipientLimit != Integer.MAX_VALUE && totalRecipientsCount > recipientLimit) { - new AlertDialog.Builder(this) - .setMessage(getString(R.string.too_many_recipients, totalRecipientsCount, - recipientLimit)) - .setPositiveButton(android.R.string.ok, new OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - // if already exists some recipients, - // then new pick recipients with exists recipients count - // can't more than recipient limit count. - int newPickRecipientsCount = recipientLimit - mExistsRecipientsCount; - if (newPickRecipientsCount <= 0) { - return; - } - processAddRecipients(keySet, newPickRecipientsCount); - } - }) - .setNegativeButton(android.R.string.cancel, null) - .create().show(); - return; + mRecipientsEditor.addTextChangedListener(mRecipientsWatcher); + mRecipientsWatcher.afterTextChanged(mRecipientsEditor.getText()); } - - processAddRecipients(keySet, recipientCount); } private Uri[] buildUris(final Set<String> keySet, final int newPickRecipientsCount) { @@ -3801,70 +3752,6 @@ public class ComposeMessageActivity extends Activity return newUris; } - private void processAddRecipients(final Set<String> keySet, final int newPickRecipientsCount) { - // if process pick result that is pick recipients from Contacts - mIsProcessPickedRecipients = true; - final Handler handler = new Handler(); - final ProgressDialog progressDialog = new ProgressDialog(this); - progressDialog.setTitle(getText(R.string.pick_too_many_recipients)); - progressDialog.setMessage(getText(R.string.adding_recipients)); - progressDialog.setIndeterminate(true); - progressDialog.setCancelable(false); - - final Runnable showProgress = new Runnable() { - @Override - public void run() { - progressDialog.show(); - } - }; - // Only show the progress dialog if we can not finish off parsing the return data in 1s, - // otherwise the dialog could flicker. - handler.postDelayed(showProgress, 1000); - - new Thread(new Runnable() { - @Override - public void run() { - final ContactList list; - try { - list = ContactList.blockingGetByUris(buildUris(keySet, newPickRecipientsCount)); - } finally { - handler.removeCallbacks(showProgress); - } - if (mRecipientsEditor != null) { - ContactList exsitList = mRecipientsEditor.constructContactsFromInput(true); - // Remove the repeat recipients. - if (exsitList.equals(list)) { - exsitList.clear(); - list.addAll(0, exsitList); - } else { - list.removeAll(exsitList); - list.addAll(0, exsitList); - } - } - // TODO: there is already code to update the contact header - // widget and recipients - // editor if the contacts change. we can re-use that code. - final Runnable populateWorker = new Runnable() { - @Override - public void run() { - mRecipientsEditor.populate(list); - // Set value for mRecipientsPickList and - // mRecipientsWatcher will update the UI. - mRecipientsPickList = list; - updateTitle(list); - // if process finished, then dismiss the progress dialog - progressDialog.dismiss(); - - // if populate finished, then recipients pick process - // end - mIsProcessPickedRecipients = false; - } - }; - handler.post(populateWorker); - } - }, "ComoseMessageActivity.processPickResult").start(); - } - private final ResizeImageResultCallback mResizeImageCallback = new ResizeImageResultCallback() { // TODO: make this produce a Uri, that's what we want anyway @Override diff --git a/src/com/android/mms/ui/RecipientsEditor.java b/src/com/android/mms/ui/RecipientsEditor.java index 862d5a15..b519ab59 100644 --- a/src/com/android/mms/ui/RecipientsEditor.java +++ b/src/com/android/mms/ui/RecipientsEditor.java @@ -326,7 +326,7 @@ public class RecipientsEditor extends RecipientEditTextView { return s; } - public void populate(ContactList list) { + public void populate(final ContactList list) { // Very tricky bug. In the recipient editor, we always leave a trailing // comma to make it easy for users to add additional recipients. When a // user types (or chooses from the dropdown) a new contact Mms has never @@ -360,27 +360,21 @@ public class RecipientsEditor extends RecipientEditTextView { public void run() { // Clear the recipient when add contact again setText(""); - } - }); - for (Contact c : list) { - // Calling setText to set the recipients won't create chips, - // but calling append() will. + for (Contact c : list) { + // Calling setText to set the recipients won't create chips, + // but calling append() will. - // Need to judge whether contactToToken(c) return valid data,if it is not, - // do not append it so that the comma can not be displayed. - final CharSequence charSequence = contactToToken(c); + // Need to judge whether contactToToken(c) return valid data,if it is not, + // do not append it so that the comma can not be displayed. + final CharSequence charSequence = contactToToken(c); - if (charSequence != null && charSequence.length() > 0) { - post(new Runnable() { - @Override - public void run() { + if (charSequence != null && charSequence.length() > 0) { append(charSequence + ", "); } - }); - + } } - } + }); } } |
