diff options
author | daniel oeh <daniel.oeh@gmail.com> | 2014-06-15 21:02:35 +0200 |
---|---|---|
committer | daniel oeh <daniel.oeh@gmail.com> | 2014-06-15 21:02:35 +0200 |
commit | a2757866402f01c6683d0ba17cf19e3e7d158fbe (patch) | |
tree | 1b511227321097b7819ac5a2d2083547e9f9ee82 /src | |
parent | 8a951d0dbf220e2c7b26b18d6dbc1de4ed5cf718 (diff) | |
download | AntennaPod-a2757866402f01c6683d0ba17cf19e3e7d158fbe.zip |
Remove HTML markup in OnlineFeedView. closes #401
Diffstat (limited to 'src')
-rw-r--r-- | src/de/danoeh/antennapod/activity/DefaultOnlineFeedViewActivity.java | 29 | ||||
-rw-r--r-- | src/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java | 12 |
2 files changed, 38 insertions, 3 deletions
diff --git a/src/de/danoeh/antennapod/activity/DefaultOnlineFeedViewActivity.java b/src/de/danoeh/antennapod/activity/DefaultOnlineFeedViewActivity.java index 597189885..9c4634d93 100644 --- a/src/de/danoeh/antennapod/activity/DefaultOnlineFeedViewActivity.java +++ b/src/de/danoeh/antennapod/activity/DefaultOnlineFeedViewActivity.java @@ -5,19 +5,26 @@ import android.content.Intent; import android.os.AsyncTask; import android.os.Bundle; import android.support.v4.app.NavUtils; +import android.util.Log; import android.view.LayoutInflater; import android.view.MenuItem; import android.view.View; import android.widget.*; +import de.danoeh.antennapod.BuildConfig; import de.danoeh.antennapod.R; import de.danoeh.antennapod.adapter.FeedItemlistDescriptionAdapter; import de.danoeh.antennapod.asynctask.ImageDiskCache; import de.danoeh.antennapod.dialog.DownloadRequestErrorDialogCreator; import de.danoeh.antennapod.feed.EventDistributor; import de.danoeh.antennapod.feed.Feed; +import de.danoeh.antennapod.feed.FeedItem; import de.danoeh.antennapod.storage.DBReader; import de.danoeh.antennapod.storage.DownloadRequestException; import de.danoeh.antennapod.storage.DownloadRequester; +import org.apache.commons.lang3.StringUtils; +import org.jsoup.Jsoup; +import org.jsoup.examples.HtmlToPlainText; +import org.jsoup.nodes.Document; import java.util.ArrayList; import java.util.Date; @@ -25,9 +32,11 @@ import java.util.List; import java.util.Map; /** - * Created by daniel on 24.08.13. + * Default implementation of OnlineFeedViewActivity. Shows the downloaded feed's items with their descriptions, + * a subscribe button and a spinner for choosing alternate feed URLs. */ public class DefaultOnlineFeedViewActivity extends OnlineFeedViewActivity { + private static final String TAG = "DefaultOnlineFeedViewActivity"; private static final int EVENTS = EventDistributor.DOWNLOAD_HANDLED | EventDistributor.DOWNLOAD_QUEUED | EventDistributor.FEED_LIST_UPDATE; private volatile List<Feed> feeds; @@ -64,6 +73,22 @@ public class DefaultOnlineFeedViewActivity extends OnlineFeedViewActivity { } @Override + protected void beforeShowFeedInformation(Feed feed, Map<String, String> alternateFeedUrls) { + super.beforeShowFeedInformation(feed, alternateFeedUrls); + + // remove HTML tags from descriptions + + if (BuildConfig.DEBUG) Log.d(TAG, "Removing HTML from shownotes"); + if (feed.getItems() != null) { + HtmlToPlainText formatter = new HtmlToPlainText(); + for (FeedItem item : feed.getItems()) { + Document description = Jsoup.parse(item.getDescription()); + item.setDescription(StringUtils.trim(formatter.getPlainText(description))); + } + } + } + + @Override protected void showFeedInformation(final Feed feed, final Map<String, String> alternateFeedUrls) { super.showFeedInformation(feed, alternateFeedUrls); setContentView(R.layout.listview_activity); @@ -131,7 +156,7 @@ public class DefaultOnlineFeedViewActivity extends OnlineFeedViewActivity { for (String url : alternateFeedUrls.keySet()) { alternateUrlsTitleList.add(alternateFeedUrls.get(url)); } - ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, alternateUrlsTitleList); + ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, alternateUrlsTitleList); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spAlternateUrls.setAdapter(adapter); spAlternateUrls.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { diff --git a/src/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java b/src/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java index e397ff2ca..322c32741 100644 --- a/src/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java +++ b/src/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java @@ -253,6 +253,7 @@ public abstract class OnlineFeedViewActivity extends ActionBarActivity { } if (successful) { + beforeShowFeedInformation(feed, alternateFeedUrls); runOnUiThread(new Runnable() { @Override public void run() { @@ -285,7 +286,16 @@ public abstract class OnlineFeedViewActivity extends ActionBarActivity { } /** - * Called when feed parsed successfully + * Called after the feed has been downloaded and parsed and before showFeedInformation is called. + * This method is executed on a background thread + */ + protected void beforeShowFeedInformation(Feed feed, Map<String, String> alternateFeedUrls) { + + } + + /** + * Called when feed parsed successfully. + * This method is executed on the GUI thread. */ protected void showFeedInformation(Feed feed, Map<String, String> alternateFeedUrls) { |