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);
}
}
}
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;
}
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);
}
}
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);
}
}
}
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);
}
Aggregations