Example usage for android.text.util Linkify addLinks

List of usage examples for android.text.util Linkify addLinks

Introduction

In this page you can find the example usage for android.text.util Linkify addLinks.

Prototype

public static final boolean addLinks(@NonNull TextView text, @LinkifyMask int mask) 

Source Link

Document

Scans the text of the provided TextView and turns all occurrences of the link types indicated in the mask into clickable links.

Usage

From source file:Main.java

public static SpannableString textSpannable(String text) {
    SpannableString s;//from  w  w w  .  j av  a2 s.c  om

    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
        s = new SpannableString(Html.fromHtml(text, Html.FROM_HTML_MODE_LEGACY));
    } else {
        //noinspection deprecation
        s = new SpannableString(Html.fromHtml(text));
    }
    Linkify.addLinks(s, Linkify.WEB_URLS);
    return s;
}

From source file:com.jamesgiang.aussnowcam.Utils.java

public static void About(Context c) {
    AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(c);
    dialogBuilder.setTitle(R.string.app_name);
    dialogBuilder.setIcon(R.drawable.icon);
    TextView textView = new TextView(c);
    SpannableString s = new SpannableString(c.getString(R.string.about_info));
    Linkify.addLinks(s, Linkify.WEB_URLS);
    textView.setText(s);// ww w. jav a  2 s .  c o m
    textView.setGravity(Gravity.CENTER);
    textView.setMovementMethod(LinkMovementMethod.getInstance());
    dialogBuilder.setView(textView);
    dialogBuilder.show();
}

From source file:fr.tvbarthel.apps.simpleweatherforcast.fragments.LicenseDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final LayoutInflater inflater = getActivity().getLayoutInflater();

    final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity());
    final View dialogView = inflater.inflate(R.layout.dialog_license, null);

    if (dialogView != null) {
        final TextView textViewContent = (TextView) dialogView.findViewById(R.id.dialog_license_content);
        if (textViewContent != null) {
            textViewContent.setMovementMethod(LinkMovementMethod.getInstance());
            Linkify.addLinks(textViewContent, Linkify.WEB_URLS);
        }//from   w ww  .j a  v  a 2  s. c  o  m
    }

    dialogBuilder.setCancelable(true).setView(dialogView).setPositiveButton(android.R.string.ok, null)
            .setTitle(R.string.dialog_license_title).setInverseBackgroundForced(true);

    return dialogBuilder.create();
}

From source file:com.floatboth.antigravity.ui.LicenseActivity.java

@AfterViews
public void setUpViews() {
    try {/*from w  w w .j  a  v a 2s.  c o  m*/
        InputStream is = getAssets()
                .open(uri.toString().replace("com.floatboth.antigravity.license://", "license_") + ".txt");
        app_info.setText(IOUtils.toString(is, "UTF-8"));
        Linkify.addLinks(app_info, Linkify.WEB_URLS);
        app_info.setMovementMethod(LinkMovementMethod.getInstance());
    } catch (Exception ex) {
    }
}

From source file:com.savvywits.wethepeople.AboutFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    View view = inflater.inflate(R.layout.about_layout, container, false);
    String text = new String(AboutText.ABOUT);
    TextView tv = (TextView) view.findViewById(R.id.aboutpage);
    tv.setText(Html.fromHtml(text));/*  w  ww. j av  a  2s. c  om*/

    Linkify.addLinks(tv, Linkify.ALL);

    return view;
}

From source file:com.byagowi.persiancalendar.view.fragment.AboutFragment.java

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_about, container, false);
    utils = Utils.getInstance(getContext());
    utils.setActivityTitleAndSubtitle(getActivity(), getString(R.string.about), "");

    String version = utils.programVersion();

    TextView versionTextView = (TextView) view.findViewById(R.id.version2);
    utils.setFont(versionTextView);//from   w w  w  .  ja v a  2 s .  c  o m
    versionTextView.setText(
            utils.shape(getString(R.string.version)) + " " + utils.formatNumber(version.split("-")[0]));

    TextView licenseTextView = (TextView) view.findViewById(R.id.license);
    licenseTextView.setText(
            "Android Persian Calendar Version " + version + "\n" + utils.readRawResource(R.raw.credits));

    Linkify.addLinks(licenseTextView, Linkify.ALL);

    return view;
}

From source file:com.contralabs.inmap.fragments.LegalNoticesDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Context context = getActivity();

    ScrollView scrollView = new ScrollView(context);
    // Set up the TextView
    final TextView message = new TextView(context);
    // We'll use a spannablestring to be able to make links clickable
    final SpannableString s = new SpannableString(
            GooglePlayServicesUtil.getOpenSourceSoftwareLicenseInfo(context));

    // Set some padding
    int padding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10,
            getResources().getDisplayMetrics());
    message.setPadding(padding, padding, padding, padding);
    // Set up the final string
    message.setText(s);/*from www  .j  ava2s.  com*/
    scrollView.addView(message);
    // Now linkify the text
    Linkify.addLinks(message, Linkify.ALL);
    Linkify.addLinks(message, Pattern.compile("@([A-Za-z0-9_-]+)"), "https://twitter.com/#!/");
    return new AlertDialog.Builder(getActivity()).setTitle(R.string.legal_notices).setCancelable(true)
            .setIcon(R.drawable.ic_launcher)
            .setPositiveButton(context.getString(R.string.voltar), (OnClickListener) null).setView(scrollView)
            .create();
}

From source file:org.rm3l.ddwrt.about.AboutDialog.java

/**
 * Format text view links/*from w w w  .  j  ava 2 s .  c  o  m*/
 *
 * @param textView the text view
 * @param text     the text to set as content
 */
private static void setTextContentAndLinkify(@NotNull final TextView textView, @NotNull final String text) {
    textView.setText(Html.fromHtml(text));
    textView.setLinkTextColor(Color.WHITE);
    for (final int bitFieldToLinkify : BIT_FIELDS_TO_LINKIFY) {
        Linkify.addLinks(textView, bitFieldToLinkify);
    }
}

From source file:org.uab.deic.uabdroid.fragments.GeneralInfoFragment.java

@Override
public void onActivityCreated(Bundle _savedInstanceState) {
    super.onActivityCreated(_savedInstanceState);

    GeneralInfoActivity parentActivity = (GeneralInfoActivity) getActivity();
    GeneralInfo generalInfo = parentActivity.getGeneralinfo();

    TextView textviewGeneralInfo = (TextView) parentActivity.findViewById(R.id.generalinfo_text);
    textviewGeneralInfo.setText(Html.fromHtml(generalInfo.getDescription()), BufferType.SPANNABLE);
    Linkify.addLinks(textviewGeneralInfo, Linkify.ALL);
}

From source file:com.hctrom.romcontrol.licenseadapter.LicenseDialogoAlerta.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ThemeSelectorUtility theme = new ThemeSelectorUtility(getActivity());
    theme.onActivityCreateSetTheme(getActivity());
    final View view = inflater.inflate(R.layout.license_app, container, false);
    titulo = (TextView) view.findViewById(R.id.textViewTitulo);
    licenses = (Button) view.findViewById(R.id.imageButtonCompartir);
    buttonBack = (ActionButton) view.findViewById(R.id.boton_flotante_back);
    email = (ImageView) view.findViewById(R.id.mail);
    apache = (TextView) view.findViewById(R.id.textViewApache);
    Linkify.addLinks(apache, Linkify.WEB_URLS);
    applyBlurMaskFilter(titulo, BlurMaskFilter.Blur.OUTER);
    getDialog().setCanceledOnTouchOutside(false);
    licenses.setOnClickListener(this);
    buttonBack.setOnClickListener(new View.OnClickListener() {
        @Override//from  w  ww.  ja va 2  s .co  m
        public void onClick(View v) {
            getDialog().cancel();
        }
    });

    email.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN: {
                Drawable mDrawable = getActivity().getResources().getDrawable(R.drawable.mail);
                mDrawable.setColorFilter(new PorterDuffColorFilter(
                        getActivity().getResources().getColor(R.color.selector), PorterDuff.Mode.MULTIPLY));

                email.setAnimation(AnimationUtils.loadAnimation(getActivity(), R.anim.fab_close));
                email.invalidate();
                break;
            }
            case MotionEvent.ACTION_UP: {
                Drawable mDrawable = getActivity().getResources().getDrawable(R.drawable.mail);
                mDrawable.setColorFilter(new PorterDuffColorFilter(
                        getActivity().getResources().getColor(R.color.selector), PorterDuff.Mode.MULTIPLY));
                email.setAnimation(AnimationUtils.loadAnimation(getActivity(), R.anim.fab_open));
                email.invalidate();
                break;
            }
            }
            return false;
        }
    });

    email.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            startActivity(new Intent(getActivity(), Mail.class));
        }
    });
    return view;
}