Merge pull request #2136 from mfietz/2128-subscription-counter-downloaded
Add option to show number of downloaded episodes in subscription counter
This commit is contained in:
commit
56318ae99c
|
@ -56,7 +56,6 @@ public class UserPreferences {
|
||||||
public static final String PREF_LOCKSCREEN_BACKGROUND = "prefLockscreenBackground";
|
public static final String PREF_LOCKSCREEN_BACKGROUND = "prefLockscreenBackground";
|
||||||
public static final String PREF_SHOW_DOWNLOAD_REPORT = "prefShowDownloadReport";
|
public static final String PREF_SHOW_DOWNLOAD_REPORT = "prefShowDownloadReport";
|
||||||
|
|
||||||
|
|
||||||
// Queue
|
// Queue
|
||||||
public static final String PREF_QUEUE_ADD_TO_FRONT = "prefQueueAddToFront";
|
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_FAST_FORWARD = 1;
|
||||||
private static final int NOTIFICATION_BUTTON_SKIP = 2;
|
private static final int NOTIFICATION_BUTTON_SKIP = 2;
|
||||||
private static int EPISODE_CACHE_SIZE_UNLIMITED = -1;
|
private static int EPISODE_CACHE_SIZE_UNLIMITED = -1;
|
||||||
public static int FEED_ORDER_COUNTER = 0;
|
public static final int FEED_ORDER_COUNTER = 0;
|
||||||
public static int FEED_ORDER_ALPHABETICAL = 1;
|
public static final int FEED_ORDER_ALPHABETICAL = 1;
|
||||||
public static int FEED_ORDER_LAST_UPDATE = 2;
|
public static final int FEED_ORDER_LAST_UPDATE = 2;
|
||||||
public static int FEED_COUNTER_SHOW_NEW_UNPLAYED_SUM = 0;
|
public static final int FEED_COUNTER_SHOW_NEW_UNPLAYED_SUM = 0;
|
||||||
public static int FEED_COUNTER_SHOW_NEW = 1;
|
public static final int FEED_COUNTER_SHOW_NEW = 1;
|
||||||
public static int FEED_COUNTER_SHOW_UNPLAYED = 2;
|
public static final int FEED_COUNTER_SHOW_UNPLAYED = 2;
|
||||||
public static int FEED_COUNTER_SHOW_NONE = 3;
|
public static final int FEED_COUNTER_SHOW_NONE = 3;
|
||||||
|
public static final int FEED_COUNTER_SHOW_DOWNLOADED = 4;
|
||||||
|
|
||||||
private static Context context;
|
private static Context context;
|
||||||
private static SharedPreferences prefs;
|
private static SharedPreferences prefs;
|
||||||
|
|
|
@ -42,12 +42,12 @@ import de.greenrobot.event.EventBus;
|
||||||
public class PodDBAdapter {
|
public class PodDBAdapter {
|
||||||
|
|
||||||
private static final String TAG = "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.
|
* 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.
|
* Maximum number of entries per search request.
|
||||||
|
@ -109,14 +109,14 @@ public class PodDBAdapter {
|
||||||
public static final String KEY_EXCLUDE_FILTER = "exclude_filter";
|
public static final String KEY_EXCLUDE_FILTER = "exclude_filter";
|
||||||
|
|
||||||
// Table names
|
// Table names
|
||||||
public static final String TABLE_NAME_FEEDS = "Feeds";
|
private static final String TABLE_NAME_FEEDS = "Feeds";
|
||||||
public static final String TABLE_NAME_FEED_ITEMS = "FeedItems";
|
private static final String TABLE_NAME_FEED_ITEMS = "FeedItems";
|
||||||
public static final String TABLE_NAME_FEED_IMAGES = "FeedImages";
|
private static final String TABLE_NAME_FEED_IMAGES = "FeedImages";
|
||||||
public static final String TABLE_NAME_FEED_MEDIA = "FeedMedia";
|
private static final String TABLE_NAME_FEED_MEDIA = "FeedMedia";
|
||||||
public static final String TABLE_NAME_DOWNLOAD_LOG = "DownloadLog";
|
private static final String TABLE_NAME_DOWNLOAD_LOG = "DownloadLog";
|
||||||
public static final String TABLE_NAME_QUEUE = "Queue";
|
private static final String TABLE_NAME_QUEUE = "Queue";
|
||||||
public static final String TABLE_NAME_SIMPLECHAPTERS = "SimpleChapters";
|
private static final String TABLE_NAME_SIMPLECHAPTERS = "SimpleChapters";
|
||||||
public static final String TABLE_NAME_FAVORITES = "Favorites";
|
private static final String TABLE_NAME_FAVORITES = "Favorites";
|
||||||
|
|
||||||
// SQL Statements for creating new tables
|
// SQL Statements for creating new tables
|
||||||
private static final String TABLE_PRIMARY_KEY = KEY_ID
|
private static final String TABLE_PRIMARY_KEY = KEY_ID
|
||||||
|
@ -1436,14 +1436,23 @@ public class PodDBAdapter {
|
||||||
public final LongIntMap getFeedCounters(long... feedIds) {
|
public final LongIntMap getFeedCounters(long... feedIds) {
|
||||||
int setting = UserPreferences.getFeedCounterSetting();
|
int setting = UserPreferences.getFeedCounterSetting();
|
||||||
String whereRead;
|
String whereRead;
|
||||||
if(setting == UserPreferences.FEED_COUNTER_SHOW_NEW_UNPLAYED_SUM) {
|
switch(setting) {
|
||||||
whereRead = "(" + KEY_READ + "=" + FeedItem.NEW
|
case UserPreferences.FEED_COUNTER_SHOW_NEW_UNPLAYED_SUM:
|
||||||
+ " OR " + KEY_READ + "=" + FeedItem.UNPLAYED + ")";
|
whereRead = "(" + KEY_READ + "=" + FeedItem.NEW +
|
||||||
} else if(setting == UserPreferences.FEED_COUNTER_SHOW_NEW) {
|
" OR " + KEY_READ + "=" + FeedItem.UNPLAYED + ")";
|
||||||
|
break;
|
||||||
|
case UserPreferences.FEED_COUNTER_SHOW_NEW:
|
||||||
whereRead = KEY_READ + "=" + FeedItem.NEW;
|
whereRead = KEY_READ + "=" + FeedItem.NEW;
|
||||||
} else if(setting == UserPreferences.FEED_COUNTER_SHOW_UNPLAYED) {
|
break;
|
||||||
|
case UserPreferences.FEED_COUNTER_SHOW_UNPLAYED:
|
||||||
whereRead = KEY_READ + "=" + FeedItem.UNPLAYED;
|
whereRead = KEY_READ + "=" + FeedItem.UNPLAYED;
|
||||||
} else { // NONE
|
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);
|
return new LongIntMap(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1459,8 +1468,10 @@ public class PodDBAdapter {
|
||||||
builder.deleteCharAt(builder.length() - 1);
|
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
|
+ " 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() + ") "
|
+ " WHERE " + KEY_FEED + " IN (" + builder.toString() + ") "
|
||||||
+ " AND " + whereRead + " GROUP BY " + KEY_FEED;
|
+ " AND " + whereRead + " GROUP BY " + KEY_FEED;
|
||||||
|
|
||||||
|
|
|
@ -168,12 +168,14 @@
|
||||||
<item>@string/drawer_feed_counter_new_unplayed</item>
|
<item>@string/drawer_feed_counter_new_unplayed</item>
|
||||||
<item>@string/drawer_feed_counter_new</item>
|
<item>@string/drawer_feed_counter_new</item>
|
||||||
<item>@string/drawer_feed_counter_unplayed</item>
|
<item>@string/drawer_feed_counter_unplayed</item>
|
||||||
|
<item>@string/drawer_feed_counter_downloaded</item>
|
||||||
<item>@string/drawer_feed_counter_none</item>
|
<item>@string/drawer_feed_counter_none</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
<string-array name="nav_drawer_feed_counter_values">
|
<string-array name="nav_drawer_feed_counter_values">
|
||||||
<item>0</item>
|
<item>0</item>
|
||||||
<item>1</item>
|
<item>1</item>
|
||||||
<item>2</item>
|
<item>2</item>
|
||||||
|
<item>4</item>
|
||||||
<item>3</item>
|
<item>3</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
<string name="drawer_feed_counter_new_unplayed">Number of new and unplayed episodes</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_new">Number of new episodes</string>
|
||||||
<string name="drawer_feed_counter_unplayed">Number of unplayed episodes</string>
|
<string name="drawer_feed_counter_unplayed">Number of unplayed episodes</string>
|
||||||
|
<string name="drawer_feed_counter_downloaded">Number of downloaded episodes</string>
|
||||||
<string name="drawer_feed_counter_none">None</string>
|
<string name="drawer_feed_counter_none">None</string>
|
||||||
|
|
||||||
<!-- Webview actions -->
|
<!-- Webview actions -->
|
||||||
|
|
Loading…
Reference in New Issue