Merge branch 'master' into develop

This commit is contained in:
ByteHamster 2021-08-17 23:47:16 +02:00
commit e05b8e2c45
8 changed files with 87 additions and 6 deletions

View File

@ -11,8 +11,8 @@ android {
// Version code schema:
// "1.2.3-beta4" -> 1020304
// "1.2.3" -> 1020395
versionCode 2030195
versionName "2.3.1"
versionCode 2030295
versionName "2.3.2"
def commit = ""
try {

View File

@ -52,7 +52,10 @@ public abstract class FilterDialog {
for (String filterId : filterValues) {
if (!TextUtils.isEmpty(filterId)) {
((RadioButton) layout.findViewWithTag(filterId)).setChecked(true);
RadioButton button = layout.findViewWithTag(filterId);
if (button != null) {
button.setChecked(true);
}
}
}

View File

@ -81,7 +81,7 @@ public class NSAtom extends Namespace {
String rel = attributes.getValue(LINK_REL);
SyndElement parent = state.getTagstack().peek();
if (parent.getName().matches(isFeedItem)) {
if (LINK_REL_ALTERNATE.equals(rel)) {
if (rel == null || LINK_REL_ALTERNATE.equals(rel)) {
state.getCurrentItem().setLink(href);
} else if (LINK_REL_ENCLOSURE.equals(rel)) {
String strSize = attributes.getValue(LINK_LENGTH);
@ -107,7 +107,7 @@ public class NSAtom extends Namespace {
state.getCurrentItem().setPaymentLink(href);
}
} 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);
/*
* Use as link if a) no type-attribute is given and

View File

@ -11,6 +11,7 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import java.nio.charset.MalformedInputException;
/**
* Reads the ID3 Tag of a given file.
@ -184,16 +185,29 @@ public class ID3Reader {
private String readEncodedString2(Charset charset, int max) throws IOException {
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
int bytesRead = 0;
boolean foundEnd = false;
while (bytesRead + 1 < max) {
byte c1 = readByte();
byte c2 = readByte();
if (c1 == 0 && c2 == 0) {
foundEnd = true;
break;
}
bytesRead += 2;
bytes.write(c1);
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 "";
}
}
}

View File

@ -14,6 +14,7 @@ import de.danoeh.antennapod.model.feed.FeedMedia;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertFalse;
/**
* 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
public void testLogoWithWhitespace() throws Exception {
File feedFile = FeedParserTestHelper.getFeedFile("feed-atom-testLogoWithWhitespace.xml");

View File

@ -185,4 +185,25 @@ public class ChapterReaderTest {
assertEquals(EmbeddedChapterImage.makeUrl(5330, 4015), chapters.get(0).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());
}
}

View File

@ -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.