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 | |
parent | 8a951d0dbf220e2c7b26b18d6dbc1de4ed5cf718 (diff) | |
download | AntennaPod-a2757866402f01c6683d0ba17cf19e3e7d158fbe.zip |
Remove HTML markup in OnlineFeedView. closes #401
-rw-r--r-- | assets/LICENSE_JSOUP.txt | 21 | ||||
-rw-r--r-- | assets/about.html | 2 | ||||
-rw-r--r-- | build.gradle | 1 | ||||
-rw-r--r-- | src/de/danoeh/antennapod/activity/DefaultOnlineFeedViewActivity.java | 29 | ||||
-rw-r--r-- | src/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java | 12 |
5 files changed, 62 insertions, 3 deletions
diff --git a/assets/LICENSE_JSOUP.txt b/assets/LICENSE_JSOUP.txt new file mode 100644 index 000000000..f3ef71dbf --- /dev/null +++ b/assets/LICENSE_JSOUP.txt @@ -0,0 +1,21 @@ +The MIT License + +Copyright (c) 2009, 2010, 2011, 2012, 2013 Jonathan Hedley <jonathan@hedley.net> + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/assets/about.html b/assets/about.html index 1d509459c..de5e9836e 100644 --- a/assets/about.html +++ b/assets/about.html @@ -62,5 +62,7 @@ licensed under the Apache 2.0 license <a href="LICENSE_DSLV.txt">(View)</a> licensed under the Apache 2.0 license <a href="LICENSE_PRESTO.txt">(View)</a> <h2>Better Pickers <a href="https://github.com/derekbrameyer/android-betterpickers">(Link)</a></h2> licensed under the Apache 2.0 license <a href="LICENSE_BETTERPICKERS.txt">(View)</a> +<h2>jsoup <a href="http://jsoup.org/">(Link)</a></h2> +licensed under the MIT license <a href="LICENSE_JSOUP.txt">(View)</a> </body> </html> diff --git a/build.gradle b/build.gradle index f1a8a5534..d367f5687 100644 --- a/build.gradle +++ b/build.gradle @@ -33,6 +33,7 @@ dependencies { compile ("com.doomonafireball.betterpickers:library:1.5.2") { exclude group: 'com.android.support', module: 'support-v4' } + compile 'org.jsoup:jsoup:1.7.3' } android { 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) { |