List of usage examples for android.text Html fromHtml
@Deprecated public static Spanned fromHtml(String source)
From source file:de.blinkt.openvpn.fragments.AboutFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.about, container, false); TextView ver = (TextView) v.findViewById(R.id.version); String version;//from w w w .jav a 2 s.c o m String name = "Openvpn"; try { PackageInfo packageinfo = getActivity().getPackageManager() .getPackageInfo(getActivity().getPackageName(), 0); version = packageinfo.versionName; name = getString(R.string.app); } catch (NameNotFoundException e) { version = "error fetching version"; } ver.setText(getString(R.string.version_info, name, version)); TextView paypal = (TextView) v.findViewById(R.id.donatestring); String donatetext = getActivity().getString(R.string.donatewithpaypal); Spanned htmltext = Html.fromHtml(donatetext); paypal.setText(htmltext); paypal.setMovementMethod(LinkMovementMethod.getInstance()); gmsTextView = (TextView) v.findViewById(R.id.donategms); /* recreating view without onCreate/onDestroy cycle */ // Disable GMS for now if (mService != null) initGooglePlayDonation(); TextView translation = (TextView) v.findViewById(R.id.translation); // Don't print a text for myself if (getString(R.string.translationby).contains("Arne Schwabe")) translation.setText(""); else translation.setText(R.string.translationby); WebView wv = (WebView) v.findViewById(R.id.webView); wv.loadUrl("file:///android_asset/full_licenses.html"); return v; }
From source file:com.dycody.android.idealnote.async.DataBackupIntentService.java
/** * Imports notes and notebooks from Springpad exported archive */*from w w w . ja v a2s. c om*/ * @param intent */ synchronized private void importDataFromSpringpad(Intent intent) { String backupPath = intent.getStringExtra(EXTRA_SPRINGPAD_BACKUP); Importer importer = new Importer(); try { importer.setZipProgressesListener(percentage -> mNotificationsHelper .setMessage(getString(com.dycody.android.idealnote.R.string.extracted) + " " + percentage + "%") .show()); importer.doImport(backupPath); // Updating notification updateImportNotification(importer); } catch (ImportException e) { new NotificationsHelper(this) .createNotification(com.dycody.android.idealnote.R.drawable.ic_emoticon_sad_white_24dp, getString(com.dycody.android.idealnote.R.string.import_fail) + ": " + e.getMessage(), null) .setLedActive().show(); return; } List<SpringpadElement> elements = importer.getSpringpadNotes(); // If nothing is retrieved it will exit if (elements == null || elements.size() == 0) { return; } // These maps are used to associate with post processing notes to categories (notebooks) HashMap<String, Category> categoriesWithUuid = new HashMap<>(); // Adds all the notebooks (categories) for (SpringpadElement springpadElement : importer.getNotebooks()) { Category cat = new Category(); cat.setName(springpadElement.getName()); cat.setColor(String.valueOf(Color.parseColor("#F9EA1B"))); DbHelper.getInstance().updateCategory(cat); categoriesWithUuid.put(springpadElement.getUuid(), cat); // Updating notification importedSpringpadNotebooks++; updateImportNotification(importer); } // And creates a default one for notes without notebook Category defaulCategory = new Category(); defaulCategory.setName("Springpad"); defaulCategory.setColor(String.valueOf(Color.parseColor("#F9EA1B"))); DbHelper.getInstance().updateCategory(defaulCategory); // And then notes are created Note note; Attachment mAttachment = null; Uri uri; for (SpringpadElement springpadElement : importer.getNotes()) { note = new Note(); // Title note.setTitle(springpadElement.getName()); // Content dependent from type of Springpad note StringBuilder content = new StringBuilder(); content.append( TextUtils.isEmpty(springpadElement.getText()) ? "" : Html.fromHtml(springpadElement.getText())); content.append( TextUtils.isEmpty(springpadElement.getDescription()) ? "" : springpadElement.getDescription()); // Some notes could have been exported wrongly if (springpadElement.getType() == null) { Toast.makeText(this, getString(com.dycody.android.idealnote.R.string.error), Toast.LENGTH_SHORT) .show(); continue; } if (springpadElement.getType().equals(SpringpadElement.TYPE_VIDEO)) { try { content.append(System.getProperty("line.separator")) .append(springpadElement.getVideos().get(0)); } catch (IndexOutOfBoundsException e) { content.append(System.getProperty("line.separator")).append(springpadElement.getUrl()); } } if (springpadElement.getType().equals(SpringpadElement.TYPE_TVSHOW)) { content.append(System.getProperty("line.separator")) .append(TextUtils.join(", ", springpadElement.getCast())); } if (springpadElement.getType().equals(SpringpadElement.TYPE_BOOK)) { content.append(System.getProperty("line.separator")).append("Author: ") .append(springpadElement.getAuthor()).append(System.getProperty("line.separator")) .append("Publication date: ").append(springpadElement.getPublicationDate()); } if (springpadElement.getType().equals(SpringpadElement.TYPE_RECIPE)) { content.append(System.getProperty("line.separator")).append("Ingredients: ") .append(springpadElement.getIngredients()).append(System.getProperty("line.separator")) .append("Directions: ").append(springpadElement.getDirections()); } if (springpadElement.getType().equals(SpringpadElement.TYPE_BOOKMARK)) { content.append(System.getProperty("line.separator")).append(springpadElement.getUrl()); } if (springpadElement.getType().equals(SpringpadElement.TYPE_BUSINESS) && springpadElement.getPhoneNumbers() != null) { content.append(System.getProperty("line.separator")).append("Phone number: ") .append(springpadElement.getPhoneNumbers().getPhone()); } if (springpadElement.getType().equals(SpringpadElement.TYPE_PRODUCT)) { content.append(System.getProperty("line.separator")).append("Category: ") .append(springpadElement.getCategory()).append(System.getProperty("line.separator")) .append("Manufacturer: ").append(springpadElement.getManufacturer()) .append(System.getProperty("line.separator")).append("Price: ") .append(springpadElement.getPrice()); } if (springpadElement.getType().equals(SpringpadElement.TYPE_WINE)) { content.append(System.getProperty("line.separator")).append("Wine type: ") .append(springpadElement.getWine_type()).append(System.getProperty("line.separator")) .append("Varietal: ").append(springpadElement.getVarietal()) .append(System.getProperty("line.separator")).append("Price: ") .append(springpadElement.getPrice()); } if (springpadElement.getType().equals(SpringpadElement.TYPE_ALBUM)) { content.append(System.getProperty("line.separator")).append("Artist: ") .append(springpadElement.getArtist()); } for (SpringpadComment springpadComment : springpadElement.getComments()) { content.append(System.getProperty("line.separator")).append(springpadComment.getCommenter()) .append(" commented at 0").append(springpadComment.getDate()).append(": ") .append(springpadElement.getArtist()); } note.setContent(content.toString()); // Checklists if (springpadElement.getType().equals(SpringpadElement.TYPE_CHECKLIST)) { StringBuilder sb = new StringBuilder(); String checkmark; for (SpringpadItem mSpringpadItem : springpadElement.getItems()) { checkmark = mSpringpadItem.getComplete() ? it.feio.android.checklistview.interfaces.Constants.CHECKED_SYM : it.feio.android.checklistview.interfaces.Constants.UNCHECKED_SYM; sb.append(checkmark).append(mSpringpadItem.getName()) .append(System.getProperty("line.separator")); } note.setContent(sb.toString()); note.setChecklist(true); } // Tags String tags = springpadElement.getTags().size() > 0 ? "#" + TextUtils.join(" #", springpadElement.getTags()) : ""; if (note.isChecklist()) { note.setTitle(note.getTitle() + tags); } else { note.setContent(note.getContent() + System.getProperty("line.separator") + tags); } // Address String address = springpadElement.getAddresses() != null ? springpadElement.getAddresses().getAddress() : ""; if (!TextUtils.isEmpty(address)) { try { double[] coords = GeocodeHelper.getCoordinatesFromAddress(this, address); note.setLatitude(coords[0]); note.setLongitude(coords[1]); } catch (IOException e) { Log.e(Constants.TAG, "An error occurred trying to resolve address to coords during Springpad import"); } note.setAddress(address); } // Reminder if (springpadElement.getDate() != null) { note.setAlarm(springpadElement.getDate().getTime()); } // Creation, modification, category note.setCreation(springpadElement.getCreated().getTime()); note.setLastModification(springpadElement.getModified().getTime()); // Image String image = springpadElement.getImage(); if (!TextUtils.isEmpty(image)) { try { File file = StorageHelper.createNewAttachmentFileFromHttp(this, image); uri = Uri.fromFile(file); String mimeType = StorageHelper.getMimeType(uri.getPath()); mAttachment = new Attachment(uri, mimeType); } catch (MalformedURLException e) { uri = Uri.parse(importer.getWorkingPath() + image); mAttachment = StorageHelper.createAttachmentFromUri(this, uri, true); } catch (IOException e) { Log.e(Constants.TAG, "Error retrieving Springpad online image"); } if (mAttachment != null) { note.addAttachment(mAttachment); } mAttachment = null; } // Other attachments for (SpringpadAttachment springpadAttachment : springpadElement.getAttachments()) { // The attachment could be the image itself so it's jumped if (image != null && image.equals(springpadAttachment.getUrl())) continue; if (TextUtils.isEmpty(springpadAttachment.getUrl())) { continue; } // Tries first with online images try { File file = StorageHelper.createNewAttachmentFileFromHttp(this, springpadAttachment.getUrl()); uri = Uri.fromFile(file); String mimeType = StorageHelper.getMimeType(uri.getPath()); mAttachment = new Attachment(uri, mimeType); } catch (MalformedURLException e) { uri = Uri.parse(importer.getWorkingPath() + springpadAttachment.getUrl()); mAttachment = StorageHelper.createAttachmentFromUri(this, uri, true); } catch (IOException e) { Log.e(Constants.TAG, "Error retrieving Springpad online image"); } if (mAttachment != null) { note.addAttachment(mAttachment); } mAttachment = null; } // If the note has a category is added to the map to be post-processed if (springpadElement.getNotebooks().size() > 0) { note.setCategory(categoriesWithUuid.get(springpadElement.getNotebooks().get(0))); } else { note.setCategory(defaulCategory); } // The note is saved DbHelper.getInstance().updateNote(note, false); ReminderHelper.addReminder(IdealNote.getAppContext(), note); // Updating notification importedSpringpadNotes++; updateImportNotification(importer); } // Delete temp data try { importer.clean(); } catch (IOException e) { Log.w(Constants.TAG, "Springpad import temp files not deleted"); } String title = getString(com.dycody.android.idealnote.R.string.data_import_completed); String text = getString(com.dycody.android.idealnote.R.string.click_to_refresh_application); createNotification(intent, this, title, text, null); }
From source file:com.liato.bankdroid.banking.banks.OKQ8.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()); }/*w ww. jav a 2s .c om*/ if (response == null) { urlopen = login(); } try { /* * The start page contains the balance of the account ("Kvar att utnytta") so read it. * The balance is the first value (of three) that are matched by reBalance expression. */ Matcher matcher; matcher = reBalance.matcher(response); /* * The start page contains the balance of the account ("Kvar att utnytta") so read it. * The balance is the first value (of three) that are matched by reBalance expression. */ matcher = reBalance.matcher(response); if (matcher.find()) { accounts.add(new Account("Kvar att utnyttja", Helpers.parseBalance(matcher.group(1)), "1")); balance = balance.add(Helpers.parseBalance(matcher.group(1))); } /* * Find the next value that is "Saldo". Add a new account but don't add to the balance. */ if (matcher.find()) { accounts.add(new Account("Saldo", Helpers.parseBalance(matcher.group(1)), "2")); accounts.add(new Account("Saldo", Helpers.parseBalance(matcher.group(1)).negate(), "4")); } /* * Find the next value that is "Kpgrns". Add a new account but don't add to the balance. */ if (matcher.find()) { accounts.add(new Account("Kpgrns", Helpers.parseBalance(matcher.group(1)), "3")); } if (accounts.isEmpty()) { throw new BankException(res.getText(R.string.no_accounts_found).toString()); } response = urlopen .open("https://nettbank.edb.com/cardpayment/transigo/card/overview/lastTransactionsAccount"); matcher = reTransactions.matcher(response); ArrayList<Transaction> transactions = new ArrayList<Transaction>(); while (matcher.find()) { /* * Capture group 1 = date * Capture group 2 = text * Capture group 3 = amount * Negate the amount since buys are reported as positive. */ transactions.add( new Transaction(matcher.group(1).trim(), Html.fromHtml(matcher.group(2)).toString().trim(), Helpers.parseBalance(matcher.group(3)).negate())); } accounts.get(0).setTransactions(transactions); } 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.example.main.BandWViewPagerActivity.java
private void getmArrays(String decode) { // TODO Auto-generated method stub try {/*from w w w .j ava2 s .c o m*/ GlobalID globalID = (GlobalID) getApplication(); JSONArray jsonArray = new JSONArray(decode); if (jsonArray.length() == 0) { return; } else { for (int i = 0; i < jsonArray.length(); i++) { JSONObject jsonObject = jsonArray.getJSONObject(i); BandWEntity entity = new BandWEntity(Boolean.valueOf(jsonObject.optString("list_type")), jsonObject.optString("Id"), jsonObject.optString("Title"), jsonObject.optString("Typeid"), Html.fromHtml(jsonObject.optString("Detail")).toString(), jsonObject.optString("Pic"), jsonObject.optString("Time")); if (!entity.getList_type()) { String pic = entity.getPicName(); if (log) Log.v(i + " pic: ", pic); Bitmap bit = FuntionUtil .downloadPic("http://" + globalID.getDBurl() + "/admin/images/" + pic); if (bit != null) { entity.setPic(bit); } else { Bitmap good = BitmapFactory.decodeResource(getResources(), R.drawable.weather_preview); entity.setPic(good); } } // mArrays.add(entity); Message msg = new Message(); msg.what = 1; msg.obj = entity; add_handler.sendMessage(msg); } } } catch (JSONException e) { e.printStackTrace(); return; } }
From source file:com.google.android.dialer.provider.DialerProvider.java
private String decodeHtml(String s) { return Html.fromHtml(s).toString(); }
From source file:com.ymt.demo1.plates.news.FireNewsFragment.java
private StringRequest newsRequest(String state, int start, int pagesize, final String type) { return new StringRequest(BaseURLUtil.getNews(state, start, pagesize, type), new Response.Listener<String>() { @Override/*from www . j a v a2 s.c o m*/ public void onResponse(String s) { try { JSONObject jsonObject = new JSONObject(s); JSONArray summaryArray = jsonObject.getJSONObject("datas").getJSONArray("listData"); switch (type) { case "hitnum": //hot JSONObject object1 = summaryArray.getJSONObject(0); hotNew = new NewsSummary(); hotNew.setContent(object1.optString("content")); hotNew.setThe_id(object1.optString("id")); hotNew.setAuthor(object1.optString("author")); hotNew.setCreateTime(object1.optString("createTime")); hotNew.setEditor(object1.optString("editor")); hotNew.setSource(object1.optString("source")); hotNew.setArticleTitle(object1.optString("articleTitle")); hotNew.setHitnum(object1.optString("hitnum")); hotNew.setType(object1.optString("type")); String pic1 = object1.optString("pic"); hotNew.setPic(pic1); hotNew.setName1(object1.optString("name1")); hotNew.setName2(object1.optString("name2")); hotNew.setPic(BaseURLUtil.BASE_URL + pic1); if (!TextUtils.isEmpty(pic1)) { hotPicView.setVisibility(View.VISIBLE); Picasso.with(getActivity()).load(hotNew.getPic()).into(hotPicView); } else { hotPicView.setVisibility(View.GONE); } hotTitleView.setText(hotNew.getArticleTitle()); hotContentView.setText( StringUtils.replaceBlank(Html.fromHtml(hotNew.getContent()).toString())); hotHitView.setVisibility(View.GONE); break; case "time": //rec JSONObject object2 = summaryArray.getJSONObject(0); recNew = new NewsSummary(); recNew.setContent(object2.optString("content")); recNew.setThe_id(object2.optString("id")); recNew.setAuthor(object2.optString("author")); recNew.setCreateTime(object2.optString("createTime")); recNew.setEditor(object2.optString("editor")); recNew.setSource(object2.optString("source")); recNew.setArticleTitle(object2.optString("articleTitle")); recNew.setHitnum(object2.optString("hitnum")); recNew.setType(object2.optString("type")); String pic2 = object2.optString("pic"); recNew.setPic(pic2); recNew.setName1(object2.optString("name1")); recNew.setName2(object2.optString("name2")); recNew.setPic(BaseURLUtil.BASE_URL + pic2); if (!TextUtils.isEmpty(pic2)) { recPicView.setVisibility(View.VISIBLE); Picasso.with(getActivity()).load(recNew.getPic()).into(recPicView); } else { recPicView.setVisibility(View.GONE); } recTitleView.setText(recNew.getArticleTitle()); recContentView.setText( StringUtils.replaceBlank(Html.fromHtml(recNew.getContent()).toString())); recHitView.setVisibility(View.GONE); break; default: break; } } catch (JSONException e) { AppContext.toastBadJson(); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError volleyError) { AppContext.toastBadInternet(); } }); }
From source file:com.equalsd.recon.UserActivity.java
private void alertDialogClick() { clickWrap = new Dialog(UserActivity.this); clickWrap.setContentView(R.layout.clickwrap_dialogue); clickWrap.setTitle(clickWrapTitle);/*from www . j av a 2 s . com*/ clickWrapText = (TextView) clickWrap.findViewById(R.id.clickText); clickWrapText.setText(Html.fromHtml(textWrap)); refuse = (Button) clickWrap.findViewById(R.id.refuse); refuse.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { clickWrap.dismiss(); } }); accept = (Button) clickWrap.findViewById(R.id.accept); accept.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //upload(); //v.setEnabled(false); if (clickWrapTitle.matches("License Agreement")) { clickWrapTitle = "Private Policy"; new RequestTask().execute("http://ada-veracity.com/signup-wrapContent.php?content=private"); clickWrap.dismiss(); Toast.makeText(getApplicationContext(), "Working...", Toast.LENGTH_LONG).show(); } else { check = false; querySubmit(); } //Toast.makeText(getApplicationContext(), "UPLOAD", Toast.LENGTH_LONG).show(); } }); clickWrap.show(); }
From source file:com.krayzk9s.imgurholo.tools.ImageUtils.java
public static void updateImageFont(JSONParcelable imageData, TextView imageScore) { try {/*from www . j a va 2 s. c om*/ if (!imageData.getJSONObject().has("vote")) { imageScore.setVisibility(View.GONE); return; } if (imageData.getJSONObject().getString("vote") != null && imageData.getJSONObject().getString("vote").equals("up")) imageScore.setText(Html.fromHtml("<font color=#89c624>" + NumberFormat.getIntegerInstance().format(imageData.getJSONObject().getInt("score")) + " points </font> (<font color=#89c624>" + NumberFormat.getIntegerInstance().format(imageData.getJSONObject().getInt("ups")) + "</font>/<font color=#ee4444>" + NumberFormat.getIntegerInstance().format(imageData.getJSONObject().getInt("downs")) + "</font>)")); else if (imageData.getJSONObject().getString("vote") != null && imageData.getJSONObject().getString("vote").equals("down")) imageScore.setText(Html.fromHtml("<font color=#ee4444>" + NumberFormat.getIntegerInstance().format(imageData.getJSONObject().getInt("score")) + " points </font> (<font color=#89c624>" + NumberFormat.getIntegerInstance().format(imageData.getJSONObject().getInt("ups")) + "</font>/<font color=#ee4444>" + NumberFormat.getIntegerInstance().format(imageData.getJSONObject().getInt("downs")) + "</font>)")); else imageScore.setText(Html.fromHtml( NumberFormat.getIntegerInstance().format(imageData.getJSONObject().getInt("score")) + " points (<font color=#89c624>" + NumberFormat.getIntegerInstance().format(imageData.getJSONObject().getInt("ups")) + "</font>/<font color=#ee4444>" + NumberFormat.getIntegerInstance() .format(imageData.getJSONObject().getInt("downs")) + "</font>)")); } catch (JSONException e) { Log.e("Error font!", e.toString()); } }
From source file:com.halzhang.android.apps.startupnews.ui.tablet.DiscussFragment.java
private void wrapHeaderView(SNNew snNew) { if (snNew != null) { mTitle.setText(snNew.getTitle()); mSubTitle.setText(Html.fromHtml(snNew.getSubText())); if (snNew.isDiscuss()) { mText.setVisibility(View.VISIBLE); mText.setText(snNew.getText()); } else {//w w w . j a v a 2 s . com mText.setVisibility(View.GONE); } } }