Remove HTML markup in OnlineFeedView. closes #401
This commit is contained in:
parent
8a951d0dbf
commit
a275786640
|
@ -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.
|
|
@ -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>
|
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>
|
<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>
|
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>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -33,6 +33,7 @@ dependencies {
|
||||||
compile ("com.doomonafireball.betterpickers:library:1.5.2") {
|
compile ("com.doomonafireball.betterpickers:library:1.5.2") {
|
||||||
exclude group: 'com.android.support', module: 'support-v4'
|
exclude group: 'com.android.support', module: 'support-v4'
|
||||||
}
|
}
|
||||||
|
compile 'org.jsoup:jsoup:1.7.3'
|
||||||
}
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
|
|
|
@ -5,19 +5,26 @@ import android.content.Intent;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.NavUtils;
|
import android.support.v4.app.NavUtils;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.*;
|
import android.widget.*;
|
||||||
|
import de.danoeh.antennapod.BuildConfig;
|
||||||
import de.danoeh.antennapod.R;
|
import de.danoeh.antennapod.R;
|
||||||
import de.danoeh.antennapod.adapter.FeedItemlistDescriptionAdapter;
|
import de.danoeh.antennapod.adapter.FeedItemlistDescriptionAdapter;
|
||||||
import de.danoeh.antennapod.asynctask.ImageDiskCache;
|
import de.danoeh.antennapod.asynctask.ImageDiskCache;
|
||||||
import de.danoeh.antennapod.dialog.DownloadRequestErrorDialogCreator;
|
import de.danoeh.antennapod.dialog.DownloadRequestErrorDialogCreator;
|
||||||
import de.danoeh.antennapod.feed.EventDistributor;
|
import de.danoeh.antennapod.feed.EventDistributor;
|
||||||
import de.danoeh.antennapod.feed.Feed;
|
import de.danoeh.antennapod.feed.Feed;
|
||||||
|
import de.danoeh.antennapod.feed.FeedItem;
|
||||||
import de.danoeh.antennapod.storage.DBReader;
|
import de.danoeh.antennapod.storage.DBReader;
|
||||||
import de.danoeh.antennapod.storage.DownloadRequestException;
|
import de.danoeh.antennapod.storage.DownloadRequestException;
|
||||||
import de.danoeh.antennapod.storage.DownloadRequester;
|
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.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
@ -25,9 +32,11 @@ import java.util.List;
|
||||||
import java.util.Map;
|
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 {
|
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 static final int EVENTS = EventDistributor.DOWNLOAD_HANDLED | EventDistributor.DOWNLOAD_QUEUED | EventDistributor.FEED_LIST_UPDATE;
|
||||||
private volatile List<Feed> feeds;
|
private volatile List<Feed> feeds;
|
||||||
|
@ -63,6 +72,22 @@ public class DefaultOnlineFeedViewActivity extends OnlineFeedViewActivity {
|
||||||
feeds = DBReader.getFeedList(this);
|
feeds = DBReader.getFeedList(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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
|
@Override
|
||||||
protected void showFeedInformation(final Feed feed, final Map<String, String> alternateFeedUrls) {
|
protected void showFeedInformation(final Feed feed, final Map<String, String> alternateFeedUrls) {
|
||||||
super.showFeedInformation(feed, alternateFeedUrls);
|
super.showFeedInformation(feed, alternateFeedUrls);
|
||||||
|
@ -131,7 +156,7 @@ public class DefaultOnlineFeedViewActivity extends OnlineFeedViewActivity {
|
||||||
for (String url : alternateFeedUrls.keySet()) {
|
for (String url : alternateFeedUrls.keySet()) {
|
||||||
alternateUrlsTitleList.add(alternateFeedUrls.get(url));
|
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);
|
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||||
spAlternateUrls.setAdapter(adapter);
|
spAlternateUrls.setAdapter(adapter);
|
||||||
spAlternateUrls.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
spAlternateUrls.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||||
|
|
|
@ -253,6 +253,7 @@ public abstract class OnlineFeedViewActivity extends ActionBarActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (successful) {
|
if (successful) {
|
||||||
|
beforeShowFeedInformation(feed, alternateFeedUrls);
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
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) {
|
protected void showFeedInformation(Feed feed, Map<String, String> alternateFeedUrls) {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue