List of usage examples for android.text Html fromHtml
@Deprecated public static Spanned fromHtml(String source)
From source file:com.givon.baseproject.xinlu.act.ActRegist.java
public void showDialog(final String phone, final String code) { int resId = getStyleRes(this, "CommonDialog"); if (resId > 0) { final String phoneNum = "+" + code + " " + splitPhoneNum(phone); final Dialog dialog = new Dialog(this, resId); resId = getLayoutRes(this, "smssdk_send_msg_dialog"); if (resId > 0) { dialog.setContentView(resId); resId = getIdRes(this, "tv_phone"); ((TextView) dialog.findViewById(resId)).setText(phoneNum); resId = getIdRes(this, "tv_dialog_hint"); TextView tv = (TextView) dialog.findViewById(resId); resId = getStringRes(this, "smssdk_make_sure_mobile_detail"); if (resId > 0) { String text = this.getString(resId); tv.setText(Html.fromHtml(text)); }/*from www . ja v a 2 s . com*/ resId = getIdRes(this, "btn_dialog_ok"); if (resId > 0) { ((Button) dialog.findViewById(resId)).setOnClickListener(new OnClickListener() { public void onClick(View v) { // ??? dialog.dismiss(); Log.e("verification phone ==>>", phone); showWaitingDialog(); SMSSDK.getVerificationCode(code, phone.trim()); } }); } resId = getIdRes(this, "btn_dialog_cancel"); if (resId > 0) { ((Button) dialog.findViewById(resId)).setOnClickListener(new OnClickListener() { public void onClick(View v) { dialog.dismiss(); } }); } dialog.setCanceledOnTouchOutside(true); dialog.show(); } } }
From source file:com.liato.bankdroid.banking.banks.PayPal.java
@Override public void update() throws BankException, LoginException, BankChoiceException { super.update(); if (username == null || password == null || username.length() == 0 || password.length() == 0) { throw new LoginException(res.getText(R.string.invalid_username_password).toString()); }//from w w w . j a v a 2 s. c o m urlopen = login(); try { response = urlopen.open("https://www.paypal.com/en/cgi-bin/webscr?cmd=_login-done&login_access=" + ((int) (System.currentTimeMillis() / 1000L))); Matcher matcher = reAccounts.matcher(response); int accId = 1; while (matcher.find()) { /* * Capture groups: * GROUP EXAMPLE DATA * 1: name SEK(Primary) * 2: amount 554.70 * 3: currency SEK * */ Account account = new Account(Html.fromHtml(matcher.group(1)).toString().trim(), Helpers.parseBalance(matcher.group(2)), "" + accId); account.setCurrency(matcher.group(3).trim()); accounts.add(account); accId++; } matcher = reBalance.matcher(response); if (matcher.find()) { /* * Capture groups: * GROUP EXAMPLE DATA * 1: balance 554.70 * 2: currency SEK * */ balance = Helpers.parseBalance(matcher.group(1)); currency = matcher.group(2).trim(); if (accounts.isEmpty()) { // Probably a premier account. Account account = new Account(currency, balance, "1"); account.setCurrency(currency); accounts.add(account); } } if (accounts.isEmpty()) { throw new BankException(res.getText(R.string.no_accounts_found).toString()); } } catch (ClientProtocolException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { super.updateComplete(); } }
From source file:com.liato.bankdroid.banking.banks.AkeliusInvest.java
@Override public void update() throws BankException, LoginException, BankChoiceException { super.update(); if (username == null || password == null || username.length() == 0 || password.length() == 0) { throw new LoginException(res.getText(R.string.invalid_username_password).toString()); }/*from w w w. j a va 2 s .c om*/ urlopen = login(); String response = null; Matcher matcher; try { response = urlopen.open("https://online.akeliusinvest.com/AccountPortfolio.mws"); matcher = reAccounts.matcher(response); int accId = 0; while (matcher.find()) { /* * Capture groups: * GROUP ICA AKELIUSINVEST * 1: ID 0000000000 Kontonamn * 2: Name ICA KONTO KontoID * 3: Disponibelt 00.000,00 Kontonummer * 4: Saldo 1.655,71 Valuta * 5: Tillgngligt belopp * 6: Saldo */ // Frsk att lsa problemet med fr lnga, icke radbrytande kontonamn: // if (matcher.group(1).length() > 24) { // matcher.group(1).replaceFirst("(", "(\n"); // } mIdMappings.put(Integer.toString(accId), matcher.group(2).trim()); accounts.add( new Account(Html.fromHtml(matcher.group(1)).toString().trim() + " (Tillgngligt belopp)", Helpers.parseBalance(matcher.group(5).trim()), Integer.toString(accId))); Account account = new Account(Html.fromHtml(matcher.group(1)).toString().trim() + " (Saldo)", Helpers.parseBalance(matcher.group(6).trim()), "a:" + accId); account.setAliasfor(matcher.group(1).trim()); accounts.add(account); balance = balance.add(Helpers.parseBalance(matcher.group(5))); accId++; } 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.cssn.samplesdk.ShowDataActivity.java
/** * // w w w .java2 s. c om */ private void setResultsForPassportCard() { PassportCard processedPassportCard = DataContext.getInstance().getProcessedPassportCard(); StringBuilder info = new StringBuilder(); // First Name info.append(("First Name").concat(" - ")).append(processedPassportCard.getNameFirst()).append("<br/>"); // Middle Name info.append(("Middle Name").concat(" - ")).append(processedPassportCard.getNameMiddle()).append("<br/>"); // Last Name info.append(("Last Name").concat(" - ")).append(processedPassportCard.getNameLast()).append("<br/>"); // Passport Number info.append(("Passport Number").concat(" - ")).append(processedPassportCard.getPassportNumber()) .append("<br/>"); // Personal Number info.append(("Personal Number").concat(" - ")).append(processedPassportCard.getPersonalNumber()) .append("<br/>"); // Sex info.append(("Sex").concat(" - ")).append(processedPassportCard.getSex()).append("<br/>"); // Country Long info.append(("Country Long").concat(" - ")).append(processedPassportCard.getCountryLong()).append("<br/>"); // Nationality Long info.append(("Nationality Long").concat(" - ")).append(processedPassportCard.getNationalityLong()) .append("<br/>"); // DOB Long info.append(("DOB Long").concat(" - ")).append(processedPassportCard.getDateOfBirth4()).append("<br/>"); // Issue Date info.append(("Issue Date Long").concat(" - ")).append(processedPassportCard.getIssueDate4()) .append("<br/>"); // Long Expiration info.append(("Expiration Date Long").concat(" - ")).append(processedPassportCard.getExpirationDate4()) .append("<br/>"); // Place of Birth info.append(("Place of Birth").concat(" - ")).append(processedPassportCard.getEnd_POB()).append("<br/>"); textViewCardInfo.setText(Html.fromHtml(info.toString())); frontSideCardImageView.setImageBitmap(Util .getRoundedCornerBitmap(processedPassportCard.getReformattedImage(), this.getApplicationContext())); imgFaceViewer.setImageBitmap(processedPassportCard.getFaceImage()); imgSignatureViewer.setImageBitmap(processedPassportCard.getSignImage()); }
From source file:com.liato.bankdroid.banking.banks.AkeliusSpar.java
@Override public void update() throws BankException, LoginException, BankChoiceException { super.update(); if (username == null || password == null || username.length() == 0 || password.length() == 0) { throw new LoginException(res.getText(R.string.invalid_username_password).toString()); }//from w w w . ja v a 2 s .c o m urlopen = login(); String response = null; Matcher matcher; try { response = urlopen.open("https://www.online.akeliusspar.se/AccountPortfolio.mws"); matcher = reAccounts.matcher(response); int accId = 0; while (matcher.find()) { /* * Capture groups: * GROUP ICA AKELIUSINVEST * 1: ID 0000000000 Kontonamn * 2: Name ICA KONTO KontoID * 3: Disponibelt 00.000,00 Kontonummer * 4: Saldo 1.655,71 Valuta * 5: Tillgngligt belopp * 6: Saldo */ // Frsk att lsa problemet med fr lnga, icke radbrytande kontonamn: // if (matcher.group(1).length() > 24) { // matcher.group(1).replaceFirst("(", "(\n"); // } mIdMappings.put(Integer.toString(accId), matcher.group(2).trim()); accounts.add( new Account(Html.fromHtml(matcher.group(1)).toString().trim() + " (Tillgngligt belopp)", Helpers.parseBalance(matcher.group(5).trim()), Integer.toString(accId))); Account account = new Account(Html.fromHtml(matcher.group(1)).toString().trim() + " (Saldo)", Helpers.parseBalance(matcher.group(6).trim()), "a:" + accId); account.setAliasfor(matcher.group(1).trim()); accounts.add(account); balance = balance.add(Helpers.parseBalance(matcher.group(5))); accId++; } 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.abcvoipsip.ui.messages.MessageAdapter.java
private CharSequence formatMessage(String contact, String body, String contentType) { SpannableStringBuilder buf = new SpannableStringBuilder(); if (!TextUtils.isEmpty(body)) { // Converts html to spannable if ContentType is "text/html". if (contentType != null && "text/html".equals(contentType)) { buf.append("\n"); buf.append(Html.fromHtml(body)); } else {/* ww w.j av a 2s . c o m*/ SmileyParser parser = SmileyParser.getInstance(); buf.append(parser.addSmileySpans(body)); } } // We always show two lines because the optional icon bottoms are // aligned with the // bottom of the text field, assuming there are two lines for the // message and the sent time. buf.append("\n"); int startOffset = buf.length(); startOffset = buf.length(); buf.setSpan(mTextSmallSpan, startOffset, buf.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); return buf; }
From source file:de.robbers.dashclock.stackextension.StackExtension.java
private void parseReputationResponse(String json) { if (json == null) { return;// ww w. j ava 2 s .c o m } mExpandedBody = ""; LongSparseArray reputationArray = new LongSparseArray(); try { JSONArray items = new JSONObject(json).getJSONArray("items"); Log.i(TAG, items.toString(2)); for (int i = 0; i < items.length(); i++) { JSONObject reputation = items.getJSONObject(i); long postId = reputation.optLong("post_id"); int reputationChange = reputation.optInt("reputation_change"); int newValue = reputationChange; newValue += (Integer) reputationArray.get(postId, 0); reputationArray.put(postId, newValue); } List<Long> postIds = new ArrayList<Long>(); for (int i = 0; i < items.length(); i++) { JSONObject reputation = items.getJSONObject(i); long postId = reputation.optLong("post_id"); int reputationChange = reputation.optInt("reputation_change"); if (postIds.contains(postId) || reputationChange == 0) { continue; } postIds.add(postId); int reputationValue = (Integer) reputationArray.get(postId); String title = String.valueOf(Html.fromHtml(reputation.optString("title"))); mExpandedBody += buildExpandedBodyPost(reputationValue, title, postIds.size()); } } catch (JSONException e) { Log.i(TAG, json); e.printStackTrace(); } if (TextUtils.isEmpty(mExpandedBody)) { mExpandedBody = getString(R.string.no_recent_reputation_changes); } }
From source file:busradar.madison.StopDialog.java
StopDialog(final Context ctx, final int stopid, final int lat, final int lon) { super(ctx);//from www . ja va 2 s .c o m this.stopid = stopid; // getWindow().requestFeature(Window.FEATURE_LEFT_ICON); getWindow().setLayout(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); final String name = DB.getStopName(stopid); setTitle(name); routes = get_time_urls(StopDialog.this.stopid); // getWindow().setLayout(LayoutParams.FILL_PARENT, // LayoutParams.FILL_PARENT); setContentView(new RelativeLayout(ctx) { { addView(new TextView(ctx) { { setId(stop_num_id); setText(Html.fromHtml(String.format( "[<a href='http://www.cityofmadison.com/metro/BusStopDepartures/StopID/%04d.pdf'>%04d</a>]", stopid, stopid))); setPadding(0, 0, 5, 0); this.setMovementMethod(LinkMovementMethod.getInstance()); } }, new RelativeLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT) { { addRule(ALIGN_PARENT_RIGHT); } }); addView(new ImageView(ctx) { boolean enabled; @Override public void setEnabled(boolean e) { enabled = e; setImageResource(e ? R.drawable.love_enabled : R.drawable.love_disabled); if (e) { G.favorites.add_favorite_stop(stopid, name, lat, lon); Toast.makeText(ctx, "Added stop to Favorites", Toast.LENGTH_SHORT).show(); } else { G.favorites.remove_favorite_stop(stopid); Toast.makeText(ctx, "Removed stop from Favorites", Toast.LENGTH_SHORT).show(); } } { enabled = G.favorites.is_stop_favorite(stopid); setImageResource(enabled ? R.drawable.love_enabled : R.drawable.love_disabled); setPadding(0, 0, 10, 0); setOnClickListener(new OnClickListener() { public void onClick(View v) { setEnabled(!enabled); } }); } }, new RelativeLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT) { { addRule(LEFT_OF, stop_num_id); setMargins(0, -3, 0, 0); } }); addView(cur_loading_text = new TextView(ctx) { { setText("Loading..."); setPadding(5, 0, 0, 0); } }); addView(new HorizontalScrollView(ctx) { { setId(route_list_id); setHorizontalScrollBarEnabled(false); addView(new LinearLayout(ctx) { float text_size; Button cur_button; { int last_route = -1; for (int i = 0; i < routes.length; i++) { final RouteURL route = routes[i]; if (route.route == last_route) continue; last_route = route.route; addView(new Button(ctx) { public void setEnabled(boolean e) { if (e) { setBackgroundColor(0xff000000 | G.route_points[route.route].color); setTextSize(TypedValue.COMPLEX_UNIT_PX, text_size * 1.5f); } else { setBackgroundColor(0x90000000 | G.route_points[route.route].color); setTextSize(TypedValue.COMPLEX_UNIT_PX, text_size); } } { setText(G.route_points[route.route].name); setTextColor(0xffffffff); setTypeface(Typeface.DEFAULT_BOLD); text_size = getTextSize(); if (G.active_route == route.route) { setEnabled(true); cur_button = this; } else setEnabled(false); final Button b = this; setOnClickListener(new OnClickListener() { public void onClick(View v) { if (cur_button != null) { cur_button.setEnabled(false); } if (cur_button == b) { cur_button.setEnabled(false); cur_button = null; selected_route = null; update_time_display(); } else { cur_button = b; cur_button.setEnabled(true); selected_route = route; update_time_display(); } } }); } }); } } }); } }, new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT) { { addRule(RelativeLayout.BELOW, stop_num_id); addRule(RelativeLayout.CENTER_HORIZONTAL); } }); addView(status_text = new TextView(ctx) { { setText(""); } }, new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT) { { addRule(RelativeLayout.BELOW, route_list_id); addRule(RelativeLayout.CENTER_HORIZONTAL); } }); addView(list_view = new ListView(ctx) { { setId(time_list_id); setVerticalScrollBarEnabled(false); setAdapter(times_adapter = new BaseAdapter() { public View getView(final int position, View convertView, ViewGroup parent) { CellView v; if (convertView == null) v = new CellView(ctx); else v = (CellView) convertView; RouteTime rt = curr_times.get(position); v.setBackgroundColor(G.route_points[rt.route].color | 0xff000000); v.route_textview.setText(G.route_points[rt.route].name); if (rt.dir != null) v.dir_textview.setText("to " + rt.dir); v.time_textview.setText(rt.time); return v; } public int getCount() { return curr_times.size(); } public Object getItem(int position) { return null; } public long getItemId(int position) { return 0; } }); } }, new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT) { { addRule(RelativeLayout.BELOW, route_list_id); } }); } }); TextView title = (TextView) findViewById(android.R.id.title); title.setEllipsize(TextUtils.TruncateAt.MARQUEE); title.setSelected(true); title.setTextColor(0xffffffff); title.setMarqueeRepeatLimit(-1); // getWindow().set, value) // getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, // android.R.drawable.ic_dialog_info); // title.setGravity(Gravity.CENTER_HORIZONTAL|Gravity.CENTER_VERTICAL); if (G.active_route >= 0) for (int i = 0; i < routes.length; i++) if (routes[i].route == G.active_route) { selected_route = routes[i]; RouteURL[] rnew = new RouteURL[routes.length]; rnew[0] = selected_route; for (int j = 0, k = 1; j < routes.length; j++) if (j != i) rnew[k++] = routes[j]; routes = rnew; break; } update_time_display(); }
From source file:com.nttec.everychan.ui.downloading.HtmlBuilder.java
public static String buildTitle(SerializablePage page) { String title;//w w w . jav a 2 s . c o m if (page.posts != null && page.posts.length != 0) { title = "/" + page.boardModel.boardName + " - "; title += page.posts[0].subject != null && page.posts[0].subject.length() != 0 ? page.posts[0].subject : Html.fromHtml(page.posts[0].comment).toString().replace('\n', ' '); if (title.length() > 255) title = title.substring(0, 256); } else { title = page.boardModel.boardDescription != null ? page.boardModel.boardDescription : page.boardModel.boardName; } return title; }
From source file:com.github.wakhub.monodict.activity.bean.ActivityHelper.java
public Spanned getHtmlFromRaw(int resId) { return Html.fromHtml(getStringFromRaw(resId)); }