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:de.baumann.sieben.about.About_content.java

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

    // Add items to card

    appCardBuilder.addItem(/*from ww w . j ava 2 s  .com*/
            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.createWebViewDialogOnClickAction(c,
                    c.getString(R.string.about_changelog),
                    "https://github.com/scoute-dich/Sieben/blob/master/CHANGELOG.md", true, false))
            .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.app_ok),
                                    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)
            .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.createWebViewDialogOnClickAction(c,
                            c.getString(R.string.about_dev), "https://github.com/scoute-dich/", true, false))
                    .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("Gilles Coulais")
            .subText(R.string.about_title_ext1).icon(R.drawable.github_circle)
            .setOnClickListener(
                    ConvenienceBuilder.createWebsiteOnClickAction(c, Uri.parse("https://github.com/Djiko")))
            .build());

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

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

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

    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());

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

    convenienceCardBuilder.addItem(new MaterialAboutActionItem.Builder().text(R.string.about_license_1_title)
            .subText(R.string.about_license_1).icon(R.drawable.earth2)
            .setOnClickListener(ConvenienceBuilder.createWebViewDialogOnClickAction(c, "Workout images",
                    "http://almostfearless.com/the-21-minute-workout-or-7-minutes-if-youre-really-fit", true,
                    false))
            .build());

    convenienceCardBuilder
            .addItem(new MaterialAboutActionItem.Builder().text(R.string.about_license_2_title)
                    .subText(R.string.about_license_2).icon(R.drawable.earth2)
                    .setOnClickListener(ConvenienceBuilder.createWebViewDialogOnClickAction(c, "Whistle",
                            "http://freesound.org/people/MentalSanityOff/sounds/218318/", true, false))
                    .build());

    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("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 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.AboutActivity.java

/**
 * Creazione dell’attività.
 * //from  w w w. j a v a 2 s  .  c o  m
 * @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, AppUtils.getFullPackageName(this, false));
}

From source file:com.android.example.githubuserlist.UserDetailActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_user_detail);
    ImageView avatarImageView = (ImageView) findViewById(R.id.imageview_user_detail_avatar);
    TextView userNameTextView = (TextView) findViewById(R.id.textview_user_detail_name);
    TextView userUrlTextView = (TextView) findViewById(R.id.textview_user_detail_url);

    User user = getIntent().getParcelableExtra("user");

    Picasso.with(this).load(user.getAvatarUrl()).into(avatarImageView);
    userNameTextView.setText(getString(R.string.user_name, user.getLogin()));
    userUrlTextView.setText(getString(R.string.user_url, user.getHtmlUrl()));
    BetterLinkMovementMethod movementMethod = BetterLinkMovementMethod.linkify(Linkify.WEB_URLS,
            userUrlTextView);//from w ww.  ja v a2s  .c  om
    movementMethod.setOnLinkClickListener(new BetterLinkMovementMethod.OnLinkClickListener() {
        @Override
        public boolean onClick(TextView textView, String url) {
            getCustomTabIntentInstance().launchUrl(UserDetailActivity.this, Uri.parse(url));
            return true;
        }
    });
}

From source file:com.nineducks.hereader.HackfulReaderActivity.java

@Override
protected Dialog onCreateDialog(int id) {
    Dialog result = null;/*  w  w w.  ja  v a  2 s.  co  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: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;//from   w  w w  .ja v  a  2s.  c o  m
    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);//from   ww  w.ja va 2 s .com

    return rootView;
}

From source file:org.firebears.scouting2846.TeamDetailFragment.java

private void onTeamLoaded(Cursor c) {
    if (c == null) {
        Log.d(TAG, "team not found");
        Activity a = getActivity();/*from   w w w. j a  va  2s.c  o  m*/
        if (a != null) {
            Intent intent = new Intent();
            intent.putExtra(TeamListActivity.ERROR_CODE, R.string.invalid_number);
            a.setResult(Activity.RESULT_CANCELED, intent);
            a.finish();
        }
        return;
    }
    Log.d(TAG, "team loaded");
    if (null == root_view)
        return;
    Toolbar bar = (Toolbar) getActivity().findViewById(R.id.detail_toolbar);
    if (bar != null) {
        int team_num = c.getInt(c.getColumnIndex(Team.COL_TEAM_NUMBER));
        String nick = c.getString(c.getColumnIndex(Team.COL_NICKNAME));
        bar.setTitle("" + team_num + ' ' + nick);
    }
    setViewText(R.id.locality, c, Team.COL_LOCALITY);
    setViewText(R.id.region, c, Team.COL_REGION);
    setViewText(R.id.country, c, Team.COL_COUNTRY);
    TextView tv = setViewText(R.id.team_website, c, Team.COL_WEBSITE);
    Linkify.addLinks(tv, Linkify.WEB_URLS);
    tv = (TextView) root_view.findViewById(R.id.team_rookie_year);
    String t = c.getString(c.getColumnIndex(Team.COL_ROOKIE_YEAR));
    if (t != null)
        tv.setText(getText(R.string.rookie_year) + " " + t);
    initScoutingSpinner();
    setViewText(R.id.team_motto, c, Team.COL_MOTTO);
}

From source file:info.icefilms.icestream.HelpFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    // Call the base class method
    super.onActivityCreated(savedInstanceState);

    // Get the contact and about views
    TextView support = (TextView) getActivity().findViewById(R.id.support);
    TextView about = (TextView) getActivity().findViewById(R.id.about);

    // Linkify the support view
    Linkify.addLinks(support, Pattern.compile("(Ice Stream Support Thread)"), "", null, new TransformFilter() {
        public String transformUrl(Matcher match, String url) {
            // Return the proper link
            return "http://forum.icefilms.info/viewtopic.php?t=58350";
        }//from  www.  j  av a2s .c o  m
    });

    // Get the version information
    String version;
    try {
        version = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(),
                PackageManager.GET_META_DATA).versionName;
    } catch (PackageManager.NameNotFoundException exception) {
        version = "?.?.?";
    }

    // Format the about text with the correct info and add it to the view
    about.setText(String.format(getString(R.string.help_about), getString(R.string.app_name), version));

    // Linkify the about view
    Linkify.addLinks(about, Linkify.WEB_URLS);
}

From source file:com.avapira.bobroreader.hanabira.HanabiraParser.java

public HanabiraParser(HanabiraPost post) {
    Context context = Hanabira.getFlower();
    if (!contextInitCompleted) {
        bulletMarginPerLevel = Utils.convertDpToPx(context.getApplicationContext(), 12);
        spoilerHiddenColor = context.getColor(R.color.dobro_dark);
        spoilerShownColor = context.getColor(R.color.dobro_primary_text);
        refLinkColor = context.getColor(R.color.dobro_ref_text);
        quoteColor = context.getColor(R.color.dobro_quote);
        showSpoilers = PreferenceManager.getDefaultSharedPreferences(context).getBoolean("show_spoilers",
                false);/* ww  w. ja v a  2  s. c o m*/
        contextInitCompleted = true;
    }
    this.post = post;
    builder = new SpannableStringBuilder(replaceInternalLinkWithReference(post.getMessage()));
    Linkify.addLinks(builder, Linkify.WEB_URLS);
}

From source file:com.facebook.android.GraphExplorer.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mHandler = new Handler();

    setContentView(R.layout.graph_explorer);

    url = BASE_GRAPH_URL; // Base URL

    mInputId = (EditText) findViewById(R.id.inputId);
    mOutput = (TextView) findViewById(R.id.output);
    mSubmitButton = (Button) findViewById(R.id.submitButton);
    mViewURLButton = (Button) findViewById(R.id.viewURLButton);
    mGetPermissionsButton = (Button) findViewById(R.id.accessTokenButton);
    mFieldsConnectionsButton = (Button) findViewById(R.id.fieldsAndConnectionsButton);
    mBackParentButton = (Button) findViewById(R.id.backParentButton);

    mScrollView = (ScrollView) findViewById(R.id.ScrollView01);

    mTextDeleteButton = (Button) findViewById(R.id.textDeleteButton);
    mMeButton = (Button) findViewById(R.id.meButton);
    if (Utility.mFacebook.isSessionValid()) {
        mMeButton.setVisibility(View.VISIBLE);
    }/*ww w.j  a va 2  s . co  m*/

    params = new Bundle();
    mSubmitButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {

            ((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE))
                    .hideSoftInputFromWindow(mInputId.getWindowToken(), 0);

            // Prepare the URL to be shown on 'View URL' click action. This
            // is not used by the SDK
            url = BASE_GRAPH_URL; // Base URL

            /*
             * Source Tag: graph_explorer
             */
            rootString = mInputId.getText().toString();
            if (!TextUtils.isEmpty(rootString)) {
                dialog = ProgressDialog.show(GraphExplorer.this, "", getString(R.string.please_wait), true,
                        true);
                params.putString("metadata", "1");
                Utility.mAsyncRunner.request(rootString, params, new graphApiRequestListener());
                url += "/" + rootString; // Relative Path provided by you
            }

        }
    });

    mViewURLButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            setText(url);
            Linkify.addLinks(mOutput, Linkify.WEB_URLS);
        }
    });

    mGetPermissionsButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (Utility.mFacebook.isSessionValid()) {
                dialog = ProgressDialog.show(GraphExplorer.this, "",
                        getString(R.string.fetching_current_permissions), true, true);
                Bundle params = new Bundle();
                params.putString("access_token", Utility.mFacebook.getAccessToken());
                Utility.mAsyncRunner.request("me/permissions", params, new permissionsRequestListener());
            } else {
                new PermissionsDialog(GraphExplorer.this).show();
            }
        }
    });

    mFieldsConnectionsButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (metadataObject == null) {
                makeToast("No fields, connections availalbe for this object.");
            } else {
                new FieldsConnectionsDialog(GraphExplorer.this, metadataObject).show();
            }
        }
    });

    mTextDeleteButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            url = BASE_GRAPH_URL; // Base URL
            mParentObjectId = "";
            mInputId.setText("");
            params.clear();
            metadataObject = null;
            setText("");
            mBackParentButton.setVisibility(View.INVISIBLE);
        }
    });

    mMeButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            mInputId.setText("me");
            mSubmitButton.performClick();
        }
    });

    mBackParentButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            mInputId.setText(mParentObjectId);
            mParentObjectId = "";
            mSubmitButton.performClick();
        }
    });
}