List of usage examples for android.text Html FROM_HTML_MODE_LEGACY
int FROM_HTML_MODE_LEGACY
To view the source code for android.text Html FROM_HTML_MODE_LEGACY.
Click Source Link
From source file:com.tortel.deploytrack.dialog.AboutDialog.java
@NonNull @Override//from w ww. jav a 2 s . c o m public Dialog onCreateDialog(Bundle savedInstanceState) { final Context wrappedContext = new ContextThemeWrapper(getActivity(), R.style.Theme_DeployThemeLight); MaterialDialog.Builder builder = new MaterialDialog.Builder(wrappedContext); LayoutInflater inflater = getActivity().getLayoutInflater().cloneInContext(wrappedContext); @SuppressLint("InflateParams") View view = inflater.inflate(R.layout.dialog_about, null); TextView text = (TextView) view.findViewById(R.id.about_view); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { text.setText(Html.fromHtml(readRawTextFile(getContent()), Html.FROM_HTML_MODE_LEGACY)); } else { //noinspection deprecation text.setText(Html.fromHtml(readRawTextFile(getContent()))); } Linkify.addLinks(text, Linkify.ALL); text.setMovementMethod(LinkMovementMethod.getInstance()); builder.customView(view, false); builder.title(getTitleString()); builder.positiveText(R.string.close); return builder.build(); }
From source file:com.loserskater.suhidegui.PackageActivity.java
private void showAbout() { Spanned temp;//from www .ja v a 2s. c om String links = String.format(getString(R.string.version), BuildConfig.VERSION_NAME) + "<br><br><br><a href='https://github.com/loserskater/suhide-GUI'>" + getString(R.string.github) + "</a><br><br>" + "<a href='http://forum.xda-developers.com/android/apps-games/app-suhide-gui-1-0-t3469667'>" + getString(R.string.xda) + "</a>"; if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) { temp = Html.fromHtml(links, Html.FROM_HTML_MODE_LEGACY); } else { temp = Html.fromHtml(links); } AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(getString(R.string.about)); builder.setMessage(temp); builder.setPositiveButton(getString(android.R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); AlertDialog dialog = builder.create(); dialog.show(); ((TextView) dialog.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance()); }
From source file:org.mozilla.focus.fragment.DownloadDialogFragment.java
public Spanned getSpannedTextFromHtml(int text, int replaceString) { if (Build.VERSION.SDK_INT >= 24) { return (Html.fromHtml(String.format(getText(text).toString(), getString(replaceString)), Html.FROM_HTML_MODE_LEGACY)); } else {//from w ww . j a v a2 s . c o m return (Html.fromHtml(String.format(getText(text).toString(), getString(replaceString)))); } }
From source file:com.jimandreas.android.designlibdemo.Leak1TestActivity.java
@SuppressLint("SetTextI18n") @Override/*w w w . j ava 2s . c o m*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // setContentView(R.layout.leak_detail); ButterKnife.bind(this); Intent intent = getIntent(); final String leakTestName = intent.getStringExtra(EXTRA_NAME); final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); CollapsingToolbarLayout collapsingToolbar = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar); collapsingToolbar.setTitle(leakTestName); loadBackdrop(); /** * This leak is courtesy of: * * https://medium.com/freenet-engineering/memory-leaks-in-android-identify-treat-and-avoid-d0b1233acc8#.9sanu6r7h */ leak_title.setText(R.string.leak1); String desc_raw = "Switch between the activities by selecting the BottomNavigationView item." + " This should leak the listener in the code" + " and produce a LeakCanary response.\n\n" + "This leak is courtesy of the entry by: \n\n" + "<big><strong>Johan Olsson</big></strong>\n\n" + "on his post to medium.com titled:\n\n" + "<big><strong>Memory leaks in Androididentify, treat and avoid</big></strong>\n" + "\nFor more information, press the FAB (floating action button)."; desc_raw = desc_raw.replace("\n", "<br>"); Spanned desc; if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) { desc = Html.fromHtml(desc_raw, Html.FROM_HTML_MODE_LEGACY); } else { //noinspection deprecation desc = Html.fromHtml(desc_raw); } leak_text.setText(desc); /** * And here is the actual leak! */ locationManager = (LocationManager) getSystemService(LOCATION_SERVICE); if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { // ActivityCompat#requestPermissions // here to request the missing permissions, and then overriding // public void onRequestPermissionsResult(int requestCode, String[] permissions, // int[] grantResults) // to handle the case where the user grants the permission. See the documentation // for ActivityCompat#requestPermissions for more details. Log.e(TAG, "******* Do not have Manifest permission for Location access!!"); return; } try { locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, TimeUnit.MINUTES.toMillis(5), 100, this); } catch (Exception e) { Toast.makeText(this, "Sorry can't do this test, no location service", Toast.LENGTH_LONG).show(); } /* * FAB button (floating action button = FAB) to get more information * No more snackbar - until it is "BottomNavigationView" sensitive... */ more_button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse( "https://medium.com/freenet-engineering/memory-leaks-in-android-identify-treat-and-avoid-d0b1233acc8#.9sanu6r7h")); startActivity(intent); } }); }
From source file:im.vector.fragments.GroupDetailsHomeFragment.java
/** * Update the long description text//from www. j a va 2 s .com */ private void refreshLongDescription() { if (null != mGroupHtmlTextView) { Group group = mActivity.getGroup(); if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) { mGroupHtmlTextView.setText( Html.fromHtml(group.getLongDescription(), Html.FROM_HTML_MODE_LEGACY, mImageGetter, null)); } else { mGroupHtmlTextView.setText(Html.fromHtml(group.getLongDescription(), mImageGetter, null)); } } }
From source file:com.grarak.kerneladiutor.utils.Utils.java
public static CharSequence htmlFrom(String text) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { return Html.fromHtml(text, Html.FROM_HTML_MODE_LEGACY); } else {//from w ww . j a v a 2 s. c o m return Html.fromHtml(text); } }
From source file:io.github.hidroh.materialistic.AppUtils.java
public static CharSequence fromHtml(String htmlText, boolean compact) { if (TextUtils.isEmpty(htmlText)) { return null; }/* www. ja v a 2 s. co m*/ CharSequence spanned; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { //noinspection InlinedApi spanned = Html.fromHtml(htmlText, compact ? Html.FROM_HTML_MODE_COMPACT : Html.FROM_HTML_MODE_LEGACY); } else { //noinspection deprecation spanned = Html.fromHtml(htmlText); } return trim(spanned); }
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 . j a v a2 s.co m 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:tech.salroid.filmy.activities.CharacterDetailsActivity.java
void personDetailsParsing(String detailsResult) { try {/*w ww . j a v a2 s . c o m*/ JSONObject jsonObject = new JSONObject(detailsResult); String char_name = jsonObject.getString("name"); String char_face = "http://image.tmdb.org/t/p/w185" + jsonObject.getString("profile_path"); String char_desc = jsonObject.getString("biography"); String char_birthday = jsonObject.getString("birthday"); String char_birthplace = jsonObject.getString("place_of_birth"); character_title = char_name; character_bio = char_desc; ch_name.setText(char_name); if (char_birthday.equals("null")) ch_birth.setVisibility(View.GONE); else ch_birth.setText(char_birthday); if (char_birthplace.equals("null")) ch_place.setVisibility(View.GONE); else ch_place.setText(char_birthplace); if (char_desc.length() <= 0) { headerContainer.setVisibility(View.GONE); ch_desc.setVisibility(View.GONE); } else { if (Build.VERSION.SDK_INT >= 24) { ch_desc.setText(Html.fromHtml(char_desc, Html.FROM_HTML_MODE_LEGACY)); } else { ch_desc.setText(Html.fromHtml(char_desc)); } } /*Glide.with(co) .load(char_banner) .fitCenter() .into(character_banner);*/ try { Glide.with(co).load(char_face).diskCacheStrategy(DiskCacheStrategy.NONE).fitCenter() .into(character_small); } catch (Exception e) { //Log.d(LOG_TAG, e.getMessage()); } } catch (JSONException e) { e.printStackTrace(); } }
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 {/*w w w . j a v a 2s . co m*/ //noinspection deprecation return Html.fromHtml(String.format(INBOX_STYLE_LINE_FORMAT_OLD, task.title, duration)); } }