Search in sources :

Example 1 with Rfc822Token

use of android.text.util.Rfc822Token in project Etar-Calendar by Etar-Group.

the class AttendeesView method addAttendees.

public void addAttendees(String attendees) {
    final LinkedHashSet<Rfc822Token> addresses = EditEventHelper.getAddressesFromList(attendees, mValidator);
    synchronized (this) {
        for (final Rfc822Token address : addresses) {
            final Attendee attendee = new Attendee(address.getName(), address.getAddress());
            if (TextUtils.isEmpty(attendee.mName)) {
                attendee.mName = attendee.mEmail;
            }
            addOneAttendee(attendee);
        }
    }
}
Also used : Rfc822Token(android.text.util.Rfc822Token) Attendee(com.android.calendar.CalendarEventModel.Attendee)

Example 2 with Rfc822Token

use of android.text.util.Rfc822Token in project Etar-Calendar by Etar-Group.

the class EditEventHelper method getAddressesFromList.

public static LinkedHashSet<Rfc822Token> getAddressesFromList(String list, Rfc822Validator validator) {
    LinkedHashSet<Rfc822Token> addresses = new LinkedHashSet<Rfc822Token>();
    Rfc822Tokenizer.tokenize(list, addresses);
    if (validator == null) {
        return addresses;
    }
    // validate the emails, out of paranoia. they should already be
    // validated on input, but drop any invalid emails just to be safe.
    Iterator<Rfc822Token> addressIterator = addresses.iterator();
    while (addressIterator.hasNext()) {
        Rfc822Token address = addressIterator.next();
        if (!validator.isValid(address.getAddress())) {
            Log.v(TAG, "Dropping invalid attendee email address: " + address.getAddress());
            addressIterator.remove();
        }
    }
    return addresses;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Rfc822Token(android.text.util.Rfc822Token)

Example 3 with Rfc822Token

use of android.text.util.Rfc822Token in project Etar-Calendar by Etar-Group.

the class EventInfoFragment method showContactInfo.

/**
     * Taken from com.google.android.gm.HtmlConversationActivity
     *
     * Send the intent that shows the Contact info corresponding to the email address.
     */
public void showContactInfo(Attendee attendee, Rect rect) {
    // First perform lookup query to find existing contact
    final ContentResolver resolver = getActivity().getContentResolver();
    final String address = attendee.mEmail;
    final Uri dataUri = Uri.withAppendedPath(CommonDataKinds.Email.CONTENT_FILTER_URI, Uri.encode(address));
    final Uri lookupUri = ContactsContract.Data.getContactLookupUri(resolver, dataUri);
    if (lookupUri != null) {
        // Found matching contact, trigger QuickContact
        QuickContact.showQuickContact(getActivity(), rect, lookupUri, QuickContact.MODE_MEDIUM, null);
    } else {
        // No matching contact, ask user to create one
        final Uri mailUri = Uri.fromParts("mailto", address, null);
        final Intent intent = new Intent(Intents.SHOW_OR_CREATE_CONTACT, mailUri);
        // Pass along full E-mail string for possible create dialog
        Rfc822Token sender = new Rfc822Token(attendee.mName, attendee.mEmail, null);
        intent.putExtra(Intents.EXTRA_CREATE_DESCRIPTION, sender.toString());
        // Only provide personal name hint if we have one
        final String senderPersonal = attendee.mName;
        if (!TextUtils.isEmpty(senderPersonal)) {
            intent.putExtra(Intents.Insert.NAME, senderPersonal);
        }
        startActivity(intent);
    }
}
Also used : Intent(android.content.Intent) Rfc822Token(android.text.util.Rfc822Token) Uri(android.net.Uri) ContentResolver(android.content.ContentResolver)

Example 4 with Rfc822Token

use of android.text.util.Rfc822Token in project Etar-Calendar by Etar-Group.

the class CalendarEventModel method addAttendees.

public void addAttendees(String attendees, Rfc822Validator validator) {
    final LinkedHashSet<Rfc822Token> addresses = EditEventHelper.getAddressesFromList(attendees, validator);
    synchronized (this) {
        for (final Rfc822Token address : addresses) {
            final Attendee attendee = new Attendee(address.getName(), address.getAddress());
            if (TextUtils.isEmpty(attendee.mName)) {
                attendee.mName = attendee.mEmail;
            }
            addAttendee(attendee);
        }
    }
}
Also used : Rfc822Token(android.text.util.Rfc822Token)

Example 5 with Rfc822Token

use of android.text.util.Rfc822Token in project Etar-Calendar by Etar-Group.

the class EditEventHelperTest method testGetAddressesFromList.

@Smoke
@SmallTest
public void testGetAddressesFromList() {
    mActivity = buildTestContext();
    mHelper = new EditEventHelper(mActivity, null);
    LinkedHashSet<Rfc822Token> expected = new LinkedHashSet<Rfc822Token>();
    expected.add(new Rfc822Token(null, "ad1@email.com", ""));
    expected.add(new Rfc822Token("First Last", "first@email.com", "comment"));
    expected.add(new Rfc822Token(null, "one.two.three@email.grue", ""));
    LinkedHashSet<Rfc822Token> actual = mHelper.getAddressesFromList(TEST_ADDRESSES, new Rfc822Validator(null));
    assertEquals(expected, actual);
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Rfc822Validator(com.android.common.Rfc822Validator) Rfc822Token(android.text.util.Rfc822Token) SmallTest(android.test.suitebuilder.annotation.SmallTest) Smoke(android.test.suitebuilder.annotation.Smoke)

Aggregations

Rfc822Token (android.text.util.Rfc822Token)5 LinkedHashSet (java.util.LinkedHashSet)2 ContentResolver (android.content.ContentResolver)1 Intent (android.content.Intent)1 Uri (android.net.Uri)1 SmallTest (android.test.suitebuilder.annotation.SmallTest)1 Smoke (android.test.suitebuilder.annotation.Smoke)1 Attendee (com.android.calendar.CalendarEventModel.Attendee)1 Rfc822Validator (com.android.common.Rfc822Validator)1