Merge branch 'develop' into typos
This commit is contained in:
commit
5febe9248a
|
@ -328,6 +328,7 @@ public class OnlineFeedViewActivity extends ActionBarActivity {
|
|||
subscriber.onError(e);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, Log.getStackTraceString(e));
|
||||
subscriber.onError(e);
|
||||
} finally {
|
||||
boolean rc = new File(feed.getFile_url()).delete();
|
||||
|
|
|
@ -4,6 +4,7 @@ import android.Manifest;
|
|||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.TimePickerDialog;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
|
@ -86,6 +87,8 @@ public class PreferenceController implements SharedPreferences.OnSharedPreferenc
|
|||
public static final String PREF_GPODNET_HOSTNAME = "pref_gpodnet_hostname";
|
||||
public static final String PREF_EXPANDED_NOTIFICATION = "prefExpandNotify";
|
||||
public static final String PREF_PROXY = "prefProxy";
|
||||
public static final String PREF_KNOWN_ISSUES = "prefKnownIssues";
|
||||
public static final String PREF_SEND_CRASH_REPORT = "prefSendCrashReport";
|
||||
|
||||
private final PreferenceUI ui;
|
||||
|
||||
|
@ -373,7 +376,18 @@ public class PreferenceController implements SharedPreferences.OnSharedPreferenc
|
|||
dialog.createDialog().show();
|
||||
return true;
|
||||
});
|
||||
ui.findPreference("prefSendCrashReport").setOnPreferenceClickListener(preference -> {
|
||||
ui.findPreference(PREF_KNOWN_ISSUES).setOnPreferenceClickListener(preference -> {
|
||||
String url = "https://github.com/AntennaPod/AntennaPod/labels/bug";
|
||||
try {
|
||||
Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
|
||||
ui.getActivity().startActivity(myIntent);
|
||||
} catch (ActivityNotFoundException e) {
|
||||
Toast.makeText(ui.getActivity(), R.string.pref_no_browser_found, Toast.LENGTH_LONG).show();
|
||||
Log.e(TAG, Log.getStackTraceString(e));
|
||||
}
|
||||
return true;
|
||||
});
|
||||
ui.findPreference(PREF_SEND_CRASH_REPORT).setOnPreferenceClickListener(preference -> {
|
||||
Intent emailIntent = new Intent(Intent.ACTION_SEND);
|
||||
emailIntent.setType("text/plain");
|
||||
emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[]{"Martin.Fietz@gmail.com"});
|
||||
|
@ -532,7 +546,7 @@ public class PreferenceController implements SharedPreferences.OnSharedPreferenc
|
|||
ui.findPreference(UserPreferences.PREF_ENABLE_AUTODL_WIFI_FILTER).setEnabled(autoDownload);
|
||||
setSelectedNetworksEnabled(autoDownload && UserPreferences.isEnableAutodownloadWifiFilter());
|
||||
|
||||
ui.findPreference("prefSendCrashReport").setEnabled(CrashReportWriter.getFile().exists());
|
||||
ui.findPreference(PREF_SEND_CRASH_REPORT).setEnabled(CrashReportWriter.getFile().exists());
|
||||
|
||||
if (Build.VERSION.SDK_INT >= 16) {
|
||||
ui.findPreference(UserPreferences.PREF_SONIC).setEnabled(true);
|
||||
|
|
|
@ -185,7 +185,7 @@
|
|||
android:title="@string/pref_automatic_download_title"
|
||||
android:defaultValue="false"/>
|
||||
<com.afollestad.materialdialogs.prefs.MaterialListPreference
|
||||
android:defaultValue="20"
|
||||
android:defaultValue="25"
|
||||
android:entries="@array/episode_cache_size_entries"
|
||||
android:key="prefEpisodeCacheSize"
|
||||
android:title="@string/pref_episode_cache_title"
|
||||
|
@ -271,6 +271,9 @@
|
|||
<Preference
|
||||
android:key="prefAbout"
|
||||
android:title="@string/about_pref"/>
|
||||
<Preference
|
||||
android:key="prefKnownIssues"
|
||||
android:title="@string/pref_known_issues"/>
|
||||
<Preference
|
||||
android:key="prefSendCrashReport"
|
||||
android:title="@string/crash_report_title"
|
||||
|
|
|
@ -324,12 +324,11 @@ public class Feed extends FeedFile implements FlattrThing, ImageResource {
|
|||
if (super.compareWithOther(other)) {
|
||||
return true;
|
||||
}
|
||||
if (!title.equals(other.title)) {
|
||||
if (!TextUtils.equals(title, other.title)) {
|
||||
return true;
|
||||
}
|
||||
if (other.feedIdentifier != null) {
|
||||
if (feedIdentifier == null
|
||||
|| !feedIdentifier.equals(other.feedIdentifier)) {
|
||||
if (feedIdentifier == null || !feedIdentifier.equals(other.feedIdentifier)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package de.danoeh.antennapod.core.feed;
|
||||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
|
@ -54,7 +56,7 @@ public abstract class FeedFile extends FeedComponent {
|
|||
if (super.compareWithOther(other)) {
|
||||
return true;
|
||||
}
|
||||
if (!download_url.equals(other.download_url)) {
|
||||
if (!TextUtils.equals(download_url, other.download_url)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -95,8 +95,9 @@ public class FeedPreferences {
|
|||
* @return True if the two objects are different.
|
||||
*/
|
||||
public boolean compareWithOther(FeedPreferences other) {
|
||||
if (other == null)
|
||||
if (other == null) {
|
||||
return true;
|
||||
}
|
||||
if (!TextUtils.equals(username, other.username)) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -901,6 +901,7 @@ public final class DBReader {
|
|||
Cursor mediaCursor = adapter.getSingleFeedMediaCursor(mediaId);
|
||||
|
||||
if (!mediaCursor.moveToFirst()) {
|
||||
mediaCursor.close();
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
package de.danoeh.antennapod.core.syndication.namespace;
|
||||
|
||||
import de.danoeh.antennapod.core.syndication.handler.HandlerState;
|
||||
import org.xml.sax.Attributes;
|
||||
|
||||
import de.danoeh.antennapod.core.syndication.handler.HandlerState;
|
||||
|
||||
public class NSContent extends Namespace {
|
||||
public static final String NSTAG = "content";
|
||||
public static final String NSURI = "http://purl.org/rss/1.0/modules/content/";
|
||||
|
@ -17,7 +18,8 @@ public class NSContent extends Namespace {
|
|||
|
||||
@Override
|
||||
public void handleElementEnd(String localName, HandlerState state) {
|
||||
if (localName.equals(ENCODED)) {
|
||||
if (ENCODED.equals(localName) && state.getCurrentItem() != null &&
|
||||
state.getContentBuf() != null) {
|
||||
state.getCurrentItem().setContentEncoded(state.getContentBuf().toString());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package de.danoeh.antennapod.core.syndication.namespace;
|
|||
|
||||
import org.xml.sax.Attributes;
|
||||
|
||||
import de.danoeh.antennapod.core.feed.FeedItem;
|
||||
import de.danoeh.antennapod.core.syndication.handler.HandlerState;
|
||||
import de.danoeh.antennapod.core.util.DateUtils;
|
||||
|
||||
|
@ -21,17 +22,16 @@ public class NSDublinCore extends Namespace {
|
|||
|
||||
@Override
|
||||
public void handleElementEnd(String localName, HandlerState state) {
|
||||
if(state.getTagstack().size() >= 2
|
||||
&& state.getContentBuf() != null) {
|
||||
String content = state.getContentBuf().toString();
|
||||
SyndElement topElement = state.getTagstack().peek();
|
||||
String top = topElement.getName();
|
||||
SyndElement secondElement = state.getSecondTag();
|
||||
String second = secondElement.getName();
|
||||
if (top.equals(DATE) && second.equals(ITEM)) {
|
||||
state.getCurrentItem().setPubDate(
|
||||
DateUtils.parse(content));
|
||||
if (state.getCurrentItem() != null && state.getContentBuf() != null &&
|
||||
state.getTagstack() != null && state.getTagstack().size() >= 2) {
|
||||
FeedItem currentItem = state.getCurrentItem();
|
||||
String top = state.getTagstack().peek().getName();
|
||||
String second = state.getSecondTag().getName();
|
||||
if (DATE.equals(top) && ITEM.equals(second)) {
|
||||
String content = state.getContentBuf().toString();
|
||||
currentItem.setPubDate(DateUtils.parse(content));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package de.danoeh.antennapod.core.syndication.namespace;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import org.xml.sax.Attributes;
|
||||
|
||||
|
@ -10,6 +11,7 @@ import de.danoeh.antennapod.core.feed.FeedImage;
|
|||
import de.danoeh.antennapod.core.syndication.handler.HandlerState;
|
||||
|
||||
public class NSITunes extends Namespace {
|
||||
|
||||
public static final String NSTAG = "itunes";
|
||||
public static final String NSURI = "http://www.itunes.com/dtds/podcast-1.0.dtd";
|
||||
|
||||
|
@ -26,69 +28,82 @@ public class NSITunes extends Namespace {
|
|||
@Override
|
||||
public SyndElement handleElementStart(String localName, HandlerState state,
|
||||
Attributes attributes) {
|
||||
if (localName.equals(IMAGE)) {
|
||||
if (IMAGE.equals(localName)) {
|
||||
FeedImage image = new FeedImage();
|
||||
image.setTitle(IMAGE_TITLE);
|
||||
image.setDownload_url(attributes.getValue(IMAGE_HREF));
|
||||
|
||||
if (state.getCurrentItem() != null) {
|
||||
// this is an items image
|
||||
image.setTitle(state.getCurrentItem().getTitle()+IMAGE_TITLE);
|
||||
image.setTitle(state.getCurrentItem().getTitle() + IMAGE_TITLE);
|
||||
image.setOwner(state.getCurrentItem());
|
||||
state.getCurrentItem().setImage(image);
|
||||
|
||||
} else {
|
||||
} else {
|
||||
// this is the feed image
|
||||
// prefer to all other images
|
||||
if(!TextUtils.isEmpty(image.getDownload_url())) {
|
||||
if (!TextUtils.isEmpty(image.getDownload_url())) {
|
||||
image.setOwner(state.getFeed());
|
||||
state.getFeed().setImage(image);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return new SyndElement(localName, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleElementEnd(String localName, HandlerState state) {
|
||||
if (localName.equals(AUTHOR)) {
|
||||
state.getFeed().setAuthor(state.getContentBuf().toString());
|
||||
} else if (localName.equals(DURATION)) {
|
||||
String[] parts = state.getContentBuf().toString().trim().split(":");
|
||||
if(state.getContentBuf() == null) {
|
||||
return;
|
||||
}
|
||||
if (AUTHOR.equals(localName)) {
|
||||
if (state.getFeed() != null) {
|
||||
String author = state.getContentBuf().toString();
|
||||
state.getFeed().setAuthor(author);
|
||||
}
|
||||
} else if (DURATION.equals(localName)) {
|
||||
String duration = state.getContentBuf().toString();
|
||||
if(TextUtils.isEmpty(duration)) {
|
||||
return;
|
||||
}
|
||||
String[] parts = duration.trim().split(":");
|
||||
try {
|
||||
int duration = 0;
|
||||
int durationMs = 0;
|
||||
if (parts.length == 2) {
|
||||
duration += TimeUnit.MINUTES.toMillis(Long.parseLong(parts[0])) +
|
||||
durationMs += TimeUnit.MINUTES.toMillis(Long.parseLong(parts[0])) +
|
||||
TimeUnit.SECONDS.toMillis(Long.parseLong(parts[1]));
|
||||
} else if (parts.length >= 3) {
|
||||
duration += TimeUnit.HOURS.toMillis(Long.parseLong(parts[0])) +
|
||||
durationMs += TimeUnit.HOURS.toMillis(Long.parseLong(parts[0])) +
|
||||
TimeUnit.MINUTES.toMillis(Long.parseLong(parts[1])) +
|
||||
TimeUnit.SECONDS.toMillis(Long.parseLong(parts[2]));
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
state.getTempObjects().put(DURATION, duration);
|
||||
state.getTempObjects().put(DURATION, durationMs);
|
||||
} catch (NumberFormatException e) {
|
||||
e.printStackTrace();
|
||||
Log.e(NSTAG, Log.getStackTraceString(e));
|
||||
}
|
||||
} else if (localName.equals(SUBTITLE)) {
|
||||
} else if (SUBTITLE.equals(localName)) {
|
||||
String subtitle = state.getContentBuf().toString();
|
||||
if (TextUtils.isEmpty(subtitle)) {
|
||||
return;
|
||||
}
|
||||
if (state.getCurrentItem() != null) {
|
||||
if (TextUtils.isEmpty(state.getCurrentItem().getDescription())) {
|
||||
state.getCurrentItem().setDescription(subtitle);
|
||||
}
|
||||
} else {
|
||||
if (TextUtils.isEmpty(state.getFeed().getDescription())) {
|
||||
if (state.getFeed() != null && TextUtils.isEmpty(state.getFeed().getDescription())) {
|
||||
state.getFeed().setDescription(subtitle);
|
||||
}
|
||||
}
|
||||
} else if (localName.equals(SUMMARY)) {
|
||||
} else if (SUMMARY.equals(localName)) {
|
||||
String summary = state.getContentBuf().toString();
|
||||
if (TextUtils.isEmpty(summary)) {
|
||||
return;
|
||||
}
|
||||
if (state.getCurrentItem() != null) {
|
||||
state.getCurrentItem().setDescription(summary);
|
||||
} else {
|
||||
} else if (state.getFeed() != null) {
|
||||
state.getFeed().setDescription(summary);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
package de.danoeh.antennapod.core.syndication.namespace;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import de.danoeh.antennapod.core.BuildConfig;
|
||||
import de.danoeh.antennapod.core.feed.FeedMedia;
|
||||
import de.danoeh.antennapod.core.syndication.handler.HandlerState;
|
||||
import de.danoeh.antennapod.core.syndication.util.SyndTypeUtils;
|
||||
|
||||
import org.xml.sax.Attributes;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import de.danoeh.antennapod.core.feed.FeedMedia;
|
||||
import de.danoeh.antennapod.core.syndication.handler.HandlerState;
|
||||
import de.danoeh.antennapod.core.syndication.util.SyndTypeUtils;
|
||||
|
||||
/** Processes tags from the http://search.yahoo.com/mrss/ namespace. */
|
||||
public class NSMedia extends Namespace {
|
||||
private static final String TAG = "NSMedia";
|
||||
|
@ -25,36 +27,40 @@ public class NSMedia extends Namespace {
|
|||
@Override
|
||||
public SyndElement handleElementStart(String localName, HandlerState state,
|
||||
Attributes attributes) {
|
||||
if (localName.equals(CONTENT)) {
|
||||
if (CONTENT.equals(localName)) {
|
||||
String url = attributes.getValue(DOWNLOAD_URL);
|
||||
String type = attributes.getValue(MIME_TYPE);
|
||||
if (state.getCurrentItem().getMedia() == null
|
||||
&& url != null
|
||||
&& (SyndTypeUtils.enclosureTypeValid(type) || ((type = SyndTypeUtils
|
||||
.getValidMimeTypeFromUrl(url)) != null))) {
|
||||
|
||||
boolean validType;
|
||||
if(SyndTypeUtils.enclosureTypeValid(type)) {
|
||||
validType = true;
|
||||
} else {
|
||||
type = SyndTypeUtils.getValidMimeTypeFromUrl(url);
|
||||
validType = type != null;
|
||||
}
|
||||
if (state.getCurrentItem() != null && state.getCurrentItem().getMedia() == null &&
|
||||
url != null && validType) {
|
||||
long size = 0;
|
||||
try {
|
||||
size = Long.parseLong(attributes.getValue(SIZE));
|
||||
} catch (NumberFormatException e) {
|
||||
if (BuildConfig.DEBUG)
|
||||
Log.d(TAG, "Length attribute could not be parsed.");
|
||||
Log.e(TAG, "Length attribute could not be parsed.");
|
||||
}
|
||||
|
||||
int duration = 0;
|
||||
try {
|
||||
String durationStr = attributes.getValue(DURATION);
|
||||
if (durationStr != null) {
|
||||
duration = (int) TimeUnit.MILLISECONDS.convert(
|
||||
Long.parseLong(durationStr), TimeUnit.SECONDS);
|
||||
|
||||
int durationMs = 0;
|
||||
String durationStr = attributes.getValue(DURATION);
|
||||
if (!TextUtils.isEmpty(durationStr)) {
|
||||
try {
|
||||
long duration = Long.parseLong(durationStr);
|
||||
durationMs = (int) TimeUnit.MILLISECONDS.convert(duration, TimeUnit.SECONDS);
|
||||
} catch (NumberFormatException e) {
|
||||
Log.e(TAG, "Duration attribute could not be parsed");
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
if (BuildConfig.DEBUG)
|
||||
Log.d(TAG, "Duration attribute could not be parsed");
|
||||
}
|
||||
|
||||
state.getCurrentItem().setMedia(
|
||||
new FeedMedia(state.getCurrentItem(), url, size, type));
|
||||
FeedMedia media = new FeedMedia(state.getCurrentItem(), url, size, type);
|
||||
if(durationMs > 0) {
|
||||
media.setDuration(durationMs);
|
||||
}
|
||||
state.getCurrentItem().setMedia(media);
|
||||
}
|
||||
}
|
||||
return new SyndElement(localName, this);
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package de.danoeh.antennapod.core.syndication.namespace;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import org.xml.sax.Attributes;
|
||||
|
||||
import de.danoeh.antennapod.core.BuildConfig;
|
||||
import de.danoeh.antennapod.core.feed.Feed;
|
||||
import de.danoeh.antennapod.core.feed.FeedImage;
|
||||
import de.danoeh.antennapod.core.feed.FeedItem;
|
||||
|
@ -43,18 +43,23 @@ public class NSRSS20 extends Namespace {
|
|||
@Override
|
||||
public SyndElement handleElementStart(String localName, HandlerState state,
|
||||
Attributes attributes) {
|
||||
if (localName.equals(ITEM)) {
|
||||
if (ITEM.equals(localName)) {
|
||||
state.setCurrentItem(new FeedItem());
|
||||
state.getItems().add(state.getCurrentItem());
|
||||
state.getCurrentItem().setFeed(state.getFeed());
|
||||
|
||||
} else if (localName.equals(ENCLOSURE)) {
|
||||
} else if (ENCLOSURE.equals(localName)) {
|
||||
String type = attributes.getValue(ENC_TYPE);
|
||||
String url = attributes.getValue(ENC_URL);
|
||||
if (state.getCurrentItem().getMedia() == null
|
||||
&& (SyndTypeUtils.enclosureTypeValid(type) || ((type = SyndTypeUtils
|
||||
.getValidMimeTypeFromUrl(url)) != null))) {
|
||||
|
||||
boolean validType;
|
||||
if(SyndTypeUtils.enclosureTypeValid(type)) {
|
||||
validType = true;
|
||||
} else {
|
||||
type = type = SyndTypeUtils.getValidMimeTypeFromUrl(url);
|
||||
validType = type != null;
|
||||
}
|
||||
if (state.getCurrentItem() != null && state.getCurrentItem().getMedia() == null &&
|
||||
validType) {
|
||||
long size = 0;
|
||||
try {
|
||||
size = Long.parseLong(attributes.getValue(ENC_LEN));
|
||||
|
@ -63,19 +68,18 @@ public class NSRSS20 extends Namespace {
|
|||
size = 0;
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
if (BuildConfig.DEBUG)
|
||||
Log.d(TAG, "Length attribute could not be parsed.");
|
||||
Log.d(TAG, "Length attribute could not be parsed.");
|
||||
}
|
||||
state.getCurrentItem().setMedia(
|
||||
new FeedMedia(state.getCurrentItem(), url, size, type));
|
||||
}
|
||||
|
||||
} else if (localName.equals(IMAGE)) {
|
||||
} else if (IMAGE.equals(localName)) {
|
||||
if (state.getTagstack().size() >= 1) {
|
||||
String parent = state.getTagstack().peek().getName();
|
||||
if (parent.equals(CHANNEL)) {
|
||||
if (CHANNEL.equals(parent)) {
|
||||
Feed feed = state.getFeed();
|
||||
if(feed.getImage() == null) {
|
||||
if(feed != null && feed.getImage() == null) {
|
||||
feed.setImage(new FeedImage());
|
||||
feed.getImage().setOwner(state.getFeed());
|
||||
}
|
||||
|
@ -87,26 +91,26 @@ public class NSRSS20 extends Namespace {
|
|||
|
||||
@Override
|
||||
public void handleElementEnd(String localName, HandlerState state) {
|
||||
if (localName.equals(ITEM)) {
|
||||
if (ITEM.equals(localName)) {
|
||||
if (state.getCurrentItem() != null) {
|
||||
FeedItem currentItem = state.getCurrentItem();
|
||||
// the title tag is optional in RSS 2.0. The description is used
|
||||
// as a
|
||||
// title if the item has no title-tag.
|
||||
if (state.getCurrentItem().getTitle() == null) {
|
||||
state.getCurrentItem().setTitle(
|
||||
state.getCurrentItem().getDescription());
|
||||
if (currentItem.getTitle() == null) {
|
||||
currentItem.setTitle(currentItem.getDescription());
|
||||
}
|
||||
|
||||
if (state.getTempObjects().containsKey(NSITunes.DURATION)) {
|
||||
if (state.getCurrentItem().hasMedia()) {
|
||||
state.getCurrentItem().getMedia().setDuration((Integer) state.getTempObjects().get(NSITunes.DURATION));
|
||||
if (currentItem.hasMedia()) {
|
||||
Integer duration = (Integer) state.getTempObjects().get(NSITunes.DURATION);
|
||||
currentItem.getMedia().setDuration(duration);
|
||||
}
|
||||
state.getTempObjects().remove(NSITunes.DURATION);
|
||||
}
|
||||
}
|
||||
state.setCurrentItem(null);
|
||||
} else if (state.getTagstack().size() >= 2
|
||||
&& state.getContentBuf() != null) {
|
||||
} else if (state.getTagstack().size() >= 2 && state.getContentBuf() != null) {
|
||||
String content = state.getContentBuf().toString();
|
||||
SyndElement topElement = state.getTagstack().peek();
|
||||
String top = topElement.getName();
|
||||
|
@ -116,46 +120,44 @@ public class NSRSS20 extends Namespace {
|
|||
if (state.getTagstack().size() >= 3) {
|
||||
third = state.getThirdTag().getName();
|
||||
}
|
||||
|
||||
if (top.equals(GUID) && second.equals(ITEM)) {
|
||||
if (GUID.equals(top) && ITEM.equals(second)) {
|
||||
// some feed creators include an empty or non-standard guid-element in their feed, which should be ignored
|
||||
if (!content.isEmpty()) {
|
||||
if (!TextUtils.isEmpty(content) && state.getCurrentItem() != null) {
|
||||
state.getCurrentItem().setItemIdentifier(content);
|
||||
}
|
||||
} else if (top.equals(TITLE)) {
|
||||
} else if (TITLE.equals(top)) {
|
||||
String title = content.trim();
|
||||
if (second.equals(ITEM)) {
|
||||
if (ITEM.equals(second) && state.getCurrentItem() != null) {
|
||||
state.getCurrentItem().setTitle(title);
|
||||
} else if (second.equals(CHANNEL)) {
|
||||
} else if (CHANNEL.equals(second) && state.getFeed() != null) {
|
||||
state.getFeed().setTitle(title);
|
||||
} else if (second.equals(IMAGE) && third != null
|
||||
&& third.equals(CHANNEL)) {
|
||||
if(state.getFeed().getImage().getTitle() == null) {
|
||||
} else if (IMAGE.equals(second) && CHANNEL.equals(third)) {
|
||||
if(state.getFeed() != null && state.getFeed().getImage() != null &&
|
||||
state.getFeed().getImage().getTitle() == null) {
|
||||
state.getFeed().getImage().setTitle(title);
|
||||
}
|
||||
}
|
||||
} else if (top.equals(LINK)) {
|
||||
if (second.equals(CHANNEL)) {
|
||||
} else if (LINK.equals(top)) {
|
||||
if (CHANNEL.equals(second) && state.getFeed() != null) {
|
||||
state.getFeed().setLink(content);
|
||||
} else if (second.equals(ITEM)) {
|
||||
} else if (ITEM.equals(second) && state.getCurrentItem() != null) {
|
||||
state.getCurrentItem().setLink(content);
|
||||
}
|
||||
} else if (top.equals(PUBDATE) && second.equals(ITEM)) {
|
||||
state.getCurrentItem().setPubDate(
|
||||
DateUtils.parse(content));
|
||||
} else if (top.equals(URL) && second.equals(IMAGE) && third != null
|
||||
&& third.equals(CHANNEL)) {
|
||||
if(state.getFeed().getImage().getDownload_url() == null) { // prefer itunes:image
|
||||
} else if (PUBDATE.equals(top) && ITEM.equals(second) && state.getCurrentItem() != null) {
|
||||
state.getCurrentItem().setPubDate(DateUtils.parse(content));
|
||||
} else if (URL.equals(top) && IMAGE.equals(second) && CHANNEL.equals(third)) {
|
||||
// prefer itunes:image
|
||||
if(state.getFeed() != null && state.getFeed().getImage() != null &&
|
||||
state.getFeed().getImage().getDownload_url() == null) {
|
||||
state.getFeed().getImage().setDownload_url(content);
|
||||
}
|
||||
} else if (localName.equals(DESCR)) {
|
||||
if (second.equals(CHANNEL)) {
|
||||
} else if (DESCR.equals(localName)) {
|
||||
if (CHANNEL.equals(second) && state.getFeed() != null) {
|
||||
state.getFeed().setDescription(content);
|
||||
} else if (second.equals(ITEM)) {
|
||||
} else if (ITEM.equals(second) && state.getCurrentItem() != null) {
|
||||
state.getCurrentItem().setDescription(content);
|
||||
}
|
||||
|
||||
} else if (localName.equals(LANGUAGE)) {
|
||||
} else if (LANGUAGE.equals(localName) && state.getFeed() != null) {
|
||||
state.getFeed().setLanguage(content.toLowerCase());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,8 +6,7 @@ import org.xml.sax.Attributes;
|
|||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import de.danoeh.antennapod.core.BuildConfig;
|
||||
import de.danoeh.antennapod.core.feed.Chapter;
|
||||
import de.danoeh.antennapod.core.feed.FeedItem;
|
||||
import de.danoeh.antennapod.core.feed.SimpleChapter;
|
||||
import de.danoeh.antennapod.core.syndication.handler.HandlerState;
|
||||
import de.danoeh.antennapod.core.util.DateUtils;
|
||||
|
@ -27,21 +26,22 @@ public class NSSimpleChapters extends Namespace {
|
|||
@Override
|
||||
public SyndElement handleElementStart(String localName, HandlerState state,
|
||||
Attributes attributes) {
|
||||
if (localName.equals(CHAPTERS)) {
|
||||
state.getCurrentItem().setChapters(new ArrayList<Chapter>());
|
||||
} else if (localName.equals(CHAPTER)) {
|
||||
try {
|
||||
state.getCurrentItem()
|
||||
.getChapters()
|
||||
.add(new SimpleChapter(DateUtils
|
||||
.parseTimeString(attributes.getValue(START)),
|
||||
attributes.getValue(TITLE), state.getCurrentItem(),
|
||||
attributes.getValue(HREF)));
|
||||
} catch (NumberFormatException e) {
|
||||
if (BuildConfig.DEBUG) Log.w(TAG, "Unable to read chapter", e);
|
||||
FeedItem currentItem = state.getCurrentItem();
|
||||
if(currentItem != null) {
|
||||
if (localName.equals(CHAPTERS)) {
|
||||
currentItem.setChapters(new ArrayList<>());
|
||||
} else if (localName.equals(CHAPTER)) {
|
||||
try {
|
||||
long start = DateUtils.parseTimeString(attributes.getValue(START));
|
||||
String title = attributes.getValue(TITLE);
|
||||
String link = attributes.getValue(HREF);
|
||||
SimpleChapter chapter = new SimpleChapter(start, title, currentItem, link);
|
||||
currentItem.getChapters().add(chapter);
|
||||
} catch (NumberFormatException e) {
|
||||
Log.e(TAG, "Unable to read chapter", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new SyndElement(localName, this);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package de.danoeh.antennapod.core.syndication.namespace.atom;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import org.xml.sax.Attributes;
|
||||
|
@ -65,21 +66,21 @@ public class NSAtom extends Namespace {
|
|||
@Override
|
||||
public SyndElement handleElementStart(String localName, HandlerState state,
|
||||
Attributes attributes) {
|
||||
if (localName.equals(ENTRY)) {
|
||||
if (ENTRY.equals(localName)) {
|
||||
state.setCurrentItem(new FeedItem());
|
||||
state.getItems().add(state.getCurrentItem());
|
||||
state.getCurrentItem().setFeed(state.getFeed());
|
||||
} else if (localName.matches(isText)) {
|
||||
String type = attributes.getValue(TEXT_TYPE);
|
||||
return new AtomText(localName, this, type);
|
||||
} else if (localName.equals(LINK)) {
|
||||
} else if (LINK.equals(localName)) {
|
||||
String href = attributes.getValue(LINK_HREF);
|
||||
String rel = attributes.getValue(LINK_REL);
|
||||
SyndElement parent = state.getTagstack().peek();
|
||||
if (parent.getName().matches(isFeedItem)) {
|
||||
if (rel == null || rel.equals(LINK_REL_ALTERNATE)) {
|
||||
if (LINK_REL_ALTERNATE.equals(rel)) {
|
||||
state.getCurrentItem().setLink(href);
|
||||
} else if (rel.equals(LINK_REL_ENCLOSURE)) {
|
||||
} else if (LINK_REL_ENCLOSURE.equals(rel)) {
|
||||
String strSize = attributes.getValue(LINK_LENGTH);
|
||||
long size = 0;
|
||||
try {
|
||||
|
@ -90,40 +91,45 @@ public class NSAtom extends Namespace {
|
|||
Log.d(TAG, "Length attribute could not be parsed.");
|
||||
}
|
||||
String type = attributes.getValue(LINK_TYPE);
|
||||
if (SyndTypeUtils.enclosureTypeValid(type)
|
||||
|| (type = SyndTypeUtils.getValidMimeTypeFromUrl(href)) != null) {
|
||||
boolean validType;
|
||||
if(SyndTypeUtils.enclosureTypeValid(type)) {
|
||||
validType = true;
|
||||
} else {
|
||||
type = SyndTypeUtils.getValidMimeTypeFromUrl(href);
|
||||
validType = type != null;
|
||||
}
|
||||
if (validType) {
|
||||
FeedItem currItem = state.getCurrentItem();
|
||||
if(!currItem.hasMedia()) {
|
||||
if(currItem != null && !currItem.hasMedia()) {
|
||||
currItem.setMedia(new FeedMedia(currItem, href, size, type));
|
||||
}
|
||||
}
|
||||
} else if (rel.equals(LINK_REL_PAYMENT)) {
|
||||
} else if (LINK_REL_PAYMENT.equals(rel)) {
|
||||
state.getCurrentItem().setPaymentLink(href);
|
||||
}
|
||||
} else if (parent.getName().matches(isFeed)) {
|
||||
if (rel == null || rel.equals(LINK_REL_ALTERNATE)) {
|
||||
if (LINK_REL_ALTERNATE.equals(rel)) {
|
||||
String type = attributes.getValue(LINK_TYPE);
|
||||
/*
|
||||
* Use as link if a) no type-attribute is given and
|
||||
* feed-object has no link yet b) type of link is
|
||||
* LINK_TYPE_HTML or LINK_TYPE_XHTML
|
||||
*/
|
||||
if ((type == null && state.getFeed().getLink() == null)
|
||||
|| (type != null && (type.equals(LINK_TYPE_HTML)
|
||||
|| type.equals(LINK_TYPE_XHTML)))) {
|
||||
if (state.getFeed() != null &&
|
||||
((type == null && state.getFeed().getLink() == null) ||
|
||||
(LINK_TYPE_HTML.equals(type) || LINK_TYPE_XHTML.equals(type)))) {
|
||||
state.getFeed().setLink(href);
|
||||
} else if (type != null && (type.equals(LINK_TYPE_ATOM)
|
||||
|| type.equals(LINK_TYPE_RSS))) {
|
||||
} else if (LINK_TYPE_ATOM.equals(type) || LINK_TYPE_RSS.equals(type)) {
|
||||
// treat as podlove alternate feed
|
||||
String title = attributes.getValue(LINK_TITLE);
|
||||
if (title == null) {
|
||||
if (TextUtils.isEmpty(title)) {
|
||||
title = href;
|
||||
}
|
||||
state.addAlternateFeedUrl(title, href);
|
||||
}
|
||||
} else if (rel.equals(LINK_REL_PAYMENT)) {
|
||||
} else if (LINK_REL_PAYMENT.equals(rel) && state.getFeed() != null) {
|
||||
state.getFeed().setPaymentLink(href);
|
||||
} else if (rel.equals(LINK_REL_NEXT)) {
|
||||
} else if (LINK_REL_NEXT.equals(rel) && state.getFeed() != null) {
|
||||
state.getFeed().setPaged(true);
|
||||
state.getFeed().setNextPageLink(href);
|
||||
}
|
||||
|
@ -134,11 +140,13 @@ public class NSAtom extends Namespace {
|
|||
|
||||
@Override
|
||||
public void handleElementEnd(String localName, HandlerState state) {
|
||||
if (localName.equals(ENTRY)) {
|
||||
if (ENTRY.equals(localName)) {
|
||||
if (state.getCurrentItem() != null &&
|
||||
state.getTempObjects().containsKey(NSITunes.DURATION)) {
|
||||
if (state.getCurrentItem().hasMedia()) {
|
||||
state.getCurrentItem().getMedia().setDuration((Integer) state.getTempObjects().get(NSITunes.DURATION));
|
||||
FeedItem currentItem = state.getCurrentItem();
|
||||
if (currentItem.hasMedia()) {
|
||||
Integer duration = (Integer) state.getTempObjects().get(NSITunes.DURATION);
|
||||
currentItem.getMedia().setDuration(duration);
|
||||
}
|
||||
state.getTempObjects().remove(NSITunes.DURATION);
|
||||
}
|
||||
|
@ -163,47 +171,32 @@ public class NSAtom extends Namespace {
|
|||
textElement.setContent(content);
|
||||
}
|
||||
|
||||
if (top.equals(ID)) {
|
||||
if (second.equals(FEED)) {
|
||||
if (ID.equals(top)) {
|
||||
if (FEED.equals(second) && state.getFeed() != null) {
|
||||
state.getFeed().setFeedIdentifier(content);
|
||||
} else if (second.equals(ENTRY)) {
|
||||
} else if (ENTRY.equals(second) && state.getCurrentItem() != null) {
|
||||
state.getCurrentItem().setItemIdentifier(content);
|
||||
}
|
||||
} else if (top.equals(TITLE)) {
|
||||
|
||||
if (second.equals(FEED)) {
|
||||
} else if (TITLE.equals(top) && textElement != null) {
|
||||
if (FEED.equals(second) && state.getFeed() != null) {
|
||||
state.getFeed().setTitle(textElement.getProcessedContent());
|
||||
} else if (second.equals(ENTRY)) {
|
||||
state.getCurrentItem().setTitle(
|
||||
textElement.getProcessedContent());
|
||||
}
|
||||
} else if (top.equals(SUBTITLE)) {
|
||||
if (second.equals(FEED)) {
|
||||
state.getFeed().setDescription(
|
||||
textElement.getProcessedContent());
|
||||
}
|
||||
} else if (top.equals(CONTENT)) {
|
||||
if (second.equals(ENTRY)) {
|
||||
state.getCurrentItem().setDescription(
|
||||
textElement.getProcessedContent());
|
||||
}
|
||||
} else if (top.equals(UPDATED)) {
|
||||
if (second.equals(ENTRY)
|
||||
&& state.getCurrentItem().getPubDate() == null) {
|
||||
state.getCurrentItem().setPubDate(
|
||||
DateUtils.parse(content));
|
||||
}
|
||||
} else if (top.equals(PUBLISHED)) {
|
||||
if (second.equals(ENTRY)) {
|
||||
state.getCurrentItem().setPubDate(
|
||||
DateUtils.parse(content));
|
||||
}
|
||||
} else if (top.equals(IMAGE)) {
|
||||
if(state.getFeed().getImage() == null) {
|
||||
state.getFeed().setImage(new FeedImage(state.getFeed(), content, null));
|
||||
} else if (ENTRY.equals(second) && state.getCurrentItem() != null) {
|
||||
state.getCurrentItem().setTitle(textElement.getProcessedContent());
|
||||
}
|
||||
} else if (SUBTITLE.equals(top) && FEED.equals(second) && textElement != null &&
|
||||
state.getFeed() != null) {
|
||||
state.getFeed().setDescription(textElement.getProcessedContent());
|
||||
} else if (CONTENT.equals(top) && ENTRY.equals(second) && textElement != null &&
|
||||
state.getCurrentItem() != null) {
|
||||
state.getCurrentItem().setDescription(textElement.getProcessedContent());
|
||||
} else if (UPDATED.equals(top) && ENTRY.equals(second) && state.getCurrentItem() != null &&
|
||||
state.getCurrentItem().getPubDate() == null) {
|
||||
state.getCurrentItem().setPubDate(DateUtils.parse(content));
|
||||
} else if (PUBLISHED.equals(top) && ENTRY.equals(second) && state.getCurrentItem() != null) {
|
||||
state.getCurrentItem().setPubDate(DateUtils.parse(content));
|
||||
} else if (IMAGE.equals(top) && state.getFeed() != null && state.getFeed().getImage() == null) {
|
||||
state.getFeed().setImage(new FeedImage(state.getFeed(), content, null));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,8 +30,7 @@ public class SyndTypeUtils {
|
|||
if (url != null) {
|
||||
String extension = FilenameUtils.getExtension(url);
|
||||
if (extension != null) {
|
||||
String type = MimeTypeMap.getSingleton()
|
||||
.getMimeTypeFromExtension(extension);
|
||||
String type = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension);
|
||||
if (type != null && enclosureTypeValid(type)) {
|
||||
return type;
|
||||
}
|
||||
|
|
|
@ -394,6 +394,8 @@
|
|||
<string name="pref_current_value">Current value: %1$s</string>
|
||||
<string name="pref_proxy_title">Proxy</string>
|
||||
<string name="pref_proxy_sum">Set a network proxy</string>
|
||||
<string name="pref_known_issues">Known issues</string>
|
||||
<string name="pref_no_browser_found">No web browser found."</string>
|
||||
|
||||
<!-- Auto-Flattr dialog -->
|
||||
<string name="auto_flattr_enable">Enable automatic flattring</string>
|
||||
|
|
Loading…
Reference in New Issue