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 d5a1007af..aa3bbaeab 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
@@ -56,7 +56,6 @@ public class UserPreferences {
public static final String PREF_LOCKSCREEN_BACKGROUND = "prefLockscreenBackground";
public static final String PREF_SHOW_DOWNLOAD_REPORT = "prefShowDownloadReport";
-
// Queue
public static final String PREF_QUEUE_ADD_TO_FRONT = "prefQueueAddToFront";
@@ -123,13 +122,14 @@ public class UserPreferences {
private static final int NOTIFICATION_BUTTON_FAST_FORWARD = 1;
private static final int NOTIFICATION_BUTTON_SKIP = 2;
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;
- public static int FEED_COUNTER_SHOW_NONE = 3;
+ public static final int FEED_ORDER_COUNTER = 0;
+ public static final int FEED_ORDER_ALPHABETICAL = 1;
+ public static final int FEED_ORDER_LAST_UPDATE = 2;
+ public static final int FEED_COUNTER_SHOW_NEW_UNPLAYED_SUM = 0;
+ public static final int FEED_COUNTER_SHOW_NEW = 1;
+ public static final int FEED_COUNTER_SHOW_UNPLAYED = 2;
+ public static final int FEED_COUNTER_SHOW_NONE = 3;
+ public static final int FEED_COUNTER_SHOW_DOWNLOADED = 4;
private static Context context;
private static SharedPreferences prefs;
diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java b/core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java
index 7631d26d5..b0d053f5a 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java
@@ -42,12 +42,12 @@ import de.greenrobot.event.EventBus;
public class PodDBAdapter {
private static final String TAG = "PodDBAdapter";
- public static final String DATABASE_NAME = "Antennapod.db";
+ private static final String DATABASE_NAME = "Antennapod.db";
/**
* Maximum number of arguments for IN-operator.
*/
- public static final int IN_OPERATOR_MAXIMUM = 800;
+ private static final int IN_OPERATOR_MAXIMUM = 800;
/**
* Maximum number of entries per search request.
@@ -109,14 +109,14 @@ public class PodDBAdapter {
public static final String KEY_EXCLUDE_FILTER = "exclude_filter";
// Table names
- public static final String TABLE_NAME_FEEDS = "Feeds";
- public static final String TABLE_NAME_FEED_ITEMS = "FeedItems";
- public static final String TABLE_NAME_FEED_IMAGES = "FeedImages";
- public static final String TABLE_NAME_FEED_MEDIA = "FeedMedia";
- public static final String TABLE_NAME_DOWNLOAD_LOG = "DownloadLog";
- public static final String TABLE_NAME_QUEUE = "Queue";
- public static final String TABLE_NAME_SIMPLECHAPTERS = "SimpleChapters";
- public static final String TABLE_NAME_FAVORITES = "Favorites";
+ private static final String TABLE_NAME_FEEDS = "Feeds";
+ private static final String TABLE_NAME_FEED_ITEMS = "FeedItems";
+ private static final String TABLE_NAME_FEED_IMAGES = "FeedImages";
+ private static final String TABLE_NAME_FEED_MEDIA = "FeedMedia";
+ private static final String TABLE_NAME_DOWNLOAD_LOG = "DownloadLog";
+ private static final String TABLE_NAME_QUEUE = "Queue";
+ private static final String TABLE_NAME_SIMPLECHAPTERS = "SimpleChapters";
+ private static final String TABLE_NAME_FAVORITES = "Favorites";
// SQL Statements for creating new tables
private static final String TABLE_PRIMARY_KEY = KEY_ID
@@ -1436,15 +1436,24 @@ public class PodDBAdapter {
public final LongIntMap getFeedCounters(long... feedIds) {
int setting = UserPreferences.getFeedCounterSetting();
String whereRead;
- if(setting == UserPreferences.FEED_COUNTER_SHOW_NEW_UNPLAYED_SUM) {
- whereRead = "(" + KEY_READ + "=" + FeedItem.NEW
- + " OR " + KEY_READ + "=" + FeedItem.UNPLAYED + ")";
- } else if(setting == UserPreferences.FEED_COUNTER_SHOW_NEW) {
- whereRead = KEY_READ + "=" + FeedItem.NEW;
- } else if(setting == UserPreferences.FEED_COUNTER_SHOW_UNPLAYED) {
- whereRead = KEY_READ + "=" + FeedItem.UNPLAYED;
- } else { // NONE
- return new LongIntMap(0);
+ switch(setting) {
+ case UserPreferences.FEED_COUNTER_SHOW_NEW_UNPLAYED_SUM:
+ whereRead = "(" + KEY_READ + "=" + FeedItem.NEW +
+ " OR " + KEY_READ + "=" + FeedItem.UNPLAYED + ")";
+ break;
+ case UserPreferences.FEED_COUNTER_SHOW_NEW:
+ whereRead = KEY_READ + "=" + FeedItem.NEW;
+ break;
+ case UserPreferences.FEED_COUNTER_SHOW_UNPLAYED:
+ whereRead = KEY_READ + "=" + FeedItem.UNPLAYED;
+ break;
+ case UserPreferences.FEED_COUNTER_SHOW_DOWNLOADED:
+ whereRead = KEY_DOWNLOADED + "=1";
+ break;
+ case UserPreferences.FEED_COUNTER_SHOW_NONE:
+ // deliberate fall-through
+ default: // NONE
+ return new LongIntMap(0);
}
// work around TextUtils.join wanting only boxed items
@@ -1459,8 +1468,10 @@ public class PodDBAdapter {
builder.deleteCharAt(builder.length() - 1);
}
- final String query = "SELECT " + KEY_FEED + ", COUNT(" + KEY_ID + ") AS count "
+ final String query = "SELECT " + KEY_FEED + ", COUNT(" + TABLE_NAME_FEED_ITEMS + "." + KEY_ID + ") AS count "
+ " FROM " + TABLE_NAME_FEED_ITEMS
+ + " LEFT JOIN " + TABLE_NAME_FEED_MEDIA + " ON "
+ + TABLE_NAME_FEED_ITEMS + "." + KEY_ID + "=" + TABLE_NAME_FEED_MEDIA + "." + KEY_FEEDITEM
+ " WHERE " + KEY_FEED + " IN (" + builder.toString() + ") "
+ " AND " + whereRead + " GROUP BY " + KEY_FEED;
diff --git a/core/src/main/res/values/arrays.xml b/core/src/main/res/values/arrays.xml
index c8c5162ef..133a3ed6e 100644
--- a/core/src/main/res/values/arrays.xml
+++ b/core/src/main/res/values/arrays.xml
@@ -168,12 +168,14 @@
- @string/drawer_feed_counter_new_unplayed
- @string/drawer_feed_counter_new
- @string/drawer_feed_counter_unplayed
+ - @string/drawer_feed_counter_downloaded
- @string/drawer_feed_counter_none
- 0
- 1
- 2
+ - 4
- 3
diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml
index 36f846381..8a92ab5b2 100644
--- a/core/src/main/res/values/strings.xml
+++ b/core/src/main/res/values/strings.xml
@@ -42,6 +42,7 @@
Number of new and unplayed episodes
Number of new episodes
Number of unplayed episodes
+ Number of downloaded episodes
None