List of usage examples for android.text Html fromHtml
@Deprecated public static Spanned fromHtml(String source)
From source file:com.akhbulatov.wordkeeper.ui.fragment.WordListFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.fragment_word, menu); MenuItem searchItem = menu.findItem(R.id.menu_search_word); SearchView searchView = (SearchView) searchItem.getActionView(); SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE); searchView.setSearchableInfo(//from w ww .j a va2s .c o m searchManager.getSearchableInfo(new ComponentName(getActivity(), MainActivity.class))); searchView.setImeOptions(EditorInfo.IME_ACTION_SEARCH); searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String query) { return false; } @Override public boolean onQueryTextChange(String newText) { final Cursor cursor = mWordDbAdapter.getAll(sSortMode); final int column = cursor.getColumnIndex(WordEntry.COLUMN_NAME); if (newText.length() > 0) { mWordAdapter.swapCursor(new FilterCursorWrapper(cursor, newText, column)); mTextEmptyWordList.setVisibility(View.GONE); if (mWordAdapter.getItemCount() == 0) { String escapedNewText = TextUtils.htmlEncode(newText); String formattedNoResults = String.format(getString(R.string.no_results_word), escapedNewText); CharSequence styledNoResults = Html.fromHtml(formattedNoResults); mTextNoResultsWord.setText(styledNoResults); mTextNoResultsWord.setVisibility(View.VISIBLE); } else { mTextNoResultsWord.setVisibility(View.GONE); } } else { mWordAdapter.swapCursor(cursor); mTextNoResultsWord.setVisibility(View.GONE); if (mWordAdapter.getItemCount() == 0) { mTextEmptyWordList.setVisibility(View.VISIBLE); } } return true; } }); }
From source file:com.liato.bankdroid.banking.banks.IkanoPartnerBase.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()); }// ww w. j ava 2s . c o m urlopen = login(); Matcher matcher; try { String creditPageUrl = null; String transactionsPageUrl = null; matcher = reCreditInfoUrl.matcher(response); if (matcher.find()) { creditPageUrl = matcher.group(1); } matcher = reTransactionsUrl.matcher(response); if (!matcher.find() && creditPageUrl == null) { throw new BankException(res.getText(R.string.unable_to_find).toString() + " transactions url."); } transactionsPageUrl = matcher.group(1); // If a url for the credit page is found we request that page first. If no url for the credit page is // found we only need to request the transactions page as all the credit info should be available on // that page. response = urlopen.open("https://partner.ikanobank.se/web/engines/" + (creditPageUrl == null ? transactionsPageUrl : creditPageUrl)); matcher = reAccounts.matcher(response); int accId = 0; while (matcher.find()) { /* * Capture groups: * GROUP EXAMPLE DATA * 1: Name Kvar att handla fr * 2: Amount 17 229,85 * 3: Currency kr * */ Account account = new Account(Html.fromHtml(matcher.group(1)).toString().trim(), Helpers.parseBalance(matcher.group(2)), Integer.toString(accId)); if (accId > 0) { account.setAliasfor("0"); } accounts.add(account); accId++; } if (accounts.isEmpty()) { throw new BankException(res.getText(R.string.no_accounts_found).toString()); } // Use the amount from "Kvar att handla fr" which should be the last account in the list. this.balance = accounts.get(accounts.size() - 1).getBalance(); if (creditPageUrl != null) { response = urlopen.open("https://partner.ikanobank.se/web/engines/" + transactionsPageUrl); } ArrayList<Transaction> transactions = new ArrayList<Transaction>(); matcher = reTransactions.matcher(response); while (matcher.find()) { /* * Capture groups: * GROUP EXAMPLE DATA * 1: Date 2011-02-27 * 2: Specification Best Buy<br> * 3: Amount 143,07 kr * 4: Currency SEK * */ Transaction transaction = new Transaction(matcher.group(1).trim(), Html.fromHtml(matcher.group(2).replaceAll("<br>", " ")).toString().trim(), Helpers.parseBalance(matcher.group(3))); transactions.add(transaction); } accounts.get(0).setTransactions(transactions); } catch (ClientProtocolException e) { throw new BankException(e.getMessage()); } catch (IOException e) { throw new BankException(e.getMessage()); } finally { super.updateComplete(); } }
From source file:com.armtimes.activities.SingleArticlePreviewActivity.java
private Intent createShareIntent() { Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.setType("text/plain"); // Get Description. String description = getIntent().getStringExtra(EXTRA_SHORT_DESC); if (description == null || description.isEmpty()) return null; String url = getIntent().getStringExtra(EXTRA_URL); if (url == null || url.isEmpty()) return null; description = Html.fromHtml(description).toString(); final String textToShare = String.format("%s... <a href=\"%s\">%s</a>", description, url, getString(R.string.read_more)); shareIntent.putExtra(Intent.EXTRA_TEXT, textToShare); return shareIntent; }
From source file:com.android.nsboc.ComposeFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (mItem != null) { switch (mItem.id + "") { case "1": mRootView = inflater.inflate(R.layout.form_unlicensed, container, false); break; case "2": mRootView = inflater.inflate(R.layout.form_salon, container, false); break; }/* w w w .j a va 2 s . c om*/ } showCurrentDateInEditText(); ToggleButton complianceToggle = (ToggleButton) mRootView.findViewById(R.id.compliance_toggle); if (complianceToggle != null) { final LinearLayout complianceContainer = (LinearLayout) mRootView .findViewById(R.id.compliance_container); complianceToggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (!isChecked) { complianceContainer.setVisibility(View.VISIBLE); final LinearLayout complianceLayout = (LinearLayout) View.inflate(getActivity(), R.layout.compliance_layout, null); Spinner violationTypeSpinner = (Spinner) complianceLayout .findViewById(R.id.violation_type_spinner); violationTypeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { switch (position) { case 0: complianceLayout.findViewById(R.id.type_citation_container) .setVisibility(View.VISIBLE); break; case 1: complianceLayout.findViewById(R.id.type_citation_container) .setVisibility(View.GONE); break; } } @Override public void onNothingSelected(AdapterView<?> parent) { } }); ToggleButton anotherToggle = (ToggleButton) complianceLayout .findViewById(R.id.compliance_toggle); anotherToggle.setOnCheckedChangeListener(getNextToggleListener(complianceLayout)); complianceContainer.addView(complianceLayout); } else { complianceContainer.setVisibility(View.GONE); } } }); } ToggleButton emailToggle = (ToggleButton) mRootView.findViewById(R.id.emailTo_toggle); if (emailToggle != null) { final LinearLayout emailLayout = (LinearLayout) mRootView.findViewById(R.id.emailTo_layout); emailToggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { emailLayout.setVisibility(View.VISIBLE); } else { emailLayout.setVisibility(View.GONE); } } }); } final TextView noticeTextView = (TextView) mRootView.findViewById(R.id.notice_textview); if (noticeTextView != null) { noticeTextView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (noticeTextView.getCurrentTextColor() == Color.BLACK) { noticeTextView.setText(R.string.civil_citation_header); noticeTextView.setTextColor(Color.parseColor("#17405e")); noticeTextView.setText(Html.fromHtml("<u>" + noticeTextView.getText() + "</u>")); mRootView.findViewById(R.id.civil_citation).requestFocus(); } else { noticeTextView.setText(R.string.civil_citation_notice); noticeTextView.setMaxLines(Integer.MAX_VALUE); noticeTextView.setTextColor(Color.BLACK); noticeTextView.setText( noticeTextView.getText().toString().replace("<u>", "").replace("</u>", "")); } } }); } Spinner stateSpinner = (Spinner) mRootView.findViewById(R.id.state); if (stateSpinner != null) { stateSpinner.setSelection(27); } return mRootView; }
From source file:com.blogspot.marioboehmer.thingibrowse.fragments.ThingDetailsFragment.java
private void showInstructions(String instructions) { if (TextUtils.isEmpty(instructions)) { thingInstructions.setVisibility(View.GONE); thingInstructionsLabel.setVisibility(View.GONE); } else {//from ww w .j a v a 2s .c o m thingInstructions.setText(Html.fromHtml(instructions.replaceAll("\n", "<br />"))); thingInstructions.setVisibility(View.VISIBLE); thingInstructionsLabel.setVisibility(View.VISIBLE); } }
From source file:com.citrus.sdk.CitrusActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { mPaymentType = getIntent().getParcelableExtra(Constants.INTENT_EXTRA_PAYMENT_TYPE); if (!(mPaymentType instanceof PaymentType.CitrusCash)) { setTheme(R.style.Base_Theme_AppCompat_Light_DarkActionBar); }/* w w w.j ava 2 s .co m*/ super.onCreate(savedInstanceState); setContentView(R.layout.activity_citrus); mPaymentParams = getIntent().getParcelableExtra(Constants.INTENT_EXTRA_PAYMENT_PARAMS); mCitrusConfig = CitrusConfig.getInstance(); mActivityTitle = mCitrusConfig.getCitrusActivityTitle(); mCitrusClient = CitrusClient.getInstance(mContext); // Set payment Params if (mPaymentParams != null) { mPaymentType = mPaymentParams.getPaymentType(); mPaymentOption = mPaymentParams.getPaymentOption(); mCitrusUser = mPaymentParams.getUser(); mColorPrimary = mPaymentParams.getColorPrimary(); mColorPrimaryDark = mPaymentParams.getColorPrimaryDark(); mTextColorPrimary = mPaymentParams.getTextColorPrimary(); } else if (mPaymentType != null) { mPaymentOption = mPaymentType.getPaymentOption(); mCitrusUser = mPaymentType.getCitrusUser(); mColorPrimary = mCitrusConfig.getColorPrimary(); mColorPrimaryDark = mCitrusConfig.getColorPrimaryDark(); mTextColorPrimary = mCitrusConfig.getTextColorPrimary(); } else { throw new IllegalArgumentException("Payment Type Should not be null"); } mActionBar = getSupportActionBar(); mProgressDialog = new ProgressDialog(mContext); mPaymentWebview = (WebView) findViewById(R.id.payment_webview); mPaymentWebview.getSettings().setJavaScriptEnabled(true); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { /* This setting is required to enable redirection of urls from https to http or vice-versa. This redirection is blocked by default from Lollipop (Android 21). */ mPaymentWebview.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW); } mPaymentWebview.addJavascriptInterface(new JsInterface(), Constants.JS_INTERFACE_NAME); mPaymentWebview.setWebChromeClient(new WebChromeClient()); mPaymentWebview.setWebViewClient(new CitrusWebClient()); // Make the webview visible only in case of PGPayment or LoadMoney. if (mPaymentType instanceof PaymentType.CitrusCash) { mPaymentWebview.setVisibility(View.GONE); } if (mPaymentType instanceof PaymentType.PGPayment || mPaymentType instanceof PaymentType.CitrusCash) { if (mPaymentType.getPaymentBill() != null) { // TODO Need to refactor the code. if (PaymentBill.toJSONObject(mPaymentType.getPaymentBill()) != null) { proceedToPayment(PaymentBill.toJSONObject(mPaymentType.getPaymentBill()).toString()); } } else { fetchBill(); } } else { //load cash does not requires Bill Generator Amount amount = mPaymentType.getAmount(); LoadMoney loadMoney = new LoadMoney(amount.getValue(), mPaymentType.getUrl()); PG paymentgateway = new PG(mPaymentOption, loadMoney, new UserDetails(CitrusUser.toJSONObject(mCitrusUser))); paymentgateway.load(CitrusActivity.this, new Callback() { @Override public void onTaskexecuted(String success, String error) { processresponse(success, error); } }); } if (TextUtils.isEmpty(mActivityTitle)) { mActivityTitle = "Processing..."; } setTitle(Html.fromHtml("<font color=\"" + mTextColorPrimary + "\">" + mActivityTitle + "</font>")); setActionBarBackground(); }
From source file:co.dilaver.quoter.fragments.PopularFragment.java
@Override public void pqInfoClicked() { android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(getActivity()); builder.setTitle(getString(R.string.str_Info)); builder.setMessage(Html.fromHtml(getString(R.string.str_TakenFromReddit))); builder.setCancelable(true);/*from w w w .j a v a 2s.c o m*/ builder.show(); }
From source file:com.liato.bankdroid.banking.banks.Coop.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()); }//from w w w .j a v a 2s . co m urlopen = login(); Matcher matcher; Account account; class RequestDetails { public String url, name, id; public RequestDetails(String url, String name, String id) { this.url = url; this.name = name; this.id = id; } } ArrayList<RequestDetails> arrRD = new ArrayList<RequestDetails>(); arrRD.add(new RequestDetails("https://www.coop.se/Mina-sidor/Oversikt/Kontoutdrag-MedMera-Visa/", "MedMera Visa", "1")); arrRD.add( new RequestDetails("https://www.coop.se/Mina-sidor/Oversikt/MedMera-Konto/", "MedMera Konto", "2")); arrRD.add(new RequestDetails("https://www.coop.se/Mina-sidor/Oversikt/Kontoutdrag-MedMera-Faktura/", "MedMera Faktura", "3")); for (RequestDetails rd : arrRD) { try { response = urlopen.open(rd.url); matcher = reBalance.matcher(response); if (matcher.find()) { account = new Account(rd.name, Helpers.parseBalance(matcher.group(1).trim()), rd.id); balance = balance.add(Helpers.parseBalance(matcher.group(1))); matcher = reTransactions.matcher(response); ArrayList<Transaction> transactions = new ArrayList<Transaction>(); while (matcher.find()) { /* * Capture groups: * GROUP EXAMPLE DATA * 1: Date 2010-11-04 * 2: Activity Kp * 3: User John Doe * 4: Place Coop Extra Stenungsund * 5: Amount -809,37 kr * * */ String title = Html.fromHtml(matcher.group(4)).toString().trim().length() > 0 ? Html.fromHtml(matcher.group(4)).toString().trim() : Html.fromHtml(matcher.group(2)).toString().trim(); if (Html.fromHtml(matcher.group(3)).toString().trim().length() > 0) { title = title + " (" + Html.fromHtml(matcher.group(3)).toString().trim() + ")"; } transactions.add(new Transaction(matcher.group(1).trim(), title, Helpers.parseBalance(matcher.group(5)))); } account.setTransactions(transactions); accounts.add(account); } } catch (ClientProtocolException e) { //404 or 500 response } catch (IOException e) { } } if (accounts.isEmpty()) { throw new BankException(res.getText(R.string.no_accounts_found).toString()); } super.updateComplete(); }
From source file:com.liato.bankdroid.banking.banks.DanskeBank.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 w w . j a v a2s .co m*/ urlopen = login(); Matcher matcher; matcher = reSessionId.matcher(response); if (matcher.find()) { mSessionId = matcher.group(1); } else { throw new BankException(res.getText(R.string.unable_to_find).toString() + " session id."); } matcher = rePersonnr.matcher(response); if (matcher.find()) { mPersonnr = matcher.group(1); } else { throw new BankException(res.getText(R.string.unable_to_find).toString() + " personnummer."); } try { response = urlopen .open(String.format("https://mobil.danskebank.se/XI?WP=XAS&WO=Konto&WA=KTList&WSES=%s&WAFT=%s", mSessionId, mPersonnr)); matcher = reAccounts.matcher(response); while (matcher.find()) { /* * Capture groups: * GROUP EXAMPLE DATA * 1: Internal acc number? 0123456789 * 2: Account name Danske Direkt Bas * 3: Account number 01234567890 * 4: Balance 1.124,56 * 5: Balance (disp.) 1.124,56 * */ String name = Html.fromHtml(matcher.group(2)).toString().trim(); Account account = new Account(name, Helpers.parseBalance(matcher.group(5)), matcher.group(1).trim()); if (name.contains("ln") || name.contains("Ln")) { account.setType(Account.LOANS); } else { balance = balance.add(Helpers.parseBalance(matcher.group(5))); } accounts.add(account); } 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:org.openintents.openpgp.keyserver.HkpKeyServer.java
private ArrayList<KeyInfo> parseQuery(String searchString) throws QueryException, TooManyResponses, InsufficientQuery { ArrayList<KeyInfo> results = new ArrayList<KeyInfo>(); String encodedQuery;//from www .j a v a 2s . c o m try { encodedQuery = URLEncoder.encode(searchString, "utf8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); return results; } final String request = "/pks/lookup?op=index&search=" + encodedQuery; String data = null; try { data = submitQuery(request); } catch (HttpError e) { if (e.getCode() == 404) { return results; } else { if (e.getData().toLowerCase(Locale.ENGLISH).contains("no keys found")) { return results; } else if (e.getData().toLowerCase(Locale.ENGLISH).contains("too many")) { throw new TooManyResponses(); } else if (e.getData().toLowerCase(Locale.ENGLISH).contains("insufficient")) { throw new InsufficientQuery(); } } throw new QueryException("querying server(s) for '" + mHost + "' failed"); } Matcher matcher = PUB_KEY_LINE.matcher(data); while (matcher.find()) { KeyInfo info = new KeyInfo(); info.size = Integer.parseInt(matcher.group(1)); info.algorithm = matcher.group(2); info.setFingerprint(matcher.group(3)); String chunks[] = matcher.group(4).split("-"); info.creationDate = new GregorianCalendar(Integer.parseInt(chunks[0]), Integer.parseInt(chunks[1]), Integer.parseInt(chunks[2])).getTime(); info.userIds = new ArrayList<String>(); if (matcher.group(5).startsWith("*** KEY REVOKED ***")) { info.isRevoked = true; } else { info.isRevoked = false; String tmp = matcher.group(5).replaceAll("<.*?>", ""); tmp = Html.fromHtml(tmp).toString(); info.userIds.add(tmp); } if (matcher.group(6).length() > 0) { Matcher matcher2 = USER_ID_LINE.matcher(matcher.group(6)); while (matcher2.find()) { String tmp = matcher2.group(1).replaceAll("<.*?>", ""); tmp = Html.fromHtml(tmp).toString(); info.userIds.add(tmp); } } results.add(info); } return results; }