List of usage examples for android.text.util Linkify addLinks
public static final boolean addLinks(@NonNull TextView text, @LinkifyMask int mask)
From source file:org.appcelerator.titanium.util.TiUIHelper.java
public static void linkifyIfEnabled(final TextView tv, final Object autoLink) { if (autoLink != null) { //Default to Ti.UI.AUTOLINK_NONE boolean success = Linkify.addLinks(tv, TiConvert.toInt(autoLink, 0) & Linkify.ALL); if (success && tv.getText() instanceof Spanned) { tv.setMovementMethod(LinkMovementMethod.getInstance()); }/*from w w w . ja v a2 s.c o m*/ } }
From source file:com.github.irshulx.Components.InputExtensions.java
private TextView getNewTextView(CharSequence text) { final TextView textView = new TextView( new ContextThemeWrapper(this.editorCore.getContext(), R.style.WysiwygEditText)); addEditableStyling(textView);/*w ww . j a v a2s . c o m*/ LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); textView.setLayoutParams(params); if (!TextUtils.isEmpty(text)) { Spanned __ = Html.fromHtml(text.toString()); CharSequence toReplace = noTrailingwhiteLines(__); textView.setText(toReplace); Linkify.addLinks(textView, Linkify.ALL); } if (this.lineSpacing != -1) { setLineSpacing(textView, this.lineSpacing); } return textView; }
From source file:org.easyrpg.player.player.EasyRpgPlayerActivity.java
private void reportBug() { AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); alertDialogBuilder.setTitle(R.string.app_name); final SpannableString bug_msg = new SpannableString( getApplicationContext().getString(R.string.report_bug_msg)); Linkify.addLinks(bug_msg, Linkify.ALL); // set dialog message alertDialogBuilder.setMessage(bug_msg).setCancelable(false) .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { ArrayList<Uri> files = new ArrayList<Uri>(); String savepath = getIntent().getStringExtra(TAG_SAVE_PATH); files.add(Uri.fromFile(new File(savepath + "/easyrpg_log.txt"))); for (File f : GameBrowserHelper.getSavegames(new File(savepath))) { files.add(Uri.fromFile(f)); }// ww w . j a v a 2 s . co m if (Build.VERSION.SDK_INT >= 24) { // Lazy workaround as suggested on https://stackoverflow.com/q/38200282 try { Method m = StrictMode.class.getMethod("disableDeathOnFileUriExposure"); m.invoke(null); } catch (Exception e) { Log.i("EasyRPG", "Bug report: Calling disableDeathOnFileUriExposure failed"); } } Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE); intent.setData(Uri.parse("mailto:")); intent.setType("*/*"); intent.putExtra(Intent.EXTRA_EMAIL, new String[] { "easyrpg@easyrpg.org" }); intent.putExtra(Intent.EXTRA_SUBJECT, "Bug report"); intent.putExtra(Intent.EXTRA_TEXT, getApplicationContext().getString(R.string.report_bug_mail)); intent.putExtra(Intent.EXTRA_STREAM, files); if (intent.resolveActivity(getPackageManager()) != null) { startActivity(intent); } } }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alertDialog = alertDialogBuilder.create(); alertDialog.show(); ((TextView) alertDialog.findViewById(android.R.id.message)) .setMovementMethod(LinkMovementMethod.getInstance()); }
From source file:org.umit.icm.mobile.gui.ControlActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.controlactivity); WebsiteSuggestButton = (Button) this.findViewById(R.id.suggestWebsite); ServiceSuggestButton = (Button) this.findViewById(R.id.suggestService); scanButton = (Button) this.findViewById(R.id.scanButton); // filterButton = (Button) this.findViewById(R.id.filterButton); // servicesFilterButton = (Button) this.findViewById(R.id.serviceFilterButton); mapSelectionButton = (Button) this.findViewById(R.id.mapSelectionButton); enableTwitterButton = (Button) this.findViewById(R.id.enableTwitterButton); bugReportButton = (Button) this.findViewById(R.id.bugReportButton); aboutButton = (Button) this.findViewById(R.id.aboutButton); scanButton.setText(getString(R.string.scan_text) + " " + getString(R.string.scan_off)); try {/*from w w w. j a v a 2 s . c o m*/ if (Globals.runtimeParameters.getTwitter().equals("Off")) { enableTwitterButton.setText(getString(R.string.enable_twitter_button)); } else { enableTwitterButton.setText(getString(R.string.disable_twitter_button)); } } catch (RuntimeException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } BroadcastReceiver receiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { if (intent.getAction().equals("org.umit.icm.mobile.CONTROL_ACTIVITY")) { scanButton.setText(getString(R.string.scan_text) + " " + getString(R.string.scan_on)); } } }; registerReceiver(receiver, new IntentFilter("org.umit.icm.mobile.CONTROL_ACTIVITY")); WebsiteSuggestButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { WebsiteSuggestionDialog websiteSuggestionDialog = new WebsiteSuggestionDialog(ControlActivity.this, "", new OnReadyListener()); websiteSuggestionDialog.show(); } }); ServiceSuggestButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { ServiceSuggestionDialog suggestionDialog = new ServiceSuggestionDialog(ControlActivity.this, "", new OnReadyListener()); suggestionDialog.show(); } }); enableTwitterButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { try { if (Globals.runtimeParameters.getTwitter().equals("Off")) { progressDialog = ProgressDialog.show(ControlActivity.this, getString(R.string.loading), getString(R.string.retrieving_website), true, false); new LaunchBrowser().execute(); TwitterDialog twitterDialog = new TwitterDialog(ControlActivity.this, ""); twitterDialog.show(); enableTwitterButton.setText(getString(R.string.disable_twitter_button)); } else { Globals.runtimeParameters.setTwitter("Off"); enableTwitterButton.setText(getString(R.string.enable_twitter_button)); } } catch (RuntimeException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); mapSelectionButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { MapSelectionDialog MapSelectionDialog = new MapSelectionDialog(ControlActivity.this, ""); MapSelectionDialog.show(); } }); /* filterButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent intent = new Intent(ControlActivity.this, WebsiteFilterActivity.class); startActivity(intent); } } ); servicesFilterButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent intent = new Intent(ControlActivity.this, ServiceFilterActivity.class); startActivity(intent); } } );*/ bugReportButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent intent = new Intent(ControlActivity.this, BugReportActivity.class); startActivity(intent); } }); aboutButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { String msg = getString(R.string.about_text) + "\n" + getString(R.string.link_to_open_monitor) + "\n" + getString(R.string.link_to_umit) + "\n" + getString(R.string.icons_by); final SpannableString spannableString = new SpannableString(msg); Linkify.addLinks(spannableString, Linkify.ALL); AlertDialog alertDialog = new AlertDialog.Builder(ControlActivity.this).create(); alertDialog.setTitle(getString(R.string.about_button)); alertDialog.setMessage(spannableString); alertDialog.setIcon(R.drawable.umit_128); alertDialog.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); alertDialog.show(); } }); scanButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { if (Globals.scanStatus.equalsIgnoreCase(getString(R.string.scan_on))) { scanButton.setText(getString(R.string.scan_text) + " " + getString(R.string.scan_on)); Globals.scanStatus = getString(R.string.scan_off); stopService(new Intent(ControlActivity.this, ConnectivityService.class)); } else { scanButton.setText(getString(R.string.scan_text) + " " + getString(R.string.scan_off)); Globals.scanStatus = getString(R.string.scan_on); startService(new Intent(ControlActivity.this, ConnectivityService.class)); } try { Globals.runtimeParameters.setScanStatus(Globals.scanStatus); } catch (RuntimeException e) { e.printStackTrace(); } Context context = getApplicationContext(); CharSequence text = getString(R.string.toast_scan_change) + " " + Globals.scanStatus; int duration = Toast.LENGTH_SHORT; Toast toast = Toast.makeText(context, text, duration); toast.show(); } }); }
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/*from w w w . j ava 2s . 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: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 w ww. j a v a 2s .co 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: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 www . j av a2 s.c om 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 w w w .j a v a 2 s. c om*/ 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); }
From source file:com.abcvoipsip.ui.prefs.CodecsFragment.java
@Override @SuppressWarnings("unchecked") public boolean onContextItemSelected(MenuItem item) { AdapterView.AdapterContextMenuInfo info; try {//from ww w . j a v a 2s.c o m info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo(); } catch (ClassCastException e) { Log.e(THIS_FILE, "bad menuInfo", e); return false; } HashMap<String, Object> codec = null; codec = (HashMap<String, Object>) mAdapter.getItem(info.position); if (codec == null) { // If for some reason the requested item isn't available, do nothing return false; } int selId = item.getItemId(); if (selId == MENU_ITEM_ACTIVATE) { boolean isDisabled = ((Short) codec.get(CODEC_PRIORITY) == 0); final short newPrio = isDisabled ? (short) 1 : (short) 0; if (NON_FREE_CODECS.containsKey(codec.get(CODEC_ID)) && isDisabled) { final HashMap<String, Object> fCodec = codec; final TextView message = new TextView(getActivity()); final SpannableString s = new SpannableString( getString(R.string.this_codec_is_not_free) + NON_FREE_CODECS.get(codec.get(CODEC_ID))); Linkify.addLinks(s, Linkify.WEB_URLS); message.setText(s); message.setMovementMethod(LinkMovementMethod.getInstance()); message.setPadding(10, 10, 10, 10); //Alert user that we will disable for all incoming calls as he want to quit new AlertDialog.Builder(getActivity()).setTitle(R.string.warning).setView(message) .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { setCodecActivated(fCodec, newPrio); } }).setNegativeButton(R.string.cancel, null).show(); } else { setCodecActivated(codec, newPrio); } return true; } return false; }