use of de.danoeh.antennapod.core.util.syndication.HtmlToPlainText in project AntennaPod by AntennaPod.
the class OnlineFeedViewActivity method beforeShowFeedInformation.
/**
* Called after the feed has been downloaded and parsed and before showFeedInformation is called.
* This method is executed on a background thread
*/
private void beforeShowFeedInformation(Feed feed) {
final HtmlToPlainText formatter = new HtmlToPlainText();
if (Feed.TYPE_ATOM1.equals(feed.getType()) && feed.getDescription() != null) {
// remove HTML tags from descriptions
Log.d(TAG, "Removing HTML from feed description");
Document feedDescription = Jsoup.parse(feed.getDescription());
feed.setDescription(StringUtils.trim(formatter.getPlainText(feedDescription)));
}
Log.d(TAG, "Removing HTML from shownotes");
if (feed.getItems() != null) {
for (FeedItem item : feed.getItems()) {
if (item.getDescription() != null) {
Document itemDescription = Jsoup.parse(item.getDescription());
item.setDescription(StringUtils.trim(formatter.getPlainText(itemDescription)));
}
}
}
}
use of de.danoeh.antennapod.core.util.syndication.HtmlToPlainText in project AntennaPod by AntennaPod.
the class FeedInfoActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
setTheme(UserPreferences.getTheme());
super.onCreate(savedInstanceState);
setContentView(R.layout.feedinfo);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
long feedId = getIntent().getLongExtra(EXTRA_FEED_ID, -1);
imgvCover = (ImageView) findViewById(R.id.imgvCover);
txtvTitle = (TextView) findViewById(R.id.txtvTitle);
txtvDescription = (TextView) findViewById(R.id.txtvDescription);
lblLanguage = (TextView) findViewById(R.id.lblLanguage);
txtvLanguage = (TextView) findViewById(R.id.txtvLanguage);
lblAuthor = (TextView) findViewById(R.id.lblAuthor);
txtvAuthor = (TextView) findViewById(R.id.txtvAuthor);
txtvUrl = (TextView) findViewById(R.id.txtvUrl);
cbxAutoDownload = (CheckBox) findViewById(R.id.cbxAutoDownload);
cbxKeepUpdated = (CheckBox) findViewById(R.id.cbxKeepUpdated);
spnAutoDelete = (Spinner) findViewById(R.id.spnAutoDelete);
etxtUsername = (EditText) findViewById(R.id.etxtUsername);
etxtPassword = (EditText) findViewById(R.id.etxtPassword);
etxtFilterText = (EditText) findViewById(R.id.etxtEpisodeFilterText);
rdoFilterInclude = (RadioButton) findViewById(R.id.radio_filter_include);
rdoFilterInclude.setOnClickListener(v -> {
filterInclude = true;
filterTextChanged = true;
});
rdoFilterExclude = (RadioButton) findViewById(R.id.radio_filter_exclude);
rdoFilterExclude.setOnClickListener(v -> {
filterInclude = false;
filterTextChanged = true;
});
txtvUrl.setOnClickListener(copyUrlToClipboard);
subscription = Observable.fromCallable(() -> DBReader.getFeed(feedId)).subscribeOn(Schedulers.newThread()).observeOn(AndroidSchedulers.mainThread()).subscribe(result -> {
if (result == null) {
Log.e(TAG, "Activity was started with invalid arguments");
finish();
}
feed = result;
Log.d(TAG, "Language is " + feed.getLanguage());
Log.d(TAG, "Author is " + feed.getAuthor());
Log.d(TAG, "URL is " + feed.getDownload_url());
FeedPreferences prefs = feed.getPreferences();
Glide.with(FeedInfoActivity.this).load(feed.getImageLocation()).placeholder(R.color.light_gray).error(R.color.light_gray).diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY).fitCenter().dontAnimate().into(imgvCover);
txtvTitle.setText(feed.getTitle());
String description = feed.getDescription();
if (description != null) {
if (Feed.TYPE_ATOM1.equals(feed.getType())) {
HtmlToPlainText formatter = new HtmlToPlainText();
Document feedDescription = Jsoup.parse(feed.getDescription());
description = StringUtils.trim(formatter.getPlainText(feedDescription));
}
} else {
description = "";
}
txtvDescription.setText(description);
if (!TextUtils.isEmpty(feed.getAuthor())) {
txtvAuthor.setText(feed.getAuthor());
} else {
lblAuthor.setVisibility(View.GONE);
txtvAuthor.setVisibility(View.GONE);
}
if (!TextUtils.isEmpty(feed.getLanguage())) {
txtvLanguage.setText(LangUtils.getLanguageString(feed.getLanguage()));
} else {
lblLanguage.setVisibility(View.GONE);
txtvLanguage.setVisibility(View.GONE);
}
txtvUrl.setText(feed.getDownload_url() + " {fa-paperclip}");
Iconify.addIcons(txtvUrl);
cbxAutoDownload.setEnabled(UserPreferences.isEnableAutodownload());
cbxAutoDownload.setChecked(prefs.getAutoDownload());
cbxAutoDownload.setOnCheckedChangeListener((compoundButton, checked) -> {
feed.getPreferences().setAutoDownload(checked);
feed.savePreferences(FeedInfoActivity.this);
updateAutoDownloadSettings();
ApplyToEpisodesDialog dialog = new ApplyToEpisodesDialog(FeedInfoActivity.this, feed, checked);
dialog.createNewDialog().show();
});
cbxKeepUpdated.setChecked(prefs.getKeepUpdated());
cbxKeepUpdated.setOnCheckedChangeListener((compoundButton, checked) -> {
feed.getPreferences().setKeepUpdated(checked);
feed.savePreferences(FeedInfoActivity.this);
});
spnAutoDelete.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
FeedPreferences.AutoDeleteAction auto_delete_action;
switch(parent.getSelectedItemPosition()) {
case 0:
auto_delete_action = FeedPreferences.AutoDeleteAction.GLOBAL;
break;
case 1:
auto_delete_action = FeedPreferences.AutoDeleteAction.YES;
break;
case 2:
auto_delete_action = FeedPreferences.AutoDeleteAction.NO;
break;
default:
return;
}
feed.getPreferences().setAutoDeleteAction(auto_delete_action);
autoDeleteChanged = true;
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
spnAutoDelete.setSelection(prefs.getAutoDeleteAction().ordinal());
etxtUsername.setText(prefs.getUsername());
etxtPassword.setText(prefs.getPassword());
etxtUsername.addTextChangedListener(authTextWatcher);
etxtPassword.addTextChangedListener(authTextWatcher);
FeedFilter filter = prefs.getFilter();
if (filter.includeOnly()) {
etxtFilterText.setText(filter.getIncludeFilter());
rdoFilterInclude.setChecked(true);
rdoFilterExclude.setChecked(false);
filterInclude = true;
} else if (filter.excludeOnly()) {
etxtFilterText.setText(filter.getExcludeFilter());
rdoFilterInclude.setChecked(false);
rdoFilterExclude.setChecked(true);
filterInclude = false;
} else {
Log.d(TAG, "No filter set");
rdoFilterInclude.setChecked(false);
rdoFilterExclude.setChecked(false);
etxtFilterText.setText("");
}
etxtFilterText.addTextChangedListener(filterTextWatcher);
supportInvalidateOptionsMenu();
updateAutoDownloadSettings();
}, error -> {
Log.d(TAG, Log.getStackTraceString(error));
finish();
});
}
Aggregations