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; }
private MultiAutoCompleteTextView initMultiAutoCompleteTextView(RecipientEditTextView list) { if (ChipsUtil.supportsChipsUi()) { mAddressAdapter = new RecipientAdapter(mActivity); list.setAdapter((BaseRecipientAdapter) mAddressAdapter); list.setOnFocusListShrinkRecipients(false); } else { mAddressAdapter = new EmailAddressAdapter(mActivity); list.setAdapter((EmailAddressAdapter)mAddressAdapter); } list.setTokenizer(new Rfc822Tokenizer()); list.setValidator(mEmailValidator); // NOTE: assumes no other filters are set list.setFilters(sRecipientFilters); return list; }
/** * 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; }
/** * 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 */); }
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(); }
/** * 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 void bindView(View view, Context context, RecipientEntry entry) { TextView display = (TextView) view.findViewById(android.R.id.title); ImageView imageView = (ImageView) view.findViewById(android.R.id.icon); display.setText(entry.getDisplayName()); display.setVisibility(View.VISIBLE); imageView.setVisibility(View.VISIBLE); TextView destination = (TextView) view.findViewById(android.R.id.text1); destination.setText(Rfc822Tokenizer.tokenize(entry.getDestination())[0].getAddress()); }
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; }
private static void bindView(View view,RecipientEntry entry) { TextView display=(TextView)view.findViewById(android.R.id.title); ImageView imageView=(ImageView)view.findViewById(android.R.id.icon); display.setText(entry.getDisplayName()); display.setVisibility(View.VISIBLE); imageView.setVisibility(View.VISIBLE); TextView destination=(TextView)view.findViewById(android.R.id.text1); destination.setText(Rfc822Tokenizer.tokenize(entry.getDestination())[0].getAddress()); }
/** * 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 */); }
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; }
public String extractAddressFromEmailAddress(String email) { Rfc822Token[] tokens = Rfc822Tokenizer.tokenize(email); if (tokens.length == 0) { return null; } return tokens[0].getAddress().trim(); }
public static Address[] parseUnencoded(String addressList) { List<Address> addresses = new ArrayList<Address>(); if (addressList!=null && !"".equals(addressList)) { Rfc822Token[] tokens = Rfc822Tokenizer.tokenize(addressList); for (Rfc822Token token : tokens) { String address = token.getAddress(); if (address!=null && !"".equals(address)) { addresses.add(new Address(token.getAddress(), token.getName())); } } } return addresses.toArray(new Address[0]); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mApp = (ImApp)getApplication(); mHandler = new SimpleAlertHandler(this); resolveIntent(getIntent()); setContentView(R.layout.add_contact_activity); BrandingResources brandingRes = mApp.getBrandingResource(mProviderId); setTitle(brandingRes.getString(BrandingResourceIDs.STRING_ADD_CONTACT_TITLE)); TextView label = (TextView) findViewById(R.id.input_contact_label); label.setText(brandingRes.getString(BrandingResourceIDs.STRING_LABEL_INPUT_CONTACT)); mAddressList = (MultiAutoCompleteTextView) findViewById(R.id.email); mAddressList.setAdapter(new EmailAddressAdapter(this)); mAddressList.setTokenizer(new Rfc822Tokenizer()); mAddressList.addTextChangedListener(mTextWatcher); mListSpinner = (Spinner) findViewById(R.id.choose_list); Cursor c = queryContactLists(); int initSelection = searchInitListPos(c, getIntent().getStringExtra(ImServiceConstants.EXTRA_INTENT_LIST_NAME)); SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, android.R.layout.simple_spinner_item, c, new String[] { Imps.ContactList.NAME }, new int[] { android.R.id.text1 }); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mListSpinner.setAdapter(adapter); mListSpinner.setSelection(initSelection); mInviteButton = (Button) findViewById(R.id.invite); mInviteButton.setText(brandingRes.getString(BrandingResourceIDs.STRING_BUTTON_ADD_CONTACT)); mInviteButton.setOnClickListener(mButtonHandler); mInviteButton.setEnabled(false); }
void inviteBuddies() { Rfc822Token[] recipients = Rfc822Tokenizer.tokenize(mAddressList.getText()); try { IImConnection conn = mApp.getConnection(mProviderId); IContactList list = getContactList(conn); if (list == null) { Log.e(ImApp.LOG_TAG, "<AddContactActivity> can't find given contact list:" + getSelectedListName()); finish(); } else { boolean fail = false; for (Rfc822Token recipient : recipients) { String username = recipient.getAddress(); if (mDefaultDomain != null && username.indexOf('@') == -1) { username = username + "@" + mDefaultDomain; } if (Log.isLoggable(ImApp.LOG_TAG, Log.DEBUG)) { log("addContact:" + username); } int res = list.addContact(username); if (res != ImErrorInfo.NO_ERROR) { fail = true; mHandler.showAlert(R.string.error, ErrorResUtils.getErrorRes(getResources(), res, username)); } } // close the screen if there's no error. if (!fail) { finish(); } } } catch (RemoteException ex) { Log.e(ImApp.LOG_TAG, "<AddContactActivity> inviteBuddies: caught " + ex); } }