summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/opml/OpmlSymbols.java1
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/opml/OpmlWriter.java33
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java1
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java79
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/storage/DBReader.java23
-rw-r--r--core/src/main/res/values/arrays.xml5
-rw-r--r--core/src/main/res/values/strings.xml1
7 files changed, 87 insertions, 56 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/opml/OpmlSymbols.java b/core/src/main/java/de/danoeh/antennapod/core/opml/OpmlSymbols.java
index 2b831ca2a..c973713cb 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/opml/OpmlSymbols.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/opml/OpmlSymbols.java
@@ -13,6 +13,7 @@ public final class OpmlSymbols {
public static final String VERSION = "version";
public static final String HEAD = "head";
public static final String TITLE = "title";
+ public static final String DATE_CREATED = "dateCreated";
private OpmlSymbols() {
diff --git a/core/src/main/java/de/danoeh/antennapod/core/opml/OpmlWriter.java b/core/src/main/java/de/danoeh/antennapod/core/opml/OpmlWriter.java
index 641190f62..673c602df 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/opml/OpmlWriter.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/opml/OpmlWriter.java
@@ -2,14 +2,17 @@ package de.danoeh.antennapod.core.opml;
import android.util.Log;
import android.util.Xml;
-import de.danoeh.antennapod.core.BuildConfig;
-import de.danoeh.antennapod.core.feed.Feed;
+
import org.xmlpull.v1.XmlSerializer;
import java.io.IOException;
import java.io.Writer;
+import java.util.Date;
import java.util.List;
+import de.danoeh.antennapod.core.feed.Feed;
+import de.danoeh.antennapod.core.util.DateUtils;
+
/** Writes OPML documents. */
public class OpmlWriter {
private static final String TAG = "OpmlWriter";
@@ -27,23 +30,38 @@ public class OpmlWriter {
*/
public void writeDocument(List<Feed> feeds, Writer writer)
throws IllegalArgumentException, IllegalStateException, IOException {
- if (BuildConfig.DEBUG)
- Log.d(TAG, "Starting to write document");
+ Log.d(TAG, "Starting to write document");
XmlSerializer xs = Xml.newSerializer();
xs.setOutput(writer);
xs.startDocument(ENCODING, false);
+ xs.text("\n");
xs.startTag(null, OpmlSymbols.OPML);
xs.attribute(null, OpmlSymbols.VERSION, OPML_VERSION);
+ xs.text("\n");
+ xs.text(" ");
xs.startTag(null, OpmlSymbols.HEAD);
+ xs.text("\n");
+ xs.text(" ");
xs.startTag(null, OpmlSymbols.TITLE);
xs.text(OPML_TITLE);
xs.endTag(null, OpmlSymbols.TITLE);
+ xs.text("\n");
+ xs.text(" ");
+ xs.startTag(null, OpmlSymbols.DATE_CREATED);
+ xs.text(DateUtils.formatRFC822Date(new Date()));
+ xs.endTag(null, OpmlSymbols.DATE_CREATED);
+ xs.text("\n");
+ xs.text(" ");
xs.endTag(null, OpmlSymbols.HEAD);
+ xs.text("\n");
+ xs.text(" ");
xs.startTag(null, OpmlSymbols.BODY);
+ xs.text("\n");
for (Feed feed : feeds) {
+ xs.text(" ");
xs.startTag(null, OpmlSymbols.OUTLINE);
xs.attribute(null, OpmlSymbols.TEXT, feed.getTitle());
xs.attribute(null, OpmlSymbols.TITLE, feed.getTitle());
@@ -55,11 +73,14 @@ public class OpmlWriter {
xs.attribute(null, OpmlSymbols.HTMLURL, feed.getLink());
}
xs.endTag(null, OpmlSymbols.OUTLINE);
+ xs.text("\n");
}
+ xs.text(" ");
xs.endTag(null, OpmlSymbols.BODY);
+ xs.text("\n");
xs.endTag(null, OpmlSymbols.OPML);
+ xs.text("\n");
xs.endDocument();
- if (BuildConfig.DEBUG)
- Log.d(TAG, "Finished writing document");
+ Log.d(TAG, "Finished writing document");
}
}
diff --git a/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java b/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java
index 5d9400069..4561c9bad 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java
@@ -106,6 +106,7 @@ public class UserPreferences {
private static int EPISODE_CACHE_SIZE_UNLIMITED = -1;
public static int FEED_ORDER_COUNTER = 0;
public static int FEED_ORDER_ALPHABETICAL = 1;
+ public static int FEED_ORDER_LAST_UPDATE = 2;
public static int FEED_COUNTER_SHOW_NEW_UNPLAYED_SUM = 0;
public static int FEED_COUNTER_SHOW_NEW = 1;
public static int FEED_COUNTER_SHOW_UNPLAYED = 2;
diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java b/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java
index cb050463e..0698107a7 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java
@@ -130,7 +130,6 @@ public class DownloadService extends Service {
private NotificationCompat.Builder notificationCompatBuilder;
- private Notification.BigTextStyle notificationBuilder;
private int NOTIFICATION_ID = 2;
private int REPORT_ID = 3;
@@ -322,23 +321,16 @@ public class DownloadService extends Service {
DBTasks.autodownloadUndownloadedItems(getApplicationContext());
}
- @SuppressLint("NewApi")
private void setupNotificationBuilders() {
Bitmap icon = BitmapFactory.decodeResource(getResources(),
R.drawable.stat_notify_sync);
- if (android.os.Build.VERSION.SDK_INT >= 16) {
- notificationBuilder = new Notification.BigTextStyle(
- new Notification.Builder(this).setOngoing(true)
- .setContentIntent(ClientConfig.downloadServiceCallbacks.getNotificationContentIntent(this)).setLargeIcon(icon)
- .setSmallIcon(R.drawable.stat_notify_sync)
- );
- } else {
notificationCompatBuilder = new NotificationCompat.Builder(this)
- .setOngoing(true).setContentIntent(ClientConfig.downloadServiceCallbacks.getNotificationContentIntent(this))
+ .setOngoing(true)
+ .setContentIntent(ClientConfig.downloadServiceCallbacks.getNotificationContentIntent(this))
.setLargeIcon(icon)
.setSmallIcon(R.drawable.stat_notify_sync);
- }
+
Log.d(TAG, "Notification set up");
}
@@ -346,58 +338,47 @@ public class DownloadService extends Service {
* Updates the contents of the service's notifications. Should be called
* before setupNotificationBuilders.
*/
- @SuppressLint("NewApi")
private Notification updateNotifications() {
String contentTitle = getString(R.string.download_notification_title);
int numDownloads = requester.getNumberOfDownloads();
String downloadsLeft;
if (numDownloads > 0) {
- downloadsLeft = requester.getNumberOfDownloads()
- + getString(R.string.downloads_left);
+ downloadsLeft = requester.getNumberOfDownloads() + getString(R.string.downloads_left);
} else {
downloadsLeft = getString(R.string.downloads_processing);
}
- if (android.os.Build.VERSION.SDK_INT >= 16) {
-
- if (notificationBuilder != null) {
-
- StringBuilder bigText = new StringBuilder("");
- for (int i = 0; i < downloads.size(); i++) {
- Downloader downloader = downloads.get(i);
- final DownloadRequest request = downloader
- .getDownloadRequest();
- if (request.getFeedfileType() == Feed.FEEDFILETYPE_FEED) {
- if (request.getTitle() != null) {
- if (i > 0) {
- bigText.append("\n");
- }
- bigText.append("\u2022 " + request.getTitle());
+ if (notificationCompatBuilder != null) {
+
+ StringBuilder bigText = new StringBuilder("");
+ for (int i = 0; i < downloads.size(); i++) {
+ Downloader downloader = downloads.get(i);
+ final DownloadRequest request = downloader
+ .getDownloadRequest();
+ if (request.getFeedfileType() == Feed.FEEDFILETYPE_FEED) {
+ if (request.getTitle() != null) {
+ if (i > 0) {
+ bigText.append("\n");
}
- } else if (request.getFeedfileType() == FeedMedia.FEEDFILETYPE_FEEDMEDIA) {
- if (request.getTitle() != null) {
- if (i > 0) {
- bigText.append("\n");
- }
- bigText.append("\u2022 " + request.getTitle()
- + " (" + request.getProgressPercent()
- + "%)");
+ bigText.append("\u2022 " + request.getTitle());
+ }
+ } else if (request.getFeedfileType() == FeedMedia.FEEDFILETYPE_FEEDMEDIA) {
+ if (request.getTitle() != null) {
+ if (i > 0) {
+ bigText.append("\n");
}
+ bigText.append("\u2022 " + request.getTitle()
+ + " (" + request.getProgressPercent()
+ + "%)");
}
-
}
- notificationBuilder.setSummaryText(downloadsLeft);
- notificationBuilder.setBigContentTitle(contentTitle);
- if (bigText != null) {
- notificationBuilder.bigText(bigText.toString());
- }
- return notificationBuilder.build();
+
}
- } else {
- if (notificationCompatBuilder != null) {
- notificationCompatBuilder.setContentTitle(contentTitle);
- notificationCompatBuilder.setContentText(downloadsLeft);
- return notificationCompatBuilder.build();
+ notificationCompatBuilder.setContentTitle(contentTitle);
+ notificationCompatBuilder.setContentText(downloadsLeft);
+ if (bigText != null) {
+ notificationCompatBuilder.setStyle(new NotificationCompat.BigTextStyle().bigText(bigText.toString()));
}
+ return notificationCompatBuilder.build();
}
return null;
}
diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/DBReader.java b/core/src/main/java/de/danoeh/antennapod/core/storage/DBReader.java
index d95e4ff02..7a8609b04 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/storage/DBReader.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/storage/DBReader.java
@@ -8,6 +8,7 @@ import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
+import java.util.Date;
import java.util.List;
import de.danoeh.antennapod.core.feed.Chapter;
@@ -947,13 +948,33 @@ public final class DBReader {
return 1;
}
};
- } else {
+ } else if(feedOrder == UserPreferences.FEED_ORDER_ALPHABETICAL) {
comparator = (lhs, rhs) -> {
if(lhs.getTitle() == null) {
return 1;
}
return lhs.getTitle().compareTo(rhs.getTitle());
};
+ } else {
+ comparator = (lhs, rhs) -> {
+ if(lhs.getItems() == null || lhs.getItems().size() == 0) {
+ List<FeedItem> items = DBReader.getFeedItemList(lhs);
+ lhs.setItems(items);
+ }
+ if(rhs.getItems() == null || rhs.getItems().size() == 0) {
+ List<FeedItem> items = DBReader.getFeedItemList(rhs);
+ rhs.setItems(items);
+ }
+ if(lhs.getMostRecentItem() == null) {
+ return 1;
+ } else if(rhs.getMostRecentItem() == null) {
+ return -1;
+ } else {
+ Date d1 = lhs.getMostRecentItem().getPubDate();
+ Date d2 = rhs.getMostRecentItem().getPubDate();
+ return d2.compareTo(d1);
+ }
+ };
}
Collections.sort(feeds, comparator);
diff --git a/core/src/main/res/values/arrays.xml b/core/src/main/res/values/arrays.xml
index 34339783e..341a7e520 100644
--- a/core/src/main/res/values/arrays.xml
+++ b/core/src/main/res/values/arrays.xml
@@ -78,8 +78,11 @@
<item>0.5</item>
<item>0.6</item>
<item>0.7</item>
+ <item>0.75</item>
<item>0.8</item>
+ <item>0.85</item>
<item>0.9</item>
+ <item>0.95</item>
<item>1.0</item>
<item>1.05</item>
<item>1.10</item>
@@ -150,10 +153,12 @@
<string-array name="nav_drawer_feed_order_options">
<item>@string/drawer_feed_order_unplayed_episodes</item>
<item>@string/drawer_feed_order_alphabetical</item>
+ <item>@string/drawer_feed_order_last_update</item>
</string-array>
<string-array name="nav_drawer_feed_order_values">
<item>0</item>
<item>1</item>
+ <item>2</item>
</string-array>
<string-array name="nav_drawer_feed_counter_options">
diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml
index f3a17a8cc..168477463 100644
--- a/core/src/main/res/values/strings.xml
+++ b/core/src/main/res/values/strings.xml
@@ -36,6 +36,7 @@
<string name="drawer_preferences">Drawer Preferences</string>
<string name="drawer_feed_order_unplayed_episodes">Sort by counter</string>
<string name="drawer_feed_order_alphabetical">Sort alphabetically</string>
+ <string name="drawer_feed_order_last_update">Sort by publication date</string>
<string name="drawer_feed_counter_new_unplayed">Number of new and unplayed episodes</string>
<string name="drawer_feed_counter_new">Number of new episodes</string>
<string name="drawer_feed_counter_unplayed">Number of unplayed episodes</string>