Example usage for android.text Html fromHtml

List of usage examples for android.text Html fromHtml

Introduction

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

Prototype

@Deprecated
public static Spanned fromHtml(String source) 

Source Link

Document

Returns displayable styled text from the provided HTML string with the legacy flags #FROM_HTML_MODE_LEGACY .

Usage

From source file:de.incoherent.suseconferenceclient.app.SocialWrapper.java

public static ArrayList<SocialItem> getGooglePlusItems(Context context, String tag, int maximum) {
    String twitterSearch = "https://www.googleapis.com/plus/v1/activities?orderBy=recent&query=" + tag + "&key="
            + Config.PLUS_KEY;// w  w  w .  ja v  a 2s . co m
    Log.d("SUSEConferences", "Google search: " + twitterSearch);
    ArrayList<SocialItem> socialItems = new ArrayList<SocialItem>();
    SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSSSS'Z'");
    formatter.setTimeZone(TimeZone.getTimeZone("UTC"));

    Bitmap icon = BitmapFactory.decodeResource(context.getResources(), R.drawable.google_icon);

    try {
        JSONObject result = HTTPWrapper.get(twitterSearch);
        JSONArray items = result.getJSONArray("items");
        int len = items.length();
        if ((len > 0) && (maximum > 0) && (len > maximum))
            len = maximum;

        for (int i = 0; i < len; i++) {
            JSONObject jsonItem = items.getJSONObject(i);
            JSONObject actorItem = jsonItem.getJSONObject("actor");
            JSONObject imageItem = actorItem.getJSONObject("image");
            JSONObject objectItem = jsonItem.getJSONObject("object");
            Bitmap image = HTTPWrapper.getImage(imageItem.getString("url"));
            String content = Html.fromHtml(objectItem.getString("content")).toString();
            Date formattedDate = new Date();
            try {
                formattedDate = formatter.parse(jsonItem.getString("published"));
            } catch (ParseException e) {
                e.printStackTrace();
            }

            SocialItem newItem = new SocialItem(SocialItem.GOOGLE, actorItem.getString("displayName"), content,
                    formattedDate,
                    DateUtils
                            .formatDateTime(context, formattedDate.getTime(),
                                    DateUtils.FORMAT_SHOW_WEEKDAY | DateUtils.FORMAT_NUMERIC_DATE
                                            | DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_SHOW_DATE),
                    image, icon);
            newItem.setLink(jsonItem.getString("url"));
            socialItems.add(newItem);
        }
    } catch (IllegalStateException e) {
        e.printStackTrace();
    } catch (SocketException e) {
        e.printStackTrace();
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } catch (JSONException e) {
        e.printStackTrace();
    }

    return socialItems;
}

From source file:com.ratusapparatus.tapsaff.TapsAff.java

protected void onPostExecute(String feed) {
    ComponentName thisWidget = new ComponentName(context, TapsAff.class);
    RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_layout);

    Log.i("tapsaffonPostExecuteFeed", feed);
    JSONObject jsonObj;/*from   ww  w.  j a  v a2  s .  c  o m*/
    try {
        jsonObj = new JSONObject(feed);
        /*for (int i = 0; i < jsonArray.length(); i++)
        {
        JSONObject jsonObject = jsonArray.getJSONObject(i);
        Log.i(TapsAff.class.getName(), jsonObject.getString("text"));
        }*/
        String oanAff = jsonObj.get("taps").toString();
        Integer itsClose = (Integer) jsonObj.get("temp_f");
        if (itsClose >= TapsAff.tapsTemp - 5 && itsClose <= TapsAff.tapsTemp)
            views.setViewVisibility(R.id.bottom, View.VISIBLE);
        else
            views.setViewVisibility(R.id.bottom, View.GONE);
        String colour = "blue";
        if (oanAff == "Aff")
            colour = "red";
        String text = "taps" + " " + "<font color='" + colour + "'>" + oanAff + "</font>";
        //textView.setText(, TextView.BufferType.SPANNABLE);
        views.setTextViewText(R.id.main, Html.fromHtml(text));
    } catch (Exception e) {
        Log.i("tapsaffonPostExecuteException", e.getLocalizedMessage());
    }
    appWidgetManager.updateAppWidget(thisWidget, views);
}

From source file:com.best.ui.Otpdescdetail.java

public void init(Context context) {

    System.out.println("in init ");
    m_context = context;/*from   w  w w. ja  va  2  s. c o  m*/
    routeDisplayed = false;
    tripId = Find.tripIdList.toArray(new String[Find.tripIdList.size()]);

    scrStopId = Find._sourceStopId;
    destStopId = Find._destStopId;
    sourceStopName = Find.sourceStop;
    destStopName = Find.destStop;
    ((TextView) ((Activity) m_context).findViewById(com.best.ui.R.id.search_for))
            .setTypeface(Best.m_marathi_typeface);
    ((TextView) ((Activity) m_context).findViewById(com.best.ui.R.id.search_for))
            .setText(Html.fromHtml("<font color = 'Red'>Search Results for : </font><font color = 'Black'>"
                    + sourceStopName + " to " + destStopName + "</font>"));

    EfficientAdapter adapter = new EfficientAdapter(m_context);

    try {
        if (adapter != null && context != null && routeDisplayed == false) {
            ((ListView) ((Activity) m_context).findViewById(com.best.ui.R.id.routinglist)).setAdapter(adapter);

        } else if (context != null)
            Best.log("ADAPTER IS NULL");
        else
            Best.log("CONTEXT IS NULL");
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.liato.bankdroid.banking.banks.ICA.java

@Override
public Urllib login() throws LoginException, BankException {
    try {/* w ww  .  ja  v a 2  s  .  c o  m*/
        LoginPackage lp = preLogin();
        String response = urlopen.open(lp.getLoginTarget(), lp.getPostData());
        Matcher matcher = reLoginError.matcher(response);
        if (matcher.find()) {
            throw new LoginException(Html.fromHtml(matcher.group(1)).toString().trim());
        }
    } catch (ClientProtocolException e) {
        throw new BankException(e.getMessage());
    } catch (IOException e) {
        throw new BankException(e.getMessage());
    }
    return urlopen;
}

From source file:com.hybris.mobile.activity.CheckoutActivity.java

private void updateUI() {
    CartDeliveryAddress address = controller.getCart().getDeliveryAddress();

    //delivery address section
    String strList = "";
    TextView addressView = (TextView) findViewById(R.id.lbl_addressView);
    TextView deliveryView = (TextView) findViewById(R.id.lbl_deliveryMethod);
    TextView paymentView = (TextView) findViewById(R.id.lbl_paymentDetails);
    if (address != null) {
        String firstName = address.getFirstName();
        String lastName = address.getLastName();
        String title = address.getTitle();

        strList = "<b>" + strList + title + " " + firstName + " " + lastName + "</b>";

        strList += StringUtils.isNotBlank(address.getLine1()) ? "<br />" + address.getLine1() : "";
        strList += StringUtils.isNotBlank(address.getLine2()) ? "<br />" + address.getLine2() : "";
        strList += StringUtils.isNotBlank(address.getTown()) ? "<br />" + address.getTown() : "";
        strList += StringUtils.isNotBlank(address.getPostalCode()) ? "<br />" + address.getPostalCode() : "";
        strList += (address.getCountry() != null && StringUtils.isNotBlank(address.getCountry().getName()))
                ? "<br />" + address.getCountry().getName()
                : "";

        addressView.setText(Html.fromHtml(strList));
        ((TextView) findViewById(R.id.textView1)).setTextColor(colorStepDone);

        ((TextView) findViewById(R.id.textView3)).setTextColor(colorStepCurrent);
        deliveryView.setVisibility(View.VISIBLE);

        ((ImageButton) findViewById(R.id.imageButtonDeliveryAddress)).setImageResource(R.drawable.accept);
        ((ImageButton) findViewById(R.id.imageButtonDeliveryMethod)).setVisibility(View.VISIBLE);
    }//ww w . j  a v a  2 s.  c o m

    //delivery mode section
    CartDeliveryMode deliveryMode = controller.getCart().getDeliveryMode();
    if (deliveryMode != null) {

        strList = "<b>" + deliveryMode.getName() + "</b><br />" + deliveryMode.getDescription() + "<br />"
                + deliveryMode.getDeliveryCost().getFormattedValue();
        deliveryView.setText(Html.fromHtml(strList));
        ((TextView) findViewById(R.id.textView3)).setTextColor(colorStepDone);

        ((TextView) findViewById(R.id.textView4)).setTextColor(colorStepCurrent);
        paymentView.setVisibility(View.VISIBLE);

        ((ImageButton) findViewById(R.id.imageButtonDeliveryMethod)).setImageResource(R.drawable.accept);
        ((ImageButton) findViewById(R.id.imageButtonPaymentDetails)).setVisibility(View.VISIBLE);
    }

    //payment section
    CartPaymentInfo payment = controller.getCart().getPaymentInfo();
    if (payment != null) {
        String accountHolderName = payment.getAccountHolderName();
        String cardType = payment.getCardType().getName();
        String cardNumber = payment.getCardNumber();

        strList = "<b>" + accountHolderName + "<b> <br />" + cardNumber + "<br />" + cardType;
        paymentView.setText(Html.fromHtml(strList));
        ((TextView) findViewById(R.id.textView4)).setTextColor(colorStepDone);

        ((ImageButton) findViewById(R.id.imageButtonPaymentDetails)).setImageResource(R.drawable.accept);
    }

    TextView items = (TextView) findViewById(R.id.textView5);
    items.setText(controller.getCart().getTotalItems() + " " + getString(R.string.items_label));

    TextView subtotal = (TextView) findViewById(R.id.lbl_subTotal);
    subtotal.setText(controller.getCart().getSubTotal().getFormattedValue());

    TextView discounts = (TextView) findViewById(R.id.lbl_totalDiscounts);
    discounts.setText(
            getString(R.string.discount, controller.getCart().getTotalDiscounts().getFormattedValue()));

    TextView totaltax = (TextView) findViewById(R.id.lbl_totalTax);
    totaltax.setText(controller.getCart().getTotalTax().getFormattedValue());

    TextView totalprice = (TextView) findViewById(R.id.lbl_totalPrice);
    totalprice.setText(controller.getCart().getTotalPrice().getFormattedValue());

    boolean stepsComplete = address != null && deliveryMode != null && payment != null;
    RelativeLayout containerTerms = (RelativeLayout) findViewById(R.id.containerTerms);
    containerTerms.setVisibility(stepsComplete ? View.VISIBLE : View.GONE);

    CheckBox checkBoxTerms = (CheckBox) findViewById(R.id.checkBoxTerms);
    boolean readyToConfirm = stepsComplete && checkBoxTerms.isChecked();
    findViewById(R.id.buttonConfirmOrder).setEnabled(readyToConfirm);

}

From source file:com.liato.bankdroid.banking.banks.Avanza.java

@Override
public void update() throws BankException, LoginException {
    super.update();
    if (username == null || password == null || username.length() == 0 || password.length() == 0) {
        throw new LoginException(res.getText(R.string.invalid_username_password).toString());
    }//  w  ww.j  a  v  a 2  s .c o m
    Urllib urlopen = login();
    String response = null;
    Matcher matcher;
    try {
        response = urlopen.open("https://www.avanza.se/aza/depa/sammanfattning/sammanfattning.jsp");

        matcher = reAccounts.matcher(response);
        while (matcher.find()) {
            /*
             * Capture groups:
             * GROUP                EXAMPLE DATA
             * 1: ID                3505060
             * 2: Type              Aktie- och fondkonto Premium Silver
             * 3: % since purchase  1,90
             * 4: Amount in SEK     820
             *    
             */
            accounts.add(new Account(Html.fromHtml(matcher.group(1)).toString().trim(),
                    Helpers.parseBalance(matcher.group(4)), matcher.group(1).trim()));
            balance = balance.add(Helpers.parseBalance(matcher.group(4)));
        }
        if (accounts.isEmpty()) {
            throw new BankException(res.getText(R.string.no_accounts_found).toString());
        }
    } catch (ClientProtocolException e) {
        throw new BankException(e.getMessage());
    } catch (IOException e) {
        throw new BankException(e.getMessage());
    } finally {
        super.updateComplete();
    }
}

From source file:com.hybris.mobile.activity.OrderDetailActivity.java

private void updateUI() {
    String pageTitle = getString(R.string.order_completed_text);
    if (getIntent().hasExtra(DataConstants.ORDER_ID)) {
        pageTitle += " " + mOrderDetails.getCode();

        String strOrderStatus = "<b>" + mOrderDetails.getStatusDisplay() + "</b>";
        Calendar cal = DateUtil.fromIso8601(mOrderDetails.getCreated());
        strOrderStatus = strOrderStatus + "<br />" + getString(R.string.placed_on_placeholder_text) + " "
                + cal.getTime().toString();
        TextView orderStatus = (TextView) findViewById(R.id.lbl_orderStatusView);
        orderStatus.setText(Html.fromHtml(strOrderStatus));
        findViewById(R.id.containerOrderStatus).setVisibility(View.VISIBLE);
        findViewById(R.id.dividerOrderStatus).setVisibility(View.VISIBLE);

    }//from www .ja  v a2s  .  c o  m
    setTitle(pageTitle);

    CartDeliveryAddress address = mOrderDetails.getDeliveryAddress();

    // delivery address section
    String strList = "";
    if (address != null) {
        String firstName = address.getTitle();
        String lastName = address.getLastName();
        String title = address.getFirstName();

        // strList = "Delivery address\n\n";
        strList = "<b>" + strList + title + " " + firstName + " " + lastName + "</b>";

        strList += StringUtils.isNotBlank(address.getLine1()) ? "<br />" + address.getLine1() : "";
        strList += StringUtils.isNotBlank(address.getLine2()) ? "<br />" + address.getLine2() : "";
        strList += StringUtils.isNotBlank(address.getTown()) ? "<br />" + address.getTown() : "";
        strList += StringUtils.isNotBlank(address.getPostalCode()) ? "<br />" + address.getPostalCode() : "";
        strList += (address.getCountry() != null && StringUtils.isNotBlank(address.getCountry().getName()))
                ? "<br />" + address.getCountry().getName()
                : "";

        TextView addressView = (TextView) findViewById(R.id.lbl_addressView);
        addressView.setText(Html.fromHtml(strList));
    }

    // delivery mode section
    CartDeliveryMode deliveryMode = mOrderDetails.getDeliveryMode();
    if (deliveryMode != null) {
        strList = "<b>" + deliveryMode.getName() + "</b><br />" + deliveryMode.getDescription() + "<br />"
                + deliveryMode.getDeliveryCost().getFormattedValue();
        TextView deliveryView = (TextView) findViewById(R.id.lbl_deliveryMethod);
        deliveryView.setText(Html.fromHtml(strList));
    }

    // payment section
    CartPaymentInfo payment = mOrderDetails.getPaymentInfo();
    if (payment != null) {
        String accountHolderName = payment.getAccountHolderName();
        String cardType = payment.getCardType().getName();
        String cardNumber = payment.getCardNumber();

        strList = "<b>" + accountHolderName + "</b><br />" + cardNumber + "<br />" + cardType;
        TextView paymentView = (TextView) findViewById(R.id.lbl_paymentDetails);
        paymentView.setText(Html.fromHtml(strList));
    }

    TextView subtotal = (TextView) findViewById(R.id.lbl_subTotal);
    subtotal.setText(mOrderDetails.getSubTotal().getFormattedValue());

    TextView totaltax = (TextView) findViewById(R.id.lbl_totalTax);
    totaltax.setText(mOrderDetails.getTotalTax().getFormattedValue());

    TextView deliveryprice = (TextView) findViewById(R.id.lbl_deliveryCharge);
    deliveryprice.setText(mOrderDetails.getDeliveryCost().getFormattedValue());

    TextView totalprice = (TextView) findViewById(R.id.lbl_totalPriceWithTax);
    totalprice.setText(mOrderDetails.getTotalPrice().getFormattedValue());

}

From source file:com.androzic.About.java

private void updateAboutInfo(final View view) {
    // version//from   w  w w .j av  a2 s.c  om
    String versionName = null;
    int versionBuild = 0;
    try {
        versionName = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(),
                0).versionName;
        versionBuild = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(),
                0).versionCode;
    } catch (NameNotFoundException ex) {
        versionName = "unable to retreive version";
    }
    final TextView version = (TextView) view.findViewById(R.id.version);
    version.setText(getString(R.string.version, versionName, versionBuild));

    // home links
    StringBuilder links = new StringBuilder();
    links.append("<a href=\"");
    links.append(": http://androzic.com");
    links.append("\">");
    links.append(getString(R.string.homepage));
    links.append("</a><br /><a href=\"");
    links.append(getString(R.string.faquri));
    links.append("\">");
    links.append(getString(R.string.faq));
    links.append("</a><br /><a href=\"");
    links.append(getString(R.string.featureuri));
    links.append("\">");
    links.append(getString(R.string.feedback));
    links.append("</a>");
    final TextView homelinks = (TextView) view.findViewById(R.id.homelinks);
    homelinks.setText(Html.fromHtml(links.toString()));
    homelinks.setMovementMethod(LinkMovementMethod.getInstance());

    // community links
    StringBuilder communities = new StringBuilder();
    communities.append("<a href=\"");
    communities.append(getString(R.string.googleplusuri));
    communities.append("\">");
    communities.append(getString(R.string.googleplus));
    communities.append("</a><br /><a href=\"");
    communities.append(getString(R.string.facebookuri));
    communities.append("\">");
    communities.append(getString(R.string.facebook));
    communities.append("</a><br /><a href=\"");
    communities.append(getString(R.string.twitteruri));
    communities.append("\">");
    communities.append(getString(R.string.twitter));
    communities.append("</a>");
    final TextView communitylinks = (TextView) view.findViewById(R.id.communitylinks);
    communitylinks.setText(Html.fromHtml(communities.toString()));
    communitylinks.setMovementMethod(LinkMovementMethod.getInstance());

    // donations
    StringBuilder donations = new StringBuilder();
    donations.append("<a href=\"");
    donations.append(getString(R.string.playuri));
    donations.append("\">");
    donations.append(getString(R.string.donate_google));
    donations.append("</a><br /><a href=\"");
    donations.append(getString(R.string.paypaluri));
    donations.append("\">");
    donations.append(getString(R.string.donate_paypal));
    donations.append("</a>");

    final TextView donationlinks = (TextView) view.findViewById(R.id.donationlinks);
    donationlinks.setText(Html.fromHtml(donations.toString()));
    donationlinks.setMovementMethod(LinkMovementMethod.getInstance());

    Androzic application = Androzic.getApplication();
    if (application.isPaid) {
        view.findViewById(R.id.donations).setVisibility(View.GONE);
        view.findViewById(R.id.donationtext).setVisibility(View.GONE);
        donationlinks.setVisibility(View.GONE);
    }

    // license
    final SpannableString message = new SpannableString(
            Html.fromHtml(getString(R.string.app_eula).replace("/n", "<br/>")));
    Linkify.addLinks(message, Linkify.WEB_URLS);
    final TextView license = (TextView) view.findViewById(R.id.license);
    license.setText(message);
    license.setMovementMethod(LinkMovementMethod.getInstance());

    // credits
    String[] names = getResources().getStringArray(R.array.credit_names);
    String[] merits = getResources().getStringArray(R.array.credit_merits);

    StringBuilder credits = new StringBuilder();
    for (int i = 0; i < names.length; i++) {
        credits.append("<b>");
        credits.append(merits[i]);
        credits.append("</b> &mdash; ");
        credits.append(names[i]);
        credits.append("<br />");
    }

    final TextView creditlist = (TextView) view.findViewById(R.id.credits);
    creditlist.setText(Html.fromHtml(credits.toString()));

    // dedication
    final TextView dedicated = (TextView) view.findViewById(R.id.dedicated);
    dedicated.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            clicks = 1;
            dedicated.setVisibility(View.GONE);
            View photo = view.findViewById(R.id.photo);
            photo.setVisibility(View.VISIBLE);
            photo.setOnClickListener(redirect);
        }
    });
}

From source file:de.appplant.cordova.plugin.emailcomposer.EmailComposer.java

/**
 * Setzt den Body der Mail.//from ww  w  . ja v a2  s. co m
 */
private void setBody(String body, Boolean isHTML, Intent draft) {
    if (isHTML) {
        draft.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml(body));
        draft.setType("text/html");
    } else {
        draft.putExtra(android.content.Intent.EXTRA_TEXT, body);
        draft.setType("text/plain");
    }
}

From source file:app.hacked.ScheduleItemDetailFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.schedule_detail_fragment, container, false);

    ((TextView) rootView.findViewById(R.id.times)).setText(scheduleStartTime + " till " + scheduleEndTime);
    ((TextView) rootView.findViewById(R.id.times))
            .setTypeface(Typeface.create("sans-serif-light", Typeface.NORMAL));

    if (rootView.findViewById(R.id.Title) != null) {
        ((TextView) rootView.findViewById(R.id.Title)).setText(scheduleDesc);
        ((TextView) rootView.findViewById(R.id.Title))
                .setTypeface(Typeface.create("sans-serif-light", Typeface.NORMAL));
        ((TextView) rootView.findViewById(R.id.times))
                .setTypeface(Typeface.create("sans-serif-condensed", Typeface.NORMAL));
        getActivity().getActionBar()/*w  w w  .  j a  v a 2  s.co m*/
                .setTitle(scheduleTitle + " - " + getActivity().getString(R.string.app_name));
    }

    TextView fullDetailsTV = (TextView) rootView.findViewById(R.id.fullDetails);

    if (null == scheduleFullDataHTML || scheduleFullDataHTML.equals("")
            || scheduleFullDataHTML.equals("null")) {
        fullDetailsTV.setText(Html.fromHtml(scheduleDesc));
    } else {
        fullDetailsTV.setText(Html.fromHtml(scheduleFullDataHTML));
    }
    fullDetailsTV.setTypeface(Typeface.create("sans-serif", Typeface.NORMAL));

    try {
        fullDetailsTV.setMovementMethod(LinkMovementMethod.getInstance());
    } catch (Exception e) {
        //Worth a shot
    }
    return rootView;
}