Store tags in the database
This commit is contained in:
parent
1eb47a2d6b
commit
19e427b524
|
@ -22,8 +22,8 @@ android {
|
||||||
// "1.2.3-SNAPSHOT" -> 1020300
|
// "1.2.3-SNAPSHOT" -> 1020300
|
||||||
// "1.2.3-RC4" -> 1020304
|
// "1.2.3-RC4" -> 1020304
|
||||||
// "1.2.3" -> 1020395
|
// "1.2.3" -> 1020395
|
||||||
versionCode 2010295
|
versionCode 2020000
|
||||||
versionName "2.1.2"
|
versionName "2.2.0"
|
||||||
|
|
||||||
multiDexEnabled false
|
multiDexEnabled false
|
||||||
vectorDrawables.useSupportLibrary true
|
vectorDrawables.useSupportLibrary true
|
||||||
|
|
|
@ -9,6 +9,10 @@ import de.danoeh.antennapod.core.preferences.UserPreferences;
|
||||||
import de.danoeh.antennapod.core.storage.DBWriter;
|
import de.danoeh.antennapod.core.storage.DBWriter;
|
||||||
import de.danoeh.antennapod.core.storage.PodDBAdapter;
|
import de.danoeh.antennapod.core.storage.PodDBAdapter;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contains preferences for a single feed.
|
* Contains preferences for a single feed.
|
||||||
*/
|
*/
|
||||||
|
@ -16,6 +20,7 @@ public class FeedPreferences {
|
||||||
|
|
||||||
public static final float SPEED_USE_GLOBAL = -1;
|
public static final float SPEED_USE_GLOBAL = -1;
|
||||||
public static final String TAG_ROOT = "#root";
|
public static final String TAG_ROOT = "#root";
|
||||||
|
public static final String TAG_SEPARATOR = ",";
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
private FeedFilter filter;
|
private FeedFilter filter;
|
||||||
|
@ -37,14 +42,17 @@ public class FeedPreferences {
|
||||||
private float feedPlaybackSpeed;
|
private float feedPlaybackSpeed;
|
||||||
private int feedSkipIntro;
|
private int feedSkipIntro;
|
||||||
private int feedSkipEnding;
|
private int feedSkipEnding;
|
||||||
private String[] tags = {TAG_ROOT, "Test 1", "Test 2"};
|
private final Set<String> tags = new HashSet<>();
|
||||||
|
|
||||||
public FeedPreferences(long feedID, boolean autoDownload, AutoDeleteAction auto_delete_action, VolumeAdaptionSetting volumeAdaptionSetting, String username, String password) {
|
public FeedPreferences(long feedID, boolean autoDownload, AutoDeleteAction auto_delete_action, VolumeAdaptionSetting volumeAdaptionSetting, String username, String password) {
|
||||||
this(feedID, autoDownload, true, auto_delete_action, volumeAdaptionSetting,
|
this(feedID, autoDownload, true, auto_delete_action, volumeAdaptionSetting,
|
||||||
username, password, new FeedFilter(), SPEED_USE_GLOBAL, 0, 0);
|
username, password, new FeedFilter(), SPEED_USE_GLOBAL, 0, 0, new HashSet<>());
|
||||||
}
|
}
|
||||||
|
|
||||||
private FeedPreferences(long feedID, boolean autoDownload, boolean keepUpdated, AutoDeleteAction auto_delete_action, VolumeAdaptionSetting volumeAdaptionSetting, String username, String password, @NonNull FeedFilter filter, float feedPlaybackSpeed, int feedSkipIntro, int feedSkipEnding) {
|
private FeedPreferences(long feedID, boolean autoDownload, boolean keepUpdated, AutoDeleteAction auto_delete_action,
|
||||||
|
VolumeAdaptionSetting volumeAdaptionSetting, String username, String password,
|
||||||
|
@NonNull FeedFilter filter, float feedPlaybackSpeed, int feedSkipIntro, int feedSkipEnding,
|
||||||
|
Set<String> tags) {
|
||||||
this.feedID = feedID;
|
this.feedID = feedID;
|
||||||
this.autoDownload = autoDownload;
|
this.autoDownload = autoDownload;
|
||||||
this.keepUpdated = keepUpdated;
|
this.keepUpdated = keepUpdated;
|
||||||
|
@ -56,6 +64,7 @@ public class FeedPreferences {
|
||||||
this.feedPlaybackSpeed = feedPlaybackSpeed;
|
this.feedPlaybackSpeed = feedPlaybackSpeed;
|
||||||
this.feedSkipIntro = feedSkipIntro;
|
this.feedSkipIntro = feedSkipIntro;
|
||||||
this.feedSkipEnding = feedSkipEnding;
|
this.feedSkipEnding = feedSkipEnding;
|
||||||
|
this.tags.addAll(tags);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FeedPreferences fromCursor(Cursor cursor) {
|
public static FeedPreferences fromCursor(Cursor cursor) {
|
||||||
|
@ -71,6 +80,7 @@ public class FeedPreferences {
|
||||||
int indexFeedPlaybackSpeed = cursor.getColumnIndex(PodDBAdapter.KEY_FEED_PLAYBACK_SPEED);
|
int indexFeedPlaybackSpeed = cursor.getColumnIndex(PodDBAdapter.KEY_FEED_PLAYBACK_SPEED);
|
||||||
int indexAutoSkipIntro = cursor.getColumnIndex(PodDBAdapter.KEY_FEED_SKIP_INTRO);
|
int indexAutoSkipIntro = cursor.getColumnIndex(PodDBAdapter.KEY_FEED_SKIP_INTRO);
|
||||||
int indexAutoSkipEnding = cursor.getColumnIndex(PodDBAdapter.KEY_FEED_SKIP_ENDING);
|
int indexAutoSkipEnding = cursor.getColumnIndex(PodDBAdapter.KEY_FEED_SKIP_ENDING);
|
||||||
|
int indexTags = cursor.getColumnIndex(PodDBAdapter.KEY_FEED_TAGS);
|
||||||
|
|
||||||
long feedId = cursor.getLong(indexId);
|
long feedId = cursor.getLong(indexId);
|
||||||
boolean autoDownload = cursor.getInt(indexAutoDownload) > 0;
|
boolean autoDownload = cursor.getInt(indexAutoDownload) > 0;
|
||||||
|
@ -86,6 +96,11 @@ public class FeedPreferences {
|
||||||
float feedPlaybackSpeed = cursor.getFloat(indexFeedPlaybackSpeed);
|
float feedPlaybackSpeed = cursor.getFloat(indexFeedPlaybackSpeed);
|
||||||
int feedAutoSkipIntro = cursor.getInt(indexAutoSkipIntro);
|
int feedAutoSkipIntro = cursor.getInt(indexAutoSkipIntro);
|
||||||
int feedAutoSkipEnding = cursor.getInt(indexAutoSkipEnding);
|
int feedAutoSkipEnding = cursor.getInt(indexAutoSkipEnding);
|
||||||
|
String tagsString = cursor.getString(indexTags);
|
||||||
|
if (TextUtils.isEmpty(tagsString)) {
|
||||||
|
tagsString = TAG_ROOT;
|
||||||
|
}
|
||||||
|
|
||||||
return new FeedPreferences(feedId,
|
return new FeedPreferences(feedId,
|
||||||
autoDownload,
|
autoDownload,
|
||||||
autoRefresh,
|
autoRefresh,
|
||||||
|
@ -96,8 +111,8 @@ public class FeedPreferences {
|
||||||
new FeedFilter(includeFilter, excludeFilter),
|
new FeedFilter(includeFilter, excludeFilter),
|
||||||
feedPlaybackSpeed,
|
feedPlaybackSpeed,
|
||||||
feedAutoSkipIntro,
|
feedAutoSkipIntro,
|
||||||
feedAutoSkipEnding
|
feedAutoSkipEnding,
|
||||||
);
|
new HashSet<>(Arrays.asList(tagsString.split(TAG_SEPARATOR))));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -243,11 +258,7 @@ public class FeedPreferences {
|
||||||
return feedSkipEnding;
|
return feedSkipEnding;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[] getTags() {
|
public Set<String> getTags() {
|
||||||
return tags;
|
return tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTags(String[] tags) {
|
|
||||||
this.tags = tags;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -305,10 +305,14 @@ class DBUpgrader {
|
||||||
+ " ADD COLUMN " + PodDBAdapter.KEY_IMAGE_URL + " TEXT DEFAULT NULL");
|
+ " ADD COLUMN " + PodDBAdapter.KEY_IMAGE_URL + " TEXT DEFAULT NULL");
|
||||||
}
|
}
|
||||||
if (oldVersion < 1090001) {
|
if (oldVersion < 1090001) {
|
||||||
db.execSQL("ALTER TABLE " + PodDBAdapter.TABLE_NAME_FEEDS +
|
db.execSQL("ALTER TABLE " + PodDBAdapter.TABLE_NAME_FEEDS
|
||||||
" ADD COLUMN " + PodDBAdapter.KEY_FEED_SKIP_INTRO + " INTEGER DEFAULT 0;");
|
+ " ADD COLUMN " + PodDBAdapter.KEY_FEED_SKIP_INTRO + " INTEGER DEFAULT 0;");
|
||||||
db.execSQL("ALTER TABLE " + PodDBAdapter.TABLE_NAME_FEEDS +
|
db.execSQL("ALTER TABLE " + PodDBAdapter.TABLE_NAME_FEEDS
|
||||||
" ADD COLUMN " + PodDBAdapter.KEY_FEED_SKIP_ENDING + " INTEGER DEFAULT 0;");
|
+ " ADD COLUMN " + PodDBAdapter.KEY_FEED_SKIP_ENDING + " INTEGER DEFAULT 0;");
|
||||||
|
}
|
||||||
|
if (oldVersion < 2020000) {
|
||||||
|
db.execSQL("ALTER TABLE " + PodDBAdapter.TABLE_NAME_FEEDS
|
||||||
|
+ " ADD COLUMN " + PodDBAdapter.KEY_FEED_TAGS + " TEXT;");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ public class PodDBAdapter {
|
||||||
|
|
||||||
private static final String TAG = "PodDBAdapter";
|
private static final String TAG = "PodDBAdapter";
|
||||||
public static final String DATABASE_NAME = "Antennapod.db";
|
public static final String DATABASE_NAME = "Antennapod.db";
|
||||||
public static final int VERSION = 1090001;
|
public static final int VERSION = 2020000;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maximum number of arguments for IN-operator.
|
* Maximum number of arguments for IN-operator.
|
||||||
|
@ -113,6 +113,7 @@ public class PodDBAdapter {
|
||||||
public static final String KEY_FEED_PLAYBACK_SPEED = "feed_playback_speed";
|
public static final String KEY_FEED_PLAYBACK_SPEED = "feed_playback_speed";
|
||||||
public static final String KEY_FEED_SKIP_INTRO = "feed_skip_intro";
|
public static final String KEY_FEED_SKIP_INTRO = "feed_skip_intro";
|
||||||
public static final String KEY_FEED_SKIP_ENDING = "feed_skip_ending";
|
public static final String KEY_FEED_SKIP_ENDING = "feed_skip_ending";
|
||||||
|
public static final String KEY_FEED_TAGS = "tags";
|
||||||
|
|
||||||
// Table names
|
// Table names
|
||||||
static final String TABLE_NAME_FEEDS = "Feeds";
|
static final String TABLE_NAME_FEEDS = "Feeds";
|
||||||
|
@ -149,6 +150,7 @@ public class PodDBAdapter {
|
||||||
+ KEY_AUTO_DELETE_ACTION + " INTEGER DEFAULT 0,"
|
+ KEY_AUTO_DELETE_ACTION + " INTEGER DEFAULT 0,"
|
||||||
+ KEY_FEED_PLAYBACK_SPEED + " REAL DEFAULT " + SPEED_USE_GLOBAL + ","
|
+ KEY_FEED_PLAYBACK_SPEED + " REAL DEFAULT " + SPEED_USE_GLOBAL + ","
|
||||||
+ KEY_FEED_VOLUME_ADAPTION + " INTEGER DEFAULT 0,"
|
+ KEY_FEED_VOLUME_ADAPTION + " INTEGER DEFAULT 0,"
|
||||||
|
+ KEY_FEED_TAGS + " TEXT,"
|
||||||
+ KEY_FEED_SKIP_INTRO + " INTEGER DEFAULT 0,"
|
+ KEY_FEED_SKIP_INTRO + " INTEGER DEFAULT 0,"
|
||||||
+ KEY_FEED_SKIP_ENDING + " INTEGER DEFAULT 0)";
|
+ KEY_FEED_SKIP_ENDING + " INTEGER DEFAULT 0)";
|
||||||
|
|
||||||
|
@ -251,6 +253,7 @@ public class PodDBAdapter {
|
||||||
TABLE_NAME_FEEDS + "." + KEY_INCLUDE_FILTER,
|
TABLE_NAME_FEEDS + "." + KEY_INCLUDE_FILTER,
|
||||||
TABLE_NAME_FEEDS + "." + KEY_EXCLUDE_FILTER,
|
TABLE_NAME_FEEDS + "." + KEY_EXCLUDE_FILTER,
|
||||||
TABLE_NAME_FEEDS + "." + KEY_FEED_PLAYBACK_SPEED,
|
TABLE_NAME_FEEDS + "." + KEY_FEED_PLAYBACK_SPEED,
|
||||||
|
TABLE_NAME_FEEDS + "." + KEY_FEED_TAGS,
|
||||||
TABLE_NAME_FEEDS + "." + KEY_FEED_SKIP_INTRO,
|
TABLE_NAME_FEEDS + "." + KEY_FEED_SKIP_INTRO,
|
||||||
TABLE_NAME_FEEDS + "." + KEY_FEED_SKIP_ENDING
|
TABLE_NAME_FEEDS + "." + KEY_FEED_SKIP_ENDING
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue