Example usage for android.text Html FROM_HTML_MODE_LEGACY

List of usage examples for android.text Html FROM_HTML_MODE_LEGACY

Introduction

In this page you can find the example usage for android.text Html FROM_HTML_MODE_LEGACY.

Prototype

int FROM_HTML_MODE_LEGACY

To view the source code for android.text Html FROM_HTML_MODE_LEGACY.

Click Source Link

Document

Flags for #fromHtml(String,int,ImageGetter,TagHandler) : Separate block-level elements with blank lines (two newline characters) in between.

Usage

From source file:Main.java

public static Spanned fromHtml(String source) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
        return Html.fromHtml(source, Html.FROM_HTML_MODE_LEGACY);
    } else {//from  w ww  .j a  v a 2 s  . com
        return Html.fromHtml(source);
    }
}

From source file:Main.java

@SuppressWarnings("deprecation")
public static CharSequence htmlDecode(String input) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
        return Html.fromHtml(input, Html.FROM_HTML_MODE_LEGACY);
    } else {//w w w.jav  a2s  .  co m
        return Html.fromHtml(input);
    }
}

From source file:Main.java

public static Spanned fromHtml(String html) {
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N)
        return Html.fromHtml(html, Html.FROM_HTML_MODE_LEGACY);
    else/*from  ww  w.  j  a v a  2  s .c  o m*/
        return Html.fromHtml(html);
}

From source file:Main.java

@SuppressWarnings("deprecation")
public static Spanned fromHtml(String source) {
    Spanned result;/*from   w  w w . ja  v a  2 s.  c o  m*/
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
        result = Html.fromHtml(source, Html.FROM_HTML_MODE_LEGACY);
    } else {
        result = Html.fromHtml(source);
    }
    return result;
}

From source file:Main.java

@TargetApi(N)
public static Spanned fromHtml(String source) {
    if (isCompatible(N)) {
        return Html.fromHtml(source, Html.FROM_HTML_MODE_LEGACY);
    } else {/*from   w  ww  .j  av a2 s  . c om*/
        return Html.fromHtml(source);
    }
}

From source file:Main.java

@SuppressWarnings("deprecation")
public static Spanned fromHtml(String html) {
    Spanned result;/*w  ww .  j a v  a  2s.  c  om*/
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
        result = Html.fromHtml(html, Html.FROM_HTML_MODE_LEGACY);
    } else {
        result = Html.fromHtml(html);
    }
    return result;
}

From source file:Main.java

public static SpannableString textSpannable(String text) {
    SpannableString s;// w ww .  j  a  va  2 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: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(/*  www .j  av  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.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: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(//  w ww .j  a  v a 2  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.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.davidmiguel.gobees.utils.AndroidUtils.java

/**
 * Html.fromHtml wrapper supporting new and old versions.
 *
 * @param html html to parse./*w  w  w.  ja v a2s  .  co m*/
 * @return Spanned text.
 */
@SuppressWarnings("deprecation")
public static Spanned fromHtml(String html) {
    Spanned result;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
        result = Html.fromHtml(html, Html.FROM_HTML_MODE_LEGACY);
    } else {
        result = Html.fromHtml(html);
    }
    return result;
}