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:de.baumann.thema.FragmentWallpaper.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    int id = item.getItemId();

    if (id == R.id.color) {
        ColorPickerDialogBuilder.with(getActivity()).initialColor(0xff2196f3).setTitle(R.string.custom)
                .wheelType(ColorPickerView.WHEEL_TYPE.FLOWER).density(9)
                .setPositiveButton(R.string.yes, new ColorPickerClickListener() {
                    @Override//from  w  ww .j  av a 2s .c  om
                    public void onClick(DialogInterface dialog, int selectedColor, Integer[] allColors) {
                        try {
                            WallpaperManager wm = WallpaperManager.getInstance(getActivity());
                            // Create 1x1 bitmap to store the color
                            Bitmap bmp = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888);
                            // Make a canvas with which we can draw to the bitmap
                            Canvas canvas = new Canvas(bmp);
                            // Fill with color and save
                            canvas.drawColor(selectedColor);
                            canvas.save();

                            wm.setBitmap(bmp);
                            bmp.recycle();
                            Snackbar.make(imgHeader, R.string.applying, Snackbar.LENGTH_LONG).show();
                        } catch (IOException e) {
                            // oh lord!
                        }
                    }
                }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                    }
                }).build().show();
        return false;
    }

    if (id == R.id.help) {

        SpannableString s;

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

        final AlertDialog.Builder dialog = new AlertDialog.Builder(getActivity())
                .setTitle(R.string.title_wallpaper).setMessage(s)
                .setPositiveButton(getString(R.string.yes), null);
        dialog.show();

        return false;
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.gammalabs.wifianalyzer.MainActivity.java

@SuppressWarnings("deprecation")
@NonNull/* w w w. j ava  2s .c  om*/
Spanned fromHtml(@NonNull String subtitleText) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
        return Html.fromHtml(subtitleText, Html.FROM_HTML_MODE_LEGACY);
    }
    return Html.fromHtml(subtitleText);
}

From source file:de.baumann.thema.Screen_Main.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();

    if (id == R.id.license) {

        SpannableString s;/*  ww  w.j  a  va 2s . c  o  m*/

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

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

    if (id == R.id.changelog) {
        Uri uri = Uri.parse("https://github.com/scoute-dich/Blue-Minimal/blob/master/CHANGELOG.md"); // missing 'http://' will cause crashed
        Intent intent = new Intent(Intent.ACTION_VIEW, uri);
        startActivity(intent);
    }

    if (id == R.id.donate) {
        Uri uri = Uri
                .parse("https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=NP6TGYDYP9SHY"); // missing 'http://' will cause crashed
        Intent intent = new Intent(Intent.ACTION_VIEW, uri);
        startActivity(intent);
    }

    return super.onOptionsItemSelected(item);
}

From source file:com.adkdevelopment.earthquakesurvival.utils.Utilities.java

/**
 * Makes text version of an html string.
 *
 * @param input informatted html text./*from   w  w w. java2  s  . co m*/
 * @return only formatted text from html input.
 */
public static Spanned getHtmlText(String input) {
    Spanned result;

    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
        result = Html.fromHtml(input, Html.FROM_HTML_MODE_LEGACY);
    } else {
        //noinspection deprecation
        result = Html.fromHtml(input);
    }

    return result;
}

From source file:net.fabiszewski.ulogger.MainActivity.java

/**
 * Display About dialog/*w  w w. ja va2s. c  o m*/
 */
private void showAbout() {
    @SuppressLint("InflateParams")
    View view = getLayoutInflater().inflate(R.layout.about, null, false);
    AlertDialog alertDialog = new AlertDialog.Builder(MainActivity.this).create();
    alertDialog.setTitle(getString(R.string.app_name));
    alertDialog.setView(view);
    alertDialog.setIcon(R.drawable.ic_ulogger_logo_24dp);
    alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, getString(R.string.ok),
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });
    alertDialog.show();
    final TextView versionLabel = (TextView) alertDialog.findViewById(R.id.about_version);
    versionLabel.setText(getString(R.string.about_version, BuildConfig.VERSION_NAME));
    final TextView descriptionLabel = (TextView) alertDialog.findViewById(R.id.about_description);
    final TextView description2Label = (TextView) alertDialog.findViewById(R.id.about_description2);
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
        descriptionLabel.setText(fromHtmlDepreciated(getString(R.string.about_description)));
        description2Label.setText(fromHtmlDepreciated(getString(R.string.about_description2)));
    } else {
        descriptionLabel.setText(
                Html.fromHtml(getString(R.string.about_description), android.text.Html.FROM_HTML_MODE_LEGACY));
        description2Label.setText(
                Html.fromHtml(getString(R.string.about_description2), android.text.Html.FROM_HTML_MODE_LEGACY));
    }
}

From source file:de.baumann.thema.FragmentSound.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    switch (item.getItemId()) {
    case R.id.help:
        SpannableString s;/*w  ww .  java  2s . c o m*/

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

        final AlertDialog.Builder dialog = new AlertDialog.Builder(getActivity()).setTitle(R.string.sound)
                .setMessage(s).setPositiveButton(getString(R.string.yes), null);
        dialog.show();
        return true;
    }
    return super.onOptionsItemSelected(item);
}

From source file:net.inbox.InboxMessage.java

private void html_text(String html_txt) {
    Spanned spn;/*from  w  w  w  .  jav a  2s.  co m*/
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
        spn = Html.fromHtml(html_txt, Html.FROM_HTML_MODE_LEGACY);
    } else {
        spn = Html.fromHtml(html_txt);
    }
    tv_contents.setText(spn);
}

From source file:net.gsantner.opoc.util.ContextUtils.java

/**
 * Convert a html string to an android {@link Spanned} object
 *//*w  ww . ja v a2  s.com*/
public Spanned htmlToSpanned(String html) {
    Spanned result;
    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:com.forrestguice.suntimeswidget.SuntimesUtils.java

/**
 * @param htmlString html markup/*from w  ww.j a  v  a 2 s .c o  m*/
 * @return an html span
 */
@SuppressWarnings("deprecation")
public static Spanned fromHtml(String htmlString) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
        return Html.fromHtml(htmlString, Html.FROM_HTML_MODE_LEGACY);
    else
        return Html.fromHtml(htmlString);
}

From source file:org.mdc.chess.MDChess.java

private void updateThinkingInfo() {
    boolean thinkingEmpty = true;
    {//from w ww  . jav  a2s .  com
        String s = "";
        if (mShowThinking || gameMode.analysisMode()) {
            s = thinkingStr1;
            if (s.length() > 0)
                thinkingEmpty = false;
            if (mShowStats) {
                if (!thinkingEmpty) {
                    s += "\n";
                }
                s += thinkingStr2;
                if (s.length() > 0)
                    thinkingEmpty = false;
            }
        }
        thinking.setText(s, TextView.BufferType.SPANNABLE);
    }
    if (mShowBookHints && (bookInfoStr.length() > 0)) {
        String s = "";
        if (!thinkingEmpty) {
            s += "<br>";
        }
        s += Util.boldStart + getString(R.string.book) + Util.boldStop + bookInfoStr;
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
            thinking.append(Html.fromHtml(s, Html.FROM_HTML_MODE_LEGACY));
        } else {
            //noinspection deprecation
            thinking.append(Html.fromHtml(s));
        }

        thinkingEmpty = false;
    }
    if (showVariationLine && (variantStr.indexOf(' ') >= 0)) {
        String s = "";
        if (!thinkingEmpty) {
            s += "<br>";
        }
        s += Util.boldStart + getString(R.string.variation) + Util.boldStop + variantStr;
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
            thinking.append(Html.fromHtml(s, Html.FROM_HTML_MODE_LEGACY));
        } else {
            //noinspection deprecation
            thinking.append(Html.fromHtml(s));
        }
        thinkingEmpty = false;
    }
    thinking.setVisibility(thinkingEmpty ? View.GONE : View.VISIBLE);

    List<Move> hints = null;
    if (mShowThinking || gameMode.analysisMode()) {
        ArrayList<ArrayList<Move>> pvMovesTmp = pvMoves;
        if (pvMovesTmp.size() == 1) {
            hints = pvMovesTmp.get(0);
        } else if (pvMovesTmp.size() > 1) {
            hints = new ArrayList<>();
            for (ArrayList<Move> pv : pvMovesTmp) {
                if (!pv.isEmpty()) {
                    hints.add(pv.get(0));
                }
            }
        }
    }
    if ((hints == null) && mShowBookHints) {
        hints = bookMoves;
    }
    if (((hints == null) || hints.isEmpty()) && (variantMoves != null) && variantMoves.size() > 1) {
        hints = variantMoves;
    }
    if ((hints != null) && (hints.size() > maxNumArrows)) {
        hints = hints.subList(0, maxNumArrows);
    }
    cb.setMoveHints(hints);
}