@Override public final String convertToString(Cursor cursor) { int POST_HONEYCOMB_NAME_INDEX = cursor.getColumnIndex(HoneycombMR1Util.getDisplayName()); int POST_HONEYCOMB_EMAIL_INDEX = cursor.getColumnIndex(HoneycombMR1Util.getEmailAddress()); String name = ""; String address = ""; if (SdkLevel.getLevel() >= SdkLevel.LEVEL_HONEYCOMB_MR1) { name = cursor.getString(POST_HONEYCOMB_NAME_INDEX); address = cursor.getString(POST_HONEYCOMB_EMAIL_INDEX); } else { name = cursor.getString(PRE_HONEYCOMB_NAME_INDEX); address = cursor.getString(PRE_HONEYCOMB_DATA_INDEX); } return new Rfc822Token(name, address, null).toString(); }
String createAddressText(RecipientEntry entry) { String display = entry.getDisplayName(); String address = entry.getDestination(); if (TextUtils.isEmpty(display) || TextUtils.equals(display, address)) { display = null; } String trimmedDisplayText; if (isPhoneQuery() && isPhoneNumber(address)) { trimmedDisplayText = address.trim(); } else { if (address != null) { // Tokenize out the address in case the address already // contained the username as well. Rfc822Token[] tokenized = Rfc822Tokenizer.tokenize(address); if (tokenized != null && tokenized.length > 0) { address = tokenized[0].getAddress(); } } Rfc822Token token = new Rfc822Token(display, address, null); trimmedDisplayText = token.toString().trim(); } int index = trimmedDisplayText.indexOf(","); return mTokenizer != null && !TextUtils.isEmpty(trimmedDisplayText) && index < trimmedDisplayText.length() - 1 ? (String) mTokenizer .terminateToken(trimmedDisplayText) : trimmedDisplayText; }
private final String l() { if (TextUtils.isEmpty(this.o)) {} String str; do { Rfc822Token[] arrayOfRfc822Token; do { return null; arrayOfRfc822Token = Rfc822Tokenizer.tokenize(this.o); } while ((arrayOfRfc822Token == null) || (arrayOfRfc822Token.length <= 0)); str = arrayOfRfc822Token[0].getAddress(); } while ((TextUtils.isEmpty(str)) || (!E.matcher(str).matches())); return str; }
public final void b(String paramString) { Rfc822Token[] arrayOfRfc822Token = null; if (paramString != null) { arrayOfRfc822Token = Rfc822Tokenizer.tokenize(paramString); } if ((arrayOfRfc822Token == null) || (arrayOfRfc822Token.length == 0)) { return; } Rfc822Token localRfc822Token = arrayOfRfc822Token[0]; if ((TextUtils.isEmpty(localRfc822Token.getName())) && (!TextUtils.isEmpty(this.b.Z))) { localRfc822Token.setName(this.b.Z); } String str1 = String.valueOf(Uri.encode(localRfc822Token.toString())); if (str1.length() != 0) {} for (String str2 = "mailto:".concat(str1);; str2 = new String("mailto:")) { f(new Intent("android.intent.action.SENDTO", Uri.parse(str2))); return; } }
private static String getNumberAt(Spanned sp, int start, int end, Context context) { String number = getFieldAt("number", sp, start, end, context); number = PhoneNumberUtils.replaceUnicodeDigits(number); if (!TextUtils.isEmpty(number)) { int pos = number.indexOf('<'); if (pos >= 0 && pos < number.indexOf('>')) { // The number looks like an Rfc882 address, i.e. <fred flinstone> 891-7823 Rfc822Token[] tokens = Rfc822Tokenizer.tokenize(number); if (tokens.length == 0) { return number; } return tokens[0].getAddress(); } } return number; }
String createChipDisplayText(RecipientEntry entry) { String display = entry.getDisplayName(); String address = entry.getDestination(); if (TextUtils.isEmpty(display) || TextUtils.equals(display, address)) { display = null; } if (address != null && !(isPhoneQuery() && isPhoneNumber(address))) { // Tokenize out the address in case the address already // contained the username as well. Rfc822Token[] tokenized = Rfc822Tokenizer.tokenize(address); if (tokenized != null && tokenized.length > 0) { address = tokenized[0].getAddress(); } } if (!TextUtils.isEmpty(display)) { return display; } else if (!TextUtils.isEmpty(address)){ return address; } else { return new Rfc822Token(display, address, null).toString(); } }
String createAddressText(final RecipientEntry entry) { String display=entry.getDisplayName(); String address=entry.getDestination(); if(TextUtils.isEmpty(display)||TextUtils.equals(display,address)) display=null; String trimmedDisplayText; if(isPhoneQuery()&&isPhoneNumber(address)) trimmedDisplayText=address.trim(); else { if(address!=null) { // Tokenize out the address in case the address already // contained the username as well. final Rfc822Token[] tokenized=Rfc822Tokenizer.tokenize(address); if(tokenized!=null&&tokenized.length>0) address=tokenized[0].getAddress(); } final Rfc822Token token=new Rfc822Token(display,address,null); trimmedDisplayText=token.toString().trim(); } final int index=trimmedDisplayText.indexOf(","); return mTokenizer!=null&&!TextUtils.isEmpty(trimmedDisplayText)&&index<trimmedDisplayText.length()-1 ? (String)mTokenizer.terminateToken(trimmedDisplayText) : trimmedDisplayText; }
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; }
/** * Parse a comma separated list of email addresses in human readable format and return an * array of Address objects, RFC-822 encoded. * * @param addressList * @return An array of 0 or more Addresses. */ public static Address[] parseUnencoded(String addressList) { List<Address> addresses = new ArrayList<Address>(); if (!TextUtils.isEmpty(addressList)) { Rfc822Token[] tokens = Rfc822Tokenizer.tokenize(addressList); for (Rfc822Token token : tokens) { String address = token.getAddress(); if (!TextUtils.isEmpty(address)) { addresses.add(new Address(token.getAddress(), token.getName(), false)); } } } return addresses.toArray(EMPTY_ADDRESS_ARRAY); }
private static String tokenizeAddress(String destination) { Rfc822Token[] tokens = Rfc822Tokenizer.tokenize(destination); if (tokens != null && tokens.length > 0) { return tokens[0].getAddress(); } return destination; }
String createChipDisplayText(RecipientEntry entry) { String display = entry.getDisplayName(); String address = entry.getDestination(); if (TextUtils.isEmpty(display) || TextUtils.equals(display, address)) { display = null; } if (!TextUtils.isEmpty(display)) { return display; } else if (!TextUtils.isEmpty(address)) { return address; } else { return new Rfc822Token(display, address, null).toString(); } }
/** * Construct a RecipientEntry from just an address that has been entered. * This address has not been resolved to a contact and therefore does not * have a contact id or photo. */ public static RecipientEntry constructFakeEntry(final String address, final boolean isValid) { final Rfc822Token[] tokens = Rfc822Tokenizer.tokenize(address); final String tokenizedAddress = tokens.length > 0 ? tokens[0].getAddress() : address; return new RecipientEntry(ENTRY_TYPE_PERSON, tokenizedAddress, tokenizedAddress, INVALID_DESTINATION_TYPE, null, INVALID_CONTACT, null /* directoryId */, INVALID_CONTACT, null, true, isValid, null /* lookupKey */); }
@Override public CharSequence convertResultToString(Object resultValue) { final RecipientEntry entry = (RecipientEntry)resultValue; final String displayName = entry.getDisplayName(); final String emailAddress = entry.getDestination(); if (TextUtils.isEmpty(displayName) || TextUtils.equals(displayName, emailAddress)) { return emailAddress; } else { return new Rfc822Token(displayName, emailAddress, null).toString(); } }
private static String c(String paramString) { Rfc822Token[] arrayOfRfc822Token = Rfc822Tokenizer.tokenize(paramString); if (arrayOfRfc822Token.length == 0) {} String str; do { return null; str = arrayOfRfc822Token[0].getAddress(); } while (TextUtils.isEmpty(str)); return str.toLowerCase(); }
@Override public final String convertToString(Cursor cursor) { String name = cursor.getString(NAME_INDEX); String address = cursor.getString(DATA_INDEX); return new Rfc822Token(name, address, null).toString(); }
/** * Parse a comma separated list of email addresses in human readable format and return an * array of Address objects, RFC-822 encoded. * * @param addressList * @return An array of 0 or more Addresses. */ public static Address[] parseUnencoded(String addressList) { List<Address> addresses = new ArrayList<Address>(); if (!StringUtils.isNullOrEmpty(addressList)) { Rfc822Token[] tokens = Rfc822Tokenizer.tokenize(addressList); for (Rfc822Token token : tokens) { String address = token.getAddress(); if (!StringUtils.isNullOrEmpty(address)) { addresses.add(new Address(token.getAddress(), token.getName(), false)); } } } return addresses.toArray(EMPTY_ADDRESS_ARRAY); }
@SmallTest public void testRfc822TokenizeItemWithError() { Rfc822Token[] tokens = Rfc822Tokenizer.tokenize("\"Foo Bar\\"); assertNotNull(tokens); assertEquals(1, tokens.length); assertEquals("Foo Bar", tokens[0].getAddress()); }
void inviteBuddies() { Rfc822Token[] recipients = Rfc822Tokenizer.tokenize(mNewAddress.getText()); Pattern pattern = Pattern.compile(EMAIL_PATTERN); boolean foundOne = false; for (Rfc822Token recipient : recipients) { String address = recipient.getAddress(); if (pattern.matcher(address).matches()) { new AddContactAsyncTask(mApp.getDefaultProviderId(), mApp.getDefaultAccountId(), mApp).execute(address, null, null); foundOne = true; } } if (foundOne) { Intent intent = new Intent(); intent.putExtra(ContactsPickerActivity.EXTRA_RESULT_USERNAME, recipients[0].getAddress()); intent.putExtra(ContactsPickerActivity.EXTRA_RESULT_PROVIDER, mApp.getDefaultProviderId()); setResult(RESULT_OK, intent); finish(); } }
private String tokenizeAddress(String destination) { Rfc822Token[] tokens = Rfc822Tokenizer.tokenize(destination); if (tokens != null && tokens.length > 0) { return tokens[0].getAddress(); } return destination; }
private static String tokenizeAddress(final String destination) { final Rfc822Token[] tokens=Rfc822Tokenizer.tokenize(destination); if(tokens!=null&&tokens.length>0) return tokens[0].getAddress(); return destination; }
String createChipDisplayText(final RecipientEntry entry) { String display=entry.getDisplayName(); final String address=entry.getDestination(); if(TextUtils.isEmpty(display)||TextUtils.equals(display,address)) display=null; if(!TextUtils.isEmpty(display)) return display; else if(!TextUtils.isEmpty(address)) return address; else return new Rfc822Token(display,address,null).toString(); }
/** * Construct a RecipientEntry from just an address that has been entered. This address has not been resolved to a * contact and therefore does not have a contact id or photo. */ public static RecipientEntry constructFakeEntry(final String address,final boolean isValid) { final Rfc822Token[] tokens=Rfc822Tokenizer.tokenize(address); final String tokenizedAddress=tokens.length>0 ? tokens[0].getAddress() : address; return new RecipientEntry(ENTRY_TYPE_PERSON,tokenizedAddress,tokenizedAddress,INVALID_DESTINATION_TYPE,null,INVALID_CONTACT,INVALID_CONTACT,null,true,isValid,false /* isGalContact */); }
@Override public CharSequence convertResultToString(final Object resultValue) { final RecipientEntry entry=(RecipientEntry)resultValue; final String displayName=entry.getDisplayName(); final String emailAddress=entry.getDestination(); if(TextUtils.isEmpty(displayName)||TextUtils.equals(displayName,emailAddress)) return emailAddress; else return new Rfc822Token(displayName,emailAddress,null).toString(); }
public String extractHandleFromEmailAddress(String email) { Rfc822Token[] tokens = Rfc822Tokenizer.tokenize(email); if (tokens.length == 0) { return null; } String address = tokens[0].getAddress(); int at = address.indexOf('@'); if (at != -1) { return address.substring(0, at); } return null; }