List of usage examples for android.text Html fromHtml
public static Spanned fromHtml(String source, int flags)
From source file:Main.java
public static Spanned fromHtml(String source) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { return Html.fromHtml(source, Html.FROM_HTML_MODE_LEGACY); } else {/*from w ww .j a va 2 s . co m*/ return Html.fromHtml(source); } }
From source file:Main.java
@SuppressWarnings("deprecation") public static CharSequence htmlDecode(String input) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { return Html.fromHtml(input, Html.FROM_HTML_MODE_LEGACY); } else {//from w w w . j a v a 2 s . com return Html.fromHtml(input); } }
From source file:Main.java
public static Spanned fromHtml(String html) { if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) return Html.fromHtml(html, Html.FROM_HTML_MODE_LEGACY); else//from ww w. j a va2 s. c om return Html.fromHtml(html); }
From source file:Main.java
@SuppressWarnings("deprecation") public static Spanned fromHtml(String source) { Spanned result;/*from ww w .j a va2s. c o m*/ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { result = Html.fromHtml(source, Html.FROM_HTML_MODE_LEGACY); } else { result = Html.fromHtml(source); } return result; }
From source file:Main.java
@TargetApi(N) public static Spanned fromHtml(String source) { if (isCompatible(N)) { return Html.fromHtml(source, Html.FROM_HTML_MODE_LEGACY); } else {/*from w w w.ja va 2 s. co m*/ return Html.fromHtml(source); } }
From source file:Main.java
@SuppressWarnings("deprecation") public static Spanned fromHtml(String html) { Spanned result;//from w ww . j av a2s. c o m if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) { result = Html.fromHtml(html, Html.FROM_HTML_MODE_LEGACY); } else { result = Html.fromHtml(html); } return result; }
From source file:Main.java
public static SpannableString textSpannable(String text) { SpannableString s;/*from w w w .ja va 2s.co m*/ if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) { s = new SpannableString(Html.fromHtml(text, Html.FROM_HTML_MODE_LEGACY)); } else { //noinspection deprecation s = new SpannableString(Html.fromHtml(text)); } Linkify.addLinks(s, Linkify.WEB_URLS); return s; }
From source file:cc.metapro.openct.customviews.TableChooseDialog.java
private void setView() { mTableIds = new ArrayList<>(tableMap.size()); for (String s : tableMap.keySet()) { mTableIds.add(s);/* w w w . j av a 2s. c om*/ } final List<View> views = new ArrayList<>(mTableIds.size()); for (String s : mTableIds) { TextView textView = new TextView(getActivity()); String content = tableMap.get(s).toString(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { textView.setText(Html.fromHtml(content, Html.FROM_HTML_MODE_COMPACT)); } else { textView.setText(Html.fromHtml(content)); } views.add(textView); } mTabBar.setupWithViewPager(mViewPager); mViewPager.setAdapter(new PagerAdapter() { @Override public int getCount() { return mTableIds.size(); } @Override public CharSequence getPageTitle(int position) { return mTableIds.get(position); } @Override public boolean isViewFromObject(View view, Object object) { return view == object; } @Override public void destroyItem(ViewGroup container, int position, Object object) { container.removeView(views.get(position)); } @Override public Object instantiateItem(ViewGroup container, int position) { container.addView(views.get(position)); return views.get(position); } }); }
From source file:bupt.tiantian.callrecorder.callrecorder.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { Intent intent = new Intent(this, SettingsActivity.class); intent.putExtra("write_external", permissionWriteExternal); startActivity(intent);/* w ww . ja va 2 s . com*/ return true; } if (id == R.id.action_save) { if (null != selectedItems && selectedItems.length > 0) { Runnable runnable = new Runnable() { @Override public void run() { for (PhoneCallRecord record : selectedItems) { record.getPhoneCall().setKept(true); record.getPhoneCall().save(MainActivity.this); } LocalBroadcastManager.getInstance(MainActivity.this) .sendBroadcast(new Intent(LocalBroadcastActions.NEW_RECORDING_BROADCAST)); // Causes refresh } }; handler.post(runnable); } return true; } if (id == R.id.action_share) { if (null != selectedItems && selectedItems.length > 0) { Runnable runnable = new Runnable() { @Override public void run() { ArrayList<Uri> fileUris = new ArrayList<Uri>(); for (PhoneCallRecord record : selectedItems) { fileUris.add(Uri.fromFile(new File(record.getPhoneCall().getPathToRecording()))); } Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND_MULTIPLE); shareIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, fileUris); shareIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.email_title)); if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) { shareIntent.putExtra(Intent.EXTRA_HTML_TEXT, Html.fromHtml(getString(R.string.email_body_html), Html.FROM_HTML_MODE_LEGACY)); } else { shareIntent.putExtra(Intent.EXTRA_HTML_TEXT, Html.fromHtml(getString(R.string.email_body_html))); } shareIntent.putExtra(Intent.EXTRA_TEXT, getString(R.string.email_body)); shareIntent.setType("audio/*"); startActivity(Intent.createChooser(shareIntent, getString(R.string.action_share))); } }; handler.post(runnable); } return true; } if (id == R.id.action_delete) { if (null != selectedItems && selectedItems.length > 0) { AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle(R.string.delete_recording_title); alert.setMessage(R.string.delete_recording_subject); alert.setPositiveButton(R.string.dialog_yes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Runnable runnable = new Runnable() { @Override public void run() { Database callLog = Database.getInstance(MainActivity.this); for (PhoneCallRecord record : selectedItems) { int id = record.getPhoneCall().getId(); callLog.removeCall(id); } LocalBroadcastManager.getInstance(MainActivity.this).sendBroadcast( new Intent(LocalBroadcastActions.RECORDING_DELETED_BROADCAST)); //?selectedItems onListFragmentInteraction(new PhoneCallRecord[] {}); } }; handler.post(runnable); dialog.dismiss(); } }); alert.setNegativeButton(R.string.dialog_no, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); alert.show(); } return true; } if (id == R.id.action_delete_all) { AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle(R.string.delete_recording_title); alert.setMessage(R.string.delete_all_recording_subject); alert.setPositiveButton(R.string.dialog_yes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Runnable runnable = new Runnable() { @Override public void run() { Database.getInstance(MainActivity.this).removeAllCalls(false); LocalBroadcastManager.getInstance(getApplicationContext()) .sendBroadcast(new Intent(LocalBroadcastActions.RECORDING_DELETED_BROADCAST)); //?selectedItems onListFragmentInteraction(new PhoneCallRecord[] {}); } }; handler.post(runnable); dialog.dismiss(); } }); alert.setNegativeButton(R.string.dialog_no, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); alert.show(); return true; } if (R.id.action_whitelist == id) { if (permissionReadContacts) { Intent intent = new Intent(this, WhitelistActivity.class); startActivity(intent); } else { AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle(R.string.permission_whitelist_title); alert.setMessage(R.string.permission_whitelist); } return true; } return super.onOptionsItemSelected(item); }
From source file:com.actinarium.nagbox.service.NotificationHelper.java
private static CharSequence makeInboxStyleLine(Context context, Task task, long now) { final String duration = DateUtils.prettyPrintNagDuration(context, task.lastStartedAt, now); if (Build.VERSION.SDK_INT >= 24) { return Html.fromHtml(String.format(INBOX_STYLE_LINE_FORMAT_L, task.title, duration), Html.FROM_HTML_MODE_LEGACY); } else if (Build.VERSION.SDK_INT >= 21) { //noinspection deprecation return Html.fromHtml(String.format(INBOX_STYLE_LINE_FORMAT_L, task.title, duration)); } else {/*ww w .j a va2 s. c o m*/ //noinspection deprecation return Html.fromHtml(String.format(INBOX_STYLE_LINE_FORMAT_OLD, task.title, duration)); } }