Merge branch 'master' into develop
This commit is contained in:
commit
e05b8e2c45
|
@ -11,8 +11,8 @@ android {
|
||||||
// Version code schema:
|
// Version code schema:
|
||||||
// "1.2.3-beta4" -> 1020304
|
// "1.2.3-beta4" -> 1020304
|
||||||
// "1.2.3" -> 1020395
|
// "1.2.3" -> 1020395
|
||||||
versionCode 2030195
|
versionCode 2030295
|
||||||
versionName "2.3.1"
|
versionName "2.3.2"
|
||||||
|
|
||||||
def commit = ""
|
def commit = ""
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -52,7 +52,10 @@ public abstract class FilterDialog {
|
||||||
|
|
||||||
for (String filterId : filterValues) {
|
for (String filterId : filterValues) {
|
||||||
if (!TextUtils.isEmpty(filterId)) {
|
if (!TextUtils.isEmpty(filterId)) {
|
||||||
((RadioButton) layout.findViewWithTag(filterId)).setChecked(true);
|
RadioButton button = layout.findViewWithTag(filterId);
|
||||||
|
if (button != null) {
|
||||||
|
button.setChecked(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,7 @@ public class NSAtom extends Namespace {
|
||||||
String rel = attributes.getValue(LINK_REL);
|
String rel = attributes.getValue(LINK_REL);
|
||||||
SyndElement parent = state.getTagstack().peek();
|
SyndElement parent = state.getTagstack().peek();
|
||||||
if (parent.getName().matches(isFeedItem)) {
|
if (parent.getName().matches(isFeedItem)) {
|
||||||
if (LINK_REL_ALTERNATE.equals(rel)) {
|
if (rel == null || LINK_REL_ALTERNATE.equals(rel)) {
|
||||||
state.getCurrentItem().setLink(href);
|
state.getCurrentItem().setLink(href);
|
||||||
} else if (LINK_REL_ENCLOSURE.equals(rel)) {
|
} else if (LINK_REL_ENCLOSURE.equals(rel)) {
|
||||||
String strSize = attributes.getValue(LINK_LENGTH);
|
String strSize = attributes.getValue(LINK_LENGTH);
|
||||||
|
@ -107,7 +107,7 @@ public class NSAtom extends Namespace {
|
||||||
state.getCurrentItem().setPaymentLink(href);
|
state.getCurrentItem().setPaymentLink(href);
|
||||||
}
|
}
|
||||||
} else if (parent.getName().matches(isFeed)) {
|
} else if (parent.getName().matches(isFeed)) {
|
||||||
if (LINK_REL_ALTERNATE.equals(rel)) {
|
if (rel == null || LINK_REL_ALTERNATE.equals(rel)) {
|
||||||
String type = attributes.getValue(LINK_TYPE);
|
String type = attributes.getValue(LINK_TYPE);
|
||||||
/*
|
/*
|
||||||
* Use as link if a) no type-attribute is given and
|
* Use as link if a) no type-attribute is given and
|
||||||
|
|
|
@ -11,6 +11,7 @@ import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
|
import java.nio.charset.MalformedInputException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads the ID3 Tag of a given file.
|
* Reads the ID3 Tag of a given file.
|
||||||
|
@ -184,16 +185,29 @@ public class ID3Reader {
|
||||||
private String readEncodedString2(Charset charset, int max) throws IOException {
|
private String readEncodedString2(Charset charset, int max) throws IOException {
|
||||||
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
|
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
|
||||||
int bytesRead = 0;
|
int bytesRead = 0;
|
||||||
|
boolean foundEnd = false;
|
||||||
while (bytesRead + 1 < max) {
|
while (bytesRead + 1 < max) {
|
||||||
byte c1 = readByte();
|
byte c1 = readByte();
|
||||||
byte c2 = readByte();
|
byte c2 = readByte();
|
||||||
if (c1 == 0 && c2 == 0) {
|
if (c1 == 0 && c2 == 0) {
|
||||||
|
foundEnd = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
bytesRead += 2;
|
bytesRead += 2;
|
||||||
bytes.write(c1);
|
bytes.write(c1);
|
||||||
bytes.write(c2);
|
bytes.write(c2);
|
||||||
}
|
}
|
||||||
return charset.newDecoder().decode(ByteBuffer.wrap(bytes.toByteArray())).toString();
|
if (!foundEnd && bytesRead < max) {
|
||||||
|
// Last character
|
||||||
|
byte c = readByte();
|
||||||
|
if (c != 0) {
|
||||||
|
bytes.write(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return charset.newDecoder().decode(ByteBuffer.wrap(bytes.toByteArray())).toString();
|
||||||
|
} catch (MalformedInputException e) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ import de.danoeh.antennapod.model.feed.FeedMedia;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.Assert.assertNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests for Atom feeds in FeedHandler.
|
* Tests for Atom feeds in FeedHandler.
|
||||||
|
@ -54,6 +55,34 @@ public class AtomParserTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testEmptyRelLinks() throws Exception {
|
||||||
|
File feedFile = FeedParserTestHelper.getFeedFile("feed-atom-testEmptyRelLinks.xml");
|
||||||
|
Feed feed = FeedParserTestHelper.runFeedParser(feedFile);
|
||||||
|
assertEquals(Feed.TYPE_ATOM1, feed.getType());
|
||||||
|
assertEquals("title", feed.getTitle());
|
||||||
|
assertEquals("http://example.com/feed", feed.getFeedIdentifier());
|
||||||
|
assertEquals("http://example.com", feed.getLink());
|
||||||
|
assertEquals("This is the description", feed.getDescription());
|
||||||
|
assertNull(feed.getPaymentLinks());
|
||||||
|
assertEquals("http://example.com/picture", feed.getImageUrl());
|
||||||
|
assertEquals(1, feed.getItems().size());
|
||||||
|
|
||||||
|
// feed entry
|
||||||
|
FeedItem item = feed.getItems().get(0);
|
||||||
|
assertEquals("http://example.com/item-0", item.getItemIdentifier());
|
||||||
|
assertEquals("item-0", item.getTitle());
|
||||||
|
assertNull(item.getDescription());
|
||||||
|
assertEquals("http://example.com/items/0", item.getLink());
|
||||||
|
assertEquals(new Date(0), item.getPubDate());
|
||||||
|
assertNull(item.getPaymentLink());
|
||||||
|
assertEquals("http://example.com/picture", item.getImageLocation());
|
||||||
|
// media
|
||||||
|
assertFalse(item.hasMedia());
|
||||||
|
// chapters
|
||||||
|
assertNull(item.getChapters());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testLogoWithWhitespace() throws Exception {
|
public void testLogoWithWhitespace() throws Exception {
|
||||||
File feedFile = FeedParserTestHelper.getFeedFile("feed-atom-testLogoWithWhitespace.xml");
|
File feedFile = FeedParserTestHelper.getFeedFile("feed-atom-testLogoWithWhitespace.xml");
|
||||||
|
|
|
@ -185,4 +185,25 @@ public class ChapterReaderTest {
|
||||||
assertEquals(EmbeddedChapterImage.makeUrl(5330, 4015), chapters.get(0).getImageUrl());
|
assertEquals(EmbeddedChapterImage.makeUrl(5330, 4015), chapters.get(0).getImageUrl());
|
||||||
assertEquals(EmbeddedChapterImage.makeUrl(9498, 4364), chapters.get(1).getImageUrl());
|
assertEquals(EmbeddedChapterImage.makeUrl(9498, 4364), chapters.get(1).getImageUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRealFileMp3chapsPy() throws IOException, ID3ReaderException {
|
||||||
|
CountingInputStream inputStream = new CountingInputStream(getClass().getClassLoader()
|
||||||
|
.getResource("media-parser/mp3chaps-py.mp3").openStream());
|
||||||
|
ChapterReader reader = new ChapterReader(inputStream);
|
||||||
|
reader.readInputStream();
|
||||||
|
List<Chapter> chapters = reader.getChapters();
|
||||||
|
|
||||||
|
assertEquals(4, chapters.size());
|
||||||
|
|
||||||
|
assertEquals(0, chapters.get(0).getStart());
|
||||||
|
assertEquals(7000, chapters.get(1).getStart());
|
||||||
|
assertEquals(9000, chapters.get(2).getStart());
|
||||||
|
assertEquals(11000, chapters.get(3).getStart());
|
||||||
|
|
||||||
|
assertEquals("Start", chapters.get(0).getTitle());
|
||||||
|
assertEquals("Chapter 1", chapters.get(1).getTitle());
|
||||||
|
assertEquals("Chapter 2", chapters.get(2).getTitle());
|
||||||
|
assertEquals("Chapter 3", chapters.get(3).getTitle());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<feed xmlns="http://www.w3.org/2005/Atom">
|
||||||
|
<id>http://example.com/feed</id>
|
||||||
|
<title>title</title>
|
||||||
|
<link href="http://example.com" />
|
||||||
|
<subtitle>This is the description</subtitle>
|
||||||
|
<logo>http://example.com/picture</logo>
|
||||||
|
<entry>
|
||||||
|
<id>http://example.com/item-0</id>
|
||||||
|
<title>item-0</title>
|
||||||
|
<link href="http://example.com/items/0" />
|
||||||
|
<published>1970-01-01T00:00:00Z</published>
|
||||||
|
</entry>
|
||||||
|
</feed>
|
Binary file not shown.
Loading…
Reference in New Issue