List of usage examples for android.text.util Linkify WEB_URLS
int WEB_URLS
To view the source code for android.text.util Linkify WEB_URLS.
Click Source Link
From source file:com.github.wakhub.monodict.activity.bean.ActivityHelper.java
public AlertDialog.Builder buildNoticeDialog(CharSequence text) { TextView textView = new TextView(activity); textView.setAutoLinkMask(Linkify.WEB_URLS | Linkify.EMAIL_ADDRESSES); textView.setPadding((int) spaceSuperRelax, (int) spaceSuperRelax, (int) spaceSuperRelax, (int) spaceSuperRelax); textView.setText(text);//from www . ja v a 2s . c om ScrollView scrollView = new ScrollView(activity); scrollView.addView(textView); return new AlertDialog.Builder(activity).setView(scrollView).setPositiveButton(android.R.string.ok, null); }
From source file:com.github.wakhub.monodict.activity.settings.DownloadsActivity.java
@ItemClick(android.R.id.list) void onClickListItem(int position) { final DownloadsItem item = listAdapter.getItem(position); TextView textView = new TextView(this); textView.setAutoLinkMask(Linkify.WEB_URLS | Linkify.EMAIL_ADDRESSES); textView.setPadding((int) spaceRelax, (int) spaceRelax, (int) spaceRelax, (int) spaceRelax); textView.setText(String.format("%s\nsize: %s", item.getDescription(), item.getSize())); ScrollView scrollView = new ScrollView(this); scrollView.addView(textView);// w w w . j a va 2s. c o m new AlertDialog.Builder(this) .setPositiveButton(R.string.action_download, new AlertDialog.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { resultIntent.putExtra(RESULT_INTENT_ENGLISH, item.isEnglish()); resultIntent.putExtra(RESULT_INTENT_FILENAME, item.getName()); startDownload(item); } }).setNegativeButton(android.R.string.cancel, null).setIcon(R.drawable.ic_action_download) .setTitle(item.getName()).setView(scrollView).show(); }
From source file:com.ugedal.weeklyschedule.MainActivity.java
@SuppressWarnings("StatementWithEmptyBody") @Override//from w w w. ja va2s. c om public boolean onNavigationItemSelected(MenuItem item) { // Handle navigation view item clicks here. int id = item.getItemId(); int group_id = item.getGroupId(); if (group_id == R.id.trinn_chooser) { // Save new state, and update the fragment SharedPreferences sharedPref = getPreferences(Context.MODE_PRIVATE); SharedPreferences.Editor editor = sharedPref.edit(); editor.putInt(getString(R.string.current_grade_key), id); editor.apply(); TextView text = (TextView) findViewById(R.id.textView); text.setText(item.getTitle()); getSupportActionBar().setTitle(item.getTitle()); mListFragment.myList.clear(); mListFragment.adapter.notifyDataSetChanged(); swipeContainer.setRefreshing(true); mListFragment.refreshContent(); } if (id == R.id.nav_about) { AlertDialog alertDialog = new AlertDialog.Builder(MainActivity.this).create(); alertDialog.setTitle(getString(R.string.about)); final SpannableString s = new SpannableString(getText(R.string.about_message)); Linkify.addLinks(s, Linkify.WEB_URLS); alertDialog.setMessage(s); alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, getString(android.R.string.cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); alertDialog.show(); } DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); drawer.closeDrawer(GravityCompat.START); return true; }
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);// ww w . j av a 2 s .com 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.androzic.About.java
private void updateAboutInfo(final View view) { // version//w w w .j a v a 2s. c o m String versionName = null; int versionBuild = 0; try { versionName = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0).versionName; versionBuild = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0).versionCode; } catch (NameNotFoundException ex) { versionName = "unable to retreive version"; } final TextView version = (TextView) view.findViewById(R.id.version); version.setText(getString(R.string.version, versionName, versionBuild)); // home links StringBuilder links = new StringBuilder(); links.append("<a href=\""); links.append(": http://androzic.com"); links.append("\">"); links.append(getString(R.string.homepage)); links.append("</a><br /><a href=\""); links.append(getString(R.string.faquri)); links.append("\">"); links.append(getString(R.string.faq)); links.append("</a><br /><a href=\""); links.append(getString(R.string.featureuri)); links.append("\">"); links.append(getString(R.string.feedback)); links.append("</a>"); final TextView homelinks = (TextView) view.findViewById(R.id.homelinks); homelinks.setText(Html.fromHtml(links.toString())); homelinks.setMovementMethod(LinkMovementMethod.getInstance()); // community links StringBuilder communities = new StringBuilder(); communities.append("<a href=\""); communities.append(getString(R.string.googleplusuri)); communities.append("\">"); communities.append(getString(R.string.googleplus)); communities.append("</a><br /><a href=\""); communities.append(getString(R.string.facebookuri)); communities.append("\">"); communities.append(getString(R.string.facebook)); communities.append("</a><br /><a href=\""); communities.append(getString(R.string.twitteruri)); communities.append("\">"); communities.append(getString(R.string.twitter)); communities.append("</a>"); final TextView communitylinks = (TextView) view.findViewById(R.id.communitylinks); communitylinks.setText(Html.fromHtml(communities.toString())); communitylinks.setMovementMethod(LinkMovementMethod.getInstance()); // donations StringBuilder donations = new StringBuilder(); donations.append("<a href=\""); donations.append(getString(R.string.playuri)); donations.append("\">"); donations.append(getString(R.string.donate_google)); donations.append("</a><br /><a href=\""); donations.append(getString(R.string.paypaluri)); donations.append("\">"); donations.append(getString(R.string.donate_paypal)); donations.append("</a>"); final TextView donationlinks = (TextView) view.findViewById(R.id.donationlinks); donationlinks.setText(Html.fromHtml(donations.toString())); donationlinks.setMovementMethod(LinkMovementMethod.getInstance()); Androzic application = Androzic.getApplication(); if (application.isPaid) { view.findViewById(R.id.donations).setVisibility(View.GONE); view.findViewById(R.id.donationtext).setVisibility(View.GONE); donationlinks.setVisibility(View.GONE); } // license final SpannableString message = new SpannableString( Html.fromHtml(getString(R.string.app_eula).replace("/n", "<br/>"))); Linkify.addLinks(message, Linkify.WEB_URLS); final TextView license = (TextView) view.findViewById(R.id.license); license.setText(message); license.setMovementMethod(LinkMovementMethod.getInstance()); // credits String[] names = getResources().getStringArray(R.array.credit_names); String[] merits = getResources().getStringArray(R.array.credit_merits); StringBuilder credits = new StringBuilder(); for (int i = 0; i < names.length; i++) { credits.append("<b>"); credits.append(merits[i]); credits.append("</b> — "); credits.append(names[i]); credits.append("<br />"); } final TextView creditlist = (TextView) view.findViewById(R.id.credits); creditlist.setText(Html.fromHtml(credits.toString())); // dedication final TextView dedicated = (TextView) view.findViewById(R.id.dedicated); dedicated.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { clicks = 1; dedicated.setVisibility(View.GONE); View photo = view.findViewById(R.id.photo); photo.setVisibility(View.VISIBLE); photo.setOnClickListener(redirect); } }); }
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 w ww.j a va2 s .c om 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); }
From source file:org.eyeseetea.malariacare.LoginActivity.java
/** * Shows an alert dialog asking for acceptance of the EULA terms. If ok calls login function, * do// w w w.j a v a2 s . c o m * nothing otherwise */ public void askEula(int titleId, int rawId, final Context context) { InputStream message = context.getResources().openRawResource(rawId); String stringMessage = Utils.convertFromInputStreamToString(message).toString(); final SpannableString linkedMessage = new SpannableString(Html.fromHtml(stringMessage)); Linkify.addLinks(linkedMessage, Linkify.EMAIL_ADDRESSES | Linkify.WEB_URLS); AlertDialog dialog = new AlertDialog.Builder(context).setTitle(context.getString(titleId)) .setMessage(linkedMessage) .setNeutralButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { rememberEulaAccepted(context); login(serverText.getText().toString(), usernameEditText.getText().toString(), passwordEditText.getText().toString()); } }).setNegativeButton(android.R.string.no, null).create(); dialog.show(); ((TextView) dialog.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance()); }
From source file:com.slx.funstream.adapters.ChatAdapter.java
private void addLinks(Spannable spannable) { Linkify.addLinks(spannable, Linkify.WEB_URLS); }
From source file:org.navitproject.navit.Navit.java
private void showInfos() { SharedPreferences settings = getSharedPreferences(NAVIT_PREFS, MODE_PRIVATE); boolean firstStart = settings.getBoolean("firstStart", true); if (firstStart) { AlertDialog.Builder infobox = new AlertDialog.Builder(this); infobox.setTitle(getString(R.string.initial_info_box_title)); // TRANS infobox.setCancelable(false);/*from ww w.j a v a2 s .com*/ final TextView message = new TextView(this); message.setFadingEdgeLength(20); message.setVerticalFadingEdgeEnabled(true); // message.setVerticalScrollBarEnabled(true); RelativeLayout.LayoutParams rlp = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT); message.setLayoutParams(rlp); final SpannableString s = new SpannableString(getString(R.string.initial_info_box_message)); // TRANS Linkify.addLinks(s, Linkify.WEB_URLS); message.setText(s); message.setMovementMethod(LinkMovementMethod.getInstance()); infobox.setView(message); // TRANS infobox.setPositiveButton(getString(R.string.initial_info_box_OK), new DialogInterface.OnClickListener() { public void onClick(DialogInterface arg0, int arg1) { Log.e("Navit", "Ok, user saw the infobox"); } }); // TRANS infobox.setNeutralButton(getString(R.string.initial_info_box_more_info), new DialogInterface.OnClickListener() { public void onClick(DialogInterface arg0, int arg1) { Log.e("Navit", "user wants more info, show the website"); String url = "http://wiki.navit-project.org/index.php/Navit_on_Android"; Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(url)); startActivity(i); } }); infobox.show(); SharedPreferences.Editor edit_settings = settings.edit(); edit_settings.putBoolean("firstStart", false); edit_settings.commit(); } }
From source file:io.github.protino.codewatch.ui.ProfileActivity.java
private void bindViews() { Glide.with(this).load(profileItem.getPhotoUrl()).asBitmap() .placeholder(R.drawable.ic_account_circle_white_24dp).into(new BitmapImageViewTarget(avatar) { @Override//from ww w . ja va 2s .c o m protected void setResource(Bitmap resource) { RoundedBitmapDrawable drawable = RoundedBitmapDrawableFactory.create(getResources(), resource); drawable.setCircular(true); avatar.setImageDrawable(drawable); } }); userName.setText(profileItem.getName()); collapsingToolbarLayout.setTitle(profileItem.getName()); rank.setText(String.valueOf(profileItem.getRank())); website.setText(profileItem.getWebsite()); Linkify.addLinks(website, Linkify.WEB_URLS); removeViewIfNoData(website); email.setText(profileItem.getEmail()); Linkify.addLinks(email, Linkify.EMAIL_ADDRESSES); removeViewIfNoData(email); location.setText(profileItem.getLocation()); removeViewIfNoData(location); dailyAverage.setText(getString(R.string.daily_average_format, FormatUtils.getFormattedTime(this, profileItem.getDailyAverage()))); JSONObject languageMap; try { languageMap = new JSONObject(profileItem.getLanguageStats()); Iterator<?> keys = languageMap.keys(); while (keys.hasNext()) { String key = (String) keys.next(); languageList.add(new Pair<>(key, languageMap.getInt(key))); } } catch (JSONException e) { Timber.e(e); } languageAdapter.swapData(languageList); }