Search in sources :

Example 1 with ContactList

use of com.android.mms.data.ContactList in project android-aosp-mms by slvn.

the class ComposeMessageActivity method launchMultiplePhonePicker.

private void launchMultiplePhonePicker() {
    Intent intent = new Intent(Intents.ACTION_GET_MULTIPLE_PHONES);
    intent.addCategory("android.intent.category.DEFAULT");
    intent.setType(Phone.CONTENT_TYPE);
    // We have to wait for the constructing complete.
    ContactList contacts = mRecipientsEditor.constructContactsFromInput(true);
    int urisCount = 0;
    Uri[] uris = new Uri[contacts.size()];
    urisCount = 0;
    for (Contact contact : contacts) {
        if (Contact.CONTACT_METHOD_TYPE_PHONE == contact.getContactMethodType()) {
            uris[urisCount++] = contact.getPhoneUri();
        }
    }
    if (urisCount > 0) {
        intent.putExtra(Intents.EXTRA_PHONE_URIS, uris);
    }
    startActivityForResult(intent, REQUEST_CODE_PICK);
}
Also used : Intent(android.content.Intent) ContactList(com.android.mms.data.ContactList) Uri(android.net.Uri) Contact(com.android.mms.data.Contact) QuickContact(android.provider.ContactsContract.QuickContact)

Example 2 with ContactList

use of com.android.mms.data.ContactList in project android-aosp-mms by slvn.

the class ComposeMessageActivity method confirmSendMessageIfNeeded.

private void confirmSendMessageIfNeeded() {
    if (!isRecipientsEditorVisible()) {
        sendMessage(true);
        return;
    }
    boolean isMms = mWorkingMessage.requiresMms();
    if (mRecipientsEditor.hasInvalidRecipient(isMms)) {
        if (mRecipientsEditor.hasValidRecipient(isMms)) {
            String title = getResourcesString(R.string.has_invalid_recipient, mRecipientsEditor.formatInvalidNumbers(isMms));
            new AlertDialog.Builder(this).setTitle(title).setMessage(R.string.invalid_recipient_message).setPositiveButton(R.string.try_to_send, new SendIgnoreInvalidRecipientListener()).setNegativeButton(R.string.no, new CancelSendingListener()).show();
        } else {
            new AlertDialog.Builder(this).setTitle(R.string.cannot_send_message).setMessage(R.string.cannot_send_message_reason).setPositiveButton(R.string.yes, new CancelSendingListener()).show();
        }
    } else {
        // The recipients editor is still open. Make sure we use what's showing there
        // as the destination.
        ContactList contacts = mRecipientsEditor.constructContactsFromInput(false);
        mDebugRecipients = contacts.serialize();
        sendMessage(true);
    }
}
Also used : AlertDialog(android.app.AlertDialog) SpannableString(android.text.SpannableString) ContactList(com.android.mms.data.ContactList)

Example 3 with ContactList

use of com.android.mms.data.ContactList in project android-aosp-mms by slvn.

the class ConversationListItem method bind.

public final void bind(Context context, final Conversation conversation) {
    // if (DEBUG) Log.v(TAG, "bind()");
    mConversation = conversation;
    updateBackground();
    LayoutParams attachmentLayout = (LayoutParams) mAttachmentView.getLayoutParams();
    boolean hasError = conversation.hasError();
    // As far as I know, there's no way to specify that relationship in xml.
    if (hasError) {
        attachmentLayout.addRule(RelativeLayout.LEFT_OF, R.id.error);
    } else {
        attachmentLayout.addRule(RelativeLayout.LEFT_OF, R.id.date);
    }
    boolean hasAttachment = conversation.hasAttachment();
    mAttachmentView.setVisibility(hasAttachment ? VISIBLE : GONE);
    // Date
    mDateView.setText(MessageUtils.formatTimeStampString(context, conversation.getDate()));
    // From.
    mFromView.setText(formatMessage());
    // Register for updates in changes of any of the contacts in this conversation.
    ContactList contacts = conversation.getRecipients();
    if (Log.isLoggable(LogTag.CONTACT, Log.DEBUG)) {
        Log.v(TAG, "bind: contacts.addListeners " + this);
    }
    Contact.addListener(this);
    // Subject
    mSubjectView.setText(conversation.getSnippet());
    LayoutParams subjectLayout = (LayoutParams) mSubjectView.getLayoutParams();
    // We have to make the subject left of whatever optional items are shown on the right.
    subjectLayout.addRule(RelativeLayout.LEFT_OF, hasAttachment ? R.id.attachment : (hasError ? R.id.error : R.id.date));
    // Transmission error indicator.
    mErrorIndicator.setVisibility(hasError ? VISIBLE : GONE);
    updateAvatarView();
}
Also used : ContactList(com.android.mms.data.ContactList)

Example 4 with ContactList

use of com.android.mms.data.ContactList in project android-aosp-mms by slvn.

the class RecipientsEditor method constructContactsFromInput.

public ContactList constructContactsFromInput(boolean blocking) {
    List<String> numbers = mTokenizer.getNumbers();
    ContactList list = new ContactList();
    for (String number : numbers) {
        Contact contact = Contact.get(number, blocking);
        contact.setNumber(number);
        list.add(contact);
    }
    return list;
}
Also used : SpannableString(android.text.SpannableString) ContactList(com.android.mms.data.ContactList) Contact(com.android.mms.data.Contact)

Example 5 with ContactList

use of com.android.mms.data.ContactList in project android-aosp-mms by slvn.

the class ComposeMessageActivityTests method testCreateManyThreads.

// Here's how to execute just this one test:
// runtest -m testCreateManyThreads mms -c com.android.mms.ui.ComposeMessageActivityTests
// This test intentionally uses the UI functions to create the threads rather than adding
// the threads directly to the mms provider's threads table.
@LargeTest
public void testCreateManyThreads() {
    for (int i = 0; i < 10; i++) {
        String phoneNum = String.format("424-123-%04d", i);
        ContactList contactList = ContactList.getByNumbers(phoneNum, false, false);
        Conversation conv = Conversation.get(mActivity, contactList, false);
        WorkingMessage workingMsg = WorkingMessage.loadDraft(mActivity, conv, null);
        workingMsg.setConversation(conv);
        workingMsg.setText("This is test #" + i + " thread id: " + conv.getThreadId());
        // Log.i(TAG, "[testCreateManyThreads] workingMsg: ");
        // workingMsg.dump();
        workingMsg.saveDraft(false);
    }
}
Also used : WorkingMessage(com.android.mms.data.WorkingMessage) Conversation(com.android.mms.data.Conversation) ContactList(com.android.mms.data.ContactList) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Aggregations

ContactList (com.android.mms.data.ContactList)10 Intent (android.content.Intent)3 Contact (com.android.mms.data.Contact)3 Uri (android.net.Uri)2 QuickContact (android.provider.ContactsContract.QuickContact)2 SpannableString (android.text.SpannableString)2 Conversation (com.android.mms.data.Conversation)2 ActionBar (android.app.ActionBar)1 AlertDialog (android.app.AlertDialog)1 ProgressDialog (android.app.ProgressDialog)1 Handler (android.os.Handler)1 Parcelable (android.os.Parcelable)1 LargeTest (android.test.suitebuilder.annotation.LargeTest)1 View (android.view.View)1 ViewStub (android.view.ViewStub)1 InputMethodManager (android.view.inputmethod.InputMethodManager)1 AdapterView (android.widget.AdapterView)1 ImageView (android.widget.ImageView)1 ListView (android.widget.ListView)1 TextView (android.widget.TextView)1