Example usage for android.text.method LinkMovementMethod getInstance

List of usage examples for android.text.method LinkMovementMethod getInstance

Introduction

In this page you can find the example usage for android.text.method LinkMovementMethod getInstance.

Prototype

public static MovementMethod getInstance() 

Source Link

Usage

From source file:org.iisgcp.waterwalk.utils.LicenseDialog.java

@Override
public void onStart() {
    super.onStart();
    // Make the textview clickable. Must be called after show()
    TextView message = (TextView) mDialog.findViewById(android.R.id.message);
    message.setMovementMethod(LinkMovementMethod.getInstance());
    message.setContentDescription(Html.fromHtml(mDialogText).toString());
}

From source file:com.yek.keyboard.ui.settings.AboutAnySoftKeyboardFragment.java

@Override
public void onViewStateRestored(Bundle savedInstanceState) {
    super.onViewStateRestored(savedInstanceState);
    TextView additionalSoftware = (TextView) getView().findViewById(R.id.about_legal_stuff_link);
    SpannableStringBuilder sb = new SpannableStringBuilder(additionalSoftware.getText());
    sb.clearSpans();//removing any previously (from instance-state) set click spans.
    sb.setSpan(new ClickableSpan() {
        @Override/*w ww. j  ava2s .  c o m*/
        public void onClick(View widget) {
            FragmentChauffeurActivity activity = (FragmentChauffeurActivity) getActivity();
            activity.addFragmentToUi(new AdditionalSoftwareLicensesFragment(),
                    TransitionExperiences.DEEPER_EXPERIENCE_TRANSITION);
        }
    }, 0, additionalSoftware.getText().length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
    additionalSoftware.setMovementMethod(LinkMovementMethod.getInstance());
    additionalSoftware.setText(sb);
}

From source file:org.catrobat.paintroid.dialog.DialogAbout.java

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override//from  w ww . ja va2  s  .  co  m
public Dialog onCreateDialog(Bundle savedInstanceState) {
    LayoutInflater inflater = getActivity().getLayoutInflater();
    AlertDialog.Builder builder;
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
        builder = new AlertDialog.Builder(getActivity());
    } else {
        builder = new AlertDialog.Builder(getActivity(), AlertDialog.THEME_HOLO_DARK);
    }

    builder.setTitle(R.string.about_title);
    View view = inflater.inflate(R.layout.dialog_about, null);

    TextView aboutVersionNameTextView = (TextView) view.findViewById(R.id.dialog_about_version_name_text_view);
    String versionName = PaintroidApplication.getVersionName(getActivity());
    aboutVersionNameTextView.setText(R.string.about_version);
    aboutVersionNameTextView.append(" " + versionName);

    TextView aboutTextView = (TextView) view.findViewById(R.id.about_tview_Text);
    String aboutText = String.format(getActivity().getString(R.string.about_content),
            getActivity().getString(R.string.licence_type_paintroid));
    aboutTextView.setText(aboutText);

    TextView aboutUrlTextView = (TextView) view.findViewById(R.id.about_tview_Url);
    aboutUrlTextView.setMovementMethod(LinkMovementMethod.getInstance());
    Resources resources = getActivity().getResources();
    String paintroidLicence = String.format(resources.getString(R.string.about_link_template),
            resources.getString(R.string.license_url), resources.getString(R.string.about_licence_url_text));
    aboutUrlTextView.append(Html.fromHtml(paintroidLicence));
    aboutUrlTextView.append("\n\n");
    String aboutCatroid = String.format(resources.getString(R.string.about_link_template),
            resources.getString(R.string.catroid_url), resources.getString(R.string.about_catroid_url_text));
    aboutUrlTextView.append(Html.fromHtml(aboutCatroid));
    aboutUrlTextView.append("\n");

    builder.setView(view);
    builder.setNeutralButton(R.string.done, this);

    return builder.create();

}

From source file:org.catrobat.catroid.ui.dialogs.TermsOfUseDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle bundle) {
    Bundle fragmentDialogArguments = getArguments();
    boolean acceptTermsOfUse = false;
    if (fragmentDialogArguments != null) {
        acceptTermsOfUse = fragmentDialogArguments.getBoolean(DIALOG_ARGUMENT_TERMS_OF_USE_ACCEPT, false);
    }//from w  w w .  ja  v a 2  s . co m

    View view = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_terms_of_use, null);

    final CheckBox checkBoxTermsOfUseAcceptedPermanently = (CheckBox) view
            .findViewById(R.id.dialog_terms_of_use_check_box_agree_permanently);

    TextView termsOfUseUrlTextView = (TextView) view.findViewById(R.id.dialog_terms_of_use_text_view_url);
    termsOfUseUrlTextView.setMovementMethod(LinkMovementMethod.getInstance());

    String termsOfUseUrl = getString(R.string.terms_of_use_link_template, Constants.CATROBAT_TERMS_OF_USE_URL,
            getString(R.string.dialog_terms_of_use_link_text));

    termsOfUseUrlTextView.setText(Html.fromHtml(termsOfUseUrl));

    AlertDialog.Builder termsOfUseDialogBuilder = new AlertDialog.Builder(getActivity()).setView(view)
            .setTitle(R.string.dialog_terms_of_use_title);

    if (!acceptTermsOfUse) {
        termsOfUseDialogBuilder.setNeutralButton(R.string.ok, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int id) {
                dialog.cancel();
            }
        });
    } else {
        termsOfUseDialogBuilder.setNegativeButton(R.string.dialog_terms_of_use_do_not_agree,
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int id) {
                        getActivity().finish();
                        dialog.dismiss();
                    }
                });
        termsOfUseDialogBuilder.setPositiveButton(R.string.dialog_terms_of_use_agree,
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int id) {
                        if (checkBoxTermsOfUseAcceptedPermanently.isChecked()) {
                            SettingsActivity.setTermsOfServiceAgreedPermanently(getActivity(), true);
                        }
                        dialog.dismiss();
                        DroneInitializer droneInitializer = ((PreStageActivity) getActivity())
                                .getDroneInitializer();
                        if (droneInitializer != null) {
                            droneInitializer.initialiseDrone();
                        }
                    }
                });
        termsOfUseDialogBuilder.setOnKeyListener(new OnKeyListener() {
            @Override
            public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
                Log.d(TAG, "prevent canceling the dialog with back button");
                return true;
            }
        });

        checkBoxTermsOfUseAcceptedPermanently.setVisibility(CheckBox.VISIBLE);
        checkBoxTermsOfUseAcceptedPermanently.setText(R.string.dialog_terms_of_use_agree_permanent);
        termsOfUseDialogBuilder.setCancelable(false);
    }

    AlertDialog termsOfUseDialog = termsOfUseDialogBuilder.create();
    if (!acceptTermsOfUse) {
        termsOfUseDialog.setCanceledOnTouchOutside(true);
    } else {
        termsOfUseDialog.setCancelable(false);
        termsOfUseDialog.setCanceledOnTouchOutside(false);
    }

    return termsOfUseDialog;
}

From source file:com.pocketsoap.convodroid.AuthorMessageFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.author, container, false);
    sendButton = (Button) v.findViewById(R.id.send_button);
    sendButton.setOnClickListener(this);
    sendButton.setEnabled(false);/*from  w w w . j  a  v a 2  s  .  c  o  m*/
    recipientText = (AutoCompleteTextView) v.findViewById(R.id.recipient_name);
    recipientText.setEnabled(false);
    recipientText.addTextChangedListener(new CompletionTextWatcher());
    recipients = (TextView) v.findViewById(R.id.recipients);
    recipients.setMovementMethod(LinkMovementMethod.getInstance());
    messageText = (EditText) v.findViewById(R.id.msg_body);
    messageText.addTextChangedListener(new EnablingTextWatcher());
    return v;
}

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   w w w .ja  v a2 s  . co 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.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:com.android.leanlauncher.SettingsActivity.java

private void displayAboutDialog() {
    findPreference(getString(R.string.pref_about))
            .setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
                @Override// w  w w  .  j a v  a2s. c  om
                public boolean onPreferenceClick(Preference preference) {
                    String about = String.format(getString(R.string.about_application),
                            BuildConfig.VERSION_NAME);

                    AlertDialog d = new AlertDialog.Builder(SettingsActivity.this)
                            .setIcon(R.mipmap.ic_launcher_home).setCancelable(true)
                            .setTitle(R.string.application_name).setMessage(Html.fromHtml(about)).create();
                    d.show();
                    ((TextView) d.findViewById(android.R.id.message))
                            .setMovementMethod(LinkMovementMethod.getInstance());

                    return false;
                }
            });
}

From source file:org.thbz.hanguldrill.HelpDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Activity activity = getActivity();/*from ww w  . j  a  va2s  .  co  m*/

    AlertDialog.Builder builder = new AlertDialog.Builder(activity);

    // Initialiser le texte de l'aide  partir d'un fichier inclu dans l'APK
    StringBuilder htmlHelpText = new StringBuilder();
    try {
        BufferedReader in = new BufferedReader(
                new InputStreamReader(activity.getAssets().open("help_contents.html")));
        String line;
        int state = 0;
        while ((line = in.readLine()) != null) {
            if (line.contains("<!-- START APP CONTENTS -->"))
                state = 1;
            else if (state == 1) {
                if (line.contains("<!-- END APP CONTENTS -->"))
                    state = 2;
                else
                    htmlHelpText.append(line);
            }
        }
    } catch (IOException exc) {
        htmlHelpText.setLength(0);
        htmlHelpText.append("Help is not available (").append(exc.getMessage()).append(")");
    }

    LayoutInflater inflater = activity.getLayoutInflater();
    View dialogView = inflater.inflate(R.layout.dialog_help, null);
    TextView helpTextView = (TextView) dialogView.findViewById(R.id.dialog_help_text);
    helpTextView.setText(Html.fromHtml(htmlHelpText.toString()));

    // Allow for external hyperlinks in the HTML text
    helpTextView.setMovementMethod(LinkMovementMethod.getInstance());

    // Inflate and set the layout for the dialog
    // Pass null as the parent view because its going in the dialog layout
    builder.setView(dialogView)
            // Add action buttons
            .setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int id) {
                }
            });

    return builder.create();
}

From source file:com.btmura.android.reddit.app.MarkdownTableFragment.java

private void populateTable(final View view, final LayoutInflater inflater) {
    final TableLayout table = (TableLayout) view.findViewById(R.id.table);
    MarkdownTableScanner.scan(getTableDataExtra(), new OnTableScanListener<TableRow>() {
        @Override//from ww w. j a  v  a2s .  c o  m
        public TableRow onRowStart() {
            return new TableRow(getActivity());
        }

        @Override
        public void onCell(TableRow container, Cell cell) {
            int layout = cell.isHeader ? R.layout.markdown_table_cell_header : R.layout.markdown_table_cell;

            TextView tv = (TextView) inflater.inflate(layout, container, false);
            tv.setGravity(cell.gravity);
            tv.setMovementMethod(LinkMovementMethod.getInstance());
            tv.setText(formatter.formatAll(getActivity(), cell.contents));
            container.addView(tv);

            table.setColumnShrinkable(cell.column, true);
            table.setColumnStretchable(cell.column, true);
        }

        @Override
        public void onRowEnd(TableRow row) {
            table.addView(row);
        }
    });
}

From source file:com.manning.androidhacks.hack004.preference.AboutDialog.java

@Override
protected View onCreateDialogView() {
    LinearLayout layout = new LinearLayout(mContext);
    layout.setOrientation(LinearLayout.VERTICAL);
    TextView splashText = new TextView(mContext);
    String fmt = "Version %s<br />" + "<a href=\"http://manning.com/sessa\">MoreInfo</a>";
    try {/*from  w  w  w  .  j  av  a2s . co  m*/
        String pkg = mContext.getPackageName();
        mVersionNumber = mContext.getPackageManager().getPackageInfo(pkg, 0).versionName;
    } catch (NameNotFoundException e) {
        e.printStackTrace();
    }

    if (mVersionNumber != null) {
        String aboutMsg = String.format(fmt, mVersionNumber);
        splashText.setText(Html.fromHtml(aboutMsg));
        splashText.setMovementMethod(LinkMovementMethod.getInstance());
    }

    layout.addView(splashText);

    return layout;
}