Merge pull request #4318 from johnjohndoe/htmlcompat-fromhtml

Replace deprecated Html#fromHtml with HtmlCompat#fromHtml.
This commit is contained in:
H. Lehmann 2020-07-26 17:30:36 +02:00 committed by GitHub
commit 18fd908e6b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 9 deletions

View File

@ -3,9 +3,11 @@ package de.danoeh.antennapod.fragment.preferences;
import android.app.Activity;
import android.content.SharedPreferences;
import android.os.Bundle;
import androidx.core.text.HtmlCompat;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
import android.text.Html;
import android.text.Spanned;
import android.text.format.DateUtils;
import android.widget.Toast;
import com.google.android.material.snackbar.Snackbar;
@ -115,7 +117,8 @@ public class GpodderPreferencesFragment extends PreferenceFragmentCompat {
String format = getActivity().getString(R.string.pref_gpodnet_login_status);
String summary = String.format(format, GpodnetPreferences.getUsername(),
GpodnetPreferences.getDeviceID());
findPreference(PREF_GPODNET_LOGOUT).setSummary(Html.fromHtml(summary));
Spanned formattedSummary = HtmlCompat.fromHtml(summary, HtmlCompat.FROM_HTML_MODE_LEGACY);
findPreference(PREF_GPODNET_LOGOUT).setSummary(formattedSummary);
updateLastGpodnetSyncReport(SyncService.isLastSyncSuccessful(getContext()),
SyncService.getLastSyncAttempt(getContext()));
} else {

View File

@ -1,7 +1,7 @@
package de.danoeh.antennapod.core.syndication.namespace.atom;
import android.os.Build;
import android.text.Html;
import androidx.core.text.HtmlCompat;
import de.danoeh.antennapod.core.syndication.namespace.Namespace;
import de.danoeh.antennapod.core.syndication.namespace.SyndElement;
@ -24,11 +24,7 @@ public class AtomText extends SyndElement {
if (type == null) {
return content;
} else if (type.equals(TYPE_HTML)) {
if (Build.VERSION.SDK_INT >= 24) {
return Html.fromHtml(content, Html.FROM_HTML_MODE_LEGACY).toString();
} else {
return Html.fromHtml(content).toString();
}
return HtmlCompat.fromHtml(content, HtmlCompat.FROM_HTML_MODE_LEGACY).toString();
} else if (type.equals(TYPE_XHTML)) {
return content;
} else { // Handle as text by default