Remove dependency from :ui:glide to :core module (#6998)
This commit is contained in:
parent
b84a05bd4e
commit
2d77b1f118
|
@ -9,7 +9,7 @@ import java.io.IOException;
|
|||
|
||||
import de.danoeh.antennapod.model.feed.Feed;
|
||||
import de.danoeh.antennapod.storage.preferences.UserPreferences;
|
||||
import de.danoeh.antennapod.net.download.serviceinterface.DownloadRequest;
|
||||
import de.danoeh.antennapod.model.download.DownloadRequest;
|
||||
import de.danoeh.antennapod.model.download.DownloadResult;
|
||||
import de.danoeh.antennapod.core.service.download.Downloader;
|
||||
import de.danoeh.antennapod.core.service.download.HttpDownloader;
|
||||
|
|
|
@ -30,7 +30,6 @@ public class PodcastApp extends Application {
|
|||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
ClientConfig.USER_AGENT = "AntennaPod/" + BuildConfig.VERSION_NAME;
|
||||
ClientConfig.applicationCallbacks = new ApplicationCallbacksImpl();
|
||||
|
||||
Thread.setDefaultUncaughtExceptionHandler(new CrashReportWriter());
|
||||
|
|
|
@ -44,7 +44,7 @@ import de.danoeh.antennapod.event.PlayerStatusEvent;
|
|||
import de.danoeh.antennapod.core.preferences.PlaybackPreferences;
|
||||
import de.danoeh.antennapod.net.download.serviceinterface.DownloadServiceInterface;
|
||||
import de.danoeh.antennapod.storage.preferences.UserPreferences;
|
||||
import de.danoeh.antennapod.net.download.serviceinterface.DownloadRequest;
|
||||
import de.danoeh.antennapod.model.download.DownloadRequest;
|
||||
import de.danoeh.antennapod.model.download.DownloadResult;
|
||||
import de.danoeh.antennapod.core.service.download.Downloader;
|
||||
import de.danoeh.antennapod.core.service.download.HttpDownloader;
|
||||
|
|
|
@ -13,7 +13,7 @@ import androidx.annotation.Nullable;
|
|||
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.model.playback.MediaType;
|
||||
import de.danoeh.antennapod.core.util.NetworkUtils;
|
||||
import de.danoeh.antennapod.net.common.NetworkUtils;
|
||||
import de.danoeh.antennapod.model.playback.RemoteMedia;
|
||||
import de.danoeh.antennapod.model.feed.FeedItem;
|
||||
import de.danoeh.antennapod.core.service.playback.PlaybackService;
|
||||
|
|
|
@ -13,7 +13,7 @@ import de.danoeh.antennapod.net.download.serviceinterface.DownloadServiceInterfa
|
|||
import de.danoeh.antennapod.model.feed.FeedItem;
|
||||
import de.danoeh.antennapod.model.feed.FeedMedia;
|
||||
import de.danoeh.antennapod.core.preferences.UsageStatistics;
|
||||
import de.danoeh.antennapod.core.util.NetworkUtils;
|
||||
import de.danoeh.antennapod.net.common.NetworkUtils;
|
||||
|
||||
public class DownloadActionButton extends ItemActionButton {
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ import de.danoeh.antennapod.model.feed.FeedMedia;
|
|||
import de.danoeh.antennapod.model.playback.MediaType;
|
||||
import de.danoeh.antennapod.core.preferences.UsageStatistics;
|
||||
import de.danoeh.antennapod.core.service.playback.PlaybackService;
|
||||
import de.danoeh.antennapod.core.util.NetworkUtils;
|
||||
import de.danoeh.antennapod.net.common.NetworkUtils;
|
||||
import de.danoeh.antennapod.core.util.playback.PlaybackServiceStarter;
|
||||
import de.danoeh.antennapod.dialog.StreamingConfirmationDialog;
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ import java.util.concurrent.TimeUnit;
|
|||
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.storage.preferences.UserPreferences;
|
||||
import de.danoeh.antennapod.core.service.download.AntennapodHttpClient;
|
||||
import de.danoeh.antennapod.net.common.AntennapodHttpClient;
|
||||
import de.danoeh.antennapod.model.download.ProxyConfig;
|
||||
import de.danoeh.antennapod.ui.common.ThemeUtils;
|
||||
import io.reactivex.Completable;
|
||||
|
|
|
@ -19,7 +19,7 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
|||
import androidx.fragment.app.DialogFragment;
|
||||
import com.google.android.material.button.MaterialButton;
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.core.service.download.AntennapodHttpClient;
|
||||
import de.danoeh.antennapod.net.common.AntennapodHttpClient;
|
||||
import de.danoeh.antennapod.core.sync.SyncService;
|
||||
import de.danoeh.antennapod.core.sync.SynchronizationCredentials;
|
||||
import de.danoeh.antennapod.core.sync.SynchronizationProviderViewData;
|
||||
|
|
|
@ -9,7 +9,7 @@ import androidx.annotation.Nullable;
|
|||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.core.service.download.AntennapodHttpClient;
|
||||
import de.danoeh.antennapod.net.common.AntennapodHttpClient;
|
||||
import de.danoeh.antennapod.core.sync.SyncService;
|
||||
import de.danoeh.antennapod.core.sync.SynchronizationCredentials;
|
||||
import de.danoeh.antennapod.core.sync.SynchronizationProviderViewData;
|
||||
|
|
|
@ -27,7 +27,7 @@ import de.danoeh.antennapod.activity.MainActivity;
|
|||
import de.danoeh.antennapod.core.menuhandler.MenuItemUtils;
|
||||
import de.danoeh.antennapod.ui.common.Converter;
|
||||
import de.danoeh.antennapod.core.util.IntentUtils;
|
||||
import de.danoeh.antennapod.core.util.NetworkUtils;
|
||||
import de.danoeh.antennapod.net.common.NetworkUtils;
|
||||
import de.danoeh.antennapod.core.util.ShareUtils;
|
||||
import de.danoeh.antennapod.core.util.gui.ShownotesCleaner;
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ import de.danoeh.antennapod.core.feed.util.ImageResourceUtils;
|
|||
import de.danoeh.antennapod.net.download.serviceinterface.DownloadServiceInterface;
|
||||
import de.danoeh.antennapod.storage.preferences.UserPreferences;
|
||||
import de.danoeh.antennapod.ui.common.Converter;
|
||||
import de.danoeh.antennapod.core.util.NetworkUtils;
|
||||
import de.danoeh.antennapod.net.common.NetworkUtils;
|
||||
import de.danoeh.antennapod.model.playback.Playable;
|
||||
import de.danoeh.antennapod.ui.common.CircularProgressBar;
|
||||
import de.danoeh.antennapod.ui.common.ThemeUtils;
|
||||
|
|
|
@ -36,6 +36,10 @@
|
|||
<Bug pattern="MS_MUTABLE_ARRAY"/>
|
||||
<Class name="de.danoeh.antennapod.fragment.NavDrawerFragment"/>
|
||||
</Match>
|
||||
<Match>
|
||||
<Bug pattern="MS_SHOULD_BE_FINAL"/>
|
||||
<Class name="de.danoeh.antennapod.net.common.UserAgentInterceptor"/>
|
||||
</Match>
|
||||
<Match>
|
||||
<Bug pattern="NP_NONNULL_PARAM_VIOLATION"/>
|
||||
<Class name="de.danoeh.antennapod.activity.MainActivity"/>
|
||||
|
|
|
@ -5,10 +5,5 @@ package de.danoeh.antennapod.core;
|
|||
* Apps using the core module of AntennaPod should register implementations of all interfaces here.
|
||||
*/
|
||||
public class ClientConfig {
|
||||
/**
|
||||
* Should be used when setting User-Agent header for HTTP-requests.
|
||||
*/
|
||||
public static String USER_AGENT;
|
||||
|
||||
public static ApplicationCallbacks applicationCallbacks;
|
||||
}
|
||||
|
|
|
@ -1,16 +1,19 @@
|
|||
package de.danoeh.antennapod.core;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import de.danoeh.antennapod.core.preferences.PlaybackPreferences;
|
||||
import de.danoeh.antennapod.core.preferences.SleepTimerPreferences;
|
||||
import de.danoeh.antennapod.core.preferences.UsageStatistics;
|
||||
import de.danoeh.antennapod.net.common.UserAgentInterceptor;
|
||||
import de.danoeh.antennapod.storage.preferences.UserPreferences;
|
||||
import de.danoeh.antennapod.core.service.download.AntennapodHttpClient;
|
||||
import de.danoeh.antennapod.net.common.AntennapodHttpClient;
|
||||
import de.danoeh.antennapod.net.download.serviceinterface.DownloadServiceInterface;
|
||||
import de.danoeh.antennapod.core.service.download.DownloadServiceInterfaceImpl;
|
||||
import de.danoeh.antennapod.core.sync.SyncService;
|
||||
import de.danoeh.antennapod.core.sync.queue.SynchronizationQueueSink;
|
||||
import de.danoeh.antennapod.core.util.NetworkUtils;
|
||||
import de.danoeh.antennapod.net.common.NetworkUtils;
|
||||
import de.danoeh.antennapod.core.util.download.NetworkConnectionChangeHandler;
|
||||
import de.danoeh.antennapod.net.ssl.SslProviderInstaller;
|
||||
import de.danoeh.antennapod.storage.database.PodDBAdapter;
|
||||
|
@ -25,6 +28,12 @@ public class ClientConfigurator {
|
|||
if (initialized) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
PackageInfo packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
|
||||
UserAgentInterceptor.USER_AGENT = "AntennaPod/" + packageInfo.versionName;
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
PodDBAdapter.init(context);
|
||||
UserPreferences.init(context);
|
||||
UsageStatistics.init(context);
|
||||
|
|
|
@ -27,13 +27,14 @@ import de.danoeh.antennapod.core.service.download.handler.FeedSyncTask;
|
|||
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.NetworkUtils;
|
||||
import de.danoeh.antennapod.net.common.NetworkUtils;
|
||||
import de.danoeh.antennapod.core.util.download.FeedUpdateManager;
|
||||
import de.danoeh.antennapod.model.download.DownloadError;
|
||||
import de.danoeh.antennapod.model.download.DownloadResult;
|
||||
import de.danoeh.antennapod.model.feed.Feed;
|
||||
import de.danoeh.antennapod.net.download.serviceinterface.DownloadRequest;
|
||||
import de.danoeh.antennapod.model.download.DownloadRequest;
|
||||
|
||||
import de.danoeh.antennapod.net.download.serviceinterface.DownloadRequestBuilder;
|
||||
import de.danoeh.antennapod.ui.notifications.NotificationUtils;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
@ -166,7 +167,7 @@ public class FeedUpdateWorker extends Worker {
|
|||
if (nextPage) {
|
||||
feed.setPageNr(feed.getPageNr() + 1);
|
||||
}
|
||||
DownloadRequest.Builder builder = DownloadRequestCreator.create(feed);
|
||||
DownloadRequestBuilder builder = DownloadRequestCreator.create(feed);
|
||||
builder.setForce(force || feed.hasLastUpdateFailed());
|
||||
if (nextPage) {
|
||||
builder.setSource(feed.getNextPageLink());
|
||||
|
|
|
@ -4,7 +4,7 @@ import android.util.Log;
|
|||
import android.webkit.URLUtil;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import de.danoeh.antennapod.net.download.serviceinterface.DownloadRequest;
|
||||
import de.danoeh.antennapod.model.download.DownloadRequest;
|
||||
|
||||
public class DefaultDownloaderFactory implements DownloaderFactory {
|
||||
private static final String TAG = "DefaultDwnldrFactory";
|
||||
|
|
|
@ -2,11 +2,11 @@ package de.danoeh.antennapod.core.service.download;
|
|||
|
||||
import android.util.Log;
|
||||
import android.webkit.URLUtil;
|
||||
import de.danoeh.antennapod.net.download.serviceinterface.DownloadRequestBuilder;
|
||||
import de.danoeh.antennapod.storage.preferences.UserPreferences;
|
||||
import de.danoeh.antennapod.core.util.FileNameGenerator;
|
||||
import de.danoeh.antennapod.model.feed.Feed;
|
||||
import de.danoeh.antennapod.model.feed.FeedMedia;
|
||||
import de.danoeh.antennapod.net.download.serviceinterface.DownloadRequest;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -19,7 +19,7 @@ public class DownloadRequestCreator {
|
|||
private static final String FEED_DOWNLOADPATH = "cache/";
|
||||
private static final String MEDIA_DOWNLOADPATH = "media/";
|
||||
|
||||
public static DownloadRequest.Builder create(Feed feed) {
|
||||
public static DownloadRequestBuilder create(Feed feed) {
|
||||
File dest = new File(getFeedfilePath(), getFeedfileName(feed));
|
||||
if (dest.exists()) {
|
||||
dest.delete();
|
||||
|
@ -29,12 +29,12 @@ public class DownloadRequestCreator {
|
|||
String username = (feed.getPreferences() != null) ? feed.getPreferences().getUsername() : null;
|
||||
String password = (feed.getPreferences() != null) ? feed.getPreferences().getPassword() : null;
|
||||
|
||||
return new DownloadRequest.Builder(dest.toString(), feed)
|
||||
return new DownloadRequestBuilder(dest.toString(), feed)
|
||||
.withAuthentication(username, password)
|
||||
.lastModified(feed.getLastModified());
|
||||
}
|
||||
|
||||
public static DownloadRequest.Builder create(FeedMedia media) {
|
||||
public static DownloadRequestBuilder create(FeedMedia media) {
|
||||
final boolean partiallyDownloadedFileExists =
|
||||
media.getFile_url() != null && new File(media.getFile_url()).exists();
|
||||
File dest;
|
||||
|
@ -54,7 +54,7 @@ public class DownloadRequestCreator {
|
|||
String password = (media.getItem().getFeed().getPreferences() != null)
|
||||
? media.getItem().getFeed().getPreferences().getPassword() : null;
|
||||
|
||||
return new DownloadRequest.Builder(dest.toString(), media)
|
||||
return new DownloadRequestBuilder(dest.toString(), media)
|
||||
.withAuthentication(username, password);
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import java.util.concurrent.Callable;
|
|||
import de.danoeh.antennapod.core.ClientConfig;
|
||||
import de.danoeh.antennapod.core.R;
|
||||
import de.danoeh.antennapod.model.download.DownloadResult;
|
||||
import de.danoeh.antennapod.net.download.serviceinterface.DownloadRequest;
|
||||
import de.danoeh.antennapod.model.download.DownloadRequest;
|
||||
|
||||
/**
|
||||
* Downloads files
|
||||
|
|
|
@ -2,7 +2,7 @@ package de.danoeh.antennapod.core.service.download;
|
|||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import de.danoeh.antennapod.net.download.serviceinterface.DownloadRequest;
|
||||
import de.danoeh.antennapod.model.download.DownloadRequest;
|
||||
|
||||
public interface DownloaderFactory {
|
||||
@Nullable
|
||||
|
|
|
@ -27,7 +27,7 @@ import de.danoeh.antennapod.event.MessageEvent;
|
|||
import de.danoeh.antennapod.model.download.DownloadError;
|
||||
import de.danoeh.antennapod.model.download.DownloadResult;
|
||||
import de.danoeh.antennapod.model.feed.FeedMedia;
|
||||
import de.danoeh.antennapod.net.download.serviceinterface.DownloadRequest;
|
||||
import de.danoeh.antennapod.model.download.DownloadRequest;
|
||||
import de.danoeh.antennapod.net.download.serviceinterface.DownloadServiceInterface;
|
||||
import de.danoeh.antennapod.ui.appstartintent.MainActivityStarter;
|
||||
import de.danoeh.antennapod.ui.notifications.NotificationUtils;
|
||||
|
|
|
@ -4,9 +4,10 @@ import androidx.annotation.NonNull;
|
|||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import de.danoeh.antennapod.core.util.NetworkUtils;
|
||||
import de.danoeh.antennapod.net.common.NetworkUtils;
|
||||
import de.danoeh.antennapod.model.download.DownloadResult;
|
||||
import de.danoeh.antennapod.net.download.serviceinterface.DownloadRequest;
|
||||
import de.danoeh.antennapod.model.download.DownloadRequest;
|
||||
import de.danoeh.antennapod.net.common.AntennapodHttpClient;
|
||||
import okhttp3.CacheControl;
|
||||
import okhttp3.internal.http.StatusLine;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
@ -29,7 +30,7 @@ import de.danoeh.antennapod.model.feed.FeedMedia;
|
|||
import de.danoeh.antennapod.parser.feed.util.DateUtils;
|
||||
import de.danoeh.antennapod.model.download.DownloadError;
|
||||
import de.danoeh.antennapod.core.util.StorageUtils;
|
||||
import de.danoeh.antennapod.core.util.URIUtil;
|
||||
import de.danoeh.antennapod.net.common.UriUtil;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Protocol;
|
||||
import okhttp3.Request;
|
||||
|
@ -54,7 +55,7 @@ public class HttpDownloader extends Downloader {
|
|||
ResponseBody responseBody = null;
|
||||
|
||||
try {
|
||||
final URI uri = URIUtil.getURIFromRequestUrl(request.getSource());
|
||||
final URI uri = UriUtil.getURIFromRequestUrl(request.getSource());
|
||||
Request.Builder httpReq = new Request.Builder().url(uri.toURL());
|
||||
httpReq.tag(request);
|
||||
httpReq.cacheControl(new CacheControl.Builder().noStore().build());
|
||||
|
|
|
@ -7,7 +7,7 @@ import de.danoeh.antennapod.model.feed.Feed;
|
|||
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.net.download.serviceinterface.DownloadRequest;
|
||||
import de.danoeh.antennapod.model.download.DownloadRequest;
|
||||
import de.danoeh.antennapod.model.download.DownloadResult;
|
||||
import de.danoeh.antennapod.parser.feed.FeedHandler;
|
||||
import de.danoeh.antennapod.parser.feed.FeedHandlerResult;
|
||||
|
|
|
@ -5,7 +5,7 @@ import androidx.annotation.NonNull;
|
|||
import de.danoeh.antennapod.core.storage.DBTasks;
|
||||
import de.danoeh.antennapod.model.download.DownloadResult;
|
||||
import de.danoeh.antennapod.model.feed.Feed;
|
||||
import de.danoeh.antennapod.net.download.serviceinterface.DownloadRequest;
|
||||
import de.danoeh.antennapod.model.download.DownloadRequest;
|
||||
import de.danoeh.antennapod.parser.feed.FeedHandlerResult;
|
||||
|
||||
public class FeedSyncTask {
|
||||
|
|
|
@ -14,7 +14,7 @@ import java.io.InterruptedIOException;
|
|||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import de.danoeh.antennapod.event.UnreadItemsUpdateEvent;
|
||||
import de.danoeh.antennapod.net.download.serviceinterface.DownloadRequest;
|
||||
import de.danoeh.antennapod.model.download.DownloadRequest;
|
||||
import de.danoeh.antennapod.model.download.DownloadResult;
|
||||
import de.danoeh.antennapod.core.storage.DBReader;
|
||||
import de.danoeh.antennapod.core.storage.DBWriter;
|
||||
|
|
|
@ -42,13 +42,13 @@ import androidx.media3.extractor.DefaultExtractorsFactory;
|
|||
import androidx.media3.extractor.mp3.Mp3Extractor;
|
||||
import androidx.media3.ui.DefaultTrackNameProvider;
|
||||
import androidx.media3.ui.TrackNameProvider;
|
||||
import de.danoeh.antennapod.core.ClientConfig;
|
||||
import de.danoeh.antennapod.core.R;
|
||||
import de.danoeh.antennapod.net.common.UserAgentInterceptor;
|
||||
import de.danoeh.antennapod.model.feed.VolumeAdaptionSetting;
|
||||
import de.danoeh.antennapod.storage.preferences.UserPreferences;
|
||||
import de.danoeh.antennapod.core.service.download.AntennapodHttpClient;
|
||||
import de.danoeh.antennapod.core.service.download.HttpCredentialEncoder;
|
||||
import de.danoeh.antennapod.core.util.NetworkUtils;
|
||||
import de.danoeh.antennapod.net.common.AntennapodHttpClient;
|
||||
import de.danoeh.antennapod.net.common.HttpCredentialEncoder;
|
||||
import de.danoeh.antennapod.net.common.NetworkUtils;
|
||||
import de.danoeh.antennapod.model.playback.Playable;
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
|
@ -234,7 +234,7 @@ public class ExoPlayerWrapper {
|
|||
Log.d(TAG, "setDataSource: " + s);
|
||||
final OkHttpDataSource.Factory httpDataSourceFactory =
|
||||
new OkHttpDataSource.Factory((Call.Factory) AntennapodHttpClient.getHttpClient())
|
||||
.setUserAgent(ClientConfig.USER_AGENT);
|
||||
.setUserAgent(UserAgentInterceptor.USER_AGENT);
|
||||
|
||||
if (!TextUtils.isEmpty(user) && !TextUtils.isEmpty(password)) {
|
||||
final HashMap<String, String> requestProperties = new HashMap<>();
|
||||
|
|
|
@ -76,7 +76,7 @@ import de.danoeh.antennapod.core.util.ChapterUtils;
|
|||
import de.danoeh.antennapod.core.util.FeedItemUtil;
|
||||
import de.danoeh.antennapod.core.util.FeedUtil;
|
||||
import de.danoeh.antennapod.core.util.IntentUtils;
|
||||
import de.danoeh.antennapod.core.util.NetworkUtils;
|
||||
import de.danoeh.antennapod.net.common.NetworkUtils;
|
||||
import de.danoeh.antennapod.core.util.playback.PlayableUtils;
|
||||
import de.danoeh.antennapod.core.util.playback.PlaybackServiceStarter;
|
||||
import de.danoeh.antennapod.core.widget.WidgetUpdater;
|
||||
|
|
|
@ -14,7 +14,7 @@ import de.danoeh.antennapod.model.feed.FeedItem;
|
|||
import de.danoeh.antennapod.model.feed.FeedPreferences;
|
||||
import de.danoeh.antennapod.net.download.serviceinterface.DownloadServiceInterface;
|
||||
import de.danoeh.antennapod.storage.preferences.UserPreferences;
|
||||
import de.danoeh.antennapod.core.util.NetworkUtils;
|
||||
import de.danoeh.antennapod.net.common.NetworkUtils;
|
||||
import de.danoeh.antennapod.core.util.PowerUtils;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package de.danoeh.antennapod.core.storage;
|
||||
|
||||
import android.database.Cursor;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
@ -584,42 +583,6 @@ public final class DBReader {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns credentials based on image URL
|
||||
*
|
||||
* @param imageUrl The URL of the image
|
||||
* @return Credentials in format "Username:Password", empty String if no authorization given
|
||||
*/
|
||||
public static String getImageAuthentication(final String imageUrl) {
|
||||
Log.d(TAG, "getImageAuthentication() called with: " + "imageUrl = [" + imageUrl + "]");
|
||||
|
||||
PodDBAdapter adapter = PodDBAdapter.getInstance();
|
||||
adapter.open();
|
||||
try {
|
||||
return getImageAuthentication(imageUrl, adapter);
|
||||
} finally {
|
||||
adapter.close();
|
||||
}
|
||||
}
|
||||
|
||||
private static String getImageAuthentication(final String imageUrl, PodDBAdapter adapter) {
|
||||
String credentials;
|
||||
try (Cursor cursor = adapter.getImageAuthenticationCursor(imageUrl)) {
|
||||
if (cursor.moveToFirst()) {
|
||||
String username = cursor.getString(0);
|
||||
String password = cursor.getString(1);
|
||||
if (!TextUtils.isEmpty(username) && password != null) {
|
||||
credentials = username + ":" + password;
|
||||
} else {
|
||||
credentials = "";
|
||||
}
|
||||
} else {
|
||||
credentials = "";
|
||||
}
|
||||
}
|
||||
return credentials;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a specific FeedItem from the database.
|
||||
*
|
||||
|
|
|
@ -41,7 +41,7 @@ import java.util.concurrent.TimeUnit;
|
|||
import de.danoeh.antennapod.core.R;
|
||||
import de.danoeh.antennapod.event.SyncServiceEvent;
|
||||
import de.danoeh.antennapod.storage.preferences.UserPreferences;
|
||||
import de.danoeh.antennapod.core.service.download.AntennapodHttpClient;
|
||||
import de.danoeh.antennapod.net.common.AntennapodHttpClient;
|
||||
import de.danoeh.antennapod.core.storage.DBReader;
|
||||
import de.danoeh.antennapod.core.storage.DBTasks;
|
||||
import de.danoeh.antennapod.core.storage.DBWriter;
|
||||
|
|
|
@ -9,7 +9,7 @@ import androidx.annotation.NonNull;
|
|||
import de.danoeh.antennapod.model.feed.Chapter;
|
||||
import de.danoeh.antennapod.core.feed.ChapterMerger;
|
||||
import de.danoeh.antennapod.model.feed.FeedMedia;
|
||||
import de.danoeh.antennapod.core.service.download.AntennapodHttpClient;
|
||||
import de.danoeh.antennapod.net.common.AntennapodHttpClient;
|
||||
import de.danoeh.antennapod.core.storage.DBReader;
|
||||
import de.danoeh.antennapod.core.util.comparator.ChapterStartTimeComparator;
|
||||
import de.danoeh.antennapod.parser.feed.PodcastIndexChapterParser;
|
||||
|
|
|
@ -16,7 +16,7 @@ import androidx.work.WorkManager;
|
|||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import de.danoeh.antennapod.core.R;
|
||||
import de.danoeh.antennapod.core.service.FeedUpdateWorker;
|
||||
import de.danoeh.antennapod.core.util.NetworkUtils;
|
||||
import de.danoeh.antennapod.net.common.NetworkUtils;
|
||||
import de.danoeh.antennapod.event.MessageEvent;
|
||||
import de.danoeh.antennapod.model.feed.Feed;
|
||||
import de.danoeh.antennapod.storage.preferences.UserPreferences;
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package de.danoeh.antennapod.core.util.download;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import de.danoeh.antennapod.core.service.download.AntennapodHttpClient;
|
||||
import de.danoeh.antennapod.net.common.AntennapodHttpClient;
|
||||
import de.danoeh.antennapod.core.storage.DBWriter;
|
||||
import de.danoeh.antennapod.core.util.NetworkUtils;
|
||||
import de.danoeh.antennapod.net.common.NetworkUtils;
|
||||
import de.danoeh.antennapod.model.feed.FeedMedia;
|
||||
import io.reactivex.Single;
|
||||
import io.reactivex.SingleOnSubscribe;
|
||||
|
|
|
@ -4,7 +4,7 @@ import android.content.Context;
|
|||
import android.util.Log;
|
||||
import de.danoeh.antennapod.net.download.serviceinterface.DownloadServiceInterface;
|
||||
import de.danoeh.antennapod.core.storage.DBTasks;
|
||||
import de.danoeh.antennapod.core.util.NetworkUtils;
|
||||
import de.danoeh.antennapod.net.common.NetworkUtils;
|
||||
|
||||
public abstract class NetworkConnectionChangeHandler {
|
||||
private static final String TAG = "NetConnChangeHandler";
|
||||
|
|
|
@ -5,6 +5,10 @@ apply from: "../common.gradle"
|
|||
|
||||
android {
|
||||
namespace "de.danoeh.antennapod.model"
|
||||
|
||||
lint {
|
||||
disable 'ParcelClassLoader'
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package de.danoeh.antennapod.net.download.serviceinterface;
|
||||
package de.danoeh.antennapod.model.download;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcel;
|
||||
|
@ -8,10 +8,6 @@ import android.text.TextUtils;
|
|||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import de.danoeh.antennapod.model.feed.Feed;
|
||||
import de.danoeh.antennapod.net.common.UrlChecker;
|
||||
import de.danoeh.antennapod.model.feed.FeedMedia;
|
||||
|
||||
public class DownloadRequest implements Parcelable {
|
||||
public static final String REQUEST_ARG_PAGE_NR = "page";
|
||||
|
||||
|
@ -39,19 +35,13 @@ public class DownloadRequest implements Parcelable {
|
|||
arguments, initiatedByUser);
|
||||
}
|
||||
|
||||
private DownloadRequest(Builder builder) {
|
||||
this(builder.destination, builder.source, builder.title, builder.feedfileId, builder.feedfileType,
|
||||
builder.lastModified, builder.username, builder.password, false,
|
||||
builder.arguments, builder.initiatedByUser);
|
||||
}
|
||||
|
||||
private DownloadRequest(Parcel in) {
|
||||
this(in.readString(), in.readString(), in.readString(), in.readLong(), in.readInt(), in.readString(),
|
||||
nullIfEmpty(in.readString()), nullIfEmpty(in.readString()), in.readByte() > 0,
|
||||
in.readBundle(), in.readByte() > 0);
|
||||
}
|
||||
|
||||
private DownloadRequest(String destination, String source, String title, long feedfileId, int feedfileType,
|
||||
public DownloadRequest(String destination, String source, String title, long feedfileId, int feedfileType,
|
||||
String lastModified, String username, String password,
|
||||
boolean mediaEnqueued, Bundle arguments, boolean initiatedByUser) {
|
||||
this.destination = destination;
|
||||
|
@ -234,64 +224,4 @@ public class DownloadRequest implements Parcelable {
|
|||
public Bundle getArguments() {
|
||||
return arguments;
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private final String destination;
|
||||
private String source;
|
||||
private final String title;
|
||||
private String username;
|
||||
private String password;
|
||||
private String lastModified;
|
||||
private final long feedfileId;
|
||||
private final int feedfileType;
|
||||
private final Bundle arguments = new Bundle();
|
||||
private boolean initiatedByUser = true;
|
||||
|
||||
public Builder(@NonNull String destination, @NonNull FeedMedia media) {
|
||||
this.destination = destination;
|
||||
this.source = UrlChecker.prepareUrl(media.getDownload_url());
|
||||
this.title = media.getHumanReadableIdentifier();
|
||||
this.feedfileId = media.getId();
|
||||
this.feedfileType = FeedMedia.FEEDFILETYPE_FEEDMEDIA;
|
||||
}
|
||||
|
||||
public Builder(@NonNull String destination, @NonNull Feed feed) {
|
||||
this.destination = destination;
|
||||
this.source = feed.isLocalFeed() ? feed.getDownload_url() : UrlChecker.prepareUrl(feed.getDownload_url());
|
||||
this.title = feed.getHumanReadableIdentifier();
|
||||
this.feedfileId = feed.getId();
|
||||
this.feedfileType = Feed.FEEDFILETYPE_FEED;
|
||||
arguments.putInt(REQUEST_ARG_PAGE_NR, feed.getPageNr());
|
||||
}
|
||||
|
||||
public Builder withInitiatedByUser(boolean initiatedByUser) {
|
||||
this.initiatedByUser = initiatedByUser;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void setSource(String source) {
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
public void setForce(boolean force) {
|
||||
if (force) {
|
||||
lastModified = null;
|
||||
}
|
||||
}
|
||||
|
||||
public Builder lastModified(String lastModified) {
|
||||
this.lastModified = lastModified;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder withAuthentication(String username, String password) {
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DownloadRequest build() {
|
||||
return new DownloadRequest(this);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,14 +2,20 @@ plugins {
|
|||
id("com.android.library")
|
||||
}
|
||||
apply from: "../../common.gradle"
|
||||
apply from: "../../playFlavor.gradle"
|
||||
|
||||
android {
|
||||
namespace "de.danoeh.antennapod.net.common"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation project(':model')
|
||||
implementation project(':net:ssl')
|
||||
implementation project(':storage:preferences')
|
||||
|
||||
annotationProcessor "androidx.annotation:annotation:$annotationVersion"
|
||||
implementation "com.squareup.okhttp3:okhttp:$okhttpVersion"
|
||||
implementation "com.squareup.okhttp3:okhttp-urlconnection:$okhttpVersion"
|
||||
|
||||
testImplementation "junit:junit:$junitVersion"
|
||||
testImplementation "org.robolectric:robolectric:$robolectricVersion"
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||
</manifest>
|
|
@ -1,10 +1,8 @@
|
|||
package de.danoeh.antennapod.core.service.download;
|
||||
package de.danoeh.antennapod.net.common;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import androidx.annotation.NonNull;
|
||||
import de.danoeh.antennapod.core.service.BasicAuthorizationInterceptor;
|
||||
import de.danoeh.antennapod.core.service.UserAgentInterceptor;
|
||||
import de.danoeh.antennapod.model.download.ProxyConfig;
|
||||
import de.danoeh.antennapod.net.ssl.SslClientSetup;
|
||||
import okhttp3.Cache;
|
|
@ -1,12 +1,11 @@
|
|||
package de.danoeh.antennapod.core.service;
|
||||
package de.danoeh.antennapod.net.common;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import androidx.annotation.NonNull;
|
||||
import de.danoeh.antennapod.net.download.serviceinterface.DownloadRequest;
|
||||
import de.danoeh.antennapod.core.service.download.HttpCredentialEncoder;
|
||||
import de.danoeh.antennapod.core.storage.DBReader;
|
||||
import de.danoeh.antennapod.core.util.URIUtil;
|
||||
import de.danoeh.antennapod.model.download.DownloadRequest;
|
||||
import de.danoeh.antennapod.net.common.HttpCredentialEncoder;
|
||||
import de.danoeh.antennapod.net.common.UriUtil;
|
||||
import java.io.IOException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.util.List;
|
||||
|
@ -43,17 +42,15 @@ public class BasicAuthorizationInterceptor implements Interceptor {
|
|||
}
|
||||
}
|
||||
|
||||
String userInfo;
|
||||
String userInfo = null;
|
||||
if (request.tag() instanceof DownloadRequest) {
|
||||
DownloadRequest downloadRequest = (DownloadRequest) request.tag();
|
||||
userInfo = URIUtil.getURIFromRequestUrl(downloadRequest.getSource()).getUserInfo();
|
||||
userInfo = UriUtil.getURIFromRequestUrl(downloadRequest.getSource()).getUserInfo();
|
||||
if (TextUtils.isEmpty(userInfo)
|
||||
&& (!TextUtils.isEmpty(downloadRequest.getUsername())
|
||||
|| !TextUtils.isEmpty(downloadRequest.getPassword()))) {
|
||||
userInfo = downloadRequest.getUsername() + ":" + downloadRequest.getPassword();
|
||||
}
|
||||
} else {
|
||||
userInfo = DBReader.getImageAuthentication(request.url().toString());
|
||||
}
|
||||
|
||||
if (TextUtils.isEmpty(userInfo)) {
|
|
@ -1,4 +1,4 @@
|
|||
package de.danoeh.antennapod.core.service.download;
|
||||
package de.danoeh.antennapod.net.common;
|
||||
|
||||
import android.util.Base64;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package de.danoeh.antennapod.core.util;
|
||||
package de.danoeh.antennapod.net.common;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.ConnectivityManager;
|
|
@ -1,28 +1,22 @@
|
|||
package de.danoeh.antennapod.core.util;
|
||||
|
||||
import android.util.Log;
|
||||
package de.danoeh.antennapod.net.common;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
|
||||
import de.danoeh.antennapod.core.BuildConfig;
|
||||
|
||||
/**
|
||||
* Utility methods for dealing with URL encoding.
|
||||
*/
|
||||
public class URIUtil {
|
||||
private static final String TAG = "URIUtil";
|
||||
|
||||
private URIUtil() {}
|
||||
public class UriUtil {
|
||||
private UriUtil() {}
|
||||
|
||||
public static URI getURIFromRequestUrl(String source) {
|
||||
// try without encoding the URI
|
||||
try {
|
||||
return new URI(source);
|
||||
} catch (URISyntaxException e) {
|
||||
if (BuildConfig.DEBUG) Log.d(TAG, "Source is not encoded, encoding now");
|
||||
} catch (URISyntaxException ignore) {
|
||||
System.out.println("Source is not encoded, encoding now");
|
||||
}
|
||||
try {
|
||||
URL url = new URL(source);
|
|
@ -1,16 +1,17 @@
|
|||
package de.danoeh.antennapod.core.service;
|
||||
package de.danoeh.antennapod.net.common;
|
||||
|
||||
import de.danoeh.antennapod.core.ClientConfig;
|
||||
import okhttp3.Interceptor;
|
||||
import okhttp3.Response;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class UserAgentInterceptor implements Interceptor {
|
||||
public static String USER_AGENT = "AntennaPod/0.0.0";
|
||||
|
||||
@Override
|
||||
public Response intercept(Chain chain) throws IOException {
|
||||
return chain.proceed(chain.request().newBuilder()
|
||||
.header("User-Agent", ClientConfig.USER_AGENT)
|
||||
.header("User-Agent", USER_AGENT)
|
||||
.build());
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package de.danoeh.antennapod.core.util;
|
||||
package de.danoeh.antennapod.net.common;
|
||||
|
||||
import de.danoeh.antennapod.net.common.UriUtil;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
@ -7,18 +8,18 @@ import static org.junit.Assert.assertEquals;
|
|||
/**
|
||||
* Test class for URIUtil
|
||||
*/
|
||||
public class URIUtilTest {
|
||||
public class UriUtilTest {
|
||||
|
||||
@Test
|
||||
public void testGetURIFromRequestUrlShouldNotEncode() {
|
||||
final String testUrl = "http://example.com/this%20is%20encoded";
|
||||
assertEquals(testUrl, URIUtil.getURIFromRequestUrl(testUrl).toString());
|
||||
assertEquals(testUrl, UriUtil.getURIFromRequestUrl(testUrl).toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetURIFromRequestUrlShouldEncode() {
|
||||
final String testUrl = "http://example.com/this is not encoded";
|
||||
final String expected = "http://example.com/this%20is%20not%20encoded";
|
||||
assertEquals(expected, URIUtil.getURIFromRequestUrl(testUrl).toString());
|
||||
assertEquals(expected, UriUtil.getURIFromRequestUrl(testUrl).toString());
|
||||
}
|
||||
}
|
|
@ -21,6 +21,7 @@ android {
|
|||
dependencies {
|
||||
implementation project(':core')
|
||||
implementation project(':model')
|
||||
implementation project(':net:common')
|
||||
implementation project(':net:sync:gpoddernet')
|
||||
implementation project(':net:sync:model')
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package de.danoeh.antennapod.net.discovery;
|
||||
|
||||
import de.danoeh.antennapod.core.service.download.AntennapodHttpClient;
|
||||
import de.danoeh.antennapod.net.common.AntennapodHttpClient;
|
||||
import de.mfietz.fyydlin.FyydClient;
|
||||
import de.mfietz.fyydlin.FyydResponse;
|
||||
import de.mfietz.fyydlin.SearchHit;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package de.danoeh.antennapod.net.discovery;
|
||||
|
||||
import de.danoeh.antennapod.core.sync.SynchronizationCredentials;
|
||||
import de.danoeh.antennapod.core.service.download.AntennapodHttpClient;
|
||||
import de.danoeh.antennapod.net.common.AntennapodHttpClient;
|
||||
import de.danoeh.antennapod.net.sync.gpoddernet.GpodnetService;
|
||||
import de.danoeh.antennapod.net.sync.gpoddernet.GpodnetServiceException;
|
||||
import de.danoeh.antennapod.net.sync.gpoddernet.model.GpodnetPodcast;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package de.danoeh.antennapod.net.discovery;
|
||||
|
||||
import de.danoeh.antennapod.core.feed.FeedUrlNotFoundException;
|
||||
import de.danoeh.antennapod.core.service.download.AntennapodHttpClient;
|
||||
import de.danoeh.antennapod.net.common.AntennapodHttpClient;
|
||||
import io.reactivex.Single;
|
||||
import io.reactivex.SingleOnSubscribe;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
|
|
|
@ -2,8 +2,8 @@ package de.danoeh.antennapod.net.discovery;
|
|||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import de.danoeh.antennapod.core.service.download.AntennapodHttpClient;
|
||||
import de.danoeh.antennapod.model.feed.Feed;
|
||||
import de.danoeh.antennapod.net.common.AntennapodHttpClient;
|
||||
import okhttp3.CacheControl;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package de.danoeh.antennapod.net.discovery;
|
||||
|
||||
import de.danoeh.antennapod.net.common.AntennapodHttpClient;
|
||||
import de.danoeh.antennapod.net.common.UserAgentInterceptor;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
@ -15,8 +17,6 @@ import java.util.List;
|
|||
import java.util.Locale;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import de.danoeh.antennapod.core.ClientConfig;
|
||||
import de.danoeh.antennapod.core.service.download.AntennapodHttpClient;
|
||||
import io.reactivex.Single;
|
||||
import io.reactivex.SingleOnSubscribe;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
|
@ -100,7 +100,7 @@ public class PodcastIndexPodcastSearcher implements PodcastSearcher {
|
|||
.addHeader("X-Auth-Date", apiHeaderTime)
|
||||
.addHeader("X-Auth-Key", BuildConfig.PODCASTINDEX_API_KEY)
|
||||
.addHeader("Authorization", hashString)
|
||||
.addHeader("User-Agent", ClientConfig.USER_AGENT)
|
||||
.addHeader("User-Agent", UserAgentInterceptor.USER_AGENT)
|
||||
.url(url);
|
||||
return httpReq.build();
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ plugins {
|
|||
id("java-test-fixtures")
|
||||
}
|
||||
apply from: "../../../common.gradle"
|
||||
apply from: "../../../playFlavor.gradle"
|
||||
|
||||
android {
|
||||
namespace "de.danoeh.antennapod.net.download.serviceinterface"
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
package de.danoeh.antennapod.net.download.serviceinterface;
|
||||
|
||||
import android.os.Bundle;
|
||||
import androidx.annotation.NonNull;
|
||||
import de.danoeh.antennapod.model.download.DownloadRequest;
|
||||
import de.danoeh.antennapod.model.feed.Feed;
|
||||
import de.danoeh.antennapod.model.feed.FeedMedia;
|
||||
import de.danoeh.antennapod.net.common.UrlChecker;
|
||||
|
||||
public class DownloadRequestBuilder {
|
||||
private final String destination;
|
||||
private String source;
|
||||
private final String title;
|
||||
private String username;
|
||||
private String password;
|
||||
private String lastModified;
|
||||
private final long feedfileId;
|
||||
private final int feedfileType;
|
||||
private final Bundle arguments = new Bundle();
|
||||
private boolean initiatedByUser = true;
|
||||
|
||||
public DownloadRequestBuilder(@NonNull String destination, @NonNull FeedMedia media) {
|
||||
this.destination = destination;
|
||||
this.source = UrlChecker.prepareUrl(media.getDownload_url());
|
||||
this.title = media.getHumanReadableIdentifier();
|
||||
this.feedfileId = media.getId();
|
||||
this.feedfileType = FeedMedia.FEEDFILETYPE_FEEDMEDIA;
|
||||
}
|
||||
|
||||
public DownloadRequestBuilder(@NonNull String destination, @NonNull Feed feed) {
|
||||
this.destination = destination;
|
||||
this.source = feed.isLocalFeed() ? feed.getDownload_url() : UrlChecker.prepareUrl(feed.getDownload_url());
|
||||
this.title = feed.getHumanReadableIdentifier();
|
||||
this.feedfileId = feed.getId();
|
||||
this.feedfileType = Feed.FEEDFILETYPE_FEED;
|
||||
arguments.putInt(DownloadRequest.REQUEST_ARG_PAGE_NR, feed.getPageNr());
|
||||
}
|
||||
|
||||
public DownloadRequestBuilder withInitiatedByUser(boolean initiatedByUser) {
|
||||
this.initiatedByUser = initiatedByUser;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void setSource(String source) {
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
public void setForce(boolean force) {
|
||||
if (force) {
|
||||
lastModified = null;
|
||||
}
|
||||
}
|
||||
|
||||
public DownloadRequestBuilder lastModified(String lastModified) {
|
||||
this.lastModified = lastModified;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DownloadRequestBuilder withAuthentication(String username, String password) {
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DownloadRequest build() {
|
||||
return new DownloadRequest(destination, source, title, feedfileId, feedfileType,
|
||||
lastModified, username, password, false, arguments, initiatedByUser);
|
||||
}
|
||||
}
|
|
@ -3,6 +3,7 @@ package de.danoeh.antennapod.net.download.serviceinterface;
|
|||
import android.os.Bundle;
|
||||
import android.os.Parcel;
|
||||
|
||||
import de.danoeh.antennapod.model.download.DownloadRequest;
|
||||
import de.danoeh.antennapod.model.feed.FeedMedia;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
@ -14,7 +15,7 @@ import static org.junit.Assert.assertEquals;
|
|||
import static org.junit.Assert.assertNotEquals;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class DownloadRequestTest {
|
||||
public class DownloadRequestBuilderTest {
|
||||
|
||||
@Test
|
||||
public void parcelInArrayListTest_WithAuth() {
|
||||
|
@ -40,15 +41,15 @@ public class DownloadRequestTest {
|
|||
String username = "testUser";
|
||||
String password = "testPassword";
|
||||
FeedMedia item = createFeedItem(1);
|
||||
DownloadRequest request1 = new DownloadRequest.Builder(destStr, item)
|
||||
DownloadRequest request1 = new DownloadRequestBuilder(destStr, item)
|
||||
.withAuthentication(username, password)
|
||||
.build();
|
||||
|
||||
DownloadRequest request2 = new DownloadRequest.Builder(destStr, item)
|
||||
DownloadRequest request2 = new DownloadRequestBuilder(destStr, item)
|
||||
.withAuthentication(username, password)
|
||||
.build();
|
||||
|
||||
DownloadRequest request3 = new DownloadRequest.Builder(destStr, item)
|
||||
DownloadRequest request3 = new DownloadRequestBuilder(destStr, item)
|
||||
.withAuthentication("diffUsername", "diffPassword")
|
||||
.build();
|
||||
|
||||
|
@ -65,12 +66,12 @@ public class DownloadRequestTest {
|
|||
{ // test DownloadRequests to parcel
|
||||
String destStr = "file://location/media.mp3";
|
||||
FeedMedia item1 = createFeedItem(1);
|
||||
DownloadRequest request1 = new DownloadRequest.Builder(destStr, item1)
|
||||
DownloadRequest request1 = new DownloadRequestBuilder(destStr, item1)
|
||||
.withAuthentication(username1, password1)
|
||||
.build();
|
||||
|
||||
FeedMedia item2 = createFeedItem(2);
|
||||
DownloadRequest request2 = new DownloadRequest.Builder(destStr, item2)
|
||||
DownloadRequest request2 = new DownloadRequestBuilder(destStr, item2)
|
||||
.withAuthentication(username2, password2)
|
||||
.build();
|
||||
|
|
@ -1177,18 +1177,6 @@ public class PodDBAdapter {
|
|||
return db.rawQuery(query, null);
|
||||
}
|
||||
|
||||
public Cursor getImageAuthenticationCursor(final String imageUrl) {
|
||||
String downloadUrl = DatabaseUtils.sqlEscapeString(imageUrl);
|
||||
final String query = ""
|
||||
+ "SELECT " + KEY_USERNAME + "," + KEY_PASSWORD + " FROM " + TABLE_NAME_FEED_ITEMS
|
||||
+ " INNER JOIN " + TABLE_NAME_FEEDS
|
||||
+ " ON " + TABLE_NAME_FEED_ITEMS + "." + KEY_FEED + " = " + TABLE_NAME_FEEDS + "." + KEY_ID
|
||||
+ " WHERE " + TABLE_NAME_FEED_ITEMS + "." + KEY_IMAGE_URL + "=" + downloadUrl
|
||||
+ " UNION SELECT " + KEY_USERNAME + "," + KEY_PASSWORD + " FROM " + TABLE_NAME_FEEDS
|
||||
+ " WHERE " + TABLE_NAME_FEEDS + "." + KEY_IMAGE_URL + "=" + downloadUrl;
|
||||
return db.rawQuery(query, null);
|
||||
}
|
||||
|
||||
public final Cursor getMonthlyStatisticsCursor() {
|
||||
final String query = "SELECT SUM(" + KEY_PLAYED_DURATION + ") AS total_duration"
|
||||
+ ", strftime('%m', datetime(" + KEY_LAST_PLAYED_TIME + "/1000, 'unixepoch')) AS month"
|
||||
|
|
|
@ -10,7 +10,7 @@ android {
|
|||
|
||||
dependencies {
|
||||
implementation project(":model")
|
||||
implementation project(":core")
|
||||
implementation project(':net:common')
|
||||
implementation project(':storage:preferences')
|
||||
|
||||
implementation "androidx.palette:palette:$paletteVersion"
|
||||
|
|
|
@ -10,10 +10,10 @@ import com.bumptech.glide.load.model.ModelLoader;
|
|||
import com.bumptech.glide.load.model.ModelLoaderFactory;
|
||||
import com.bumptech.glide.load.model.MultiModelLoaderFactory;
|
||||
import com.bumptech.glide.signature.ObjectKey;
|
||||
import de.danoeh.antennapod.core.service.download.AntennapodHttpClient;
|
||||
import de.danoeh.antennapod.core.util.NetworkUtils;
|
||||
import de.danoeh.antennapod.model.feed.Feed;
|
||||
import de.danoeh.antennapod.model.feed.FeedMedia;
|
||||
import de.danoeh.antennapod.net.common.AntennapodHttpClient;
|
||||
import de.danoeh.antennapod.net.common.NetworkUtils;
|
||||
import okhttp3.Interceptor;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Protocol;
|
||||
|
|
|
@ -9,13 +9,14 @@ import com.bumptech.glide.load.model.ModelLoader;
|
|||
import com.bumptech.glide.load.model.ModelLoaderFactory;
|
||||
import com.bumptech.glide.load.model.MultiModelLoaderFactory;
|
||||
import com.bumptech.glide.signature.ObjectKey;
|
||||
import de.danoeh.antennapod.core.service.download.AntennapodHttpClient;
|
||||
import de.danoeh.antennapod.model.feed.EmbeddedChapterImage;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import de.danoeh.antennapod.net.common.AntennapodHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
|
Loading…
Reference in New Issue