List of usage examples for android.text.util Linkify PHONE_NUMBERS
int PHONE_NUMBERS
To view the source code for android.text.util Linkify PHONE_NUMBERS.
Click Source Link
From source file:org.ewicom.pps.unitinfo.TabPhonesFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); phoneDataSource = new PhoneDataSource(getActivity()); phoneDataSource.open();// ww w . jav a 2s . co m LinearLayout phonesLL = (LinearLayout) getView().findViewById(R.id.ll_phones); List<Phone> phones = new ArrayList<Phone>(); phones = phoneDataSource.getPhonesByUnitId(unitID); if (phones != null && !phones.isEmpty()) { Iterator<Phone> iterator = phones.iterator(); while (iterator.hasNext()) { Phone phone = iterator.next(); LinearLayout phoneLL = (LinearLayout) getActivity().getLayoutInflater().inflate(R.layout.phone_ll, null); TextView phoneTypeTV = (TextView) phoneLL.findViewById(R.id.text_phonetype); TextView phoneTV = (TextView) phoneLL.findViewById(R.id.text_phone); phoneTypeTV.setText(phone.getType()); phoneTV.setText(phone.getPhone()); Linkify.addLinks(phoneTV, Linkify.PHONE_NUMBERS); phonesLL.addView(phoneLL); } } }
From source file:org.ewicom.pps.unitinfo.TabLeadersFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); personDataSource = new PersonDataSource(getActivity()); personDataSource.open();/*from w w w . j a v a 2s. com*/ LinearLayout leadersLL = (LinearLayout) getView().findViewById(R.id.ll_leaders); List<Person> persons = new ArrayList<Person>(); persons = personDataSource.getPersonsByUnitId(unitID); if (persons != null && !persons.isEmpty()) { Iterator<Person> iterator = persons.iterator(); while (iterator.hasNext()) { final Person person = iterator.next(); LinearLayout personLL = (LinearLayout) getActivity().getLayoutInflater().inflate(R.layout.person_ll, null); TextView positionTV = (TextView) personLL.findViewById(R.id.text_personposition); TextView nameTV = (TextView) personLL.findViewById(R.id.text_personname); TextView phoneTV = (TextView) personLL.findViewById(R.id.text_personphone); TextView emailTV = (TextView) personLL.findViewById(R.id.text_personemail); positionTV.setText(person.getPosition()); nameTV.setText(person.getPerson()); phoneTV.setText(person.getPhone()); emailTV.setText(person.getEmail()); Linkify.addLinks(phoneTV, Linkify.PHONE_NUMBERS); Linkify.addLinks(emailTV, Linkify.EMAIL_ADDRESSES); TextView saveContactLink = (TextView) getActivity().getLayoutInflater() .inflate(R.layout.textview_link_savecontact, null); LayoutParams linkParam = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); personLL.addView(saveContactLink, linkParam); saveContactLink.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent saveContactIntent = new Intent(Intents.Insert.ACTION); saveContactIntent.setType(ContactsContract.RawContacts.CONTENT_TYPE); saveContactIntent.putExtra(Intents.Insert.NAME, person.getPerson()); saveContactIntent.putExtra(Intents.Insert.JOB_TITLE, person.getPosition()); saveContactIntent.putExtra(Intents.Insert.PHONE, person.getPhone()); saveContactIntent.putExtra(Intents.Insert.EMAIL, person.getEmail()); startActivity(saveContactIntent); } }); leadersLL.addView(personLL); } } }
From source file:com.apptentive.android.sdk.module.messagecenter.view.holder.MessageComposerHolder.java
public void bindView(final MessageCenterFragment fragment, final MessageCenterRecyclerViewAdapter adapter, final Composer composer) { title.setText(composer.title);//www . ja v a2s .c o m closeButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { if (!TextUtils.isEmpty(message.getText().toString().trim()) || !images.isEmpty()) { Bundle bundle = new Bundle(); bundle.putString("message", composer.closeBody); bundle.putString("positive", composer.closeDiscard); bundle.putString("negative", composer.closeCancel); ApptentiveAlertDialog.show(fragment, bundle, Constants.REQUEST_CODE_CLOSE_COMPOSING_CONFIRMATION); } else { if (adapter.getListener() != null) { adapter.getListener().onCancelComposing(); } } } }); sendButton.setContentDescription(composer.sendButton); sendButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { if (adapter.getListener() != null) { adapter.getListener().onFinishComposing(); } } }); message.setHint(composer.messageHint); message.removeTextChangedListener(textWatcher); textWatcher = new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) { if (adapter.getListener() != null) { adapter.getListener().beforeComposingTextChanged(charSequence); } } @Override public void onTextChanged(CharSequence charSequence, int start, int before, int count) { if (adapter.getListener() != null) { adapter.getListener().onComposingTextChanged(charSequence); } } @Override public void afterTextChanged(Editable editable) { if (adapter.getListener() != null) { adapter.getListener().afterComposingTextChanged(editable.toString()); } Linkify.addLinks(editable, Linkify.WEB_URLS | Linkify.PHONE_NUMBERS | Linkify.EMAIL_ADDRESSES | Linkify.MAP_ADDRESSES); } }; message.addTextChangedListener(textWatcher); attachButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { if (adapter.getListener() != null) { adapter.getListener().onAttachImage(); } } }); attachments.setupUi(); attachments.setupLayoutListener(); attachments.setListener(new ApptentiveImageGridView.ImageItemClickedListener() { @Override public void onClick(int position, ImageItem image) { if (adapter.getListener() != null) { adapter.getListener().onClickAttachment(position, image); } } }); attachments.setAdapterIndicator(R.drawable.apptentive_ic_remove_attachment); attachments.setImageIndicatorCallback(fragment); //Initialize image attachments band with empty data clearImageAttachmentBand(); attachments.setVisibility(View.GONE); attachments.setData(new ArrayList<ImageItem>()); setAttachButtonState(); if (adapter.getListener() != null) { adapter.getListener().onComposingViewCreated(this, message, attachments); } }
From source file:com.tct.email.provider.EmailMessageCursor.java
public EmailMessageCursor(final Context c, final Cursor cursor, final String htmlColumn, final String textColumn) { super(cursor); mHtmlColumnIndex = cursor.getColumnIndex(htmlColumn); mTextColumnIndex = cursor.getColumnIndex(textColumn); final int cursorSize = cursor.getCount(); mHtmlParts = new SparseArray<String>(cursorSize); mTextParts = new SparseArray<String>(cursorSize); //TS: jian.xu 2015-11-03 EMAIL BUGFIX-845079 ADD_S mHtmlLinkifyColumnIndex = cursor.getColumnIndex(UIProvider.MessageColumns.BODY_HTML_LINKIFY); mHtmlLinkifyParts = new SparseArray<String>(cursorSize); mTextLinkifyColumnIndex = cursor.getColumnIndex(UIProvider.MessageColumns.BODY_TEXT_LINKIFY); mTextLinkifyParts = new SparseArray<String>(cursorSize); //TS: jian.xu 2015-11-03 EMAIL BUGFIX-845079 ADD_E final ContentResolver cr = c.getContentResolver(); while (cursor.moveToNext()) { final int position = cursor.getPosition(); final long messageId = cursor.getLong(cursor.getColumnIndex(BaseColumns._ID)); // TS: chao.zhang 2015-09-14 EMAIL BUGFIX-1039046 MOD_S InputStream htmlIn = null; InputStream textIn = null; try {//from ww w . j av a 2 s . c o m if (mHtmlColumnIndex != -1) { final Uri htmlUri = Body.getBodyHtmlUriForMessageWithId(messageId); //WARNING: Actually openInput will used 2 PIPE(FD) to connect,but if some exception happen during connect, //such as fileNotFoundException,maybe the connection will not be closed. just a try!!! htmlIn = cr.openInputStream(htmlUri); final String underlyingHtmlString; try { underlyingHtmlString = IOUtils.toString(htmlIn); } finally { htmlIn.close(); htmlIn = null; } //TS: zhaotianyong 2015-04-05 EMAIL BUGFIX_964325 MOD_S final String sanitizedHtml = HtmlSanitizer.sanitizeHtml(underlyingHtmlString); mHtmlParts.put(position, sanitizedHtml); //TS: zhaotianyong 2015-04-05 EMAIL BUGFIX_964325 MOD_E //TS: jian.xu 2015-11-03 EMAIL BUGFIX-845079 ADD_S //NOTE: add links for sanitized html if (!TextUtils.isEmpty(sanitizedHtml)) { final String linkifyHtml = com.tct.mail.utils.Linkify.addLinks(sanitizedHtml); mHtmlLinkifyParts.put(position, linkifyHtml); } else { mHtmlLinkifyParts.put(position, ""); } //TS: jian.xu 2015-11-03 EMAIL BUGFIX-845079 ADD_E } } catch (final IOException e) { LogUtils.v(LogUtils.TAG, e, "Did not find html body for message %d", messageId); } catch (final OutOfMemoryError oom) { LogUtils.v(LogUtils.TAG, oom, "Terrible,OOM happen durning query EmailMessageCursor in bodyHtml,current message %d", messageId); mHtmlLinkifyParts.put(position, ""); } try { if (mTextColumnIndex != -1) { final Uri textUri = Body.getBodyTextUriForMessageWithId(messageId); textIn = cr.openInputStream(textUri); final String underlyingTextString; try { underlyingTextString = IOUtils.toString(textIn); } finally { textIn.close(); textIn = null; } mTextParts.put(position, underlyingTextString); //TS: jian.xu 2015-11-03 EMAIL BUGFIX-845079 ADD_S //NOTE: add links for underlying text string if (!TextUtils.isEmpty(underlyingTextString)) { final SpannableString spannable = new SpannableString(underlyingTextString); Linkify.addLinks(spannable, Linkify.EMAIL_ADDRESSES | Linkify.WEB_URLS | Linkify.PHONE_NUMBERS); final String linkifyText = Html.toHtml(spannable); mTextLinkifyParts.put(position, linkifyText); } else { mTextLinkifyParts.put(position, ""); } //TS: jian.xu 2015-11-03 EMAIL BUGFIX-845079 ADD_E } } catch (final IOException e) { LogUtils.v(LogUtils.TAG, e, "Did not find text body for message %d", messageId); } catch (final OutOfMemoryError oom) { LogUtils.v(LogUtils.TAG, oom, "Terrible,OOM happen durning query EmailMessageCursor in bodyText,current message %d", messageId); mTextLinkifyParts.put(position, ""); } //NOTE:Remember that this just a protective code,for better release Not used Resources. if (htmlIn != null) { try { htmlIn.close(); } catch (IOException e1) { LogUtils.v(LogUtils.TAG, e1, "IOException happen while close the htmlInput connection "); } } if (textIn != null) { try { textIn.close(); } catch (IOException e2) { LogUtils.v(LogUtils.TAG, e2, "IOException happen while close the textInput connection "); } } // TS: chao.zhang 2015-09-14 EMAIL BUGFIX-1039046 MOD_E } cursor.moveToPosition(-1); }