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.todoroo.astrid.notes.EditNoteActivity.java
private void setUpInterface() { timerView = commentsBar.findViewById(R.id.timer_container); commentButton = commentsBar.findViewById(R.id.commentButton); commentField = (EditText) commentsBar.findViewById(R.id.commentField); final boolean showTimerShortcut = preferences.getBoolean(R.string.p_show_timer_shortcut, false); if (showTimerShortcut) { commentField.setOnFocusChangeListener(new OnFocusChangeListener() { @Override//from www . ja v a 2 s. c o m public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { timerView.setVisibility(View.GONE); commentButton.setVisibility(View.VISIBLE); } else { timerView.setVisibility(View.VISIBLE); commentButton.setVisibility(View.GONE); } } }); } commentField.setHorizontallyScrolling(false); commentField.setMaxLines(Integer.MAX_VALUE); commentField.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_ENTER) { AndroidUtilities.hideSoftInputForViews(activity, commentField); return true; } return false; } }); commentField.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { commentField.setCursorVisible(true); } }); commentField.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable s) { commentButton.setVisibility( (s.length() > 0 || pendingCommentPicture != null) ? View.VISIBLE : View.GONE); if (showTimerShortcut) { timerView.setVisibility( (s.length() > 0 || pendingCommentPicture != null) ? View.GONE : View.VISIBLE); } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { // } }); commentField.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView view, int actionId, KeyEvent event) { if (commentField.getText().length() > 0) { if (actionId == EditorInfo.IME_ACTION_DONE || actionId == EditorInfo.IME_NULL) { // commentField.setCursorVisible(false); addComment(); } } return false; } }); commentButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { addComment(); } }); final ClearImageCallback clearImage = new ClearImageCallback() { @Override public void clearImage() { pendingCommentPicture = null; pictureButton.setImageResource(cameraButton); } }; pictureButton = (ImageButton) commentsBar.findViewById(R.id.picture); pictureButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (pendingCommentPicture != null) { actFmCameraModule.showPictureLauncher(clearImage); } else { actFmCameraModule.showPictureLauncher(null); } respondToPicture = true; } }); if (!TextUtils.isEmpty(task.getNotes())) { TextView notes = new TextView(getContext()); notes.setLinkTextColor(Color.rgb(100, 160, 255)); notes.setTextSize(18); notes.setText(task.getNotes()); notes.setPadding(5, 10, 5, 10); Linkify.addLinks(notes, Linkify.ALL); } if (activity != null) { String uri = activity.getIntent().getStringExtra(TaskEditFragment.TOKEN_PICTURE_IN_PROGRESS); if (uri != null) { pendingCommentPicture = Uri.parse(uri); setPictureButtonToPendingPicture(); } } }
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 w ww .j ava 2s . c om*/ 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();/* ww w .j a va 2 s. c om*/ 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:com.mine.psf.PsfFileBrowserActivity.java
@Override protected Dialog onCreateDialog(int id) { // show dialog according to the id final String msg; if (id == ID_ABOUT) { // Get version code String versionString = ""; PackageManager manager = getPackageManager(); try {/*from ww w. j av a2 s . c o m*/ PackageInfo info = manager.getPackageInfo(getPackageName(), 0); versionString = info.versionName; } catch (NameNotFoundException e) { e.printStackTrace(); } // Format dialog msg msg = String.format(getString(R.string.sexypsf_about), versionString); } else { Log.e(LOGTAG, "Unknown dialog id"); msg = ""; } final TextView msgView = new TextView(this); msgView.setText(msg); msgView.setAutoLinkMask(Linkify.ALL); msgView.setTextAppearance(this, android.R.style.TextAppearance_Medium); msgView.setMovementMethod(LinkMovementMethod.getInstance()); return new AlertDialog.Builder(this).setView(msgView).setCancelable(true) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { /* User clicked OK so do some stuff */ } }).create(); }
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 {// w w w . ja v a 2s . c o m 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 w w.j a v a 2 s .co 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/*from w w w . j av a 2 s . co m*/ 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: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/* w w w. j av a2 s. co 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); }
From source file:com.acrylicgoat.devchat.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 va 2 s . c om int notesColumn = cursor.getColumnIndex(Notes.NOTE); today.setText(cursor.getString(notesColumn)); } else { if (devs.size() > 0) { today.setText(""); } else { today.setText(getString(R.string.no_devs)); } } Linkify.addLinks(today, Linkify.ALL); cursor.close(); db.close(); }
From source file:be.ppareit.swiftp.gui.PreferenceFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.preferences); final SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getActivity()); Resources resources = getResources(); TwoStatePreference runningPref = findPref("running_switch"); updateRunningState();// w w w. j a v a 2 s .com runningPref.setOnPreferenceChangeListener((preference, newValue) -> { if ((Boolean) newValue) { startServer(); } else { stopServer(); } return true; }); PreferenceScreen prefScreen = findPref("preference_screen"); Preference marketVersionPref = findPref("market_version"); marketVersionPref.setOnPreferenceClickListener(preference -> { // start the market at our application Intent intent = new Intent(Intent.ACTION_VIEW); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setData(Uri.parse("market://details?id=be.ppareit.swiftp")); try { // this can fail if there is no market installed startActivity(intent); } catch (Exception e) { Cat.e("Failed to launch the market."); e.printStackTrace(); } return false; }); if (!App.isFreeVersion()) { prefScreen.removePreference(marketVersionPref); } updateLoginInfo(); EditTextPreference usernamePref = findPref("username"); usernamePref.setOnPreferenceChangeListener((preference, newValue) -> { String newUsername = (String) newValue; if (preference.getSummary().equals(newUsername)) return false; if (!newUsername.matches("[a-zA-Z0-9]+")) { Toast.makeText(getActivity(), R.string.username_validation_error, Toast.LENGTH_LONG).show(); return false; } stopServer(); return true; }); mPassWordPref = findPref("password"); mPassWordPref.setOnPreferenceChangeListener((preference, newValue) -> { stopServer(); return true; }); mAutoconnectListPref = findPref("autoconnect_preference"); mAutoconnectListPref.setOnPopulateListener(pref -> { Cat.d("autoconnect populate listener"); WifiManager wifiManager = (WifiManager) getActivity().getApplicationContext() .getSystemService(Context.WIFI_SERVICE); List<WifiConfiguration> configs = wifiManager.getConfiguredNetworks(); if (configs == null) { Cat.e("Unable to receive wifi configurations, bark at user and bail"); Toast.makeText(getActivity(), R.string.autoconnect_error_enable_wifi_for_access_points, Toast.LENGTH_LONG).show(); return; } CharSequence[] ssids = new CharSequence[configs.size()]; CharSequence[] niceSsids = new CharSequence[configs.size()]; for (int i = 0; i < configs.size(); ++i) { ssids[i] = configs.get(i).SSID; String ssid = configs.get(i).SSID; if (ssid.length() > 2 && ssid.startsWith("\"") && ssid.endsWith("\"")) { ssid = ssid.substring(1, ssid.length() - 1); } niceSsids[i] = ssid; } pref.setEntries(niceSsids); pref.setEntryValues(ssids); }); mAutoconnectListPref.setOnPreferenceClickListener(preference -> { Cat.d("Clicked"); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (ActivityCompat.checkSelfPermission(getContext(), Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_DENIED) { if (ActivityCompat.shouldShowRequestPermissionRationale(getActivity(), Manifest.permission.ACCESS_COARSE_LOCATION)) { new AlertDialog.Builder(getContext()).setTitle(R.string.request_coarse_location_dlg_title) .setMessage(R.string.request_coarse_location_dlg_message) .setPositiveButton(android.R.string.ok, (dialog, which) -> { requestPermissions(new String[] { Manifest.permission.ACCESS_COARSE_LOCATION }, ACCESS_COARSE_LOCATION_REQUEST_CODE); }).setOnCancelListener(dialog -> { mAutoconnectListPref.getDialog().cancel(); }).create().show(); } else { requestPermissions(new String[] { Manifest.permission.ACCESS_COARSE_LOCATION }, ACCESS_COARSE_LOCATION_REQUEST_CODE); } } } return false; }); EditTextPreference portnum_pref = findPref("portNum"); portnum_pref.setSummary(sp.getString("portNum", resources.getString(R.string.portnumber_default))); portnum_pref.setOnPreferenceChangeListener((preference, newValue) -> { String newPortnumString = (String) newValue; if (preference.getSummary().equals(newPortnumString)) return false; int portnum = 0; try { portnum = Integer.parseInt(newPortnumString); } catch (Exception e) { Cat.d("Error parsing port number! Moving on..."); } if (portnum <= 0 || 65535 < portnum) { Toast.makeText(getActivity(), R.string.port_validation_error, Toast.LENGTH_LONG).show(); return false; } preference.setSummary(newPortnumString); stopServer(); return true; }); Preference chroot_pref = findPref("chrootDir"); chroot_pref.setSummary(FsSettings.getChrootDirAsString()); chroot_pref.setOnPreferenceClickListener(preference -> { AlertDialog folderPicker = new FolderPickerDialogBuilder(getActivity(), FsSettings.getChrootDir()) .setSelectedButton(R.string.select, path -> { if (preference.getSummary().equals(path)) return; if (!FsSettings.setChrootDir(path)) return; // TODO: this is a hotfix, create correct resources, improve UI/UX final File root = new File(path); if (!root.canRead()) { Toast.makeText(getActivity(), "Notice that we can't read/write in this folder.", Toast.LENGTH_LONG).show(); } else if (!root.canWrite()) { Toast.makeText(getActivity(), "Notice that we can't write in this folder, reading will work. Writing in sub folders might work.", Toast.LENGTH_LONG).show(); } preference.setSummary(path); stopServer(); }).setNegativeButton(R.string.cancel, null).create(); folderPicker.show(); return true; }); final CheckBoxPreference wakelock_pref = findPref("stayAwake"); wakelock_pref.setOnPreferenceChangeListener((preference, newValue) -> { stopServer(); return true; }); final CheckBoxPreference writeExternalStorage_pref = findPref("writeExternalStorage"); String externalStorageUri = FsSettings.getExternalStorageUri(); if (externalStorageUri == null) { writeExternalStorage_pref.setChecked(false); } writeExternalStorage_pref.setOnPreferenceChangeListener((preference, newValue) -> { if ((boolean) newValue) { Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE); startActivityForResult(intent, ACTION_OPEN_DOCUMENT_TREE); return false; } else { FsSettings.setExternalStorageUri(null); return true; } }); ListPreference theme = findPref("theme"); theme.setSummary(theme.getEntry()); theme.setOnPreferenceChangeListener((preference, newValue) -> { theme.setSummary(theme.getEntry()); getActivity().recreate(); return true; }); Preference help = findPref("help"); help.setOnPreferenceClickListener(preference -> { Cat.v("On preference help clicked"); Context context = getActivity(); AlertDialog ad = new AlertDialog.Builder(context).setTitle(R.string.help_dlg_title) .setMessage(R.string.help_dlg_message).setPositiveButton(android.R.string.ok, null).create(); ad.show(); Linkify.addLinks((TextView) ad.findViewById(android.R.id.message), Linkify.ALL); return true; }); Preference about = findPref("about"); about.setOnPreferenceClickListener(preference -> { startActivity(new Intent(getActivity(), AboutActivity.class)); return true; }); }