Example usage for android.text.util Linkify WEB_URLS

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

Introduction

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

Prototype

int WEB_URLS

To view the source code for android.text.util Linkify WEB_URLS.

Click Source Link

Document

Bit field indicating that web URLs should be matched in methods that take an options mask

Usage

From source file:Main.java

public static SpannableString textSpannable(String text) {
    SpannableString s;//from   w  ww .j  av a 2  s .  co m

    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);//from ww  w .  ja  v 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   ww w  .  j ava2  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. jav a  2 s  . c  om*/
        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.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 w  w .j a  v  a  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;
}

From source file:com.moubry.worthwatching.ui.BaseActivity.java

public static AlertDialog createWhatsNewAlert(Context context) {
    final TextView message = new TextView(context);
    final SpannableString s = new SpannableString(context.getText(R.string.whats_new_message));
    Linkify.addLinks(s, Linkify.WEB_URLS);
    message.setPadding(10, 10, 10, 10);/*  w  ww. j  ava  2  s  . c o  m*/
    message.setText(s);
    message.setLinkTextColor(context.getResources().getColor(R.color.blue));
    message.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
    message.setMovementMethod(LinkMovementMethod.getInstance());

    return new AlertDialog.Builder(context).setTitle(R.string.title_whats_new).setCancelable(true)
            .setPositiveButton("OK", null).setView(message).create();
}

From source file:im.getsocial.testapp.ui.UserInfoDialog.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);

    GetSocial getSocial = GetSocial.getInstance();
    CurrentUser user = getSocial.getCurrentUser();

    View view = inflater.inflate(R.layout.fragment_detailed_user_info, container);

    UserInfoView userInfoView = (UserInfoView) view.findViewById(R.id.detailedUserInfo_userInfo);
    userInfoView.setUser(user);/*w  ww .  ja v a 2 s.  co  m*/

    TextView detailsTextView = (TextView) view.findViewById(R.id.detailedUserInfo_detailedInfo);
    detailsTextView.setText(getUserInfo(user));
    Linkify.addLinks(detailsTextView, Linkify.WEB_URLS);

    Button closeButton = (Button) view.findViewById(R.id.detailedUserInfo_closeButton);
    closeButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            UserInfoDialog.this.dismiss();
        }
    });

    return view;
}

From source file:it.scoppelletti.mobilepower.app.HelpActivity.java

/**
 * Creazione dell’attività.
 * //w  w w  .  j  a  va  2s.com
 * @param savedInstanceState Stato dell’istanza.
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    TextView textControl;
    MarketTagHandler tagHandler;

    super.onCreate(savedInstanceState);

    setTheme(AppUtils.getActivityTheme());
    setContentView(R.layout.textview);

    textControl = (TextView) findViewById(R.id.txt_content);
    textControl.setKeyListener(null);
    textControl.setAutoLinkMask(Linkify.EMAIL_ADDRESSES | Linkify.WEB_URLS);

    tagHandler = new MarketTagHandler();
    textControl.setText(Html.fromHtml(buildText(), null, tagHandler));
    tagHandler.addLinks(textControl, myFullPkgName);
}

From source file:de.baumann.quitsmoking.about.About_content.java

static MaterialAboutList createMaterialAboutList(final Context c) {
    MaterialAboutCard.Builder appCardBuilder = new MaterialAboutCard.Builder();

    // Add items to card

    appCardBuilder.addItem(/*  w  w  w .j a  va2 s.  c o m*/
            new MaterialAboutTitleItem.Builder().text(R.string.app_name).icon(R.mipmap.ic_launcher).build());

    try {

        appCardBuilder.addItem(ConvenienceBuilder.createVersionActionItem(c,
                ContextCompat.getDrawable(c, R.drawable.earth2), "Version", false));

    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
    }

    appCardBuilder
            .addItem(new MaterialAboutActionItem.Builder().text(R.string.about_changelog)
                    .subText(R.string.about_changelog_summary).icon(R.drawable.format_list_bulleted)
                    .setOnClickListener(ConvenienceBuilder.createWebsiteOnClickAction(c,
                            Uri.parse("https://github.com/scoute-dich/QuitSmoking/blob/master/CHANGELOG.md")))
                    .build());

    appCardBuilder.addItem(new MaterialAboutActionItem.Builder().text(R.string.about_license)
            .subText(R.string.about_license_summary).icon(R.drawable.copyright)
            .setOnClickListener(new MaterialAboutActionItem.OnClickListener() {
                @Override
                public void onClick() {
                    SpannableString s;

                    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
                        s = new SpannableString(
                                Html.fromHtml(c.getString(R.string.about_text), Html.FROM_HTML_MODE_LEGACY));
                    } else {
                        //noinspection deprecation
                        s = new SpannableString(Html.fromHtml(c.getString(R.string.about_text)));
                    }

                    Linkify.addLinks(s, Linkify.WEB_URLS);

                    final AlertDialog d = new AlertDialog.Builder(c).setTitle(R.string.about_title)
                            .setMessage(s).setPositiveButton(c.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());
                }
            }).build());

    appCardBuilder.addItem(new MaterialAboutActionItem.Builder().text(R.string.about_intro)
            .subText(R.string.about_intro_summary).icon(R.drawable.information_outline_dark)
            .setOnClickListener(new MaterialAboutActionItem.OnClickListener() {
                @Override
                public void onClick() {
                    Intent intent = new Intent(c, Activity_intro.class);
                    intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
                    c.startActivity(intent);
                }
            }).build());

    MaterialAboutCard.Builder authorCardBuilder = new MaterialAboutCard.Builder();
    authorCardBuilder.title(R.string.about_title_dev);

    authorCardBuilder.addItem(
            new MaterialAboutActionItem.Builder().text(R.string.about_dev).subText(R.string.about_dev_summary)
                    .icon(R.drawable.gaukler_faun).setOnClickListener(ConvenienceBuilder
                            .createWebsiteOnClickAction(c, Uri.parse("https://github.com/scoute-dich/")))
                    .build());

    authorCardBuilder.addItem(new MaterialAboutActionItem.Builder().text(R.string.about_donate)
            .subText(R.string.about_donate_summary).icon(R.drawable.coin)
            .setOnClickListener(ConvenienceBuilder.createWebsiteOnClickAction(c, Uri.parse(
                    "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=NP6TGYDYP9SHY")))
            .build());

    MaterialAboutCard.Builder authorCardBuilder2 = new MaterialAboutCard.Builder();
    authorCardBuilder2.title(R.string.about_title_ext);

    authorCardBuilder2.addItem(new MaterialAboutActionItem.Builder().text("Neofaum")
            .subText(R.string.about_title_ext3).icon(R.drawable.github_circle)
            .setOnClickListener(
                    ConvenienceBuilder.createWebsiteOnClickAction(c, Uri.parse("https://github.com/naofum")))
            .build());

    authorCardBuilder2.addItem(new MaterialAboutActionItem.Builder().text("Primokorn")
            .subText(R.string.about_title_ext4).icon(R.drawable.github_circle)
            .setOnClickListener(
                    ConvenienceBuilder.createWebsiteOnClickAction(c, Uri.parse("https://github.com/Primokorn")))
            .build());

    MaterialAboutCard.Builder convenienceCardBuilder = new MaterialAboutCard.Builder();
    convenienceCardBuilder.title(R.string.about_title_libs);

    convenienceCardBuilder
            .addItem(new MaterialAboutActionItem.Builder().text("Android Onboarder")
                    .subText(R.string.about_license_3).icon(R.drawable.github_circle)
                    .setOnClickListener(ConvenienceBuilder.createWebViewDialogOnClickAction(c,
                            "Android Onboarder", "https://github.com/chyrta/AndroidOnboarder", true, false))
                    .build());

    convenienceCardBuilder.addItem(new MaterialAboutActionItem.Builder().text("Glide")
            .subText(R.string.about_license_9).icon(R.drawable.github_circle)
            .setOnClickListener(ConvenienceBuilder.createWebViewDialogOnClickAction(c, "Glide",
                    "https://github.com/bumptech/glide", true, false))
            .build());

    convenienceCardBuilder
            .addItem(
                    new MaterialAboutActionItem.Builder().text("Image Picker").subText(R.string.about_license_1)
                            .icon(R.drawable.github_circle)
                            .setOnClickListener(ConvenienceBuilder.createWebViewDialogOnClickAction(c,
                                    "Image Picker", "https://github.com/Mariovc/ImagePicker", true, false))
                            .build());

    convenienceCardBuilder.addItem(new MaterialAboutActionItem.Builder().text("Material About Library")
            .subText(R.string.about_license_7).icon(R.drawable.github_circle)
            .setOnClickListener(ConvenienceBuilder.createWebViewDialogOnClickAction(c, "Material About Library",
                    "https://github.com/daniel-stoneuk/material-about-library", true, false))
            .build());

    convenienceCardBuilder.addItem(new MaterialAboutActionItem.Builder().text("Material Date Time Picker")
            .subText(R.string.about_license_2).icon(R.drawable.github_circle)
            .setOnClickListener(
                    ConvenienceBuilder.createWebViewDialogOnClickAction(c, "Material Date Time Picker",
                            "https://github.com/wdullaer/MaterialDateTimePicker", true, false))
            .build());

    convenienceCardBuilder.addItem(new MaterialAboutActionItem.Builder().text("Material Design Icons")
            .subText(R.string.about_license_8).icon(R.drawable.github_circle)
            .setOnClickListener(ConvenienceBuilder.createWebViewDialogOnClickAction(c, "Material Design Icons",
                    "https://github.com/Templarian/MaterialDesign", true, false))
            .build());

    return new MaterialAboutList(appCardBuilder.build(), authorCardBuilder.build(), authorCardBuilder2.build(),
            convenienceCardBuilder.build());
}

From source file:it.scoppelletti.mobilepower.app.ReleaseNoteActivity.java

/**
 * Creazione dell’attività.
 * // w ww . ja  v a2  s.c om
 * @param savedInstanceState Stato dell’istanza.
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    String notes;
    TextView textControl;
    Button button;
    MarketTagHandler tagHandler;

    super.onCreate(savedInstanceState);

    setTheme(AppUtils.getActivityTheme());
    setContentView(R.layout.releasenotes);

    textControl = (TextView) findViewById(R.id.txt_content);
    textControl.setKeyListener(null);
    textControl.setAutoLinkMask(Linkify.EMAIL_ADDRESSES | Linkify.WEB_URLS);

    notes = getIntent().getStringExtra(ReleaseNoteActivity.EXTRA_RELEASENOTES);
    if (!StringUtils.isBlank(notes)) {
        tagHandler = new MarketTagHandler();
        textControl.setText(Html.fromHtml(notes, null, tagHandler));
        tagHandler.addLinks(textControl, AppUtils.getFullPackageName(this, false));
    }

    button = (Button) findViewById(R.id.cmd_continue);
    button.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            finish();
        }
    });
}