From 9fed944392ee31f00ef91a01a2c34dddc876a86a Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Wed, 22 Feb 2023 14:34:43 -0600 Subject: Add "New Episodes Action" preference (#6095) --- .../de/danoeh/antennapod/storage/database/DBUpgrader.java | 4 ++++ .../de/danoeh/antennapod/storage/database/PodDBAdapter.java | 12 ++++++++---- .../storage/database/mapper/FeedPreferencesCursorMapper.java | 7 +++++-- 3 files changed, 17 insertions(+), 6 deletions(-) (limited to 'storage/database') 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 78eaf6964..e4a1f5a3d 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 @@ -330,6 +330,10 @@ class DBUpgrader { db.execSQL("ALTER TABLE " + PodDBAdapter.TABLE_NAME_FEED_ITEMS + " ADD COLUMN " + PodDBAdapter.KEY_PODCASTINDEX_CHAPTER_URL + " TEXT"); } + if (oldVersion < 3010000) { + db.execSQL("ALTER TABLE " + PodDBAdapter.TABLE_NAME_FEEDS + + " ADD COLUMN " + PodDBAdapter.KEY_NEW_EPISODES_ACTION + " INTEGER DEFAULT 0"); + } } } 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 bb0218a0b..0909ea4b7 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 @@ -54,7 +54,7 @@ public class PodDBAdapter { private static final String TAG = "PodDBAdapter"; public static final String DATABASE_NAME = "Antennapod.db"; - public static final int VERSION = 2060000; + public static final int VERSION = 3010000; /** * Maximum number of arguments for IN-operator. @@ -120,6 +120,7 @@ public class PodDBAdapter { public static final String KEY_FEED_SKIP_ENDING = "feed_skip_ending"; public static final String KEY_FEED_TAGS = "tags"; public static final String KEY_EPISODE_NOTIFICATION = "episode_notification"; + public static final String KEY_NEW_EPISODES_ACTION = "new_episodes_action"; public static final String KEY_PODCASTINDEX_CHAPTER_URL = "podcastindex_chapter_url"; // Table names @@ -161,7 +162,8 @@ public class PodDBAdapter { + KEY_FEED_TAGS + " TEXT," + KEY_FEED_SKIP_INTRO + " INTEGER DEFAULT 0," + KEY_FEED_SKIP_ENDING + " INTEGER DEFAULT 0," - + KEY_EPISODE_NOTIFICATION + " INTEGER DEFAULT 0)"; + + KEY_EPISODE_NOTIFICATION + " INTEGER DEFAULT 0," + + KEY_NEW_EPISODES_ACTION + " INTEGER DEFAULT 0)"; private static final String CREATE_TABLE_FEED_ITEMS = "CREATE TABLE " + TABLE_NAME_FEED_ITEMS + " (" + TABLE_PRIMARY_KEY @@ -311,7 +313,8 @@ public class PodDBAdapter { + TABLE_NAME_FEEDS + "." + KEY_FEED_TAGS + ", " + TABLE_NAME_FEEDS + "." + KEY_FEED_SKIP_INTRO + ", " + TABLE_NAME_FEEDS + "." + KEY_FEED_SKIP_ENDING + ", " - + TABLE_NAME_FEEDS + "." + KEY_EPISODE_NOTIFICATION; + + TABLE_NAME_FEEDS + "." + KEY_EPISODE_NOTIFICATION + ", " + + TABLE_NAME_FEEDS + "." + KEY_NEW_EPISODES_ACTION; private static final String JOIN_FEED_ITEM_AND_MEDIA = " LEFT JOIN " + TABLE_NAME_FEED_MEDIA + " ON " + TABLE_NAME_FEED_ITEMS + "." + KEY_ID + "=" + TABLE_NAME_FEED_MEDIA + "." + KEY_FEEDITEM + " "; @@ -448,7 +451,7 @@ public class PodDBAdapter { ContentValues values = new ContentValues(); values.put(KEY_AUTO_DOWNLOAD_ENABLED, prefs.getAutoDownload()); values.put(KEY_KEEP_UPDATED, prefs.getKeepUpdated()); - values.put(KEY_AUTO_DELETE_ACTION, prefs.getAutoDeleteAction().ordinal()); + values.put(KEY_AUTO_DELETE_ACTION, prefs.getAutoDeleteAction().code); values.put(KEY_FEED_VOLUME_ADAPTION, prefs.getVolumeAdaptionSetting().toInteger()); values.put(KEY_USERNAME, prefs.getUsername()); values.put(KEY_PASSWORD, prefs.getPassword()); @@ -460,6 +463,7 @@ public class PodDBAdapter { values.put(KEY_FEED_SKIP_INTRO, prefs.getFeedSkipIntro()); values.put(KEY_FEED_SKIP_ENDING, prefs.getFeedSkipEnding()); values.put(KEY_EPISODE_NOTIFICATION, prefs.getShowEpisodeNotification()); + values.put(KEY_NEW_EPISODES_ACTION, prefs.getNewEpisodesAction().code); db.update(TABLE_NAME_FEEDS, values, KEY_ID + "=?", new String[]{String.valueOf(prefs.getFeedID())}); } diff --git a/storage/database/src/main/java/de/danoeh/antennapod/storage/database/mapper/FeedPreferencesCursorMapper.java b/storage/database/src/main/java/de/danoeh/antennapod/storage/database/mapper/FeedPreferencesCursorMapper.java index 289bcbab8..2de100dff 100644 --- a/storage/database/src/main/java/de/danoeh/antennapod/storage/database/mapper/FeedPreferencesCursorMapper.java +++ b/storage/database/src/main/java/de/danoeh/antennapod/storage/database/mapper/FeedPreferencesCursorMapper.java @@ -34,14 +34,14 @@ public abstract class FeedPreferencesCursorMapper { int indexAutoSkipIntro = cursor.getColumnIndexOrThrow(PodDBAdapter.KEY_FEED_SKIP_INTRO); int indexAutoSkipEnding = cursor.getColumnIndexOrThrow(PodDBAdapter.KEY_FEED_SKIP_ENDING); int indexEpisodeNotification = cursor.getColumnIndexOrThrow(PodDBAdapter.KEY_EPISODE_NOTIFICATION); + int indexNewEpisodesAction = cursor.getColumnIndexOrThrow(PodDBAdapter.KEY_NEW_EPISODES_ACTION); int indexTags = cursor.getColumnIndexOrThrow(PodDBAdapter.KEY_FEED_TAGS); long feedId = cursor.getLong(indexId); boolean autoDownload = cursor.getInt(indexAutoDownload) > 0; boolean autoRefresh = cursor.getInt(indexAutoRefresh) > 0; - int autoDeleteActionIndex = cursor.getInt(indexAutoDeleteAction); FeedPreferences.AutoDeleteAction autoDeleteAction = - FeedPreferences.AutoDeleteAction.values()[autoDeleteActionIndex]; + FeedPreferences.AutoDeleteAction.fromCode(cursor.getInt(indexAutoDeleteAction)); int volumeAdaptionValue = cursor.getInt(indexVolumeAdaption); VolumeAdaptionSetting volumeAdaptionSetting = VolumeAdaptionSetting.fromInteger(volumeAdaptionValue); String username = cursor.getString(indexUsername); @@ -52,6 +52,8 @@ public abstract class FeedPreferencesCursorMapper { float feedPlaybackSpeed = cursor.getFloat(indexFeedPlaybackSpeed); int feedAutoSkipIntro = cursor.getInt(indexAutoSkipIntro); int feedAutoSkipEnding = cursor.getInt(indexAutoSkipEnding); + FeedPreferences.NewEpisodesAction feedNewEpisodesAction = + FeedPreferences.NewEpisodesAction.fromCode(cursor.getInt(indexNewEpisodesAction)); boolean showNotification = cursor.getInt(indexEpisodeNotification) > 0; String tagsString = cursor.getString(indexTags); if (TextUtils.isEmpty(tagsString)) { @@ -69,6 +71,7 @@ public abstract class FeedPreferencesCursorMapper { feedAutoSkipIntro, feedAutoSkipEnding, showNotification, + feedNewEpisodesAction, new HashSet<>(Arrays.asList(tagsString.split(FeedPreferences.TAG_SEPARATOR)))); } } -- cgit v1.2.3