Move database to its own module
This commit is contained in:
parent
42e36328e3
commit
ff3258c34a
|
@ -118,6 +118,7 @@ dependencies {
|
|||
implementation project(':parser:feed')
|
||||
implementation project(':playback:base')
|
||||
implementation project(':playback:cast')
|
||||
implementation project(':storage:database')
|
||||
implementation project(':ui:app-start-intent')
|
||||
implementation project(':ui:common')
|
||||
implementation project(':ui:i18n')
|
||||
|
|
|
@ -2,6 +2,7 @@ package de.danoeh.antennapod.core.service.download;
|
|||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.util.Consumer;
|
||||
import de.danoeh.antennapod.model.download.DownloadStatus;
|
||||
|
||||
public class StubDownloader extends Downloader {
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ import androidx.test.espresso.util.HumanReadables;
|
|||
import androidx.test.espresso.util.TreeIterables;
|
||||
import android.view.View;
|
||||
|
||||
import de.danoeh.antennapod.storage.database.PodDBAdapter;
|
||||
import junit.framework.AssertionFailedError;
|
||||
|
||||
import de.danoeh.antennapod.R;
|
||||
|
@ -25,7 +26,6 @@ import de.danoeh.antennapod.activity.MainActivity;
|
|||
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
||||
import de.danoeh.antennapod.core.service.download.DownloadService;
|
||||
import de.danoeh.antennapod.core.service.playback.PlaybackService;
|
||||
import de.danoeh.antennapod.core.storage.PodDBAdapter;
|
||||
import de.danoeh.antennapod.dialog.RatingDialog;
|
||||
import de.danoeh.antennapod.fragment.NavDrawerFragment;
|
||||
import org.awaitility.Awaitility;
|
||||
|
|
|
@ -28,7 +28,7 @@ import de.danoeh.antennapod.model.feed.FeedMedia;
|
|||
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
||||
import de.danoeh.antennapod.core.service.download.DownloadRequest;
|
||||
import de.danoeh.antennapod.core.service.download.DownloadService;
|
||||
import de.danoeh.antennapod.core.service.download.DownloadStatus;
|
||||
import de.danoeh.antennapod.model.download.DownloadStatus;
|
||||
import de.danoeh.antennapod.core.service.download.Downloader;
|
||||
import de.danoeh.antennapod.core.service.download.DownloaderFactory;
|
||||
import de.danoeh.antennapod.core.service.download.StubDownloader;
|
||||
|
|
|
@ -10,10 +10,10 @@ import java.io.IOException;
|
|||
import de.danoeh.antennapod.model.feed.FeedFile;
|
||||
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
||||
import de.danoeh.antennapod.core.service.download.DownloadRequest;
|
||||
import de.danoeh.antennapod.core.service.download.DownloadStatus;
|
||||
import de.danoeh.antennapod.model.download.DownloadStatus;
|
||||
import de.danoeh.antennapod.core.service.download.Downloader;
|
||||
import de.danoeh.antennapod.core.service.download.HttpDownloader;
|
||||
import de.danoeh.antennapod.core.util.DownloadError;
|
||||
import de.danoeh.antennapod.model.download.DownloadError;
|
||||
import de.test.antennapod.util.service.download.HTTPBin;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
|
|
|
@ -8,6 +8,7 @@ import androidx.test.filters.MediumTest;
|
|||
import de.danoeh.antennapod.model.feed.VolumeAdaptionSetting;
|
||||
import de.danoeh.antennapod.playback.base.PlaybackServiceMediaPlayer;
|
||||
import de.danoeh.antennapod.playback.base.PlayerStatus;
|
||||
import de.danoeh.antennapod.storage.database.PodDBAdapter;
|
||||
import de.test.antennapod.EspressoTestUtils;
|
||||
import junit.framework.AssertionFailedError;
|
||||
|
||||
|
@ -27,7 +28,6 @@ import de.danoeh.antennapod.model.feed.FeedItem;
|
|||
import de.danoeh.antennapod.model.feed.FeedMedia;
|
||||
import de.danoeh.antennapod.model.feed.FeedPreferences;
|
||||
import de.danoeh.antennapod.core.service.playback.LocalPSMP;
|
||||
import de.danoeh.antennapod.core.storage.PodDBAdapter;
|
||||
import de.danoeh.antennapod.model.playback.Playable;
|
||||
import de.test.antennapod.util.service.download.HTTPBin;
|
||||
import org.junit.After;
|
||||
|
|
|
@ -8,6 +8,7 @@ import androidx.test.filters.LargeTest;
|
|||
import de.danoeh.antennapod.event.playback.SleepTimerUpdatedEvent;
|
||||
import de.danoeh.antennapod.core.preferences.SleepTimerPreferences;
|
||||
import de.danoeh.antennapod.core.widget.WidgetUpdater;
|
||||
import de.danoeh.antennapod.storage.database.PodDBAdapter;
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.junit.After;
|
||||
|
@ -23,7 +24,6 @@ import java.util.concurrent.TimeUnit;
|
|||
import de.danoeh.antennapod.model.feed.Feed;
|
||||
import de.danoeh.antennapod.model.feed.FeedItem;
|
||||
import de.danoeh.antennapod.core.service.playback.PlaybackServiceTaskManager;
|
||||
import de.danoeh.antennapod.core.storage.PodDBAdapter;
|
||||
import de.danoeh.antennapod.model.playback.Playable;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
|
|
@ -10,6 +10,7 @@ import androidx.test.platform.app.InstrumentationRegistry;
|
|||
|
||||
import com.robotium.solo.Solo;
|
||||
|
||||
import de.danoeh.antennapod.storage.database.PodDBAdapter;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
|
@ -21,7 +22,6 @@ import java.io.IOException;
|
|||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.activity.MainActivity;
|
||||
import de.danoeh.antennapod.model.feed.Feed;
|
||||
import de.danoeh.antennapod.core.storage.PodDBAdapter;
|
||||
import de.test.antennapod.EspressoTestUtils;
|
||||
|
||||
import static androidx.test.espresso.Espresso.onView;
|
||||
|
|
|
@ -7,7 +7,7 @@ import de.danoeh.antennapod.event.QueueEvent;
|
|||
import de.danoeh.antennapod.model.feed.Feed;
|
||||
import de.danoeh.antennapod.model.feed.FeedItem;
|
||||
import de.danoeh.antennapod.model.feed.FeedMedia;
|
||||
import de.danoeh.antennapod.core.storage.PodDBAdapter;
|
||||
import de.danoeh.antennapod.storage.database.PodDBAdapter;
|
||||
import de.test.antennapod.util.service.download.HTTPBin;
|
||||
import de.test.antennapod.util.syndication.feedgenerator.Rss2Generator;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
|
|
@ -45,7 +45,7 @@ import de.danoeh.antennapod.core.glide.FastBlurTransformation;
|
|||
import de.danoeh.antennapod.core.preferences.PlaybackPreferences;
|
||||
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
||||
import de.danoeh.antennapod.core.service.download.DownloadRequest;
|
||||
import de.danoeh.antennapod.core.service.download.DownloadStatus;
|
||||
import de.danoeh.antennapod.model.download.DownloadStatus;
|
||||
import de.danoeh.antennapod.core.service.download.Downloader;
|
||||
import de.danoeh.antennapod.core.service.download.HttpDownloader;
|
||||
import de.danoeh.antennapod.core.service.playback.PlaybackService;
|
||||
|
@ -54,7 +54,7 @@ import de.danoeh.antennapod.core.storage.DBWriter;
|
|||
import de.danoeh.antennapod.core.util.FileNameGenerator;
|
||||
import de.danoeh.antennapod.parser.feed.FeedHandler;
|
||||
import de.danoeh.antennapod.parser.feed.FeedHandlerResult;
|
||||
import de.danoeh.antennapod.core.util.DownloadError;
|
||||
import de.danoeh.antennapod.model.download.DownloadError;
|
||||
import de.danoeh.antennapod.core.util.IntentUtils;
|
||||
import de.danoeh.antennapod.core.util.StorageUtils;
|
||||
import de.danoeh.antennapod.core.util.URLChecker;
|
||||
|
|
|
@ -12,8 +12,8 @@ import androidx.appcompat.app.AppCompatActivity;
|
|||
import android.widget.ProgressBar;
|
||||
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.core.storage.PodDBAdapter;
|
||||
import de.danoeh.antennapod.error.CrashReportWriter;
|
||||
import de.danoeh.antennapod.storage.database.PodDBAdapter;
|
||||
import io.reactivex.Completable;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
|
|
@ -17,10 +17,10 @@ import de.danoeh.antennapod.core.service.download.DownloadRequest;
|
|||
import de.danoeh.antennapod.core.service.download.DownloadRequestCreator;
|
||||
import de.danoeh.antennapod.core.service.download.DownloadService;
|
||||
import de.danoeh.antennapod.core.service.download.Downloader;
|
||||
import de.danoeh.antennapod.core.service.download.DownloadStatus;
|
||||
import de.danoeh.antennapod.model.download.DownloadStatus;
|
||||
import de.danoeh.antennapod.core.storage.DBReader;
|
||||
import de.danoeh.antennapod.core.storage.DBTasks;
|
||||
import de.danoeh.antennapod.core.util.DownloadError;
|
||||
import de.danoeh.antennapod.model.download.DownloadError;
|
||||
import de.danoeh.antennapod.core.util.DownloadErrorLabel;
|
||||
import de.danoeh.antennapod.model.feed.Feed;
|
||||
import de.danoeh.antennapod.model.feed.FeedMedia;
|
||||
|
|
|
@ -7,7 +7,7 @@ import android.widget.TextView;
|
|||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.core.service.download.DownloadStatus;
|
||||
import de.danoeh.antennapod.model.download.DownloadStatus;
|
||||
import de.danoeh.antennapod.core.storage.DBReader;
|
||||
import de.danoeh.antennapod.event.MessageEvent;
|
||||
import de.danoeh.antennapod.model.feed.Feed;
|
||||
|
|
|
@ -17,7 +17,7 @@ import de.danoeh.antennapod.core.event.DownloaderUpdate;
|
|||
import de.danoeh.antennapod.core.menuhandler.MenuItemUtils;
|
||||
import de.danoeh.antennapod.core.service.download.DownloadRequest;
|
||||
import de.danoeh.antennapod.core.service.download.DownloadService;
|
||||
import de.danoeh.antennapod.core.service.download.DownloadStatus;
|
||||
import de.danoeh.antennapod.model.download.DownloadStatus;
|
||||
import de.danoeh.antennapod.core.service.download.Downloader;
|
||||
import de.danoeh.antennapod.core.storage.DBReader;
|
||||
import de.danoeh.antennapod.core.storage.DBWriter;
|
||||
|
|
|
@ -45,7 +45,7 @@ import de.danoeh.antennapod.core.glide.ApGlideSettings;
|
|||
import de.danoeh.antennapod.core.glide.FastBlurTransformation;
|
||||
import de.danoeh.antennapod.core.menuhandler.MenuItemUtils;
|
||||
import de.danoeh.antennapod.core.service.download.DownloadService;
|
||||
import de.danoeh.antennapod.core.service.download.DownloadStatus;
|
||||
import de.danoeh.antennapod.model.download.DownloadStatus;
|
||||
import de.danoeh.antennapod.core.storage.DBReader;
|
||||
import de.danoeh.antennapod.core.storage.DBTasks;
|
||||
import de.danoeh.antennapod.core.storage.DBWriter;
|
||||
|
|
|
@ -30,6 +30,7 @@ dependencies {
|
|||
implementation project(':parser:media')
|
||||
implementation project(':playback:base')
|
||||
implementation project(':playback:cast')
|
||||
implementation project(':storage:database')
|
||||
implementation project(':ui:app-start-intent')
|
||||
implementation project(':ui:common')
|
||||
implementation project(':ui:i18n')
|
||||
|
|
|
@ -9,9 +9,9 @@ import de.danoeh.antennapod.core.preferences.SleepTimerPreferences;
|
|||
import de.danoeh.antennapod.core.preferences.UsageStatistics;
|
||||
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
||||
import de.danoeh.antennapod.core.service.download.AntennapodHttpClient;
|
||||
import de.danoeh.antennapod.core.storage.PodDBAdapter;
|
||||
import de.danoeh.antennapod.core.util.NetworkUtils;
|
||||
import de.danoeh.antennapod.core.util.gui.NotificationUtils;
|
||||
import de.danoeh.antennapod.storage.database.PodDBAdapter;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
|
|
|
@ -22,12 +22,12 @@ import java.util.Set;
|
|||
import java.util.UUID;
|
||||
|
||||
import de.danoeh.antennapod.core.R;
|
||||
import de.danoeh.antennapod.core.service.download.DownloadStatus;
|
||||
import de.danoeh.antennapod.model.download.DownloadStatus;
|
||||
import de.danoeh.antennapod.core.storage.DBReader;
|
||||
import de.danoeh.antennapod.core.storage.DBTasks;
|
||||
import de.danoeh.antennapod.core.storage.DBWriter;
|
||||
import de.danoeh.antennapod.parser.feed.util.DateUtils;
|
||||
import de.danoeh.antennapod.core.util.DownloadError;
|
||||
import de.danoeh.antennapod.model.download.DownloadError;
|
||||
import de.danoeh.antennapod.model.feed.Feed;
|
||||
import de.danoeh.antennapod.model.feed.FeedItem;
|
||||
import de.danoeh.antennapod.model.feed.FeedMedia;
|
||||
|
|
|
@ -5,7 +5,7 @@ import android.text.TextUtils;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import de.danoeh.antennapod.core.util.LongIntMap;
|
||||
import de.danoeh.antennapod.storage.database.LongIntMap;
|
||||
import de.danoeh.antennapod.model.feed.Feed;
|
||||
import de.danoeh.antennapod.model.feed.FeedPreferences;
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ import androidx.annotation.VisibleForTesting;
|
|||
import androidx.core.app.NotificationCompat;
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import de.danoeh.antennapod.model.feed.FeedCounter;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
|
||||
|
@ -141,11 +142,6 @@ public class UserPreferences {
|
|||
public static final int FEED_ORDER_COUNTER = 0;
|
||||
public static final int FEED_ORDER_ALPHABETICAL = 1;
|
||||
public static final int FEED_ORDER_MOST_PLAYED = 3;
|
||||
public static final int FEED_COUNTER_SHOW_NEW_UNPLAYED_SUM = 0;
|
||||
public static final int FEED_COUNTER_SHOW_NEW = 1;
|
||||
public static final int FEED_COUNTER_SHOW_UNPLAYED = 2;
|
||||
public static final int FEED_COUNTER_SHOW_NONE = 3;
|
||||
public static final int FEED_COUNTER_SHOW_DOWNLOADED = 4;
|
||||
|
||||
private static Context context;
|
||||
private static SharedPreferences prefs;
|
||||
|
@ -247,9 +243,9 @@ public class UserPreferences {
|
|||
.apply();
|
||||
}
|
||||
|
||||
public static int getFeedCounterSetting() {
|
||||
String value = prefs.getString(PREF_DRAWER_FEED_COUNTER, "" + FEED_COUNTER_SHOW_NEW);
|
||||
return Integer.parseInt(value);
|
||||
public static FeedCounter getFeedCounterSetting() {
|
||||
String value = prefs.getString(PREF_DRAWER_FEED_COUNTER, "" + FeedCounter.SHOW_NEW.id);
|
||||
return FeedCounter.fromOrdinal(Integer.parseInt(value));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -20,6 +20,7 @@ import androidx.core.app.ServiceCompat;
|
|||
import androidx.core.content.ContextCompat;
|
||||
import de.danoeh.antennapod.core.R;
|
||||
import de.danoeh.antennapod.core.feed.LocalFeedUpdater;
|
||||
import de.danoeh.antennapod.model.download.DownloadStatus;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
|
@ -50,7 +51,7 @@ import de.danoeh.antennapod.core.service.download.handler.PostDownloaderTask;
|
|||
import de.danoeh.antennapod.core.storage.DBReader;
|
||||
import de.danoeh.antennapod.core.storage.DBTasks;
|
||||
import de.danoeh.antennapod.core.storage.DBWriter;
|
||||
import de.danoeh.antennapod.core.util.DownloadError;
|
||||
import de.danoeh.antennapod.model.download.DownloadError;
|
||||
|
||||
/**
|
||||
* Manages the download of feedfiles in the app. Downloads can be enqueued via the startService intent.
|
||||
|
|
|
@ -10,6 +10,7 @@ import androidx.core.app.NotificationCompat;
|
|||
import de.danoeh.antennapod.core.ClientConfig;
|
||||
import de.danoeh.antennapod.core.R;
|
||||
import de.danoeh.antennapod.core.util.DownloadErrorLabel;
|
||||
import de.danoeh.antennapod.model.download.DownloadStatus;
|
||||
import de.danoeh.antennapod.model.feed.Feed;
|
||||
import de.danoeh.antennapod.model.feed.FeedMedia;
|
||||
import de.danoeh.antennapod.core.util.gui.NotificationUtils;
|
||||
|
|
|
@ -9,6 +9,7 @@ import java.util.concurrent.Callable;
|
|||
|
||||
import de.danoeh.antennapod.core.ClientConfig;
|
||||
import de.danoeh.antennapod.core.R;
|
||||
import de.danoeh.antennapod.model.download.DownloadStatus;
|
||||
|
||||
/**
|
||||
* Downloads files
|
||||
|
|
|
@ -5,6 +5,7 @@ import android.text.TextUtils;
|
|||
import android.util.Log;
|
||||
|
||||
import de.danoeh.antennapod.core.util.NetworkUtils;
|
||||
import de.danoeh.antennapod.model.download.DownloadStatus;
|
||||
import okhttp3.CacheControl;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
|
@ -24,7 +25,7 @@ import java.util.Date;
|
|||
import de.danoeh.antennapod.core.R;
|
||||
import de.danoeh.antennapod.model.feed.FeedMedia;
|
||||
import de.danoeh.antennapod.parser.feed.util.DateUtils;
|
||||
import de.danoeh.antennapod.core.util.DownloadError;
|
||||
import de.danoeh.antennapod.model.download.DownloadError;
|
||||
import de.danoeh.antennapod.core.util.StorageUtils;
|
||||
import de.danoeh.antennapod.core.util.URIUtil;
|
||||
import okhttp3.OkHttpClient;
|
||||
|
|
|
@ -17,12 +17,12 @@ import com.bumptech.glide.Glide;
|
|||
import com.bumptech.glide.request.RequestOptions;
|
||||
import de.danoeh.antennapod.core.R;
|
||||
import de.danoeh.antennapod.model.feed.Feed;
|
||||
import de.danoeh.antennapod.model.feed.FeedCounter;
|
||||
import de.danoeh.antennapod.model.feed.FeedPreferences;
|
||||
import de.danoeh.antennapod.core.glide.ApGlideSettings;
|
||||
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
||||
import de.danoeh.antennapod.core.storage.PodDBAdapter;
|
||||
import de.danoeh.antennapod.core.util.LongIntMap;
|
||||
import de.danoeh.antennapod.storage.database.LongIntMap;
|
||||
import de.danoeh.antennapod.core.util.gui.NotificationUtils;
|
||||
import de.danoeh.antennapod.storage.database.PodDBAdapter;
|
||||
|
||||
public class NewEpisodesNotification {
|
||||
private static final String TAG = "NewEpisodesNotification";
|
||||
|
@ -36,7 +36,7 @@ public class NewEpisodesNotification {
|
|||
public void loadCountersBeforeRefresh() {
|
||||
PodDBAdapter adapter = PodDBAdapter.getInstance();
|
||||
adapter.open();
|
||||
countersBefore = adapter.getFeedCounters(UserPreferences.FEED_COUNTER_SHOW_NEW);
|
||||
countersBefore = adapter.getFeedCounters(FeedCounter.SHOW_NEW);
|
||||
adapter.close();
|
||||
}
|
||||
|
||||
|
@ -130,7 +130,7 @@ public class NewEpisodesNotification {
|
|||
private static int getNewEpisodeCount(long feedId) {
|
||||
PodDBAdapter adapter = PodDBAdapter.getInstance();
|
||||
adapter.open();
|
||||
int episodeCount = adapter.getFeedCounters(UserPreferences.FEED_COUNTER_SHOW_NEW, feedId).get(feedId);
|
||||
int episodeCount = adapter.getFeedCounters(FeedCounter.SHOW_NEW, feedId).get(feedId);
|
||||
adapter.close();
|
||||
return episodeCount;
|
||||
}
|
||||
|
|
|
@ -7,11 +7,11 @@ import de.danoeh.antennapod.model.feed.FeedItem;
|
|||
import de.danoeh.antennapod.model.feed.FeedPreferences;
|
||||
import de.danoeh.antennapod.model.feed.VolumeAdaptionSetting;
|
||||
import de.danoeh.antennapod.core.service.download.DownloadRequest;
|
||||
import de.danoeh.antennapod.core.service.download.DownloadStatus;
|
||||
import de.danoeh.antennapod.model.download.DownloadStatus;
|
||||
import de.danoeh.antennapod.parser.feed.FeedHandler;
|
||||
import de.danoeh.antennapod.parser.feed.FeedHandlerResult;
|
||||
import de.danoeh.antennapod.parser.feed.UnsupportedFeedtypeException;
|
||||
import de.danoeh.antennapod.core.util.DownloadError;
|
||||
import de.danoeh.antennapod.model.download.DownloadError;
|
||||
import de.danoeh.antennapod.core.util.InvalidFeedException;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import android.content.Context;
|
|||
|
||||
import de.danoeh.antennapod.model.feed.Feed;
|
||||
import de.danoeh.antennapod.core.service.download.DownloadRequest;
|
||||
import de.danoeh.antennapod.core.service.download.DownloadStatus;
|
||||
import de.danoeh.antennapod.model.download.DownloadStatus;
|
||||
import de.danoeh.antennapod.core.storage.DBTasks;
|
||||
import de.danoeh.antennapod.parser.feed.FeedHandlerResult;
|
||||
|
||||
|
|
|
@ -13,12 +13,12 @@ import java.util.concurrent.ExecutionException;
|
|||
|
||||
import de.danoeh.antennapod.event.UnreadItemsUpdateEvent;
|
||||
import de.danoeh.antennapod.core.service.download.DownloadRequest;
|
||||
import de.danoeh.antennapod.core.service.download.DownloadStatus;
|
||||
import de.danoeh.antennapod.model.download.DownloadStatus;
|
||||
import de.danoeh.antennapod.core.storage.DBReader;
|
||||
import de.danoeh.antennapod.core.storage.DBWriter;
|
||||
import de.danoeh.antennapod.core.sync.queue.SynchronizationQueueSink;
|
||||
import de.danoeh.antennapod.core.util.ChapterUtils;
|
||||
import de.danoeh.antennapod.core.util.DownloadError;
|
||||
import de.danoeh.antennapod.model.download.DownloadError;
|
||||
import de.danoeh.antennapod.model.feed.FeedItem;
|
||||
import de.danoeh.antennapod.model.feed.FeedMedia;
|
||||
import de.danoeh.antennapod.net.sync.model.EpisodeAction;
|
||||
|
|
|
@ -15,7 +15,6 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import de.danoeh.antennapod.core.storage.mapper.DownloadStatusCursorMapper;
|
||||
import de.danoeh.antennapod.model.feed.Chapter;
|
||||
import de.danoeh.antennapod.model.feed.Feed;
|
||||
import de.danoeh.antennapod.model.feed.FeedItem;
|
||||
|
@ -24,13 +23,15 @@ import de.danoeh.antennapod.model.feed.FeedMedia;
|
|||
import de.danoeh.antennapod.model.feed.FeedPreferences;
|
||||
import de.danoeh.antennapod.core.feed.SubscriptionsFilter;
|
||||
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
||||
import de.danoeh.antennapod.core.service.download.DownloadStatus;
|
||||
import de.danoeh.antennapod.core.storage.mapper.ChapterCursorMapper;
|
||||
import de.danoeh.antennapod.core.storage.mapper.FeedCursorMapper;
|
||||
import de.danoeh.antennapod.core.storage.mapper.FeedItemCursorMapper;
|
||||
import de.danoeh.antennapod.core.storage.mapper.FeedMediaCursorMapper;
|
||||
import de.danoeh.antennapod.core.storage.mapper.FeedPreferencesCursorMapper;
|
||||
import de.danoeh.antennapod.core.util.LongIntMap;
|
||||
import de.danoeh.antennapod.model.download.DownloadStatus;
|
||||
import de.danoeh.antennapod.storage.database.PodDBAdapter;
|
||||
import de.danoeh.antennapod.storage.database.mapper.DownloadStatusCursorMapper;
|
||||
import de.danoeh.antennapod.storage.database.mapper.ChapterCursorMapper;
|
||||
import de.danoeh.antennapod.storage.database.mapper.FeedCursorMapper;
|
||||
import de.danoeh.antennapod.storage.database.mapper.FeedItemCursorMapper;
|
||||
import de.danoeh.antennapod.storage.database.mapper.FeedMediaCursorMapper;
|
||||
import de.danoeh.antennapod.storage.database.mapper.FeedPreferencesCursorMapper;
|
||||
import de.danoeh.antennapod.storage.database.LongIntMap;
|
||||
import de.danoeh.antennapod.core.util.LongList;
|
||||
import de.danoeh.antennapod.core.util.comparator.DownloadStatusComparator;
|
||||
import de.danoeh.antennapod.core.util.comparator.FeedItemPubdateComparator;
|
||||
|
@ -877,7 +878,7 @@ public final class DBReader {
|
|||
PodDBAdapter adapter = PodDBAdapter.getInstance();
|
||||
adapter.open();
|
||||
|
||||
final LongIntMap feedCounters = adapter.getFeedCounters();
|
||||
final LongIntMap feedCounters = adapter.getFeedCounters(UserPreferences.getFeedCounterSetting());
|
||||
SubscriptionsFilter subscriptionsFilter = UserPreferences.getSubscriptionsFilter();
|
||||
List<Feed> feeds = subscriptionsFilter.filter(getFeedList(adapter), feedCounters);
|
||||
|
||||
|
|
|
@ -13,6 +13,8 @@ import androidx.annotation.VisibleForTesting;
|
|||
import de.danoeh.antennapod.core.service.download.DownloadRequest;
|
||||
import de.danoeh.antennapod.core.service.download.DownloadRequestCreator;
|
||||
import de.danoeh.antennapod.core.service.download.DownloadService;
|
||||
import de.danoeh.antennapod.storage.database.PodDBAdapter;
|
||||
import de.danoeh.antennapod.storage.database.mapper.FeedCursorMapper;
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -32,11 +34,10 @@ import de.danoeh.antennapod.event.FeedItemEvent;
|
|||
import de.danoeh.antennapod.event.FeedListUpdateEvent;
|
||||
import de.danoeh.antennapod.event.MessageEvent;
|
||||
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
||||
import de.danoeh.antennapod.core.service.download.DownloadStatus;
|
||||
import de.danoeh.antennapod.core.storage.mapper.FeedCursorMapper;
|
||||
import de.danoeh.antennapod.model.download.DownloadStatus;
|
||||
import de.danoeh.antennapod.core.sync.SyncService;
|
||||
import de.danoeh.antennapod.core.sync.queue.SynchronizationQueueSink;
|
||||
import de.danoeh.antennapod.core.util.DownloadError;
|
||||
import de.danoeh.antennapod.model.download.DownloadError;
|
||||
import de.danoeh.antennapod.core.util.LongList;
|
||||
import de.danoeh.antennapod.core.util.comparator.FeedItemPubdateComparator;
|
||||
import de.danoeh.antennapod.model.feed.Feed;
|
||||
|
|
|
@ -9,6 +9,7 @@ import androidx.annotation.Nullable;
|
|||
import androidx.core.app.NotificationManagerCompat;
|
||||
|
||||
import de.danoeh.antennapod.core.service.download.DownloadService;
|
||||
import de.danoeh.antennapod.storage.database.PodDBAdapter;
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -34,7 +35,7 @@ import de.danoeh.antennapod.event.UnreadItemsUpdateEvent;
|
|||
import de.danoeh.antennapod.core.feed.FeedEvent;
|
||||
import de.danoeh.antennapod.core.preferences.PlaybackPreferences;
|
||||
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
||||
import de.danoeh.antennapod.core.service.download.DownloadStatus;
|
||||
import de.danoeh.antennapod.model.download.DownloadStatus;
|
||||
import de.danoeh.antennapod.core.service.playback.PlaybackService;
|
||||
import de.danoeh.antennapod.core.sync.queue.SynchronizationQueueSink;
|
||||
import de.danoeh.antennapod.core.util.FeedItemPermutors;
|
||||
|
|
|
@ -8,6 +8,7 @@ import android.os.ParcelFileDescriptor;
|
|||
import android.text.format.Formatter;
|
||||
import android.util.Log;
|
||||
import de.danoeh.antennapod.core.R;
|
||||
import de.danoeh.antennapod.storage.database.PodDBAdapter;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package de.danoeh.antennapod.core.storage;
|
||||
|
||||
import de.danoeh.antennapod.model.feed.Feed;
|
||||
import de.danoeh.antennapod.core.util.LongIntMap;
|
||||
import de.danoeh.antennapod.storage.database.LongIntMap;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
|
|
@ -1,51 +0,0 @@
|
|||
package de.danoeh.antennapod.core.storage.mapper;
|
||||
|
||||
import android.database.Cursor;
|
||||
import androidx.annotation.NonNull;
|
||||
import de.danoeh.antennapod.model.feed.Chapter;
|
||||
import de.danoeh.antennapod.parser.feed.element.SimpleChapter;
|
||||
import de.danoeh.antennapod.core.storage.PodDBAdapter;
|
||||
import de.danoeh.antennapod.parser.media.id3.ID3Chapter;
|
||||
import de.danoeh.antennapod.parser.media.vorbis.VorbisCommentChapter;
|
||||
|
||||
/**
|
||||
* Converts a {@link Cursor} to a {@link Chapter} object.
|
||||
*/
|
||||
public abstract class ChapterCursorMapper {
|
||||
/**
|
||||
* Create a {@link Chapter} instance from a database row (cursor).
|
||||
*/
|
||||
@NonNull
|
||||
public static Chapter convert(@NonNull Cursor cursor) {
|
||||
int indexId = cursor.getColumnIndex(PodDBAdapter.KEY_ID);
|
||||
int indexTitle = cursor.getColumnIndex(PodDBAdapter.KEY_TITLE);
|
||||
int indexStart = cursor.getColumnIndex(PodDBAdapter.KEY_START);
|
||||
int indexLink = cursor.getColumnIndex(PodDBAdapter.KEY_LINK);
|
||||
int indexImage = cursor.getColumnIndex(PodDBAdapter.KEY_IMAGE_URL);
|
||||
int indexChapterType = cursor.getColumnIndex(PodDBAdapter.KEY_CHAPTER_TYPE);
|
||||
|
||||
long id = cursor.getLong(indexId);
|
||||
String title = cursor.getString(indexTitle);
|
||||
long start = cursor.getLong(indexStart);
|
||||
String link = cursor.getString(indexLink);
|
||||
String imageUrl = cursor.getString(indexImage);
|
||||
int chapterType = cursor.getInt(indexChapterType);
|
||||
|
||||
Chapter chapter;
|
||||
switch (chapterType) {
|
||||
case SimpleChapter.CHAPTERTYPE_SIMPLECHAPTER:
|
||||
chapter = new SimpleChapter(start, title, link, imageUrl);
|
||||
break;
|
||||
case ID3Chapter.CHAPTERTYPE_ID3CHAPTER:
|
||||
chapter = new ID3Chapter(start, title, link, imageUrl);
|
||||
break;
|
||||
case VorbisCommentChapter.CHAPTERTYPE_VORBISCOMMENT_CHAPTER:
|
||||
chapter = new VorbisCommentChapter(start, title, link, imageUrl);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unknown chapter type");
|
||||
}
|
||||
chapter.setId(id);
|
||||
return chapter;
|
||||
}
|
||||
}
|
|
@ -3,6 +3,7 @@ package de.danoeh.antennapod.core.util;
|
|||
import androidx.annotation.StringRes;
|
||||
import de.danoeh.antennapod.core.BuildConfig;
|
||||
import de.danoeh.antennapod.core.R;
|
||||
import de.danoeh.antennapod.model.download.DownloadError;
|
||||
|
||||
/**
|
||||
* Provides user-visible labels for download errors.
|
||||
|
|
|
@ -2,7 +2,7 @@ package de.danoeh.antennapod.core.util.comparator;
|
|||
|
||||
import java.util.Comparator;
|
||||
|
||||
import de.danoeh.antennapod.core.service.download.DownloadStatus;
|
||||
import de.danoeh.antennapod.model.download.DownloadStatus;
|
||||
|
||||
/** Compares the completion date of two Downloadstatus objects. */
|
||||
public class DownloadStatusComparator implements Comparator<DownloadStatus> {
|
||||
|
|
|
@ -14,6 +14,7 @@ import androidx.test.platform.app.InstrumentationRegistry;
|
|||
import de.danoeh.antennapod.core.preferences.PlaybackPreferences;
|
||||
import de.danoeh.antennapod.model.feed.Feed;
|
||||
import de.danoeh.antennapod.model.feed.FeedItem;
|
||||
import de.danoeh.antennapod.storage.database.PodDBAdapter;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
@ -34,7 +35,6 @@ import de.danoeh.antennapod.core.ClientConfig;
|
|||
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
||||
import de.danoeh.antennapod.core.storage.DBReader;
|
||||
import de.danoeh.antennapod.core.storage.DBWriter;
|
||||
import de.danoeh.antennapod.core.storage.PodDBAdapter;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.endsWith;
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
|
|
|
@ -21,6 +21,7 @@ import de.danoeh.antennapod.model.feed.FeedMedia;
|
|||
import de.danoeh.antennapod.core.preferences.PlaybackPreferences;
|
||||
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
||||
|
||||
import de.danoeh.antennapod.storage.database.PodDBAdapter;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
|
|
@ -15,6 +15,7 @@ import de.danoeh.antennapod.model.feed.Feed;
|
|||
import de.danoeh.antennapod.model.feed.FeedItem;
|
||||
import de.danoeh.antennapod.model.feed.FeedMedia;
|
||||
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
||||
import de.danoeh.antennapod.storage.database.PodDBAdapter;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
|
|
@ -13,6 +13,7 @@ import de.danoeh.antennapod.model.feed.FeedItem;
|
|||
import de.danoeh.antennapod.model.feed.FeedMedia;
|
||||
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
||||
import de.danoeh.antennapod.core.util.LongList;
|
||||
import de.danoeh.antennapod.storage.database.PodDBAdapter;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
|
|
@ -5,6 +5,7 @@ import android.content.Context;
|
|||
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
|
||||
import de.danoeh.antennapod.storage.database.PodDBAdapter;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
|
|
@ -9,8 +9,8 @@ import de.danoeh.antennapod.model.feed.Chapter;
|
|||
import de.danoeh.antennapod.model.feed.Feed;
|
||||
import de.danoeh.antennapod.model.feed.FeedItem;
|
||||
import de.danoeh.antennapod.model.feed.FeedMedia;
|
||||
import de.danoeh.antennapod.parser.feed.element.SimpleChapter;
|
||||
import de.danoeh.antennapod.core.util.comparator.FeedItemPubdateComparator;
|
||||
import de.danoeh.antennapod.storage.database.PodDBAdapter;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
|
@ -56,7 +56,7 @@ abstract class DbTestUtils {
|
|||
List<Chapter> chapters = new ArrayList<>();
|
||||
item.setChapters(chapters);
|
||||
for (int k = 0; k < numChapters; k++) {
|
||||
chapters.add(new SimpleChapter(k, "item " + j + " chapter " + k,
|
||||
chapters.add(new Chapter(k, "item " + j + " chapter " + k,
|
||||
"http://example.com", "http://example.com/image.png"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import androidx.core.util.Consumer;
|
|||
import androidx.preference.PreferenceManager;
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
|
||||
import de.danoeh.antennapod.storage.database.PodDBAdapter;
|
||||
import org.awaitility.Awaitility;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
|
|
|
@ -6,6 +6,8 @@ import android.database.Cursor;
|
|||
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
|
||||
import de.danoeh.antennapod.storage.database.PodDBAdapter;
|
||||
import de.danoeh.antennapod.storage.database.mapper.FeedCursorMapper;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
@ -13,7 +15,6 @@ import org.junit.runner.RunWith;
|
|||
import org.robolectric.RobolectricTestRunner;
|
||||
|
||||
import de.danoeh.antennapod.model.feed.Feed;
|
||||
import de.danoeh.antennapod.core.storage.PodDBAdapter;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package de.danoeh.antennapod.core.util;
|
||||
|
||||
import de.danoeh.antennapod.storage.database.LongIntMap;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package de.danoeh.antennapod.core.util;
|
||||
package de.danoeh.antennapod.model.download;
|
||||
|
||||
/** Utility class for Download Errors. */
|
||||
public enum DownloadError {
|
|
@ -1,11 +1,10 @@
|
|||
package de.danoeh.antennapod.core.service.download;
|
||||
package de.danoeh.antennapod.model.download;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import de.danoeh.antennapod.model.feed.FeedFile;
|
||||
import de.danoeh.antennapod.core.util.DownloadError;
|
||||
|
||||
/**
|
||||
* Contains status attributes for one download
|
|
@ -1,31 +1,23 @@
|
|||
package de.danoeh.antennapod.model.feed;
|
||||
|
||||
public abstract class Chapter extends FeedComponent {
|
||||
|
||||
public class Chapter extends FeedComponent {
|
||||
/** Defines starting point in milliseconds. */
|
||||
private long start;
|
||||
private String title;
|
||||
private String link;
|
||||
private String imageUrl;
|
||||
private String chapterId;
|
||||
|
||||
protected Chapter() {
|
||||
public Chapter() {
|
||||
}
|
||||
|
||||
protected Chapter(long start) {
|
||||
super();
|
||||
this.start = start;
|
||||
}
|
||||
|
||||
protected Chapter(long start, String title, String link, String imageUrl) {
|
||||
super();
|
||||
public Chapter(long start, String title, String link, String imageUrl) {
|
||||
this.start = start;
|
||||
this.title = title;
|
||||
this.link = link;
|
||||
this.imageUrl = imageUrl;
|
||||
}
|
||||
|
||||
public abstract int getChapterType();
|
||||
|
||||
public long getStart() {
|
||||
return start;
|
||||
}
|
||||
|
@ -58,8 +50,24 @@ public abstract class Chapter extends FeedComponent {
|
|||
this.imageUrl = imageUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* ID from the chapter source, not the database ID.
|
||||
*/
|
||||
public String getChapterId() {
|
||||
return chapterId;
|
||||
}
|
||||
|
||||
public void setChapterId(String chapterId) {
|
||||
this.chapterId = chapterId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHumanReadableIdentifier() {
|
||||
return title;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ID3Chapter [title=" + getTitle() + ", start=" + getStart() + ", url=" + getLink() + "]";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
package de.danoeh.antennapod.model.feed;
|
||||
|
||||
public enum FeedCounter {
|
||||
SHOW_NEW_UNPLAYED_SUM(0),
|
||||
SHOW_NEW(1),
|
||||
SHOW_UNPLAYED(2),
|
||||
SHOW_NONE(3),
|
||||
SHOW_DOWNLOADED(4);
|
||||
|
||||
public final int id;
|
||||
|
||||
FeedCounter(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public static FeedCounter fromOrdinal(int id) {
|
||||
for (FeedCounter counter : values()) {
|
||||
if (counter.id == id) {
|
||||
return counter;
|
||||
}
|
||||
}
|
||||
return SHOW_NONE;
|
||||
}
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
package de.danoeh.antennapod.parser.feed.element;
|
||||
|
||||
import de.danoeh.antennapod.model.feed.Chapter;
|
||||
|
||||
public class SimpleChapter extends Chapter {
|
||||
public static final int CHAPTERTYPE_SIMPLECHAPTER = 0;
|
||||
|
||||
public SimpleChapter(long start, String title, String link, String imageUrl) {
|
||||
super(start, title, link, imageUrl);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getChapterType() {
|
||||
return CHAPTERTYPE_SIMPLECHAPTER;
|
||||
}
|
||||
}
|
|
@ -2,8 +2,8 @@ package de.danoeh.antennapod.parser.feed.namespace;
|
|||
|
||||
import android.util.Log;
|
||||
|
||||
import de.danoeh.antennapod.model.feed.Chapter;
|
||||
import de.danoeh.antennapod.parser.feed.HandlerState;
|
||||
import de.danoeh.antennapod.parser.feed.element.SimpleChapter;
|
||||
import de.danoeh.antennapod.parser.feed.element.SyndElement;
|
||||
import de.danoeh.antennapod.parser.feed.util.DateUtils;
|
||||
import org.xml.sax.Attributes;
|
||||
|
@ -37,7 +37,7 @@ public class SimpleChapters extends Namespace {
|
|||
String title = attributes.getValue(TITLE);
|
||||
String link = attributes.getValue(HREF);
|
||||
String imageUrl = attributes.getValue(IMAGE);
|
||||
SimpleChapter chapter = new SimpleChapter(start, title, link, imageUrl);
|
||||
Chapter chapter = new Chapter(start, title, link, imageUrl);
|
||||
currentItem.getChapters().add(chapter);
|
||||
} catch (NumberFormatException e) {
|
||||
Log.e(TAG, "Unable to read chapter", e);
|
||||
|
|
|
@ -50,7 +50,10 @@ public class ChapterReader extends ID3Reader {
|
|||
String elementId = readIsoStringNullTerminated(100);
|
||||
long startTime = readInt();
|
||||
skipBytes(12); // Ignore end time, start offset, end offset
|
||||
ID3Chapter chapter = new ID3Chapter(elementId, startTime);
|
||||
|
||||
Chapter chapter = new Chapter();
|
||||
chapter.setStart(startTime);
|
||||
chapter.setChapterId(elementId);
|
||||
|
||||
// Read sub-frames
|
||||
while (getPosition() < chapterStartedPosition + frameHeader.getSize()) {
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
package de.danoeh.antennapod.parser.media.id3;
|
||||
|
||||
import de.danoeh.antennapod.model.feed.Chapter;
|
||||
|
||||
public class ID3Chapter extends Chapter {
|
||||
public static final int CHAPTERTYPE_ID3CHAPTER = 2;
|
||||
|
||||
/**
|
||||
* Identifies the chapter in its ID3 tag. This attribute does not have to be
|
||||
* store in the DB and is only used for parsing.
|
||||
*/
|
||||
private String id3ID;
|
||||
|
||||
public ID3Chapter(String id3ID, long start) {
|
||||
super(start);
|
||||
this.id3ID = id3ID;
|
||||
}
|
||||
|
||||
public ID3Chapter(long start, String title, String link, String imageUrl) {
|
||||
super(start, title, link, imageUrl);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ID3Chapter [id3ID=" + id3ID + ", title=" + getTitle() + ", start="
|
||||
+ getStart() + ", url=" + getLink() + "]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getChapterType() {
|
||||
return CHAPTERTYPE_ID3CHAPTER;
|
||||
}
|
||||
}
|
|
@ -1,88 +0,0 @@
|
|||
package de.danoeh.antennapod.parser.media.vorbis;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import de.danoeh.antennapod.model.feed.Chapter;
|
||||
|
||||
public class VorbisCommentChapter extends Chapter {
|
||||
public static final int CHAPTERTYPE_VORBISCOMMENT_CHAPTER = 3;
|
||||
|
||||
private static final int CHAPTERXXX_LENGTH = "chapterxxx".length();
|
||||
|
||||
private int vorbisCommentId;
|
||||
|
||||
public VorbisCommentChapter(int vorbisCommentId) {
|
||||
this.vorbisCommentId = vorbisCommentId;
|
||||
}
|
||||
|
||||
public VorbisCommentChapter(long start, String title, String link, String imageUrl) {
|
||||
super(start, title, link, imageUrl);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "VorbisCommentChapter [id=" + getId() + ", title=" + getTitle()
|
||||
+ ", link=" + getLink() + ", start=" + getStart() + "]";
|
||||
}
|
||||
|
||||
public static long getStartTimeFromValue(String value)
|
||||
throws VorbisCommentReaderException {
|
||||
String[] parts = value.split(":");
|
||||
if (parts.length >= 3) {
|
||||
try {
|
||||
long hours = TimeUnit.MILLISECONDS.convert(
|
||||
Long.parseLong(parts[0]), TimeUnit.HOURS);
|
||||
long minutes = TimeUnit.MILLISECONDS.convert(
|
||||
Long.parseLong(parts[1]), TimeUnit.MINUTES);
|
||||
if (parts[2].contains("-->")) {
|
||||
parts[2] = parts[2].substring(0, parts[2].indexOf("-->"));
|
||||
}
|
||||
long seconds = TimeUnit.MILLISECONDS.convert(
|
||||
((long) Float.parseFloat(parts[2])), TimeUnit.SECONDS);
|
||||
return hours + minutes + seconds;
|
||||
} catch (NumberFormatException e) {
|
||||
throw new VorbisCommentReaderException(e);
|
||||
}
|
||||
} else {
|
||||
throw new VorbisCommentReaderException("Invalid time string");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the id of a vorbiscomment chapter from a string like CHAPTERxxx*
|
||||
*
|
||||
* @return the id of the chapter key or -1 if the id couldn't be read.
|
||||
* @throws VorbisCommentReaderException
|
||||
* */
|
||||
public static int getIDFromKey(String key) throws VorbisCommentReaderException {
|
||||
if (key.length() >= CHAPTERXXX_LENGTH) { // >= CHAPTERxxx
|
||||
try {
|
||||
String strId = key.substring(8, 10);
|
||||
return Integer.parseInt(strId);
|
||||
} catch (NumberFormatException e) {
|
||||
throw new VorbisCommentReaderException(e);
|
||||
}
|
||||
}
|
||||
throw new VorbisCommentReaderException("key is too short (" + key + ")");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the string that comes after 'CHAPTERxxx', for example 'name' or
|
||||
* 'url'.
|
||||
*/
|
||||
public static String getAttributeTypeFromKey(String key) {
|
||||
if (key.length() > CHAPTERXXX_LENGTH) {
|
||||
return key.substring(CHAPTERXXX_LENGTH);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getChapterType() {
|
||||
return CHAPTERTYPE_VORBISCOMMENT_CHAPTER;
|
||||
}
|
||||
|
||||
public int getVorbisCommentId() {
|
||||
return vorbisCommentId;
|
||||
}
|
||||
}
|
|
@ -4,6 +4,7 @@ import android.util.Log;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import de.danoeh.antennapod.model.feed.Chapter;
|
||||
import de.danoeh.antennapod.parser.media.BuildConfig;
|
||||
|
@ -14,6 +15,7 @@ public class VorbisCommentChapterReader extends VorbisCommentReader {
|
|||
private static final String CHAPTER_KEY = "chapter\\d\\d\\d.*";
|
||||
private static final String CHAPTER_ATTRIBUTE_TITLE = "name";
|
||||
private static final String CHAPTER_ATTRIBUTE_LINK = "url";
|
||||
private static final int CHAPTERXXX_LENGTH = "chapterxxx".length();
|
||||
|
||||
private List<Chapter> chapters;
|
||||
|
||||
|
@ -41,14 +43,15 @@ public class VorbisCommentChapterReader extends VorbisCommentReader {
|
|||
if (BuildConfig.DEBUG) {
|
||||
Log.d(TAG, "Key: " + key + ", value: " + value);
|
||||
}
|
||||
String attribute = VorbisCommentChapter.getAttributeTypeFromKey(key);
|
||||
int id = VorbisCommentChapter.getIDFromKey(key);
|
||||
String attribute = getAttributeTypeFromKey(key);
|
||||
int id = getIdFromKey(key);
|
||||
Chapter chapter = getChapterById(id);
|
||||
if (attribute == null) {
|
||||
if (getChapterById(id) == null) {
|
||||
// new chapter
|
||||
long start = VorbisCommentChapter.getStartTimeFromValue(value);
|
||||
chapter = new VorbisCommentChapter(id);
|
||||
long start = getStartTimeFromValue(value);
|
||||
chapter = new Chapter();
|
||||
chapter.setChapterId("" + id);
|
||||
chapter.setStart(start);
|
||||
chapters.add(chapter);
|
||||
} else {
|
||||
|
@ -80,13 +83,65 @@ public class VorbisCommentChapterReader extends VorbisCommentReader {
|
|||
|
||||
private Chapter getChapterById(long id) {
|
||||
for (Chapter c : chapters) {
|
||||
if (((VorbisCommentChapter) c).getVorbisCommentId() == id) {
|
||||
if (("" + id).equals(c.getChapterId())) {
|
||||
return c;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static long getStartTimeFromValue(String value)
|
||||
throws VorbisCommentReaderException {
|
||||
String[] parts = value.split(":");
|
||||
if (parts.length >= 3) {
|
||||
try {
|
||||
long hours = TimeUnit.MILLISECONDS.convert(
|
||||
Long.parseLong(parts[0]), TimeUnit.HOURS);
|
||||
long minutes = TimeUnit.MILLISECONDS.convert(
|
||||
Long.parseLong(parts[1]), TimeUnit.MINUTES);
|
||||
if (parts[2].contains("-->")) {
|
||||
parts[2] = parts[2].substring(0, parts[2].indexOf("-->"));
|
||||
}
|
||||
long seconds = TimeUnit.MILLISECONDS.convert(
|
||||
((long) Float.parseFloat(parts[2])), TimeUnit.SECONDS);
|
||||
return hours + minutes + seconds;
|
||||
} catch (NumberFormatException e) {
|
||||
throw new VorbisCommentReaderException(e);
|
||||
}
|
||||
} else {
|
||||
throw new VorbisCommentReaderException("Invalid time string");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the id of a vorbiscomment chapter from a string like CHAPTERxxx*
|
||||
*
|
||||
* @return the id of the chapter key or -1 if the id couldn't be read.
|
||||
* @throws VorbisCommentReaderException
|
||||
* */
|
||||
private static int getIdFromKey(String key) throws VorbisCommentReaderException {
|
||||
if (key.length() >= CHAPTERXXX_LENGTH) { // >= CHAPTERxxx
|
||||
try {
|
||||
String strId = key.substring(8, 10);
|
||||
return Integer.parseInt(strId);
|
||||
} catch (NumberFormatException e) {
|
||||
throw new VorbisCommentReaderException(e);
|
||||
}
|
||||
}
|
||||
throw new VorbisCommentReaderException("key is too short (" + key + ")");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the string that comes after 'CHAPTERxxx', for example 'name' or
|
||||
* 'url'.
|
||||
*/
|
||||
private static String getAttributeTypeFromKey(String key) {
|
||||
if (key.length() > CHAPTERXXX_LENGTH) {
|
||||
return key.substring(CHAPTERXXX_LENGTH);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<Chapter> getChapters() {
|
||||
return chapters;
|
||||
}
|
||||
|
|
|
@ -96,7 +96,7 @@ public class ChapterReaderTest {
|
|||
FrameHeader header = new FrameHeader(ChapterReader.FRAME_ID_TITLE, titleSubframeContent.length, (short) 0);
|
||||
CountingInputStream inputStream = new CountingInputStream(new ByteArrayInputStream(titleSubframeContent));
|
||||
ChapterReader reader = new ChapterReader(inputStream);
|
||||
Chapter chapter = new ID3Chapter("", 0);
|
||||
Chapter chapter = new Chapter();
|
||||
reader.readChapterSubFrame(header, chapter);
|
||||
assertEquals("A", chapter.getTitle());
|
||||
|
||||
|
|
|
@ -13,6 +13,8 @@ include ':parser:media'
|
|||
include ':playback:base'
|
||||
include ':playback:cast'
|
||||
|
||||
include ':storage:database'
|
||||
|
||||
include ':ui:app-start-intent'
|
||||
include ':ui:common'
|
||||
include ':ui:i18n'
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
# :storage
|
||||
|
||||
Data storage for podcast data (subscriptions, playback state) and settings (but not settings UI).
|
|
@ -0,0 +1,3 @@
|
|||
# :storage:database
|
||||
|
||||
AntennaPod's main database, containing subscriptions and playback state (but not user settings).
|
|
@ -0,0 +1,17 @@
|
|||
plugins {
|
||||
id("com.android.library")
|
||||
}
|
||||
apply from: "../../common.gradle"
|
||||
|
||||
android {
|
||||
lintOptions {
|
||||
disable "StaticFieldLeak"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation project(':model')
|
||||
|
||||
annotationProcessor "androidx.annotation:annotation:$annotationVersion"
|
||||
implementation "commons-io:commons-io:$commonsioVersion"
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
<manifest package="de.danoeh.antennapod.storage.database" />
|
|
@ -1,4 +1,4 @@
|
|||
package de.danoeh.antennapod.core.storage;
|
||||
package de.danoeh.antennapod.storage.database;
|
||||
|
||||
import android.content.ContentValues;
|
||||
import android.database.Cursor;
|
||||
|
@ -39,7 +39,7 @@ class DBUpgrader {
|
|||
}
|
||||
if (oldVersion <= 6) {
|
||||
db.execSQL("ALTER TABLE " + PodDBAdapter.TABLE_NAME_SIMPLECHAPTERS
|
||||
+ " ADD COLUMN " + PodDBAdapter.KEY_CHAPTER_TYPE + " INTEGER");
|
||||
+ " ADD COLUMN type INTEGER");
|
||||
}
|
||||
if (oldVersion <= 7) {
|
||||
db.execSQL("ALTER TABLE " + PodDBAdapter.TABLE_NAME_FEED_MEDIA
|
||||
|
@ -117,7 +117,7 @@ class DBUpgrader {
|
|||
PodDBAdapter.KEY_START,
|
||||
PodDBAdapter.KEY_FEEDITEM,
|
||||
PodDBAdapter.KEY_LINK,
|
||||
PodDBAdapter.KEY_CHAPTER_TYPE));
|
||||
"type"));
|
||||
}
|
||||
if (oldVersion <= 14) {
|
||||
db.execSQL("ALTER TABLE " + PodDBAdapter.TABLE_NAME_FEED_ITEMS
|
|
@ -1,4 +1,4 @@
|
|||
package de.danoeh.antennapod.core.util;
|
||||
package de.danoeh.antennapod.storage.database;
|
||||
|
||||
|
||||
import java.util.Arrays;
|
|
@ -1,4 +1,4 @@
|
|||
package de.danoeh.antennapod.core.storage;
|
||||
package de.danoeh.antennapod.storage.database;
|
||||
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
|
@ -17,9 +17,8 @@ import androidx.annotation.NonNull;
|
|||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import de.danoeh.antennapod.model.feed.FeedCounter;
|
||||
import de.danoeh.antennapod.model.feed.FeedFunding;
|
||||
import de.danoeh.antennapod.core.storage.mapper.FeedItemFilterQuery;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
@ -36,10 +35,10 @@ import de.danoeh.antennapod.model.feed.FeedItem;
|
|||
import de.danoeh.antennapod.model.feed.FeedItemFilter;
|
||||
import de.danoeh.antennapod.model.feed.FeedMedia;
|
||||
import de.danoeh.antennapod.model.feed.FeedPreferences;
|
||||
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
||||
import de.danoeh.antennapod.core.service.download.DownloadStatus;
|
||||
import de.danoeh.antennapod.core.util.LongIntMap;
|
||||
import de.danoeh.antennapod.model.download.DownloadStatus;
|
||||
import de.danoeh.antennapod.model.feed.SortOrder;
|
||||
import de.danoeh.antennapod.storage.database.mapper.FeedItemFilterQuery;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import static de.danoeh.antennapod.model.feed.FeedPreferences.SPEED_USE_GLOBAL;
|
||||
import static de.danoeh.antennapod.model.feed.SortOrder.toCodeString;
|
||||
|
@ -93,7 +92,6 @@ public class PodDBAdapter {
|
|||
public static final String KEY_FEED_IDENTIFIER = "feed_identifier";
|
||||
public static final String KEY_REASON_DETAILED = "reason_detailed";
|
||||
public static final String KEY_DOWNLOADSTATUS_TITLE = "title";
|
||||
public static final String KEY_CHAPTER_TYPE = "type";
|
||||
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
|
||||
|
@ -195,7 +193,7 @@ public class PodDBAdapter {
|
|||
private static final String CREATE_TABLE_SIMPLECHAPTERS = "CREATE TABLE "
|
||||
+ TABLE_NAME_SIMPLECHAPTERS + " (" + TABLE_PRIMARY_KEY + KEY_TITLE
|
||||
+ " TEXT," + KEY_START + " INTEGER," + KEY_FEEDITEM + " INTEGER,"
|
||||
+ KEY_LINK + " TEXT," + KEY_IMAGE_URL + " TEXT," + KEY_CHAPTER_TYPE + " INTEGER)";
|
||||
+ KEY_LINK + " TEXT," + KEY_IMAGE_URL + " TEXT)";
|
||||
|
||||
// SQL Statements for creating indexes
|
||||
static final String CREATE_INDEX_FEEDITEMS_FEED = "CREATE INDEX "
|
||||
|
@ -720,7 +718,6 @@ public class PodDBAdapter {
|
|||
values.put(KEY_FEEDITEM, item.getId());
|
||||
values.put(KEY_LINK, chapter.getLink());
|
||||
values.put(KEY_IMAGE_URL, chapter.getImageUrl());
|
||||
values.put(KEY_CHAPTER_TYPE, chapter.getChapterType());
|
||||
if (chapter.getId() == 0) {
|
||||
chapter.setId(db.insert(TABLE_NAME_SIMPLECHAPTERS, null, values));
|
||||
} else {
|
||||
|
@ -737,7 +734,7 @@ public class PodDBAdapter {
|
|||
db.execSQL(sql);
|
||||
}
|
||||
|
||||
void setFeedCustomTitle(long feedId, String customTitle) {
|
||||
public void setFeedCustomTitle(long feedId, String customTitle) {
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(KEY_CUSTOM_TITLE, customTitle);
|
||||
db.update(TABLE_NAME_FEEDS, values, KEY_ID + "=?", new String[]{String.valueOf(feedId)});
|
||||
|
@ -1174,29 +1171,23 @@ public class PodDBAdapter {
|
|||
return result;
|
||||
}
|
||||
|
||||
public final LongIntMap getFeedCounters(long... feedIds) {
|
||||
int setting = UserPreferences.getFeedCounterSetting();
|
||||
|
||||
return getFeedCounters(setting, feedIds);
|
||||
}
|
||||
|
||||
public final LongIntMap getFeedCounters(int setting, long... feedIds) {
|
||||
public final LongIntMap getFeedCounters(FeedCounter setting, long... feedIds) {
|
||||
String whereRead;
|
||||
switch (setting) {
|
||||
case UserPreferences.FEED_COUNTER_SHOW_NEW_UNPLAYED_SUM:
|
||||
case SHOW_NEW_UNPLAYED_SUM:
|
||||
whereRead = "(" + KEY_READ + "=" + FeedItem.NEW +
|
||||
" OR " + KEY_READ + "=" + FeedItem.UNPLAYED + ")";
|
||||
break;
|
||||
case UserPreferences.FEED_COUNTER_SHOW_NEW:
|
||||
case SHOW_NEW:
|
||||
whereRead = KEY_READ + "=" + FeedItem.NEW;
|
||||
break;
|
||||
case UserPreferences.FEED_COUNTER_SHOW_UNPLAYED:
|
||||
case SHOW_UNPLAYED:
|
||||
whereRead = KEY_READ + "=" + FeedItem.UNPLAYED;
|
||||
break;
|
||||
case UserPreferences.FEED_COUNTER_SHOW_DOWNLOADED:
|
||||
case SHOW_DOWNLOADED:
|
||||
whereRead = KEY_DOWNLOADED + "=1";
|
||||
break;
|
||||
case UserPreferences.FEED_COUNTER_SHOW_NONE:
|
||||
case SHOW_NONE:
|
||||
// deliberate fall-through
|
||||
default: // NONE
|
||||
return new LongIntMap(0);
|
|
@ -0,0 +1,32 @@
|
|||
package de.danoeh.antennapod.storage.database.mapper;
|
||||
|
||||
import android.database.Cursor;
|
||||
import androidx.annotation.NonNull;
|
||||
import de.danoeh.antennapod.model.feed.Chapter;
|
||||
import de.danoeh.antennapod.storage.database.PodDBAdapter;
|
||||
|
||||
/**
|
||||
* Converts a {@link Cursor} to a {@link Chapter} object.
|
||||
*/
|
||||
public abstract class ChapterCursorMapper {
|
||||
/**
|
||||
* Create a {@link Chapter} instance from a database row (cursor).
|
||||
*/
|
||||
@NonNull
|
||||
public static Chapter convert(@NonNull Cursor cursor) {
|
||||
int indexId = cursor.getColumnIndex(PodDBAdapter.KEY_ID);
|
||||
int indexTitle = cursor.getColumnIndex(PodDBAdapter.KEY_TITLE);
|
||||
int indexStart = cursor.getColumnIndex(PodDBAdapter.KEY_START);
|
||||
int indexLink = cursor.getColumnIndex(PodDBAdapter.KEY_LINK);
|
||||
int indexImage = cursor.getColumnIndex(PodDBAdapter.KEY_IMAGE_URL);
|
||||
|
||||
long id = cursor.getLong(indexId);
|
||||
String title = cursor.getString(indexTitle);
|
||||
long start = cursor.getLong(indexStart);
|
||||
String link = cursor.getString(indexLink);
|
||||
String imageUrl = cursor.getString(indexImage);
|
||||
Chapter chapter = new Chapter(start, title, link, imageUrl);
|
||||
chapter.setId(id);
|
||||
return chapter;
|
||||
}
|
||||
}
|
|
@ -1,10 +1,10 @@
|
|||
package de.danoeh.antennapod.core.storage.mapper;
|
||||
package de.danoeh.antennapod.storage.database.mapper;
|
||||
|
||||
import android.database.Cursor;
|
||||
import androidx.annotation.NonNull;
|
||||
import de.danoeh.antennapod.core.service.download.DownloadStatus;
|
||||
import de.danoeh.antennapod.core.storage.PodDBAdapter;
|
||||
import de.danoeh.antennapod.core.util.DownloadError;
|
||||
import de.danoeh.antennapod.model.download.DownloadStatus;
|
||||
import de.danoeh.antennapod.model.download.DownloadError;
|
||||
import de.danoeh.antennapod.storage.database.PodDBAdapter;
|
||||
|
||||
import java.util.Date;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package de.danoeh.antennapod.core.storage.mapper;
|
||||
package de.danoeh.antennapod.storage.database.mapper;
|
||||
|
||||
import android.database.Cursor;
|
||||
|
||||
|
@ -6,8 +6,8 @@ import androidx.annotation.NonNull;
|
|||
|
||||
import de.danoeh.antennapod.model.feed.Feed;
|
||||
import de.danoeh.antennapod.model.feed.FeedPreferences;
|
||||
import de.danoeh.antennapod.core.storage.PodDBAdapter;
|
||||
import de.danoeh.antennapod.model.feed.SortOrder;
|
||||
import de.danoeh.antennapod.storage.database.PodDBAdapter;
|
||||
|
||||
/**
|
||||
* Converts a {@link Cursor} to a {@link Feed} object.
|
|
@ -1,9 +1,9 @@
|
|||
package de.danoeh.antennapod.core.storage.mapper;
|
||||
package de.danoeh.antennapod.storage.database.mapper;
|
||||
|
||||
import android.database.Cursor;
|
||||
import androidx.annotation.NonNull;
|
||||
import de.danoeh.antennapod.model.feed.FeedItem;
|
||||
import de.danoeh.antennapod.core.storage.PodDBAdapter;
|
||||
import de.danoeh.antennapod.storage.database.PodDBAdapter;
|
||||
|
||||
import java.util.Date;
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
package de.danoeh.antennapod.core.storage.mapper;
|
||||
package de.danoeh.antennapod.storage.database.mapper;
|
||||
|
||||
import de.danoeh.antennapod.model.feed.FeedItemFilter;
|
||||
import de.danoeh.antennapod.core.storage.PodDBAdapter;
|
||||
import de.danoeh.antennapod.storage.database.PodDBAdapter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
|
@ -1,9 +1,9 @@
|
|||
package de.danoeh.antennapod.core.storage.mapper;
|
||||
package de.danoeh.antennapod.storage.database.mapper;
|
||||
|
||||
import android.database.Cursor;
|
||||
import androidx.annotation.NonNull;
|
||||
import de.danoeh.antennapod.model.feed.FeedMedia;
|
||||
import de.danoeh.antennapod.core.storage.PodDBAdapter;
|
||||
import de.danoeh.antennapod.storage.database.PodDBAdapter;
|
||||
|
||||
import java.util.Date;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package de.danoeh.antennapod.core.storage.mapper;
|
||||
package de.danoeh.antennapod.storage.database.mapper;
|
||||
|
||||
import android.database.Cursor;
|
||||
import android.text.TextUtils;
|
||||
|
@ -6,7 +6,7 @@ import androidx.annotation.NonNull;
|
|||
import de.danoeh.antennapod.model.feed.FeedFilter;
|
||||
import de.danoeh.antennapod.model.feed.FeedPreferences;
|
||||
import de.danoeh.antennapod.model.feed.VolumeAdaptionSetting;
|
||||
import de.danoeh.antennapod.core.storage.PodDBAdapter;
|
||||
import de.danoeh.antennapod.storage.database.PodDBAdapter;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
Loading…
Reference in New Issue