summaryrefslogtreecommitdiff
path: root/storage
diff options
context:
space:
mode:
Diffstat (limited to 'storage')
-rw-r--r--storage/database/src/main/java/de/danoeh/antennapod/storage/database/DBUpgrader.java4
-rw-r--r--storage/database/src/main/java/de/danoeh/antennapod/storage/database/PodDBAdapter.java7
-rw-r--r--storage/database/src/main/java/de/danoeh/antennapod/storage/database/mapper/FeedItemCursorMapper.java6
-rw-r--r--storage/preferences/src/main/java/de/danoeh/antennapod/storage/preferences/UserPreferences.java67
4 files changed, 54 insertions, 30 deletions
diff --git a/storage/database/src/main/java/de/danoeh/antennapod/storage/database/DBUpgrader.java b/storage/database/src/main/java/de/danoeh/antennapod/storage/database/DBUpgrader.java
index e4a1f5a3d..cbac417a9 100644
--- a/storage/database/src/main/java/de/danoeh/antennapod/storage/database/DBUpgrader.java
+++ b/storage/database/src/main/java/de/danoeh/antennapod/storage/database/DBUpgrader.java
@@ -121,9 +121,9 @@ class DBUpgrader {
}
if (oldVersion <= 14) {
db.execSQL("ALTER TABLE " + PodDBAdapter.TABLE_NAME_FEED_ITEMS
- + " ADD COLUMN " + PodDBAdapter.KEY_AUTO_DOWNLOAD_ATTEMPTS + " INTEGER");
+ + " ADD COLUMN " + PodDBAdapter.KEY_AUTO_DOWNLOAD_ENABLED + " INTEGER");
db.execSQL("UPDATE " + PodDBAdapter.TABLE_NAME_FEED_ITEMS
- + " SET " + PodDBAdapter.KEY_AUTO_DOWNLOAD_ATTEMPTS + " = "
+ + " SET " + PodDBAdapter.KEY_AUTO_DOWNLOAD_ENABLED + " = "
+ "(SELECT " + PodDBAdapter.KEY_AUTO_DOWNLOAD_ENABLED
+ " FROM " + PodDBAdapter.TABLE_NAME_FEEDS
+ " WHERE " + PodDBAdapter.TABLE_NAME_FEEDS + "." + PodDBAdapter.KEY_ID
diff --git a/storage/database/src/main/java/de/danoeh/antennapod/storage/database/PodDBAdapter.java b/storage/database/src/main/java/de/danoeh/antennapod/storage/database/PodDBAdapter.java
index 96d80c209..ccef19dc1 100644
--- a/storage/database/src/main/java/de/danoeh/antennapod/storage/database/PodDBAdapter.java
+++ b/storage/database/src/main/java/de/danoeh/antennapod/storage/database/PodDBAdapter.java
@@ -95,7 +95,6 @@ public class PodDBAdapter {
public static final String KEY_REASON_DETAILED = "reason_detailed";
public static final String KEY_DOWNLOADSTATUS_TITLE = "title";
public static final String KEY_PLAYBACK_COMPLETION_DATE = "playback_completion_date";
- public static final String KEY_AUTO_DOWNLOAD_ATTEMPTS = "auto_download";
public static final String KEY_AUTO_DOWNLOAD_ENABLED = "auto_download"; // Both tables use the same key
public static final String KEY_KEEP_UPDATED = "keep_updated";
public static final String KEY_AUTO_DELETE_ACTION = "auto_delete_action";
@@ -171,7 +170,7 @@ public class PodDBAdapter {
+ KEY_MEDIA + " INTEGER," + KEY_FEED + " INTEGER,"
+ KEY_HAS_CHAPTERS + " INTEGER," + KEY_ITEM_IDENTIFIER + " TEXT,"
+ KEY_IMAGE_URL + " TEXT,"
- + KEY_AUTO_DOWNLOAD_ATTEMPTS + " INTEGER,"
+ + KEY_AUTO_DOWNLOAD_ENABLED + " INTEGER,"
+ KEY_PODCASTINDEX_CHAPTER_URL + " TEXT)";
private static final String CREATE_TABLE_FEED_MEDIA = "CREATE TABLE "
@@ -259,7 +258,7 @@ public class PodDBAdapter {
+ TABLE_NAME_FEED_ITEMS + "." + KEY_HAS_CHAPTERS + ", "
+ TABLE_NAME_FEED_ITEMS + "." + KEY_ITEM_IDENTIFIER + ", "
+ TABLE_NAME_FEED_ITEMS + "." + KEY_IMAGE_URL + ", "
- + TABLE_NAME_FEED_ITEMS + "." + KEY_AUTO_DOWNLOAD_ATTEMPTS + ", "
+ + TABLE_NAME_FEED_ITEMS + "." + KEY_AUTO_DOWNLOAD_ENABLED + ", "
+ TABLE_NAME_FEED_ITEMS + "." + KEY_PODCASTINDEX_CHAPTER_URL;
private static final String KEYS_FEED_MEDIA =
@@ -652,7 +651,7 @@ public class PodDBAdapter {
}
values.put(KEY_HAS_CHAPTERS, item.getChapters() != null || item.hasChapters());
values.put(KEY_ITEM_IDENTIFIER, item.getItemIdentifier());
- values.put(KEY_AUTO_DOWNLOAD_ATTEMPTS, item.getAutoDownloadAttemptsAndTime());
+ values.put(KEY_AUTO_DOWNLOAD_ENABLED, item.isAutoDownloadEnabled());
values.put(KEY_IMAGE_URL, item.getImageUrl());
values.put(KEY_PODCASTINDEX_CHAPTER_URL, item.getPodcastIndexChapterUrl());
diff --git a/storage/database/src/main/java/de/danoeh/antennapod/storage/database/mapper/FeedItemCursorMapper.java b/storage/database/src/main/java/de/danoeh/antennapod/storage/database/mapper/FeedItemCursorMapper.java
index fcf51e31e..c2c9b89d4 100644
--- a/storage/database/src/main/java/de/danoeh/antennapod/storage/database/mapper/FeedItemCursorMapper.java
+++ b/storage/database/src/main/java/de/danoeh/antennapod/storage/database/mapper/FeedItemCursorMapper.java
@@ -25,7 +25,7 @@ public abstract class FeedItemCursorMapper {
int indexHasChapters = cursor.getColumnIndexOrThrow(PodDBAdapter.KEY_HAS_CHAPTERS);
int indexRead = cursor.getColumnIndexOrThrow(PodDBAdapter.KEY_READ);
int indexItemIdentifier = cursor.getColumnIndexOrThrow(PodDBAdapter.KEY_ITEM_IDENTIFIER);
- int indexAutoDownload = cursor.getColumnIndexOrThrow(PodDBAdapter.KEY_AUTO_DOWNLOAD_ATTEMPTS);
+ int indexAutoDownload = cursor.getColumnIndexOrThrow(PodDBAdapter.KEY_AUTO_DOWNLOAD_ENABLED);
int indexImageUrl = cursor.getColumnIndexOrThrow(PodDBAdapter.KEY_IMAGE_URL);
int indexPodcastIndexChapterUrl = cursor.getColumnIndexOrThrow(PodDBAdapter.KEY_PODCASTINDEX_CHAPTER_URL);
@@ -38,11 +38,11 @@ public abstract class FeedItemCursorMapper {
boolean hasChapters = cursor.getInt(indexHasChapters) > 0;
int state = cursor.getInt(indexRead);
String itemIdentifier = cursor.getString(indexItemIdentifier);
- long autoDownload = cursor.getLong(indexAutoDownload);
+ boolean autoDownloadEnabled = cursor.getLong(indexAutoDownload) > 0;
String imageUrl = cursor.getString(indexImageUrl);
String podcastIndexChapterUrl = cursor.getString(indexPodcastIndexChapterUrl);
return new FeedItem(id, title, link, pubDate, paymentLink, feedId,
- hasChapters, imageUrl, state, itemIdentifier, autoDownload, podcastIndexChapterUrl);
+ hasChapters, imageUrl, state, itemIdentifier, autoDownloadEnabled, podcastIndexChapterUrl);
}
}
diff --git a/storage/preferences/src/main/java/de/danoeh/antennapod/storage/preferences/UserPreferences.java b/storage/preferences/src/main/java/de/danoeh/antennapod/storage/preferences/UserPreferences.java
index 80a58525d..b454ee5a1 100644
--- a/storage/preferences/src/main/java/de/danoeh/antennapod/storage/preferences/UserPreferences.java
+++ b/storage/preferences/src/main/java/de/danoeh/antennapod/storage/preferences/UserPreferences.java
@@ -54,7 +54,7 @@ public class UserPreferences {
public static final String PREF_USE_EPISODE_COVER = "prefEpisodeCover";
public static final String PREF_SHOW_TIME_LEFT = "showTimeLeft";
private static final String PREF_PERSISTENT_NOTIFICATION = "prefPersistNotify";
- public static final String PREF_COMPACT_NOTIFICATION_BUTTONS = "prefCompactNotificationButtons";
+ public static final String PREF_FULL_NOTIFICATION_BUTTONS = "prefFullNotificationButtons";
private static final String PREF_SHOW_DOWNLOAD_REPORT = "prefShowDownloadReport";
public static final String PREF_DEFAULT_PAGE = "prefDefaultPage";
public static final String PREF_FILTER_FEED = "prefSubscriptionsFilter";
@@ -67,6 +67,10 @@ public class UserPreferences {
private static final String PREF_DOWNLOADS_SORTED_ORDER = "prefDownloadSortedOrder";
private static final String PREF_INBOX_SORTED_ORDER = "prefInboxSortedOrder";
+ // Episode
+ public static final String PREF_SORT_ALL_EPISODES = "prefEpisodesSort";
+ public static final String PREF_FILTER_ALL_EPISODES = "prefEpisodesFilter";
+
// Playback
public static final String PREF_PAUSE_ON_HEADSET_DISCONNECT = "prefPauseOnHeadsetDisconnect";
public static final String PREF_UNPAUSE_ON_HEADSET_RECONNECT = "prefUnpauseOnHeadsetReconnect";
@@ -123,9 +127,12 @@ public class UserPreferences {
public static final int EPISODE_CLEANUP_DEFAULT = 0;
// Constants
- private static final int NOTIFICATION_BUTTON_REWIND = 0;
- private static final int NOTIFICATION_BUTTON_FAST_FORWARD = 1;
- private static final int NOTIFICATION_BUTTON_SKIP = 2;
+ public static final int NOTIFICATION_BUTTON_REWIND = 0;
+ public static final int NOTIFICATION_BUTTON_FAST_FORWARD = 1;
+ public static final int NOTIFICATION_BUTTON_SKIP = 2;
+
+ public static final int NOTIFICATION_BUTTON_NEXT_CHAPTER = 3;
+ public static final int NOTIFICATION_BUTTON_PLAYBACK_SPEED = 4;
public static final int EPISODE_CACHE_SIZE_UNLIMITED = -1;
public static final int FEED_ORDER_COUNTER = 0;
public static final int FEED_ORDER_ALPHABETICAL = 1;
@@ -191,11 +198,11 @@ public class UserPreferences {
return new ArrayList<>(Arrays.asList(TextUtils.split(hiddenItems, ",")));
}
- public static List<Integer> getCompactNotificationButtons() {
+ public static List<Integer> getFullNotificationButtons() {
String[] buttons = TextUtils.split(
- prefs.getString(PREF_COMPACT_NOTIFICATION_BUTTONS,
- NOTIFICATION_BUTTON_REWIND + "," + NOTIFICATION_BUTTON_FAST_FORWARD),
- ",");
+ prefs.getString(PREF_FULL_NOTIFICATION_BUTTONS,
+ NOTIFICATION_BUTTON_SKIP + "," + NOTIFICATION_BUTTON_PLAYBACK_SPEED), ",");
+
List<Integer> notificationButtons = new ArrayList<>();
for (String button : buttons) {
notificationButtons.add(Integer.parseInt(button));
@@ -204,27 +211,28 @@ public class UserPreferences {
}
/**
- * Helper function to return whether the specified button should be shown on compact
+ * Helper function to return whether the specified button should be shown on full
* notifications.
*
- * @param buttonId Either NOTIFICATION_BUTTON_REWIND, NOTIFICATION_BUTTON_FAST_FORWARD or
- * NOTIFICATION_BUTTON_SKIP.
+ * @param buttonId Either NOTIFICATION_BUTTON_REWIND, NOTIFICATION_BUTTON_FAST_FORWARD,
+ * NOTIFICATION_BUTTON_SKIP, NOTIFICATION_BUTTON_PLAYBACK_SPEED
+ * or NOTIFICATION_BUTTON_NEXT_CHAPTER.
* @return {@code true} if button should be shown, {@code false} otherwise
*/
- private static boolean showButtonOnCompactNotification(int buttonId) {
- return getCompactNotificationButtons().contains(buttonId);
+ private static boolean showButtonOnFullNotification(int buttonId) {
+ return getFullNotificationButtons().contains(buttonId);
}
- public static boolean showRewindOnCompactNotification() {
- return showButtonOnCompactNotification(NOTIFICATION_BUTTON_REWIND);
+ public static boolean showSkipOnFullNotification() {
+ return showButtonOnFullNotification(NOTIFICATION_BUTTON_SKIP);
}
- public static boolean showFastForwardOnCompactNotification() {
- return showButtonOnCompactNotification(NOTIFICATION_BUTTON_FAST_FORWARD);
+ public static boolean showNextChapterOnFullNotification() {
+ return showButtonOnFullNotification(NOTIFICATION_BUTTON_NEXT_CHAPTER);
}
- public static boolean showSkipOnCompactNotification() {
- return showButtonOnCompactNotification(NOTIFICATION_BUTTON_SKIP);
+ public static boolean showPlaybackSpeedOnFullNotification() {
+ return showButtonOnFullNotification(NOTIFICATION_BUTTON_PLAYBACK_SPEED);
}
public static int getFeedOrder() {
@@ -649,10 +657,10 @@ public class UserPreferences {
.apply();
}
- public static void setCompactNotificationButtons(List<Integer> items) {
+ public static void setFullNotificationButtons(List<Integer> items) {
String str = TextUtils.join(",", items);
prefs.edit()
- .putString(PREF_COMPACT_NOTIFICATION_BUTTONS, str)
+ .putString(PREF_FULL_NOTIFICATION_BUTTONS, str)
.apply();
}
@@ -867,4 +875,21 @@ public class UserPreferences {
public static boolean shouldShowSubscriptionTitle() {
return prefs.getBoolean(PREF_SUBSCRIPTION_TITLE, false);
}
+
+ public static void setAllEpisodesSortOrder(SortOrder s) {
+ prefs.edit().putString(PREF_SORT_ALL_EPISODES, "" + s.code).apply();
+ }
+
+ public static SortOrder getAllEpisodesSortOrder() {
+ return SortOrder.fromCodeString(prefs.getString(PREF_SORT_ALL_EPISODES,
+ "" + SortOrder.DATE_NEW_OLD.code));
+ }
+
+ public static String getPrefFilterAllEpisodes() {
+ return prefs.getString(PREF_FILTER_ALL_EPISODES, "");
+ }
+
+ public static void setPrefFilterAllEpisodes(String filter) {
+ prefs.edit().putString(PREF_FILTER_ALL_EPISODES, filter).apply();
+ }
}