Call former indicator "counter"

This commit is contained in:
Martin Fietz 2015-07-02 17:21:51 +02:00
parent 936ecc2b8e
commit dd898d1abe
8 changed files with 48 additions and 35 deletions

View File

@ -25,11 +25,11 @@
android:summary="@string/pref_nav_drawer_feed_order_sum" android:summary="@string/pref_nav_drawer_feed_order_sum"
android:defaultValue="0"/> android:defaultValue="0"/>
<ListPreference <ListPreference
android:entryValues="@array/nav_drawer_feed_indicator_values" android:entryValues="@array/nav_drawer_feed_counter_values"
android:entries="@array/nav_drawer_feed_indicator_options" android:entries="@array/nav_drawer_feed_counter_options"
android:title="@string/pref_nav_drawer_feed_indicator_title" android:title="@string/pref_nav_drawer_feed_counter_title"
android:key="prefDrawerFeedIndicator" android:key="prefDrawerFeedIndicator"
android:summary="@string/pref_nav_drawer_feed_indicator_sum" android:summary="@string/pref_nav_drawer_feed_counter_sum"
android:defaultValue="0"/> android:defaultValue="0"/>
</PreferenceScreen> </PreferenceScreen>
<CheckBoxPreference <CheckBoxPreference

View File

@ -368,14 +368,16 @@ public class FeedMedia extends FeedFile implements Playable {
@Override @Override
public void saveCurrentPosition(SharedPreferences pref, int newPosition) { public void saveCurrentPosition(SharedPreferences pref, int newPosition) {
setPosition(newPosition);
DBWriter.setFeedMediaPlaybackInformation(ClientConfig.applicationCallbacks.getApplicationInstance(), this); DBWriter.setFeedMediaPlaybackInformation(ClientConfig.applicationCallbacks.getApplicationInstance(), this);
if(item.isNew()) {
DBWriter.markItemRead(ClientConfig.applicationCallbacks.getApplicationInstance(), false, item.getId());
}
setPosition(newPosition);
} }
@Override @Override
public void onPlaybackStart() { public void onPlaybackStart() {
} }
@Override @Override
public void onPlaybackCompleted() { public void onPlaybackCompleted() {

View File

@ -44,7 +44,7 @@ public class UserPreferences {
public static final String PREF_THEME = "prefTheme"; public static final String PREF_THEME = "prefTheme";
public static final String PREF_HIDDEN_DRAWER_ITEMS = "prefHiddenDrawerItems"; public static final String PREF_HIDDEN_DRAWER_ITEMS = "prefHiddenDrawerItems";
public static final String PREF_DRAWER_FEED_ORDER = "prefDrawerFeedOrder"; public static final String PREF_DRAWER_FEED_ORDER = "prefDrawerFeedOrder";
public static final String PREF_DRAWER_FEED_INDICATOR = "prefDrawerFeedIndicator"; public static final String PREF_DRAWER_FEED_COUNTER = "prefDrawerFeedCounter";
public static final String PREF_EXPANDED_NOTIFICATION = "prefExpandNotify"; public static final String PREF_EXPANDED_NOTIFICATION = "prefExpandNotify";
public static final String PREF_PERSISTENT_NOTIFICATION = "prefPersistNotify"; public static final String PREF_PERSISTENT_NOTIFICATION = "prefPersistNotify";
public static final String PREF_SHOW_DOWNLOAD_REPORT = "prefShowDownloadReport"; public static final String PREF_SHOW_DOWNLOAD_REPORT = "prefShowDownloadReport";
@ -87,12 +87,12 @@ public class UserPreferences {
// Constants // Constants
private static int EPISODE_CACHE_SIZE_UNLIMITED = -1; private static int EPISODE_CACHE_SIZE_UNLIMITED = -1;
public static int ORDER_UNPLAYED_EPISODES = 0; public static int FEED_ORDER_UNPLAYED_EPISODES = 0;
public static int ORDER_ALPHABETICAL = 1; public static int FEED_ORDER_ALPHABETICAL = 1;
public static int SHOW_NEW_UNPLAYED_SUM = 0; public static int FEED_COUNTER_SHOW_NEW_UNPLAYED_SUM = 0;
public static int SHOW_NEW = 1; public static int FEED_COUNTER_SHOW_NEW = 1;
public static int SHOW_UNPLAYED = 2; public static int FEED_COUNTER_SHOW_UNPLAYED = 2;
public static int SHOW_NONE= 3; public static int FEED_COUNTER_SHOW_NONE = 3;
private static Context context; private static Context context;
private static SharedPreferences prefs; private static SharedPreferences prefs;
@ -141,8 +141,8 @@ public class UserPreferences {
return Integer.valueOf(value); return Integer.valueOf(value);
} }
public static int getFeedIndicator() { public static int getFeedCounter() {
String value = prefs.getString(PREF_DRAWER_FEED_INDICATOR, "0"); String value = prefs.getString(PREF_DRAWER_FEED_COUNTER, "0");
return Integer.valueOf(value); return Integer.valueOf(value);
} }

View File

@ -1144,7 +1144,7 @@ public final class DBReader {
Comparator<Feed> comparator; Comparator<Feed> comparator;
int feedOrder = UserPreferences.getFeedOrder(); int feedOrder = UserPreferences.getFeedOrder();
if(feedOrder == UserPreferences.ORDER_UNPLAYED_EPISODES) { if(feedOrder == UserPreferences.FEED_ORDER_UNPLAYED_EPISODES) {
comparator = new Comparator<Feed>() { comparator = new Comparator<Feed>() {
@Override @Override
public int compare(Feed lhs, Feed rhs) { public int compare(Feed lhs, Feed rhs) {

View File

@ -360,6 +360,10 @@ public class DBWriter {
queue.add(index, item); queue.add(index, item);
adapter.setQueue(queue); adapter.setQueue(queue);
EventBus.getDefault().post(new QueueEvent(QueueEvent.Action.ADDED, item, index)); EventBus.getDefault().post(new QueueEvent(QueueEvent.Action.ADDED, item, index));
if(item.isNew()) {
adapter.setFeedItemRead(FeedItem.UNPLAYED, item.getId());
EventDistributor.getInstance().sendUnreadItemsUpdateBroadcast();
}
} }
} }
} }
@ -379,7 +383,6 @@ public class DBWriter {
return addQueueItem(context, false, itemIds); return addQueueItem(context, false, itemIds);
} }
/** /**
* Appends FeedItem objects to the end of the queue. The 'read'-attribute of all items will be set to true. * Appends FeedItem objects to the end of the queue. The 'read'-attribute of all items will be set to true.
* If a FeedItem is already in the queue, the FeedItem will not change its position in the queue. * If a FeedItem is already in the queue, the FeedItem will not change its position in the queue.
@ -397,11 +400,11 @@ public class DBWriter {
if (itemIds.length > 0) { if (itemIds.length > 0) {
final PodDBAdapter adapter = new PodDBAdapter(context); final PodDBAdapter adapter = new PodDBAdapter(context);
adapter.open(); adapter.open();
final List<FeedItem> queue = DBReader.getQueue(context, final List<FeedItem> queue = DBReader.getQueue(context, adapter);
adapter);
if (queue != null) { if (queue != null) {
boolean queueModified = false; boolean queueModified = false;
LongList markAsUnplayedIds = new LongList();
for (int i = 0; i < itemIds.length; i++) { for (int i = 0; i < itemIds.length; i++) {
if (!itemListContains(queue, itemIds[i])) { if (!itemListContains(queue, itemIds[i])) {
final FeedItem item = DBReader.getFeedItem(context, itemIds[i]); final FeedItem item = DBReader.getFeedItem(context, itemIds[i]);
@ -415,12 +418,20 @@ public class DBWriter {
queue.add(item); queue.add(item);
} }
queueModified = true; queueModified = true;
if(item.isNew()) {
markAsUnplayedIds.add(item.getId());
}
} }
} }
} }
if (queueModified) { if (queueModified) {
adapter.setQueue(queue); adapter.setQueue(queue);
EventBus.getDefault().post(new QueueEvent(QueueEvent.Action.ADDED_ITEMS, queue)); EventBus.getDefault().post(new QueueEvent(QueueEvent.Action.ADDED_ITEMS, queue));
Log.d(TAG, "# mark as unplayed: " + markAsUnplayedIds.size());
if(markAsUnplayedIds.size() > 0) {
adapter.setFeedItemRead(FeedItem.UNPLAYED, markAsUnplayedIds.toArray());
EventDistributor.getInstance().sendUnreadItemsUpdateBroadcast();
}
} }
} }
adapter.close(); adapter.close();

View File

@ -1295,14 +1295,14 @@ public class PodDBAdapter {
} }
public final LongIntMap getFeedCounters(long... feedIds) { public final LongIntMap getFeedCounters(long... feedIds) {
int indicator = UserPreferences.getFeedIndicator(); int counter = UserPreferences.getFeedCounter();
String whereRead; String whereRead;
if(indicator == UserPreferences.SHOW_NEW_UNPLAYED_SUM) { if(counter == UserPreferences.FEED_COUNTER_SHOW_NEW_UNPLAYED_SUM) {
whereRead = "(" + KEY_READ + "=" + FeedItem.NEW whereRead = "(" + KEY_READ + "=" + FeedItem.NEW
+ " OR " + KEY_READ + "=" + FeedItem.UNPLAYED + ")"; + " OR " + KEY_READ + "=" + FeedItem.UNPLAYED + ")";
} else if(indicator == UserPreferences.SHOW_NEW) { } else if(counter == UserPreferences.FEED_COUNTER_SHOW_NEW) {
whereRead = KEY_READ + "=" + FeedItem.NEW; whereRead = KEY_READ + "=" + FeedItem.NEW;
} else if(indicator == UserPreferences.SHOW_UNPLAYED) { } else if(counter == UserPreferences.FEED_COUNTER_SHOW_UNPLAYED) {
whereRead = KEY_READ + "=" + FeedItem.UNPLAYED; whereRead = KEY_READ + "=" + FeedItem.UNPLAYED;
} else { } else {
return new LongIntMap(0); return new LongIntMap(0);

View File

@ -135,13 +135,13 @@
<item>1</item> <item>1</item>
</string-array> </string-array>
<string-array name="nav_drawer_feed_indicator_options"> <string-array name="nav_drawer_feed_counter_options">
<item>@string/drawer_feed_indicator_new_unplayed</item> <item>@string/drawer_feed_counter_new_unplayed</item>
<item>@string/drawer_feed_indicator_new</item> <item>@string/drawer_feed_counter_new</item>
<item>@string/drawer_feed_indicator_unplayed</item> <item>@string/drawer_feed_counter_unplayed</item>
<item>@string/drawer_feed_indicator_none</item> <item>@string/drawer_feed_counter_none</item>
</string-array> </string-array>
<string-array name="nav_drawer_feed_indicator_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>

View File

@ -35,10 +35,10 @@
<string name="drawer_preferences">Drawer Preferences</string> <string name="drawer_preferences">Drawer Preferences</string>
<string name="drawer_feed_order_unplayed_episodes">Sort by counter</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_alphabetical">Sort alphabetically</string>
<string name="drawer_feed_indicator_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_indicator_new">Number of new episodes</string> <string name="drawer_feed_counter_new">Number of new episodes</string>
<string name="drawer_feed_indicator_unplayed">Number of unplayed episodes</string> <string name="drawer_feed_counter_unplayed">Number of unplayed episodes</string>
<string name="drawer_feed_indicator_none">None</string> <string name="drawer_feed_counter_none">None</string>
<!-- Webview actions --> <!-- Webview actions -->
<string name="open_in_browser_label">Open in Browser</string> <string name="open_in_browser_label">Open in Browser</string>
@ -292,8 +292,8 @@
<string name="pref_nav_drawer_items_sum">Change which items appear in the navigation drawer.</string> <string name="pref_nav_drawer_items_sum">Change which items appear in the navigation drawer.</string>
<string name="pref_nav_drawer_feed_order_title">Set Subscription Order</string> <string name="pref_nav_drawer_feed_order_title">Set Subscription Order</string>
<string name="pref_nav_drawer_feed_order_sum">Change the order of your subscriptions</string> <string name="pref_nav_drawer_feed_order_sum">Change the order of your subscriptions</string>
<string name="pref_nav_drawer_feed_indicator_title">Set Subscription Counter</string> <string name="pref_nav_drawer_feed_counter_title">Set Subscription Counter</string>
<string name="pref_nav_drawer_feed_indicator_sum">Change the information displayed by the subscription counter</string> <string name="pref_nav_drawer_feed_counter_sum">Change the information displayed by the subscription counter</string>
<string name="pref_set_theme_sum">Change the appearance of AntennaPod.</string> <string name="pref_set_theme_sum">Change the appearance of AntennaPod.</string>
<string name="pref_automatic_download_title">Automatic Download</string> <string name="pref_automatic_download_title">Automatic Download</string>
<string name="pref_automatic_download_sum">Configure the automatic download of episodes.</string> <string name="pref_automatic_download_sum">Configure the automatic download of episodes.</string>