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.birthdayadapter.ui.InstallWorkaroundDialogFragment.java
/** * Creates dialog// w w w . jav a 2s.co m */ @NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { // Linkify the message final SpannableString message = new SpannableString(getString(R.string.workaround_dialog_message)); Linkify.addLinks(message, Linkify.ALL); AlertDialog.Builder alert = new AlertDialog.Builder(getActivity()); alert.setTitle(R.string.workaround_dialog_title); alert.setMessage(message); alert.setCancelable(true); alert.setIcon(android.R.drawable.ic_dialog_info); alert.setNegativeButton(R.string.workaround_dialog_close_button, new OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { dismiss(); } }); alert.setNeutralButton(R.string.workaround_dialog_dont_show_again_button, new OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { PreferencesHelper.setShowWorkaroundDialog(getActivity(), false); dismiss(); } }); alert.setPositiveButton(R.string.workaround_dialog_install_button, new OnClickListener() { public void onClick(DialogInterface dialog, int which) { String workaroundName = "org.birthdayadapter.jb.workaround"; try { startActivity( new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + workaroundName))); } catch (ActivityNotFoundException anfe) { // No Google Play installed? Weird! Try with browser! startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=" + workaroundName))); } } }); return alert.create(); }
From source file:org.keionline.keionline.AboutActivity.java
/** * The fragment argument representing the section number for this * fragment./*from w w w .j a v a2s. c o m*/ */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.fragment_about); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayShowHomeEnabled(true); toolbar.setNavigationIcon(R.drawable.ic_arrow_back_black_24dp); toolbar.setTitleTextColor(Color.BLACK); toolbar.setTitle(R.string.KEI); toolbar.setLogo(R.drawable.ic_action_keiicon); // TextView textView = (TextView) rootView.findViewById(R.id.section_label); // textView.setText(getString(R.string.section_format, getArguments().getInt(ARG_SECTION_NUMBER))); Txt1 = (TextView) findViewById(R.id.about_app); Txt1.setText(R.string.about_app); Txt2 = (TextView) findViewById(R.id.about_kei); Txt2.setText(R.string.about_kei); Txt3 = (TextView) findViewById(R.id.about_instructions); Txt3.setText(R.string.about_instructions); Linkify.addLinks(Txt3, 1); Txt4 = (TextView) findViewById(R.id.about_info); Txt4.setText(R.string.about_info); Linkify.addLinks(Txt4, 1); }
From source file:com.nineducks.hereader.HackfulReaderActivity.java
@Override protected Dialog onCreateDialog(int id) { Dialog result = null;/* w w w. j a v a2 s .c o m*/ AlertDialog.Builder builder = null; switch (id) { case R.id.open_dialog: builder = new AlertDialog.Builder(this); builder.setTitle(R.string.open_dialog_title); builder.setItems(R.array.open_dialog_options, (OnClickListener) itemsController); builder.setCancelable(true); result = builder.create(); break; case R.id.about_dialog: builder = new AlertDialog.Builder(this); builder.setTitle(R.string.about_dialog_title); ScrollView scroll = new ScrollView(this); TextView msg = new TextView(this); SpannableString s = new SpannableString(getString(R.string.about_dialog_text)); Linkify.addLinks(s, Linkify.WEB_URLS); msg.setText(s); msg.setMovementMethod(LinkMovementMethod.getInstance()); msg.setTextSize(16); msg.setPadding(15, 15, 15, 15); scroll.addView(msg); builder.setView(scroll); builder.setInverseBackgroundForced(true); result = builder.create(); break; } return result; }
From source file:it.scoppelletti.mobilepower.app.MarketTagHandler.java
/** * Attiva la rilevazione dei collegamenti. * //from w w w .j a v a2 s. c om * @param view Controllo. * @param pkgName Nome del pacchetto. */ public void addLinks(TextView view, String pkgName) { String text; if (myEndPos <= myStartPos || StringUtils.isBlank(pkgName)) { return; } myPkgName = pkgName; // http://www.indelible.org/ink/android-linkify, 09/04/2010 // La rilevazione dei collegamenti personalizzati e' attiva solo // disabilitando la rilevazione dei collegamenti di default e // riabilitandola attraverso la classe Linkify. view.setAutoLinkMask(0); Linkify.addLinks(view, Linkify.ALL); text = String.valueOf(view.getText().subSequence(myStartPos, myEndPos)); Linkify.addLinks(view, Pattern.compile(text), MarketTagHandler.SCHEME, this, this); }
From source file:com.tortel.deploytrack.dialog.AboutDialog.java
@NonNull @Override/* www . j a va 2 s . c o m*/ public Dialog onCreateDialog(Bundle savedInstanceState) { final Context wrappedContext = new ContextThemeWrapper(getActivity(), R.style.Theme_DeployThemeLight); MaterialDialog.Builder builder = new MaterialDialog.Builder(wrappedContext); LayoutInflater inflater = getActivity().getLayoutInflater().cloneInContext(wrappedContext); @SuppressLint("InflateParams") View view = inflater.inflate(R.layout.dialog_about, null); TextView text = (TextView) view.findViewById(R.id.about_view); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { text.setText(Html.fromHtml(readRawTextFile(getContent()), Html.FROM_HTML_MODE_LEGACY)); } else { //noinspection deprecation text.setText(Html.fromHtml(readRawTextFile(getContent()))); } Linkify.addLinks(text, Linkify.ALL); text.setMovementMethod(LinkMovementMethod.getInstance()); builder.customView(view, false); builder.title(getTitleString()); builder.positiveText(R.string.close); return builder.build(); }
From source file:com.chrulri.droidoflife.AboutDialogFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.about, container, false); TextView info = (TextView) v.findViewById(R.id.about_info); info.setText(infoText);/*from w w w. j av a 2s. c om*/ Linkify.addLinks(info, Linkify.ALL); TextView legal = (TextView) v.findViewById(R.id.about_legal); legal.setText(legalText); Linkify.addLinks(legal, Linkify.ALL); return v; }
From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.StatusObj.java
public void render(Context context, ViewGroup frame, Obj obj, boolean allowInteractions) { JSONObject content = obj.getJson();// w w w . j av a2 s .com TextView valueTV = new TextView(context); valueTV.setText(content.optString(TEXT)); valueTV.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); valueTV.setGravity(Gravity.TOP | Gravity.LEFT); if (Linkify.addLinks(valueTV, Linkify.ALL)) { if (!allowInteractions) valueTV.setMovementMethod(null); } frame.addView(valueTV); }
From source file:com.facebook.android.UploadPhotoResultDialog.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mHandler = new Handler(); setContentView(R.layout.upload_photo_response); LayoutParams params = getWindow().getAttributes(); params.width = LayoutParams.FILL_PARENT; params.height = LayoutParams.FILL_PARENT; getWindow().setAttributes((android.view.WindowManager.LayoutParams) params); mOutput = (TextView) findViewById(R.id.apiOutput); mUsefulTip = (TextView) findViewById(R.id.usefulTip); mViewPhotoButton = (Button) findViewById(R.id.view_photo_button); mTagPhotoButton = (Button) findViewById(R.id.tag_photo_button); mUploadedPhoto = (ImageView) findViewById(R.id.uploadedPhoto); JSONObject json;// www .j a v a2 s. c om try { json = Util.parseJson(response); final String photo_id = json.getString("id"); this.photo_id = photo_id; mOutput.setText(json.toString(2)); mUsefulTip.setText(activity.getString(R.string.photo_tip)); Linkify.addLinks(mUsefulTip, Linkify.WEB_URLS); mViewPhotoButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (hidePhoto) { mViewPhotoButton.setText(R.string.view_photo); hidePhoto = false; mUploadedPhoto.setImageBitmap(null); } else { hidePhoto = true; mViewPhotoButton.setText(R.string.hide_photo); /* * Source tag: view_photo_tag */ Bundle params = new Bundle(); params.putString("fields", "picture"); dialog = ProgressDialog.show(activity, "", activity.getString(R.string.please_wait), true, true); dialog.show(); Utility.mAsyncRunner.request(photo_id, params, new ViewPhotoRequestListener()); } } }); mTagPhotoButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { /* * Source tag: tag_photo_tag */ setTag(); } }); } catch (JSONException e) { setText(activity.getString(R.string.exception) + e.getMessage()); } catch (FacebookError e) { setText(activity.getString(R.string.facebook_error) + e.getMessage()); } }
From source file:de.tum.mw.lfe.drtrc.AboutFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_about, container, false); ((MainActivity) getActivity()).addToReportView(null);//call with (null) just to refresh the reportView String tempStr = getVersionString(); tempStr += "<br/><br/>This is an open source implementation of an application to control an Arduino Detection Response Task (DRT) via USB OTG connection."; tempStr += "<br/><br/> (c) Michael Krause <a href=\"mailto:krause@tum.de\">krause@tum.de</a> <br/>2015 Institute of Ergonomics, TUM"; tempStr += "<br/><br/>More information on <br/><a href=\"http://www.lfe.mw.tum.de/drt-rc\">http://www.lfe.mw.tum.de/drt-rc</a>"; tempStr += "<br/><br/>This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details."; final SpannableString s = new SpannableString(Html.fromHtml(tempStr)); Linkify.addLinks(s, Linkify.EMAIL_ADDRESSES | Linkify.WEB_URLS); TextView tv = (TextView) rootView.findViewById(R.id.aboutTextView); tv.setText(s);// ww w . j a v a2s . com return rootView; }
From source file:com.acrylicgoat.scrumnotes.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().requestFeature(Window.FEATURE_ACTION_BAR); setContentView(R.layout.activity_main); sharedPref = getSharedPreferences("com.acrylicgoat.scrumnotes", MODE_PRIVATE); if (savedInstanceState != null) { currentOwner = savedInstanceState.getString("currentOwner"); }/*from ww w . j a v a2s. c om*/ if (currentOwner == null || currentOwner.equals("")) { currentOwner = sharedPref.getString("currentOwner", ""); } aBar = this.getActionBar(); today = (EditText) findViewById(R.id.editToday); today.setAutoLinkMask(Linkify.ALL); today.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable s) { } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void onTextChanged(CharSequence s, int start, int before, int count) { Linkify.addLinks(today, Linkify.ALL); } }); devName = (TextView) findViewById(R.id.devName); yesterday = (ImageButton) findViewById(R.id.calendarButton); yesterday.setOnClickListener(new OnClickListener() { public void onClick(View v) { displayPopup(); } }); String[] items = getResources().getStringArray(R.array.nav_list); setDrawer(items); drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); drawerList = (ListView) findViewById(R.id.left_drawer); SimpleAdapter sAdapter = new SimpleAdapter(this, navTitles, R.layout.nav_drawer, from, to); // Set the adapter for the list view //drawerList.setAdapter(new ArrayAdapter<String>(this,R.layout.drawer_list_item, navTitles)); // Set the list's click listener drawerList.setOnItemClickListener(new DrawerItemClickListener()); drawerToggle = new ActionBarDrawerToggle(this, /* host Activity */ drawerLayout, /* DrawerLayout object */ R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */ R.string.drawer_open, /* "open drawer" description for accessibility */ R.string.drawer_close /* "close drawer" description for accessibility */ ) { public void onDrawerClosed(View view) { getActionBar().setTitle(getString(R.string.app_name)); invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() } public void onDrawerOpened(View drawerView) { getActionBar().setTitle(getString(R.string.app_name)); invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() } }; drawerToggle.setDrawerIndicatorEnabled(true); drawerToggle.syncState(); drawerLayout.setDrawerListener(drawerToggle); aBar.setTitle(getString(R.string.app_name)); //aBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); aBar.setDisplayHomeAsUpEnabled(true); aBar.setHomeButtonEnabled(true); drawerList.setAdapter(sAdapter); }