List of usage examples for android.text.util Linkify ALL
int ALL
To view the source code for android.text.util Linkify ALL.
Click Source Link
Note:
#MAP_ADDRESSES is deprecated.From source file:com.quarterfull.newsAndroid.LoginDialogFragment.java
public static void ShowAlertDialog(String title, String text, Activity activity) { // Linkify the message final SpannableString s = new SpannableString(text); Linkify.addLinks(s, Linkify.ALL); AlertDialog aDialog = new AlertDialog.Builder(activity).setTitle(title).setMessage(s) .setPositiveButton(activity.getString(android.R.string.ok), null).create(); aDialog.show();/*w w w .j a va 2s. co m*/ // Make the textview clickable. Must be called after show() ((TextView) aDialog.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance()); }
From source file:com.musiqueplayer.playlistequalizerandroidwear.activities.MainActivity.java
private void updatePosition(final MenuItem menuItem) { runnable = null;// ww w .jav a 2 s . co m switch (menuItem.getItemId()) { case R.id.nav_library: runnable = navigateLibrary; break; case R.id.nav_playlists: runnable = navigatePlaylist; break; case R.id.nav_folders: runnable = navigateFolder; break; case R.id.nav_nowplaying: NavigationUtils.navigateToNowplaying(MainActivity.this, false); break; case R.id.nav_queue: runnable = navigateQueue; break; case R.id.nav_timer: runnable = navigateTimer; break; case R.id.nav_settings: NavigationUtils.navigateToSettings(MainActivity.this); break; case R.id.nav_about: mDrawerLayout.closeDrawers(); Handler handler = new Handler(); handler.postDelayed(new Runnable() { @Override public void run() { final String APP_PNAME = "com.musiqueplayer.playlistequalizerandroidwear"; final Context mContext = getApplicationContext(); final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder( new ContextThemeWrapper(MainActivity.this, R.style.myDialog)); final SpannableString s = new SpannableString( Html.fromHtml("Thanks for downloading Music Player.<br>" + "Thanks for being an awesome user! If you enjoy using <b>Music Player</b> app, please take a moment to rate it with <b>5 stars</b>. " + "")); Linkify.addLinks(s, Linkify.ALL); alertDialogBuilder.setTitle("About"); alertDialogBuilder.setMessage(s); alertDialogBuilder.setPositiveButton("Rate Now", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { mContext.startActivity( new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + APP_PNAME))); } }); alertDialogBuilder.setNegativeButton("Remind Later", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); SharedPreferences prefs = mContext.getSharedPreferences("apprater", 0); SharedPreferences.Editor editor = prefs.edit(); editor.putLong("launch_count", 0); editor.commit(); } }); AlertDialog alertDialog = alertDialogBuilder.create(); alertDialog.show(); } }, 350); break; } if (runnable != null) { menuItem.setChecked(true); mDrawerLayout.closeDrawers(); Handler handler = new Handler(); handler.postDelayed(new Runnable() { @Override public void run() { runnable.run(); } }, 350); } }
From source file:com.todoroo.astrid.adapter.TaskAdapter.java
private void showEditNotesDialog(final Task task) { Task t = taskDao.fetch(task.getId(), Task.NOTES); if (t == null || !t.hasNotes()) { return;// w w w. j a v a 2s.c o m } SpannableString description = new SpannableString(t.getNotes()); Linkify.addLinks(description, Linkify.ALL); AlertDialog dialog = dialogBuilder.newDialog().setMessage(description) .setPositiveButton(android.R.string.ok, null).show(); View message = dialog.findViewById(android.R.id.message); if (message != null && message instanceof TextView) { ((TextView) message).setMovementMethod(LinkMovementMethod.getInstance()); } }
From source file:org.thoughtcrime.securesms.ConversationItem.java
private SpannableString linkifyMessageBody(SpannableString messageBody, boolean shouldLinkifyAllLinks) { boolean hasLinks = Linkify.addLinks(messageBody, shouldLinkifyAllLinks ? Linkify.ALL : 0); if (hasLinks) { URLSpan[] urlSpans = messageBody.getSpans(0, messageBody.length(), URLSpan.class); for (URLSpan urlSpan : urlSpans) { int start = messageBody.getSpanStart(urlSpan); int end = messageBody.getSpanEnd(urlSpan); messageBody.setSpan(new LongClickCopySpan(urlSpan.getURL()), start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); }/*from w w w. j av a 2 s.co m*/ } return messageBody; }
From source file:com.cw.litenote.note.Note_adapter.java
private String getHtmlStringWithViewPort(int position, int viewPort) { int mStyle = Note.mStyle; System.out.println("Note_adapter / _getHtmlStringWithViewPort"); String strTitle = db_page.getNoteTitle(position, true); String strBody = db_page.getNoteBody(position, true); String linkUri = db_page.getNoteLinkUri(position, true); // replace note title //TitleBody,YouTube linkWeb linkTitlelinktitle,Gray? boolean bSetGray = false; if (Util.isEmptyString(strTitle) && Util.isEmptyString(strBody)) { if (Util.isYouTubeLink(linkUri)) { strTitle = Util.getYouTubeTitle(linkUri); bSetGray = true;// ww w .j av a2s .c o m } else if (linkUri.startsWith("http")) { strTitle = mWebTitle; bSetGray = true; } } Long createTime = db_page.getNoteCreatedTime(position, true); String head = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" + "<html><head>" + "<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\" />"; if (viewPort == VIEW_PORT_BY_NONE) { head = head + "<head>"; } else if (viewPort == VIEW_PORT_BY_DEVICE_WIDTH) { head = head + "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">" + "<head>"; } else if (viewPort == VIEW_PORT_BY_SCREEN_WIDTH) { // int screen_width = UtilImage.getScreenWidth(act); int screen_width = 640; head = head + "<meta name=\"viewport\" content=\"width=" + String.valueOf(screen_width) + ", initial-scale=1\">" + "<head>"; } String separatedLineTitle = (!Util.isEmptyString(strTitle)) ? "<hr size=2 color=blue width=99% >" : ""; String separatedLineBody = (!Util.isEmptyString(strBody)) ? "<hr size=1 color=black width=99% >" : ""; // title if (!Util.isEmptyString(strTitle)) { Spannable spanTitle = new SpannableString(strTitle); Linkify.addLinks(spanTitle, Linkify.ALL); spanTitle.setSpan(new AlignmentSpan.Standard(Alignment.ALIGN_CENTER), 0, spanTitle.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); //ref http://stackoverflow.com/questions/3282940/set-color-of-textview-span-in-android if (bSetGray) { ForegroundColorSpan foregroundSpan = new ForegroundColorSpan(Color.GRAY); spanTitle.setSpan(foregroundSpan, 0, spanTitle.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } strTitle = Html.toHtml(spanTitle); } else strTitle = ""; // body if (!Util.isEmptyString(strBody)) { Spannable spanBody = new SpannableString(strBody); Linkify.addLinks(spanBody, Linkify.ALL); strBody = Html.toHtml(spanBody); } else strBody = ""; // set web view text color String colorStr = Integer.toHexString(ColorSet.mText_ColorArray[mStyle]); colorStr = colorStr.substring(2); String bgColorStr = Integer.toHexString(ColorSet.mBG_ColorArray[mStyle]); bgColorStr = bgColorStr.substring(2); return head + "<body color=\"" + bgColorStr + "\">" + "<br>" + //Note: text mode needs this, otherwise title is overlaid "<p align=\"center\"><b>" + "<font color=\"" + colorStr + "\">" + strTitle + "</font>" + "</b></p>" + separatedLineTitle + "<p>" + "<font color=\"" + colorStr + "\">" + strBody + "</font>" + "</p>" + separatedLineBody + "<p align=\"right\">" + "<font color=\"" + colorStr + "\">" + Util.getTimeString(createTime) + "</font>" + "</p>" + "</body></html>"; }
From source file:qr.cloud.qrpedia.MessageViewerActivity.java
private void parseCodeDetailsAndUpdate(Intent launchIntent, String codeContents, boolean updateCode) { // need the format to send when composing a message try {//from w w w .ja v a2 s . co m mBarcodeFormat = BarcodeFormat.valueOf(launchIntent.getStringExtra(QRCloudUtils.DATABASE_PROP_FORMAT)); } catch (IllegalArgumentException e) { } // store the type for later analysis try { mBarcodeType = ParsedResultType.valueOf(launchIntent.getStringExtra(QRCloudUtils.DATABASE_PROP_TYPE)); } catch (IllegalArgumentException e) { } // insert/update into the codes database if (updateCode) { updateCode(mCodeHash, codeContents, mBarcodeFormat, mBarcodeType); } // show the code details in a tab int barcodeTitle = launchIntent.getIntExtra(getString(R.string.key_display_title), R.string.result_text); // note: we ignore formatted contents for URLs, as this was breaking case-sensitive links String formattedBarcodeContents = launchIntent.getStringExtra(getString(R.string.key_display_contents)); if (mBarcodeType == ParsedResultType.URI) { if (formattedBarcodeContents.matches("(?i)^http[s]?\\://[a-z\\-]+\\.qrwp\\.org.*$")) { // case-insensitive barcodeTitle = R.string.result_qrpedia; // special display for QRpedia codes } formattedBarcodeContents = codeContents; } // barcodeDetailsBundle = getBarcodeDetailsBundle(mBarcodeFormat, barcodeTitle, formattedBarcodeContents, // barcodeType); // show the code details TextView titleText = (TextView) findViewById(R.id.code_info_title); titleText.setText(getString(R.string.result_type, getString(barcodeTitle))); mCodeContents = (TextView) findViewById(R.id.code_info_contents); mCodeContents.setText(formattedBarcodeContents); // request the product details if applicable if (mBarcodeFormat == BarcodeFormat.UPC_A || mBarcodeFormat == BarcodeFormat.UPC_E || mBarcodeFormat == BarcodeFormat.UPC_EAN_EXTENSION || mBarcodeFormat == BarcodeFormat.EAN_8 || mBarcodeFormat == BarcodeFormat.EAN_13) { if (mProductDetails != null) { setCodeDetails(mProductDetails); } else { try { requestBarcodeDetails(codeContents); } catch (JSONException e) { // problem getting code details - ignore } } } else if (mBarcodeType == ParsedResultType.EMAIL_ADDRESS || mBarcodeType == ParsedResultType.URI || mBarcodeType == ParsedResultType.TEL || mBarcodeType == ParsedResultType.GEO) { // linkify where appropriate Linkify.addLinks(mCodeContents, Linkify.ALL); } // set the correct fonts titleText.setTypeface(Typefaces.get(MessageViewerActivity.this, getString(R.string.default_font_bold))); mCodeContents.setTypeface(Typefaces.get(MessageViewerActivity.this, getString(R.string.default_font))); }
From source file:com.markuspage.android.atimetracker.Tasks.java
private Dialog openAboutDialog() { String versionName = ""; try {//from w w w .j a v a 2 s .c om PackageInfo pkginfo = this.getPackageManager().getPackageInfo("com.markuspage.android.atimetracker", 0); versionName = pkginfo.versionName; } catch (NameNotFoundException nnfe) { // Denada } String formattedVersion = getString(R.string.version, versionName); LayoutInflater factory = LayoutInflater.from(this); View about = factory.inflate(R.layout.about, null); TextView version = (TextView) about.findViewById(R.id.version); version.setText(formattedVersion); TextView links = (TextView) about.findViewById(R.id.usage); Linkify.addLinks(links, Linkify.ALL); links = (TextView) about.findViewById(R.id.credits); Linkify.addLinks(links, Linkify.ALL); return new AlertDialog.Builder(Tasks.this).setView(about).setPositiveButton(android.R.string.ok, null) .create(); }
From source file:github.daneren2005.dsub.util.Util.java
private static void showDialog(Context context, int icon, String title, String message) { SpannableString ss = new SpannableString(message); Linkify.addLinks(ss, Linkify.ALL); AlertDialog dialog = new AlertDialog.Builder(context).setIcon(icon).setTitle(title).setMessage(ss) .setPositiveButton(R.string.common_ok, new DialogInterface.OnClickListener() { @Override// w w w.jav a 2 s . c o m public void onClick(DialogInterface dialog, int i) { dialog.dismiss(); } }).show(); ((TextView) dialog.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance()); }
From source file:github.daneren2005.dsub.util.Util.java
private static void showDialog(Context context, int icon, String title, String message, boolean linkify) { SpannableString ss = new SpannableString(message); if (linkify) { Linkify.addLinks(ss, Linkify.ALL); }/* w w w .j a va 2 s .co m*/ AlertDialog dialog = new AlertDialog.Builder(context).setIcon(icon).setTitle(title).setMessage(ss) .setPositiveButton(R.string.common_ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int i) { dialog.dismiss(); } }).show(); ((TextView) dialog.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance()); }
From source file:com.tsp.clipsy.audio.RingdroidEditActivity.java
private void handleFatalError(final CharSequence errorInternalName, final CharSequence errorString, final Exception exception) { Log.i("Ringdroid", "handleFatalError"); SharedPreferences prefs = getPreferences(Context.MODE_PRIVATE); int failureCount = prefs.getInt(PREF_ERROR_COUNT, 0); final SharedPreferences.Editor prefsEditor = prefs.edit(); prefsEditor.putInt(PREF_ERROR_COUNT, failureCount + 1); prefsEditor.commit();/* w w w. j ava2 s . co m*/ // Check if we already have a pref for whether or not we can // contact the server. int serverAllowed = prefs.getInt(PREF_ERR_SERVER_ALLOWED, SERVER_ALLOWED_UNKNOWN); if (serverAllowed == SERVER_ALLOWED_NO) { Log.i("Ringdroid", "ERR: SERVER_ALLOWED_NO"); // Just show a simple "write error" message showFinalAlert(exception, errorString); return; } if (serverAllowed == SERVER_ALLOWED_YES) { Log.i("Ringdroid", "SERVER_ALLOWED_YES"); new AlertDialog.Builder(RingdroidEditActivity.this).setTitle(R.string.alert_title_failure) .setMessage(errorString) .setPositiveButton(R.string.alert_ok_button, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { finish(); return; } }).setCancelable(false).show(); return; } // The number of times the user must have had a failure before // we'll ask them. Defaults to 1, and each time they click "Later" // we double and add 1. final int allowServerCheckIndex = prefs.getInt(PREF_ERR_SERVER_CHECK, 1); if (failureCount < allowServerCheckIndex) { Log.i("Ringdroid", "failureCount " + failureCount + " is less than " + allowServerCheckIndex); // Just show a simple "write error" message showFinalAlert(exception, errorString); return; } final SpannableString message = new SpannableString( errorString + ". " + getResources().getText(R.string.error_server_prompt)); Linkify.addLinks(message, Linkify.ALL); AlertDialog dialog = new AlertDialog.Builder(this).setTitle(R.string.alert_title_failure) .setMessage(message).setPositiveButton(R.string.server_yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { prefsEditor.putInt(PREF_ERR_SERVER_ALLOWED, SERVER_ALLOWED_YES); prefsEditor.commit(); finish(); return; } }).setNeutralButton(R.string.server_later, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { prefsEditor.putInt(PREF_ERR_SERVER_CHECK, 1 + allowServerCheckIndex * 2); Log.i("Ringdroid", "Won't check again until " + (1 + allowServerCheckIndex * 2) + " errors."); prefsEditor.commit(); finish(); } }).setNegativeButton(R.string.server_never, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { prefsEditor.putInt(PREF_ERR_SERVER_ALLOWED, SERVER_ALLOWED_NO); prefsEditor.commit(); finish(); } }).setCancelable(false).show(); // Make links clicky ((TextView) dialog.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance()); }