summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadRequest.java82
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadServiceNotification.java9
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadStatus.java71
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/storage/DownloadRequester.java10
-rw-r--r--core/src/main/res/values/strings.xml5
5 files changed, 49 insertions, 128 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadRequest.java b/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadRequest.java
index 9053f51bf..78c4d3f48 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadRequest.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadRequest.java
@@ -31,72 +31,28 @@ public class DownloadRequest implements Parcelable {
private boolean mediaEnqueued;
private boolean initiatedByUser;
- public DownloadRequest(@NonNull String destination,
- @NonNull String source,
- @NonNull String title,
- long feedfileId,
- int feedfileType,
- String username,
- String password,
- boolean deleteOnFailure,
- Bundle arguments,
- boolean initiatedByUser) {
- this(destination,
- source,
- title,
- feedfileId,
- feedfileType,
- null,
- deleteOnFailure,
- username,
- password,
- false,
- arguments,
- initiatedByUser);
+ public DownloadRequest(@NonNull String destination, @NonNull String source, @NonNull String title, long feedfileId,
+ int feedfileType, String username, String password, boolean deleteOnFailure,
+ Bundle arguments, boolean initiatedByUser) {
+ this(destination, source, title, feedfileId, feedfileType, null, deleteOnFailure, username, password, false,
+ arguments, initiatedByUser);
}
private DownloadRequest(Builder builder) {
- this(builder.destination,
- builder.source,
- builder.title,
- builder.feedfileId,
- builder.feedfileType,
- builder.lastModified,
- builder.deleteOnFailure,
- builder.username,
- builder.password,
- false,
- (builder.arguments != null) ? builder.arguments : new Bundle(),
- builder.initiatedByUser);
+ this(builder.destination, builder.source, builder.title, builder.feedfileId, builder.feedfileType,
+ builder.lastModified, builder.deleteOnFailure, builder.username, builder.password, false,
+ builder.arguments != null ? builder.arguments : new Bundle(), builder.initiatedByUser);
}
private DownloadRequest(Parcel in) {
- this(in.readString(),
- in.readString(),
- in.readString(),
- in.readLong(),
- in.readInt(),
- in.readString(),
- in.readByte() > 0,
- 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,
- String lastModified,
- boolean deleteOnFailure,
- String username,
- String password,
- boolean mediaEnqueued,
- Bundle arguments,
- boolean initiatedByUser) {
+ this(in.readString(), in.readString(), in.readString(), in.readLong(), in.readInt(), in.readString(),
+ in.readByte() > 0, 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,
+ String lastModified, boolean deleteOnFailure, String username, String password,
+ boolean mediaEnqueued, Bundle arguments, boolean initiatedByUser) {
this.destination = destination;
this.source = source;
this.title = title;
@@ -134,7 +90,7 @@ public class DownloadRequest implements Parcelable {
dest.writeString(nonNullString(password));
dest.writeByte((mediaEnqueued) ? (byte) 1 : 0);
dest.writeBundle(arguments);
- dest.writeByte(initiatedByUser ? (byte)1 : 0);
+ dest.writeByte(initiatedByUser ? (byte) 1 : 0);
}
private static String nonNullString(String str) {
@@ -287,7 +243,9 @@ public class DownloadRequest implements Parcelable {
return mediaEnqueued;
}
- public boolean isInitiatedByUser() { return initiatedByUser; }
+ public boolean isInitiatedByUser() {
+ return initiatedByUser;
+ }
/**
* Set to true if the media is enqueued because of this download.
diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadServiceNotification.java b/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadServiceNotification.java
index 153effb57..7e8b53732 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadServiceNotification.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadServiceNotification.java
@@ -119,10 +119,11 @@ public class DownloadServiceNotification {
// create notification object
boolean autoDownloadReport = failedDownloads == 0;
- NotificationCompat.Builder builder = new NotificationCompat.Builder(
- context,
- autoDownloadReport ? NotificationUtils.CHANNEL_ID_AUTO_DOWNLOAD : NotificationUtils.CHANNEL_ID_ERROR);
- builder.setTicker(context.getString(R.string.download_report_title))
+ String channelId = autoDownloadReport ? NotificationUtils.CHANNEL_ID_AUTO_DOWNLOAD : NotificationUtils.CHANNEL_ID_ERROR;
+ int titleId = autoDownloadReport ? R.string.auto_download_report_title : R.string.download_report_title;
+
+ NotificationCompat.Builder builder = new NotificationCompat.Builder(context, channelId);
+ builder.setTicker(context.getString(titleId))
.setContentTitle(context.getString(R.string.download_report_content_title))
.setContentText(String.format(
context.getString(R.string.download_report_content),
diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadStatus.java b/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadStatus.java
index bdf98b7a3..bad2ba1ef 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadStatus.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadStatus.java
@@ -47,42 +47,17 @@ public class DownloadStatus {
private boolean done;
private boolean cancelled;
- public DownloadStatus(@NonNull DownloadRequest request,
- DownloadError reason,
- boolean successful,
- boolean cancelled,
- String reasonDetailed) {
- this(0,
- request.getTitle(),
- request.getFeedfileId(),
- request.getFeedfileType(),
- successful,
- cancelled,
- false,
- reason,
- new Date(),
- reasonDetailed,
- request.isInitiatedByUser());
+ public DownloadStatus(@NonNull DownloadRequest request, DownloadError reason, boolean successful, boolean cancelled,
+ String reasonDetailed) {
+ this(0, request.getTitle(), request.getFeedfileId(), request.getFeedfileType(), successful, cancelled, false,
+ reason, new Date(), reasonDetailed, request.isInitiatedByUser());
}
/** Constructor for creating new completed downloads. */
- public DownloadStatus(@NonNull FeedFile feedfile,
- String title,
- DownloadError reason,
- boolean successful,
- String reasonDetailed,
- boolean initiatedByUser) {
- this(0,
- title,
- feedfile.getId(),
- feedfile.getTypeAsInt(),
- successful,
- false,
- true,
- reason,
- new Date(),
- reasonDetailed,
- initiatedByUser);
+ public DownloadStatus(@NonNull FeedFile feedfile, String title, DownloadError reason, boolean successful,
+ String reasonDetailed, boolean initiatedByUser) {
+ this(0, title, feedfile.getId(), feedfile.getTypeAsInt(), successful, false, true, reason, new Date(),
+ reasonDetailed, initiatedByUser);
}
public static DownloadStatus fromCursor(Cursor cursor) {
@@ -95,30 +70,16 @@ public class DownloadStatus {
int indexCompletionDate = cursor.getColumnIndex(PodDBAdapter.KEY_COMPLETION_DATE);
int indexReasonDetailed = cursor.getColumnIndex(PodDBAdapter.KEY_REASON_DETAILED);
- return new DownloadStatus(cursor.getLong(indexId),
- cursor.getString(indexTitle),
- cursor.getLong(indexFeedFile),
- cursor.getInt(indexFileFileType),
- cursor.getInt(indexSuccessful) > 0,
- false,
- true,
- DownloadError.fromCode(cursor.getInt(indexReason)),
- new Date(cursor.getLong(indexCompletionDate)),
- cursor.getString(indexReasonDetailed),
- false);
+ return new DownloadStatus(cursor.getLong(indexId), cursor.getString(indexTitle), cursor.getLong(indexFeedFile),
+ cursor.getInt(indexFileFileType), cursor.getInt(indexSuccessful) > 0, false, true,
+ DownloadError.fromCode(cursor.getInt(indexReason)),
+ new Date(cursor.getLong(indexCompletionDate)),
+ cursor.getString(indexReasonDetailed), false);
}
- private DownloadStatus(long id,
- String title,
- long feedfileId,
- int feedfileType,
- boolean successful,
- boolean cancelled,
- boolean done,
- DownloadError reason,
- Date completionDate,
- String reasonDetailed,
- boolean initiatedByUser) {
+ private DownloadStatus(long id, String title, long feedfileId, int feedfileType, boolean successful,
+ boolean cancelled, boolean done, DownloadError reason, Date completionDate,
+ String reasonDetailed, boolean initiatedByUser) {
this.id = id;
this.title = title;
this.feedfileId = feedfileId;
diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/DownloadRequester.java b/core/src/main/java/de/danoeh/antennapod/core/storage/DownloadRequester.java
index 3a59976cf..6f9e6b056 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/storage/DownloadRequester.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/storage/DownloadRequester.java
@@ -113,9 +113,9 @@ public class DownloadRequester implements DownloadStateProvider {
}
@Nullable
- private DownloadRequest createRequest(FeedFile item, FeedFile container, File dest,
- boolean overwriteIfExists, String username, String password,
- String lastModified, boolean deleteOnFailure, Bundle arguments, boolean initiatedByUser) {
+ private DownloadRequest createRequest(FeedFile item, FeedFile container, File dest, boolean overwriteIfExists,
+ String username, String password, String lastModified,
+ boolean deleteOnFailure, Bundle arguments, boolean initiatedByUser) {
final boolean partiallyDownloadedFileExists = item.getFile_url() != null && new File(item.getFile_url()).exists();
Log.d(TAG, "partiallyDownloadedFileExists: " + partiallyDownloadedFileExists);
@@ -222,8 +222,8 @@ public class DownloadRequester implements DownloadStateProvider {
}
@VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE)
- public synchronized void downloadMedia(boolean performAutoCleanup, @NonNull Context context, boolean initiatedByUser,
- FeedItem... items)
+ public synchronized void downloadMedia(boolean performAutoCleanup, @NonNull Context context,
+ boolean initiatedByUser, FeedItem... items)
throws DownloadRequestException {
Log.d(TAG, "downloadMedia() called with: performAutoCleanup = [" + performAutoCleanup
+ "], #items = [" + items.length + "]");
diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml
index 023bf0310..3f0e62105 100644
--- a/core/src/main/res/values/strings.xml
+++ b/core/src/main/res/values/strings.xml
@@ -236,7 +236,8 @@
<string name="download_error_forbidden">Forbidden</string>
<string name="download_canceled_msg">Download canceled</string>
<string name="download_canceled_autodownload_enabled_msg">Download canceled\nDisabled <i>Auto Download</i> for this item</string>
- <string name="download_report_title">Downloads completed</string>
+ <string name="download_report_title">Downloads completed with error(s)</string>
+ <string name="auto_download_report_title">Downloads completed</string>
<string name="download_report_content_title">Download Report</string>
<string name="download_error_malformed_url">Malformed URL</string>
<string name="download_error_io_error">IO Error</string>
@@ -784,7 +785,7 @@
<string name="notification_channel_error">Errors</string>
<string name="notification_channel_error_description">Shown if something went wrong, for example if download or gpodder sync fails.</string>
<string name="notification_channel_auto_download">Auto Downloads</string>
- <string name="notification_channel_error_auto_download">Shown when episodes are automatically downloaded.</string>
+ <string name="notification_channel_error_auto_download">Shown when episodes have been automatically downloaded.</string>
<!-- Widget settings -->
<string name="widget_settings">Widget settings</string>