List of usage examples for android.text Html fromHtml
@Deprecated public static Spanned fromHtml(String source)
From source file:com.phonemetra.lockclock.weather.YahooWeatherProvider.java
@Override public WeatherInfo getWeatherInfo(Location location, boolean metric) { String language = getLanguage(); String params = String.format(Locale.US, "\"%f %f\" and locale=\"%s\"", location.getLatitude(), location.getLongitude(), language); String url = URL_PLACEFINDER + Uri.encode(params); JSONObject results = fetchResults(url); if (results == null) { return null; }/*w ww . j a v a2 s .co m*/ try { JSONObject result = results.getJSONObject("Result"); String woeid = result.getString("woeid"); String city = null; for (String name : PLACE_NAMES) { if (!result.isNull(name)) { city = result.getString(name); if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, String.format(Locale.US, "Placefinder for location %f %f " + "matched %s using %s", location.getLatitude(), location.getLongitude(), city, name)); } break; } } // The city name in the placefinder result is HTML encoded :-( if (city != null) { city = Html.fromHtml(city).toString(); } else { Log.w(TAG, "Can not resolve place name for " + location); } Log.d(TAG, "Resolved location " + location + " to " + city + " (" + woeid + ")"); WeatherInfo info = getWeatherInfo(woeid, city, metric); if (info != null) { return info; } } catch (JSONException e) { Log.e(TAG, "Received malformed placefinder data (location=" + location + ", lang=" + language + ")", e); } return null; }
From source file:com.android.dialer.lookup.google.GoogleForwardLookup.java
/** * Convert HTML to unformatted plain text. * * @param s HTML content// w w w . j a va 2 s. c o m * @return Unformatted plain text */ private String decodeHtml(String s) { return Html.fromHtml(s).toString(); }
From source file:com.liato.bankdroid.banking.banks.DanskeBank.java
@Override public void updateTransactions(Account account, Urllib urlopen) throws LoginException, BankException { super.updateTransactions(account, urlopen); //No transaction history for loans, funds and credit cards. int accType = account.getType(); if (accType == Account.LOANS || accType == Account.FUNDS || accType == Account.CCARD) return;//from w ww .jav a 2 s. co m Matcher matcher; try { response = urlopen.open( String.format("https://mobil.danskebank.se/XI?WP=XAS&WAFT=%s&WSES=%s&WO=Konto&WA=KBList&WCI=%s", mPersonnr, mSessionId, account.getId())); matcher = reTransactions.matcher(response); ArrayList<Transaction> transactions = new ArrayList<Transaction>(); while (matcher.find()) { /* * Capture groups: * GROUP EXAMPLE DATA * 1: Transaction Till Fondsparande * 2: Date 2011-07-28 * 3: Amount ? * 4: Status Vntar | Utfrd * */ transactions.add(new Transaction(Html.fromHtml(matcher.group(2)).toString().trim(), Html.fromHtml(matcher.group(1)).toString().trim(), Helpers.parseBalance(matcher.group(3)))); } account.setTransactions(transactions); } catch (ClientProtocolException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:org.liberty.android.fantastischmemo.downloader.DownloaderAnyMemo.java
@Override protected void fetchDatabase(final DownloadItem di) { final Thread downloadThread = new Thread() { @Override//from w ww .j a va 2 s .c o m public void run() { String filename = di.getExtras("filename"); try { downloadDatabase(di); filename = filename.replace(".zip", ".db"); String sdpath = AMEnv.DEFAULT_ROOT_PATH; final File dbFile = new File(sdpath + filename); mHandler.post(new Runnable() { public void run() { new AlertDialog.Builder(DownloaderAnyMemo.this) .setTitle(R.string.downloader_download_success) .setMessage(getString(R.string.downloader_download_success_message) + dbFile.toString()) .setPositiveButton(R.string.ok_text, null).create().show(); } }); } catch (final Exception e) { mHandler.post(new Runnable() { public void run() { new AlertDialog.Builder(DownloaderAnyMemo.this) .setTitle(R.string.downloader_download_fail) .setMessage(getString(R.string.downloader_download_fail_message) + " " + e.toString()) .setPositiveButton(R.string.ok_text, null).create().show(); } }); } } }; View alertView = View.inflate(DownloaderAnyMemo.this, R.layout.link_alert, null); TextView textView = (TextView) alertView.findViewById(R.id.link_alert_message); textView.setMovementMethod(LinkMovementMethod.getInstance()); textView.setText( Html.fromHtml(getString(R.string.downloader_download_alert_message) + di.getDescription())); new AlertDialog.Builder(this).setView(alertView) .setTitle(getString(R.string.downloader_download_alert) + di.getExtras("filename")) .setPositiveButton(getString(R.string.yes_text), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { downloadThread.start(); } }).setNegativeButton(getString(R.string.no_text), null).show(); }
From source file:com.liato.bankdroid.banking.banks.AkeliusInvest.java
@Override public void updateTransactions(Account account, Urllib urlopen) throws LoginException, BankException { super.updateTransactions(account, urlopen); if (account.getId().startsWith("a:") || !mIdMappings.containsKey(account.getId())) return; // No transactions for "saldo"-accounts String accountId = mIdMappings.get(account.getId()); String response = null;// w ww .j a va 2 s . co m Matcher matcher; try { response = urlopen .open("https://online.akeliusinvest.com/AccountStatement.mws?selectedaccount=" + accountId); matcher = reTransactions.matcher(response); /* ICA-banken Akelius Invest * Beskrivning 1 2 * Datum 2 1 * Belopp 3 3 */ ArrayList<Transaction> transactions = new ArrayList<Transaction>(); while (matcher.find()) { transactions.add(new Transaction(matcher.group(1).trim(), Html.fromHtml(matcher.group(2)).toString().trim(), Helpers.parseBalance(matcher.group(3)))); } account.setTransactions(transactions); } catch (ClientProtocolException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:com.flowzr.activity.FlowzrSyncActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.flowzr_sync); //@see: http://stackoverflow.com/questions/16539251/get-rid-of-blue-line, //only way found to remove on various devices 2.3x, 3.0, ... getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor("#121212"))); renderLastTime();/* w w w. java 2 s. co m*/ CheckBox chkForce = (CheckBox) findViewById(R.id.chk_sync_from_zero); chkForce.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { resetLastTime(); renderLastTime(); } }); Button syncButton = (Button) findViewById(R.id.sync); syncButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { startSync(); } }); Button textViewAbout = (Button) findViewById(R.id.buySubscription); textViewAbout.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { String accountName = MyPreferences.getFlowzrAccount(getApplicationContext()); if (accountName == null) { Toast.makeText(FlowzrSyncActivity.this, R.string.flowzr_choose_account, Toast.LENGTH_SHORT) .show(); return; } if (isOnline(FlowzrSyncActivity.this)) { //checkPlayServices(); } else { showErrorPopup(FlowzrSyncActivity.this, R.string.flowzr_sync_error_no_network); return; } // Toast.makeText(FlowzrSyncActivity.this, R.string.flowzr_sync_auth_inprogress, Toast.LENGTH_SHORT) .show(); FlowzrBillTask ft = new FlowzrBillTask(FlowzrSyncActivity.this); ft.execute(); //visitFlowzr(accountName); } }); Button textViewAboutAnon = (Button) findViewById(R.id.visitFlowzr); textViewAboutAnon.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (isOnline(FlowzrSyncActivity.this)) { visitFlowzr(null); } else { showErrorPopup(FlowzrSyncActivity.this, R.string.flowzr_sync_error_no_network); } } }); TextView textViewNotes = (TextView) findViewById(R.id.flowzrPleaseNote); textViewNotes.setMovementMethod(LinkMovementMethod.getInstance()); textViewNotes.setText(Html.fromHtml(getString(R.string.flowzr_terms_of_use))); if (MyPreferences.isAutoSync(this)) { if (checkPlayServices()) { gcm = GoogleCloudMessaging.getInstance(this); regid = getRegistrationId(getApplicationContext()); if (regid.equals("")) { registerInBackground(); } Log.i(TAG, "Google Cloud Messaging registered as :" + regid); } else { Log.i(TAG, "No valid Google Play Services APK found."); } } }
From source file:com.liato.bankdroid.banking.banks.AkeliusSpar.java
@Override public void updateTransactions(Account account, Urllib urlopen) throws LoginException, BankException { super.updateTransactions(account, urlopen); if (account.getId().startsWith("a:") || !mIdMappings.containsKey(account.getId())) return; // No transactions for "saldo"-accounts String accountId = mIdMappings.get(account.getId()); String response = null;/*www .j av a 2 s. co m*/ Matcher matcher; try { response = urlopen .open("https://www.online.akeliusspar.se/AccountStatement.mws?selectedaccount=" + accountId); matcher = reTransactions.matcher(response); /* ICA-banken Akelius Invest * Beskrivning 1 2 * Datum 2 1 * Belopp 3 3 */ ArrayList<Transaction> transactions = new ArrayList<Transaction>(); while (matcher.find()) { transactions.add(new Transaction(matcher.group(1).trim(), Html.fromHtml(matcher.group(2)).toString().trim(), Helpers.parseBalance(matcher.group(3)))); } account.setTransactions(transactions); } catch (ClientProtocolException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:com.flowzr.budget.holo.activity.FlowzrSyncActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.flowzr_sync); //@see: http://stackoverflow.com/questions/16539251/get-rid-of-blue-line, //only way found to remove on various devices 2.3x, 3.0, ... getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor("#121212"))); renderLastTime();// www. jav a 2 s. c o m CheckBox chkForce = (CheckBox) findViewById(R.id.chk_sync_from_zero); chkForce.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { resetLastTime(); renderLastTime(); } }); Button syncButton = (Button) findViewById(R.id.sync); syncButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { startSync(); } }); Button textViewAbout = (Button) findViewById(R.id.buySubscription); textViewAbout.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { String accountName = MyPreferences.getFlowzrAccount(getApplicationContext()); if (accountName == null) { Toast.makeText(FlowzrSyncActivity.this, R.string.flowzr_choose_account, Toast.LENGTH_SHORT) .show(); return; } if (isOnline(FlowzrSyncActivity.this)) { //checkPlayServices(); } else { showErrorPopup(FlowzrSyncActivity.this, R.string.flowzr_sync_error_no_network); return; } // Toast.makeText(FlowzrSyncActivity.this, R.string.flowzr_sync_auth_inprogress, Toast.LENGTH_SHORT) .show(); FlowzrBillTask ft = new FlowzrBillTask(FlowzrSyncActivity.this); ft.execute(); //visitFlowzr(accountName); } }); Button textViewAboutAnon = (Button) findViewById(R.id.visitFlowzr); textViewAboutAnon.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (isOnline(FlowzrSyncActivity.this)) { visitFlowzr(null); } else { showErrorPopup(FlowzrSyncActivity.this, R.string.flowzr_sync_error_no_network); } } }); TextView textViewNotes = (TextView) findViewById(R.id.flowzrPleaseNote); textViewNotes.setMovementMethod(LinkMovementMethod.getInstance()); textViewNotes.setText(Html.fromHtml(getString(R.string.flowzr_terms_of_use))); if (MyPreferences.isAutoSync(this)) { if (checkPlayServices()) { gcm = GoogleCloudMessaging.getInstance(this); regid = getRegistrationId(getApplicationContext()); if (regid.equals("")) { registerInBackground(); } Log.i(TAG, "Google Cloud Messaging registered as :" + regid); } else { Log.i(TAG, "No valid Google Play Services APK found."); } } }
From source file:org.liberty.android.fantastischmemopro.downloader.DownloaderAnyMemo.java
@Override protected void fetchDatabase(final DownloadItem di) { final Thread downloadThread = new Thread() { @Override//ww w . j a va 2 s. com public void run() { String filename = di.getExtras("filename"); try { downloadDatabase(di); filename = filename.replace(".zip", ".db"); String sdpath = Environment.getExternalStorageDirectory().getAbsolutePath() + getString(R.string.default_dir); final File dbFile = new File(sdpath + filename); mHandler.post(new Runnable() { public void run() { new AlertDialog.Builder(DownloaderAnyMemo.this) .setTitle(R.string.downloader_download_success) .setMessage(getString(R.string.downloader_download_success_message) + dbFile.toString()) .setPositiveButton(R.string.ok_text, null).create().show(); } }); } catch (final Exception e) { mHandler.post(new Runnable() { public void run() { new AlertDialog.Builder(DownloaderAnyMemo.this) .setTitle(R.string.downloader_download_fail) .setMessage(getString(R.string.downloader_download_fail_message) + " " + e.toString()) .setPositiveButton(R.string.ok_text, null).create().show(); } }); } } }; View alertView = View.inflate(DownloaderAnyMemo.this, R.layout.link_alert, null); TextView textView = (TextView) alertView.findViewById(R.id.link_alert_message); textView.setMovementMethod(LinkMovementMethod.getInstance()); textView.setText( Html.fromHtml(getString(R.string.downloader_download_alert_message) + di.getDescription())); new AlertDialog.Builder(this).setView(alertView) .setTitle(getString(R.string.downloader_download_alert) + di.getExtras("filename")) .setPositiveButton(getString(R.string.yes_text), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { downloadThread.start(); } }).setNegativeButton(getString(R.string.no_text), null).show(); }
From source file:com.arlib.floatingsearchviewdemo.MainActivity.java
private void setupFloatingSearch() { mSearchView.setOnQueryChangeListener(new FloatingSearchView.OnQueryChangeListener() { @Override/* w w w. j a v a 2 s .c om*/ public void onSearchTextChanged(String oldQuery, final String newQuery) { if (!oldQuery.equals("") && newQuery.equals("")) { mSearchView.clearSuggestions(); } else { //this shows the top left circular progress //you can call it where ever you want, but //it makes sense to do it when loading something in //the background. mSearchView.showProgress(); //simulates a query call to a data source //with a new query. DataHelper.findSuggestions(MainActivity.this, newQuery, 5, FIND_SUGGESTION_SIMULATED_DELAY, new DataHelper.OnFindSuggestionsListener() { @Override public void onResults(List<ColorSuggestion> results) { //this will swap the data and //render the collapse/expand animations as necessary mSearchView.swapSuggestions(results); //let the users know that the background //process has completed mSearchView.hideProgress(); } }); } Log.d(TAG, "onSearchTextChanged()"); } }); mSearchView.setOnSearchListener(new FloatingSearchView.OnSearchListener() { @Override public void onSuggestionClicked(SearchSuggestion searchSuggestion) { ColorSuggestion colorSuggestion = (ColorSuggestion) searchSuggestion; DataHelper.findColors(MainActivity.this, colorSuggestion.getBody(), new DataHelper.OnFindColorsListener() { @Override public void onResults(List<ColorWrapper> results) { mSearchResultsAdapter.swapData(results); } }); Log.d(TAG, "onSuggestionClicked()"); } @Override public void onSearchAction(String query) { DataHelper.findColors(MainActivity.this, query, new DataHelper.OnFindColorsListener() { @Override public void onResults(List<ColorWrapper> results) { mSearchResultsAdapter.swapData(results); } }); Log.d(TAG, "onSearchAction()"); } }); mSearchView.setOnFocusChangeListener(new FloatingSearchView.OnFocusChangeListener() { @Override public void onFocus() { mSearchView.clearQuery(); //show suggestions when search bar gains focus (typically history suggestions) mSearchView.swapSuggestions(DataHelper.getHistory(MainActivity.this, 3)); Log.d(TAG, "onFocus()"); } @Override public void onFocusCleared() { Log.d(TAG, "onFocusCleared()"); } }); //handle menu clicks the same way as you would //in a regular activity mSearchView.setOnMenuItemClickListener(new FloatingSearchView.OnMenuItemClickListener() { @Override public void onActionMenuItemSelected(MenuItem item) { if (item.getItemId() == R.id.action_change_colors) { mIsDarkSearchTheme = true; //demonstrate setting colors for items mSearchView.setBackgroundColor(Color.parseColor("#787878")); mSearchView.setViewTextColor(Color.parseColor("#e9e9e9")); mSearchView.setHintTextColor(Color.parseColor("#e9e9e9")); mSearchView.setActionMenuOverflowColor(Color.parseColor("#e9e9e9")); mSearchView.setMenuItemIconColor(Color.parseColor("#e9e9e9")); mSearchView.setLeftActionIconColor(Color.parseColor("#e9e9e9")); mSearchView.setClearBtnColor(Color.parseColor("#e9e9e9")); mSearchView.setDividerColor(Color.parseColor("#BEBEBE")); mSearchView.setLeftActionIconColor(Color.parseColor("#e9e9e9")); } else { //just print action Toast.makeText(getApplicationContext(), item.getTitle(), Toast.LENGTH_SHORT).show(); } } }); //use this listener to listen to menu clicks when app:floatingSearch_leftAction="showHamburger" mSearchView.setOnLeftMenuClickListener(new FloatingSearchView.OnLeftMenuClickListener() { @Override public void onMenuOpened() { Log.d(TAG, "onMenuOpened()"); mDrawerLayout.openDrawer(GravityCompat.START); } @Override public void onMenuClosed() { Log.d(TAG, "onMenuClosed()"); } }); //use this listener to listen to menu clicks when app:floatingSearch_leftAction="showHome" mSearchView.setOnHomeActionClickListener(new FloatingSearchView.OnHomeActionClickListener() { @Override public void onHomeClicked() { Log.d(TAG, "onHomeClicked()"); } }); /* * Here you have access to the left icon and the text of a given suggestion * item after as it is bound to the suggestion list. You can utilize this * callback to change some properties of the left icon and the text. For example, you * can load the left icon images using your favorite image loading library, or change text color. * * * Important: * Keep in mind that the suggestion list is a RecyclerView, so views are reused for different * items in the list. */ mSearchView.setOnBindSuggestionCallback(new SearchSuggestionsAdapter.OnBindSuggestionCallback() { @Override public void onBindSuggestion(View suggestionView, ImageView leftIcon, TextView textView, SearchSuggestion item, int itemPosition) { ColorSuggestion colorSuggestion = (ColorSuggestion) item; String textColor = mIsDarkSearchTheme ? "#ffffff" : "#000000"; String textLight = mIsDarkSearchTheme ? "#bfbfbf" : "#787878"; if (colorSuggestion.getIsHistory()) { leftIcon.setImageDrawable( ResourcesCompat.getDrawable(getResources(), R.drawable.ic_history_black_24dp, null)); Util.setIconColor(leftIcon, Color.parseColor(textColor)); leftIcon.setAlpha(.36f); } else { leftIcon.setAlpha(0.0f); leftIcon.setImageDrawable(null); } textView.setTextColor(Color.parseColor(textColor)); String text = colorSuggestion.getBody().replaceFirst(mSearchView.getQuery(), "<font color=\"" + textLight + "\">" + mSearchView.getQuery() + "</font>"); textView.setText(Html.fromHtml(text)); } }); //listen for when suggestion list expands/shrinks in order to move down/up the //search results list mSearchView.setOnSuggestionsListHeightChanged(new FloatingSearchView.OnSuggestionsListHeightChanged() { @Override public void onSuggestionsListHeightChanged(float newHeight) { mSearchResultsList.setTranslationY(newHeight); } }); }