List of usage examples for android.text.util Linkify addLinks
public static final boolean addLinks(@NonNull TextView text, @LinkifyMask int mask)
From source file:com.brq.wallet.activity.modern.ModernMain.java
private void checkGapBug() { final WalletManager walletManager = _mbwManager.getWalletManager(false); final List<Integer> gaps = walletManager.getGapsBug(); if (!gaps.isEmpty()) { try {/*from ww w .j a va 2s. com*/ final List<Address> gapAddresses = walletManager.getGapAddresses(AesKeyCipher.defaultKeyCipher()); final String gapsString = Joiner.on(", ").join(gapAddresses); Log.d("Gaps", gapsString); final SpannableString s = new SpannableString( "Sorry to interrupt you... \n \nWe discovered a bug in the account logic that will make problems if you someday need to restore from your 12 word backup.\n\nFor further information see here: https://wallet.mycelium.com/info/gaps \n\nMay we try to resolve it for you? Press OK, to share one address per affected account with us."); Linkify.addLinks(s, Linkify.ALL); final AlertDialog d = new AlertDialog.Builder(this).setTitle("Account Gap").setMessage(s) .setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { createPlaceHolderAccounts(gaps); _mbwManager.reportIgnoredException( new RuntimeException("Address gaps: " + gapsString)); } }).setNegativeButton("Ignore", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }).show(); // Make the textview clickable. Must be called after show() ((TextView) d.findViewById(android.R.id.message)) .setMovementMethod(LinkMovementMethod.getInstance()); } catch (KeyCipher.InvalidKeyCipher invalidKeyCipher) { throw new RuntimeException(invalidKeyCipher); } } }
From source file:com.acrylicgoat.scrumnotes.MainActivity.java
private void getToday(String owner) { //Log.d("MainActivity", "getToday() called: " + owner); DatabaseHelper dbHelper = new DatabaseHelper(this.getApplicationContext()); SQLiteDatabase db = dbHelper.getReadableDatabase(); cursor = db.rawQuery(getTodaySQL(), null); if (cursor.getCount() > 0) { cursor.moveToNext();//from www.j a v a 2 s. c o m int notesColumn = cursor.getColumnIndex(Notes.NOTE); today.setText(cursor.getString(notesColumn)); } else { if (devs.size() > 0) { today.setText(getString(R.string.main_insert)); } else { today.setText(getString(R.string.no_devs)); } } Linkify.addLinks(today, Linkify.ALL); cursor.close(); db.close(); }
From source file:de.baumann.thema.FragmentWallpaper.java
@Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); if (id == R.id.color) { ColorPickerDialogBuilder.with(getActivity()).initialColor(0xff2196f3).setTitle(R.string.custom) .wheelType(ColorPickerView.WHEEL_TYPE.FLOWER).density(9) .setPositiveButton(R.string.yes, new ColorPickerClickListener() { @Override// w w w . j a va 2 s . c om public void onClick(DialogInterface dialog, int selectedColor, Integer[] allColors) { try { WallpaperManager wm = WallpaperManager.getInstance(getActivity()); // Create 1x1 bitmap to store the color Bitmap bmp = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888); // Make a canvas with which we can draw to the bitmap Canvas canvas = new Canvas(bmp); // Fill with color and save canvas.drawColor(selectedColor); canvas.save(); wm.setBitmap(bmp); bmp.recycle(); Snackbar.make(imgHeader, R.string.applying, Snackbar.LENGTH_LONG).show(); } catch (IOException e) { // oh lord! } } }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }).build().show(); return false; } if (id == R.id.help) { SpannableString s; if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) { s = new SpannableString( Html.fromHtml(getString(R.string.help_wallpaper), Html.FROM_HTML_MODE_LEGACY)); } else { //noinspection deprecation s = new SpannableString(Html.fromHtml(getString(R.string.help_wallpaper))); } Linkify.addLinks(s, Linkify.WEB_URLS); final AlertDialog.Builder dialog = new AlertDialog.Builder(getActivity()) .setTitle(R.string.title_wallpaper).setMessage(s) .setPositiveButton(getString(R.string.yes), null); dialog.show(); return false; } return super.onOptionsItemSelected(item); }
From source file:org.thoughtcrime.securesms.logsubmit.SubmitLogFragment.java
private TextView handleBuildSuccessTextView(final String logUrl) { TextView showText = new TextView(getActivity()); showText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16); showText.setPadding(15, 30, 15, 30); showText.setText(getString(R.string.log_submit_activity__copy_this_url_and_add_it_to_your_issue, logUrl)); showText.setAutoLinkMask(Activity.RESULT_OK); showText.setMovementMethod(LinkMovementMethod.getInstance()); showText.setOnLongClickListener(new View.OnLongClickListener() { @Override//from ww w. j a v a 2s . c o m public boolean onLongClick(View v) { @SuppressWarnings("deprecation") ClipboardManager manager = (ClipboardManager) getActivity() .getSystemService(Activity.CLIPBOARD_SERVICE); manager.setText(logUrl); Toast.makeText(getActivity(), R.string.log_submit_activity__copied_to_clipboard, Toast.LENGTH_SHORT) .show(); return true; } }); Linkify.addLinks(showText, Linkify.WEB_URLS); return showText; }
From source file:de.baumann.hhsmoodle.popup.Popup_note.java
private void setNotesList() { //display data final int layoutstyle = R.layout.list_item_notes; int[] xml_id = new int[] { R.id.textView_title_notes, R.id.textView_des_notes, R.id.textView_create_notes }; String[] column = new String[] { "note_title", "note_content", "note_creation" }; final String search = sharedPref.getString("filter_note_subject", ""); final Cursor row = db.fetchDataByFilter(search, "note_title"); SimpleCursorAdapter adapter = new SimpleCursorAdapter(Popup_note.this, layoutstyle, row, column, xml_id, 0) {// w w w . j a v a 2s . c om @Override public View getView(final int position, View convertView, ViewGroup parent) { Cursor row2 = (Cursor) lv.getItemAtPosition(position); final String _id = row2.getString(row2.getColumnIndexOrThrow("_id")); final String note_title = row2.getString(row2.getColumnIndexOrThrow("note_title")); final String note_content = row2.getString(row2.getColumnIndexOrThrow("note_content")); final String note_icon = row2.getString(row2.getColumnIndexOrThrow("note_icon")); final String note_attachment = row2.getString(row2.getColumnIndexOrThrow("note_attachment")); final String note_creation = row2.getString(row2.getColumnIndexOrThrow("note_creation")); View v = super.getView(position, convertView, parent); ImageView iv_icon = (ImageView) v.findViewById(R.id.icon_notes); ImageView iv_attachment = (ImageView) v.findViewById(R.id.att_notes); switch (note_icon) { case "3": iv_icon.setImageResource(R.drawable.circle_green); break; case "2": iv_icon.setImageResource(R.drawable.circle_yellow); break; case "1": iv_icon.setImageResource(R.drawable.circle_red); break; } switch (note_attachment) { case "": iv_attachment.setVisibility(View.GONE); break; default: iv_attachment.setVisibility(View.VISIBLE); iv_attachment.setImageResource(R.drawable.ic_attachment); break; } File file = new File(note_attachment); if (!file.exists()) { iv_attachment.setVisibility(View.GONE); } iv_icon.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { final Item[] items = { new Item(getString(R.string.note_priority_0), R.drawable.circle_green), new Item(getString(R.string.note_priority_1), R.drawable.circle_yellow), new Item(getString(R.string.note_priority_2), R.drawable.circle_red), }; ListAdapter adapter = new ArrayAdapter<Item>(Popup_note.this, android.R.layout.select_dialog_item, android.R.id.text1, items) { @NonNull public View getView(int position, View convertView, @NonNull ViewGroup parent) { //Use super class to create the View View v = super.getView(position, convertView, parent); TextView tv = (TextView) v.findViewById(android.R.id.text1); tv.setTextSize(18); tv.setCompoundDrawablesWithIntrinsicBounds(items[position].icon, 0, 0, 0); //Add margin between image and text (support various screen densities) int dp5 = (int) (24 * getResources().getDisplayMetrics().density + 0.5f); tv.setCompoundDrawablePadding(dp5); return v; } }; new AlertDialog.Builder(Popup_note.this) .setPositiveButton(R.string.toast_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }).setAdapter(adapter, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { if (item == 0) { db.update(Integer.parseInt(_id), note_title, note_content, "3", note_attachment, note_creation); setNotesList(); } else if (item == 1) { db.update(Integer.parseInt(_id), note_title, note_content, "2", note_attachment, note_creation); setNotesList(); } else if (item == 2) { db.update(Integer.parseInt(_id), note_title, note_content, "1", note_attachment, note_creation); setNotesList(); } } }).show(); } }); iv_attachment.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { helper_main.openAtt(Popup_note.this, lv, note_attachment); } }); return v; } }; lv.setAdapter(adapter); //onClick function lv.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterview, View view, int position, long id) { Cursor row2 = (Cursor) lv.getItemAtPosition(position); final String _id = row2.getString(row2.getColumnIndexOrThrow("_id")); final String note_title = row2.getString(row2.getColumnIndexOrThrow("note_title")); final String note_content = row2.getString(row2.getColumnIndexOrThrow("note_content")); final String note_icon = row2.getString(row2.getColumnIndexOrThrow("note_icon")); final String note_attachment = row2.getString(row2.getColumnIndexOrThrow("note_attachment")); final String note_creation = row2.getString(row2.getColumnIndexOrThrow("note_creation")); final Button attachment2; final TextView textInput; LayoutInflater inflater = Popup_note.this.getLayoutInflater(); final ViewGroup nullParent = null; final View dialogView = inflater.inflate(R.layout.dialog_note_show, nullParent); final String attName = note_attachment.substring(note_attachment.lastIndexOf("/") + 1); final String att = getString(R.string.app_att) + ": " + attName; attachment2 = (Button) dialogView.findViewById(R.id.button_att); if (attName.equals("")) { attachment2.setVisibility(View.GONE); } else { attachment2.setText(att); } File file2 = new File(note_attachment); if (!file2.exists()) { attachment2.setVisibility(View.GONE); } textInput = (TextView) dialogView.findViewById(R.id.note_text_input); textInput.setText(note_content); Linkify.addLinks(textInput, Linkify.WEB_URLS); attachment2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { helper_main.openAtt(Popup_note.this, lv, note_attachment); } }); final ImageView be = (ImageView) dialogView.findViewById(R.id.imageButtonPri); switch (note_icon) { case "3": be.setImageResource(R.drawable.circle_green); break; case "2": be.setImageResource(R.drawable.circle_yellow); break; case "1": be.setImageResource(R.drawable.circle_red); break; } android.app.AlertDialog.Builder dialog = new android.app.AlertDialog.Builder(Popup_note.this) .setTitle(note_title).setView(dialogView) .setPositiveButton(R.string.toast_yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }).setNegativeButton(R.string.note_edit, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { sharedPref.edit().putString("handleTextTitle", note_title) .putString("handleTextText", note_content) .putString("handleTextIcon", note_icon).putString("handleTextSeqno", _id) .putString("handleTextAttachment", note_attachment) .putString("handleTextCreate", note_creation).apply(); helper_main.switchToActivity(Popup_note.this, Activity_EditNote.class, false); } }); dialog.show(); } }); lv.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { Cursor row2 = (Cursor) lv.getItemAtPosition(position); final String _id = row2.getString(row2.getColumnIndexOrThrow("_id")); final String note_title = row2.getString(row2.getColumnIndexOrThrow("note_title")); final String note_content = row2.getString(row2.getColumnIndexOrThrow("note_content")); final String note_icon = row2.getString(row2.getColumnIndexOrThrow("note_icon")); final String note_attachment = row2.getString(row2.getColumnIndexOrThrow("note_attachment")); final String note_creation = row2.getString(row2.getColumnIndexOrThrow("note_creation")); final CharSequence[] options = { getString(R.string.note_edit), getString(R.string.note_share), getString(R.string.todo_menu), getString(R.string.bookmark_createEvent), getString(R.string.note_remove_note) }; new AlertDialog.Builder(Popup_note.this) .setPositiveButton(R.string.toast_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }).setItems(options, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int item) { if (options[item].equals(getString(R.string.note_edit))) { sharedPref.edit().putString("handleTextTitle", note_title) .putString("handleTextText", note_content) .putString("handleTextIcon", note_icon) .putString("handleTextSeqno", _id) .putString("handleTextAttachment", note_attachment) .putString("handleTextCreate", note_creation).apply(); helper_main.switchToActivity(Popup_note.this, Activity_EditNote.class, false); } if (options[item].equals(getString(R.string.note_share))) { File attachment = new File(note_attachment); Intent sharingIntent = new Intent(Intent.ACTION_SEND); sharingIntent.setType("text/plain"); sharingIntent.putExtra(Intent.EXTRA_SUBJECT, note_title); sharingIntent.putExtra(Intent.EXTRA_TEXT, note_content); if (attachment.exists()) { Uri bmpUri = Uri.fromFile(attachment); sharingIntent.putExtra(Intent.EXTRA_STREAM, bmpUri); } startActivity(Intent.createChooser(sharingIntent, (getString(R.string.note_share_2)))); } if (options[item].equals(getString(R.string.todo_menu))) { Todo_DbAdapter db = new Todo_DbAdapter(Popup_note.this); db.open(); if (db.isExist(note_title)) { Snackbar.make(lv, getString(R.string.toast_newTitle), Snackbar.LENGTH_LONG) .show(); } else { db.insert(note_title, note_content, "3", "true", helper_main.createDate()); ViewPager viewPager = (ViewPager) Popup_note.this .findViewById(R.id.viewpager); viewPager.setCurrentItem(2); Popup_note.this.setTitle(R.string.todo_title); dialog.dismiss(); } } if (options[item].equals(getString(R.string.bookmark_createEvent))) { Intent calIntent = new Intent(Intent.ACTION_INSERT); calIntent.setType("vnd.android.cursor.item/event"); calIntent.putExtra(CalendarContract.Events.TITLE, note_title); calIntent.putExtra(CalendarContract.Events.DESCRIPTION, note_content); startActivity(calIntent); } if (options[item].equals(getString(R.string.note_remove_note))) { Snackbar snackbar = Snackbar .make(lv, R.string.note_remove_confirmation, Snackbar.LENGTH_LONG) .setAction(R.string.toast_yes, new View.OnClickListener() { @Override public void onClick(View view) { db.delete(Integer.parseInt(_id)); setNotesList(); } }); snackbar.show(); } } }).show(); return true; } }); if (lv.getAdapter().getCount() == 0) { new android.app.AlertDialog.Builder(this) .setMessage(helper_main.textSpannable(getString(R.string.toast_noEntry))) .setPositiveButton(this.getString(R.string.toast_yes), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { finish(); } }).show(); new Handler().postDelayed(new Runnable() { public void run() { finish(); } }, 2000); } }
From source file:info.guardianproject.pixelknot.PixelKnotActivity.java
private void showAbout() { AlertDialog.Builder ad = new AlertDialog.Builder(this); View about = LayoutInflater.from(this).inflate(R.layout.about_fragment, null); TextView about_gp_email = (TextView) about.findViewById(R.id.about_gp_email); about_gp_email.setText(Html.fromHtml("<a href='mailto:" + about_gp_email.getText().toString() + "'>" + about_gp_email.getText().toString() + "</a>")); TextView about_version = (TextView) about.findViewById(R.id.about_version); try {/*from w w w . j a v a 2 s . c om*/ about_version.setText(getPackageManager().getPackageInfo(getPackageName(), 0).versionName); } catch (NameNotFoundException e) { Log.e(LOG, e.toString()); e.printStackTrace(); about_version.setText("1.0"); } LinearLayout license_holder = (LinearLayout) about.findViewById(R.id.about_license_holder); String[] licenses = getResources().getStringArray(R.array.about_software); String[] licenses_ = getResources().getStringArray(R.array.about_software_); for (int l = 0; l < licenses.length; l++) { TextView license = new TextView(this); license.setText(licenses[l]); license.setTextSize(20); TextView license_ = new TextView(this); license_.setText(Html.fromHtml("<a href='" + licenses_[l] + "'>" + licenses_[l] + "</a>")); license_.setLinksClickable(true); Linkify.addLinks(license_, Linkify.ALL); license_.setPadding(0, 0, 0, 30); license_.setTextSize(20); license_holder.addView(license); license_holder.addView(license_); } ad.setView(about); ad.setPositiveButton(getString(R.string.ok), null); ad.show(); }
From source file:com.cicada.yuanxiaobao.common.BaseAdapterHelper.java
/** * Add links into a TextView./*w ww . ja va 2 s . c o m*/ * * @param viewId * The id of the TextView to linkify. * @return The BaseAdapterHelper for chaining. */ public BaseAdapterHelper linkify(int viewId) { TextView view = retrieveView(viewId); Linkify.addLinks(view, Linkify.ALL); return this; }
From source file:com.tassadar.multirommgr.MainActivity.java
@TargetApi(20) private void showDeprecatedLAlert() { SpannableString msg = new SpannableString(getString(R.string.deprecated_l_text)); Linkify.addLinks(msg, Linkify.ALL); AlertDialog.Builder b = new AlertDialog.Builder(this); b.setTitle(R.string.deprecated_l_title).setCancelable(false).setMessage(msg) .setNegativeButton(R.string.deprecated_l_btn, new DialogInterface.OnClickListener() { @Override//ww w.j a v a 2 s . com public void onClick(DialogInterface dialogInterface, int i) { finish(); } }); AlertDialog d = b.create(); d.show(); TextView msgView = (TextView) d.findViewById(android.R.id.message); msgView.setMovementMethod(LinkMovementMethod.getInstance()); }
From source file:de.baumann.thema.Screen_Main.java
@Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); if (id == R.id.license) { SpannableString s;//from www . j av a 2 s.c om if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) { s = new SpannableString(Html.fromHtml(getString(R.string.about_text), Html.FROM_HTML_MODE_LEGACY)); } else { //noinspection deprecation s = new SpannableString(Html.fromHtml(getString(R.string.about_text))); } Linkify.addLinks(s, Linkify.WEB_URLS); final AlertDialog d = new AlertDialog.Builder(Screen_Main.this).setTitle(R.string.about_title) .setMessage(s) .setPositiveButton(getString(R.string.yes), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }).show(); d.show(); ((TextView) d.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance()); } if (id == R.id.changelog) { Uri uri = Uri.parse("https://github.com/scoute-dich/Blue-Minimal/blob/master/CHANGELOG.md"); // missing 'http://' will cause crashed Intent intent = new Intent(Intent.ACTION_VIEW, uri); startActivity(intent); } if (id == R.id.donate) { Uri uri = Uri .parse("https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=NP6TGYDYP9SHY"); // missing 'http://' will cause crashed Intent intent = new Intent(Intent.ACTION_VIEW, uri); startActivity(intent); } return super.onOptionsItemSelected(item); }
From source file:com.todoroo.astrid.notes.EditNoteActivity.java
/** Helper method to set the contents and visibility of each field */ public synchronized void bindView(View view, NoteOrUpdate item) { // name/*www . ja v a 2 s . c o m*/ final TextView nameView = (TextView) view.findViewById(R.id.title); { nameView.setText(item.title); Linkify.addLinks(nameView, Linkify.ALL); } // date final TextView date = (TextView) view.findViewById(R.id.date); { CharSequence dateString = DateUtils.getRelativeTimeSpanString(item.createdAt, DateUtilities.now(), DateUtils.MINUTE_IN_MILLIS, DateUtils.FORMAT_ABBREV_RELATIVE); date.setText(dateString); } // picture final ImageView commentPictureView = (ImageView) view.findViewById(R.id.comment_picture); setupImagePopupForCommentView(view, commentPictureView, item.commentBitmap, fragment); }