From 5d70a3cc38f561a95050fb552194d8b4ab4ef56d Mon Sep 17 00:00:00 2001 From: Nathan Mascitelli Date: Fri, 7 Feb 2020 11:42:46 -0500 Subject: Rename generatedBySystem to initiatedByUser --- .../core/service/download/DownloadRequest.java | 24 ++++++------- .../download/DownloadServiceNotification.java | 2 +- .../core/service/download/DownloadStatus.java | 41 ++++++---------------- .../core/service/download/Downloader.java | 2 +- .../service/download/handler/FeedParserTask.java | 6 ++-- .../download/handler/MediaDownloadedHandler.java | 2 +- .../core/storage/APDownloadAlgorithm.java | 2 +- .../de/danoeh/antennapod/core/storage/DBTasks.java | 39 ++++++++++---------- .../antennapod/core/storage/DownloadRequester.java | 25 +++++++------ .../antennapod/core/storage/PodDBAdapter.java | 2 +- 10 files changed, 61 insertions(+), 84 deletions(-) (limited to 'core/src') 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 e1c727db5..9053f51bf 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 @@ -29,7 +29,7 @@ public class DownloadRequest implements Parcelable { private long size; private int statusMsg; private boolean mediaEnqueued; - private boolean generatedBySystem; + private boolean initiatedByUser; public DownloadRequest(@NonNull String destination, @NonNull String source, @@ -40,7 +40,7 @@ public class DownloadRequest implements Parcelable { String password, boolean deleteOnFailure, Bundle arguments, - boolean generatedBySystem) { + boolean initiatedByUser) { this(destination, source, title, @@ -52,7 +52,7 @@ public class DownloadRequest implements Parcelable { password, false, arguments, - generatedBySystem); + initiatedByUser); } private DownloadRequest(Builder builder) { @@ -67,7 +67,7 @@ public class DownloadRequest implements Parcelable { builder.password, false, (builder.arguments != null) ? builder.arguments : new Bundle(), - builder.generatedBySystem); + builder.initiatedByUser); } private DownloadRequest(Parcel in) { @@ -96,7 +96,7 @@ public class DownloadRequest implements Parcelable { String password, boolean mediaEnqueued, Bundle arguments, - boolean generatedBySystem) { + boolean initiatedByUser) { this.destination = destination; this.source = source; this.title = title; @@ -108,7 +108,7 @@ public class DownloadRequest implements Parcelable { this.password = password; this.mediaEnqueued = mediaEnqueued; this.arguments = arguments; - this.generatedBySystem = generatedBySystem; + this.initiatedByUser = initiatedByUser; } @Override @@ -134,7 +134,7 @@ public class DownloadRequest implements Parcelable { dest.writeString(nonNullString(password)); dest.writeByte((mediaEnqueued) ? (byte) 1 : 0); dest.writeBundle(arguments); - dest.writeByte(generatedBySystem ? (byte)1 : 0); + dest.writeByte(initiatedByUser ? (byte)1 : 0); } private static String nonNullString(String str) { @@ -181,7 +181,7 @@ public class DownloadRequest implements Parcelable { if (username != null ? !username.equals(that.username) : that.username != null) return false; if (mediaEnqueued != that.mediaEnqueued) return false; - if (generatedBySystem != that.generatedBySystem) return false; + if (initiatedByUser != that.initiatedByUser) return false; return true; } @@ -287,7 +287,7 @@ public class DownloadRequest implements Parcelable { return mediaEnqueued; } - public boolean isGeneratedBySystem() { return generatedBySystem; } + public boolean isInitiatedByUser() { return initiatedByUser; } /** * Set to true if the media is enqueued because of this download. @@ -312,15 +312,15 @@ public class DownloadRequest implements Parcelable { private final long feedfileId; private final int feedfileType; private Bundle arguments; - private boolean generatedBySystem; + private boolean initiatedByUser; - public Builder(@NonNull String destination, @NonNull FeedFile item, boolean generatedBySystem) { + public Builder(@NonNull String destination, @NonNull FeedFile item, boolean initiatedByUser) { this.destination = destination; this.source = URLChecker.prepareURL(item.getDownload_url()); this.title = item.getHumanReadableIdentifier(); this.feedfileId = item.getId(); this.feedfileType = item.getTypeAsInt(); - this.generatedBySystem = generatedBySystem; + this.initiatedByUser = initiatedByUser; } public Builder deleteOnFailure(boolean deleteOnFailure) { 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 f83d30db0..ff6eb3c76 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 @@ -110,7 +110,7 @@ public class DownloadServiceNotification { } else if (!status.isCancelled()) { failedDownloads++; } - if (failedDownloads > 0 || showAutoDownloadReport && status.isGeneratedBySystem() && status.getFeedfileType() == FeedMedia.FEEDFILETYPE_FEEDMEDIA) { + if (failedDownloads > 0 || showAutoDownloadReport && !status.isInitiatedByUser() && status.getFeedfileType() == FeedMedia.FEEDFILETYPE_FEEDMEDIA) { createReport = true; } } 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 cefb95c1e..78ac8ecea 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 @@ -41,7 +41,7 @@ public class DownloadStatus { * FEEDFILETYPE_FEEDIMAGE or FEEDFILETYPE_FEEDMEDIA */ private final int feedfileType; - private final boolean generatedBySystem; + private final boolean initiatedByUser; // ------------------------------------ NOT STORED IN DB private boolean done; @@ -52,7 +52,7 @@ public class DownloadStatus { boolean successful, boolean cancelled, String reasonDetailed, - boolean generatedBySystem) { + boolean initiatedByUser) { this(0, request.getTitle(), request.getFeedfileId(), @@ -63,7 +63,7 @@ public class DownloadStatus { reason, new Date(), reasonDetailed, - generatedBySystem); + initiatedByUser); } /** Constructor for creating new completed downloads. */ @@ -72,7 +72,7 @@ public class DownloadStatus { DownloadError reason, boolean successful, String reasonDetailed, - boolean generatedBySystem) { + boolean initiatedByUser) { this(0, title, feedfile.getId(), @@ -83,28 +83,7 @@ public class DownloadStatus { reason, new Date(), reasonDetailed, - generatedBySystem); - } - - /** Constructor for creating new completed downloads. */ - public DownloadStatus(long feedfileId, - int feedfileType, - String title, - DownloadError reason, - boolean successful, - String reasonDetailed, - boolean generatedBySystem) { - this(0, - title, - feedfileId, - feedfileType, - successful, - false, - true, - reason, - new Date(), - reasonDetailed, - generatedBySystem); + initiatedByUser); } public static DownloadStatus fromCursor(Cursor cursor) { @@ -116,7 +95,7 @@ public class DownloadStatus { int indexReason = cursor.getColumnIndex(PodDBAdapter.KEY_REASON); int indexCompletionDate = cursor.getColumnIndex(PodDBAdapter.KEY_COMPLETION_DATE); int indexReasonDetailed = cursor.getColumnIndex(PodDBAdapter.KEY_REASON_DETAILED); - int indexGeneratedBySystem = cursor.getColumnIndex(PodDBAdapter.KEY_GENERATED_BY_SYSTEM); + int indexInitiatedByUser = cursor.getColumnIndex(PodDBAdapter.KEY_INITIATED_BY_USER); return new DownloadStatus(cursor.getLong(indexId), cursor.getString(indexTitle), @@ -128,7 +107,7 @@ public class DownloadStatus { DownloadError.fromCode(cursor.getInt(indexReason)), new Date(cursor.getLong(indexCompletionDate)), cursor.getString(indexReasonDetailed), - cursor.getInt(indexGeneratedBySystem) > 0); + cursor.getInt(indexInitiatedByUser) > 0); } private DownloadStatus(long id, @@ -141,7 +120,7 @@ public class DownloadStatus { DownloadError reason, Date completionDate, String reasonDetailed, - boolean generatedBySystem) { + boolean initiatedByUser) { this.id = id; this.title = title; this.feedfileId = feedfileId; @@ -152,7 +131,7 @@ public class DownloadStatus { this.completionDate = (Date) completionDate.clone(); this.reasonDetailed = reasonDetailed; this.feedfileType = feedfileType; - this.generatedBySystem = generatedBySystem; + this.initiatedByUser = initiatedByUser; } @Override @@ -197,7 +176,7 @@ public class DownloadStatus { return feedfileType; } - public boolean isGeneratedBySystem() { return generatedBySystem; } + public boolean isInitiatedByUser() { return initiatedByUser; } public boolean isDone() { return done; diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/Downloader.java b/core/src/main/java/de/danoeh/antennapod/core/service/download/Downloader.java index f5bf0d1d1..51190a82a 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/download/Downloader.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/download/Downloader.java @@ -29,7 +29,7 @@ public abstract class Downloader implements Callable { this.request = request; this.request.setStatusMsg(R.string.download_pending); this.cancelled = false; - this.result = new DownloadStatus(request, null, false, false, null, request.isGeneratedBySystem()); + this.result = new DownloadStatus(request, null, false, false, null, request.isInitiatedByUser()); } protected abstract void download(); diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/handler/FeedParserTask.java b/core/src/main/java/de/danoeh/antennapod/core/service/download/handler/FeedParserTask.java index 552fa3057..6bb813c0e 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/download/handler/FeedParserTask.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/download/handler/FeedParserTask.java @@ -79,11 +79,11 @@ public class FeedParserTask implements Callable { if (successful) { downloadStatus = new DownloadStatus(feed, feed.getHumanReadableIdentifier(), DownloadError.SUCCESS, - successful, reasonDetailed, request.isGeneratedBySystem()); + successful, reasonDetailed, request.isInitiatedByUser()); return result; } else { - downloadStatus = new DownloadStatus(feed, request.getTitle(), reason, successful, reasonDetailed, - request.isGeneratedBySystem()); + downloadStatus = new DownloadStatus(feed, feed.getHumanReadableIdentifier(), reason, successful, + reasonDetailed, request.isInitiatedByUser()); return null; } } diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/handler/MediaDownloadedHandler.java b/core/src/main/java/de/danoeh/antennapod/core/service/download/handler/MediaDownloadedHandler.java index aec53207b..26a0e416e 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/download/handler/MediaDownloadedHandler.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/download/handler/MediaDownloadedHandler.java @@ -96,7 +96,7 @@ public class MediaDownloadedHandler implements Runnable { } catch (ExecutionException e) { Log.e(TAG, "ExecutionException in MediaHandlerThread: " + e.getMessage()); updatedStatus = new DownloadStatus(media, media.getEpisodeTitle(), - DownloadError.ERROR_DB_ACCESS_ERROR, false, e.getMessage(), request.isGeneratedBySystem()); + DownloadError.ERROR_DB_ACCESS_ERROR, false, e.getMessage(), request.isInitiatedByUser()); } if (GpodnetPreferences.loggedIn() && item != null) { diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/APDownloadAlgorithm.java b/core/src/main/java/de/danoeh/antennapod/core/storage/APDownloadAlgorithm.java index f0f4ed08d..7ec4db5dd 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/storage/APDownloadAlgorithm.java +++ b/core/src/main/java/de/danoeh/antennapod/core/storage/APDownloadAlgorithm.java @@ -92,7 +92,7 @@ public class APDownloadAlgorithm implements AutomaticDownloadAlgorithm { Log.d(TAG, "Enqueueing " + itemsToDownload.length + " items for download"); try { - DownloadRequester.getInstance().downloadMedia(false, context, true, itemsToDownload); + DownloadRequester.getInstance().downloadMedia(false, context, false, itemsToDownload); } catch (DownloadRequestException e) { e.printStackTrace(); } diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/DBTasks.java b/core/src/main/java/de/danoeh/antennapod/core/storage/DBTasks.java index 6c562b972..9bad98135 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/storage/DBTasks.java +++ b/core/src/main/java/de/danoeh/antennapod/core/storage/DBTasks.java @@ -148,12 +148,12 @@ public final class DBTasks { } catch (DownloadRequestException e) { e.printStackTrace(); DBWriter.addDownloadStatus( - new DownloadStatus(feed, feed - .getHumanReadableIdentifier(), - DownloadError.ERROR_REQUEST_ERROR, false, e - .getMessage(), - true - ) + new DownloadStatus(feed, + feed.getHumanReadableIdentifier(), + DownloadError.ERROR_REQUEST_ERROR, + false, + e.getMessage(), + false) ); } } @@ -169,16 +169,16 @@ public final class DBTasks { */ public static void forceRefreshCompleteFeed(final Context context, final Feed feed) { try { - refreshFeed(context, feed, true, true, true); + refreshFeed(context, feed, true, true, false); } catch (DownloadRequestException e) { e.printStackTrace(); DBWriter.addDownloadStatus( - new DownloadStatus(feed, feed - .getHumanReadableIdentifier(), - DownloadError.ERROR_REQUEST_ERROR, false, e - .getMessage(), - true - ) + new DownloadStatus(feed, + feed.getHumanReadableIdentifier(), + DownloadError.ERROR_REQUEST_ERROR, + false, + e.getMessage(), + false) ); } } @@ -198,8 +198,7 @@ public final class DBTasks { nextFeed.setPageNr(pageNr); nextFeed.setPaged(true); nextFeed.setId(feed.getId()); - DownloadRequester.getInstance().downloadFeed(context, nextFeed, loadAllPages, false, false - ); + DownloadRequester.getInstance().downloadFeed(context, nextFeed, loadAllPages, false, true); } else { Log.e(TAG, "loadNextPageOfFeed: Feed was either not paged or contained no nextPageLink"); } @@ -215,7 +214,7 @@ public final class DBTasks { private static void refreshFeed(Context context, Feed feed) throws DownloadRequestException { Log.d(TAG, "refreshFeed(feed.id: " + feed.getId() +")"); - refreshFeed(context, feed, false, false, true); + refreshFeed(context, feed, false, false, false); } /** @@ -224,13 +223,13 @@ public final class DBTasks { * @param context Used for requesting the download. * @param feed The Feed object. */ - public static void forceRefreshFeed(Context context, Feed feed, boolean generatedBySystem) + public static void forceRefreshFeed(Context context, Feed feed, boolean initiatedByUser) throws DownloadRequestException { Log.d(TAG, "refreshFeed(feed.id: " + feed.getId() +")"); - refreshFeed(context, feed, false, true, generatedBySystem); + refreshFeed(context, feed, false, true, initiatedByUser); } - private static void refreshFeed(Context context, Feed feed, boolean loadAllPages, boolean force, boolean generatedBySystem) + private static void refreshFeed(Context context, Feed feed, boolean loadAllPages, boolean force, boolean initiatedByUser) throws DownloadRequestException { Feed f; String lastUpdate = feed.hasLastUpdateFailed() ? null : feed.getLastUpdate(); @@ -241,7 +240,7 @@ public final class DBTasks { feed.getPreferences().getUsername(), feed.getPreferences().getPassword()); } f.setId(feed.getId()); - DownloadRequester.getInstance().downloadFeed(context, f, loadAllPages, force, generatedBySystem); + DownloadRequester.getInstance().downloadFeed(context, f, loadAllPages, force, initiatedByUser); } /** 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 9b871da0d..3a59976cf 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 @@ -115,7 +115,7 @@ 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 generatedBySystem) { + 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); @@ -156,7 +156,7 @@ public class DownloadRequester implements DownloadStateProvider { String baseUrl = (container != null) ? container.getDownload_url() : null; item.setDownload_url(URLChecker.prepareURL(item.getDownload_url(), baseUrl)); - DownloadRequest.Builder builder = new DownloadRequest.Builder(dest.toString(), item, generatedBySystem) + DownloadRequest.Builder builder = new DownloadRequest.Builder(dest.toString(), item, initiatedByUser) .withAuthentication(username, password) .lastModified(lastModified) .deleteOnFailure(deleteOnFailure) @@ -191,7 +191,7 @@ public class DownloadRequester implements DownloadStateProvider { * @param loadAllPages Set to true to download all pages */ public synchronized void downloadFeed(Context context, Feed feed, boolean loadAllPages, - boolean force, boolean generatedBySystem) + boolean force, boolean initiatedByUser) throws DownloadRequestException { if (feedFileValid(feed)) { String username = (feed.getPreferences() != null) ? feed.getPreferences().getUsername() : null; @@ -203,7 +203,7 @@ public class DownloadRequester implements DownloadStateProvider { args.putBoolean(REQUEST_ARG_LOAD_ALL_PAGES, loadAllPages); DownloadRequest request = createRequest(feed, null, new File(getFeedfilePath(), getFeedfileName(feed)), - true, username, password, lastModified, true, args, generatedBySystem + true, username, password, lastModified, true, args, initiatedByUser ); if (request != null) { download(context, request); @@ -212,17 +212,17 @@ public class DownloadRequester implements DownloadStateProvider { } public synchronized void downloadFeed(Context context, Feed feed) throws DownloadRequestException { - downloadFeed(context, feed, false, false, false); + downloadFeed(context, feed, false, false, true); } - public synchronized void downloadMedia(@NonNull Context context, boolean generatedBySystem, FeedItem... feedItems) + public synchronized void downloadMedia(@NonNull Context context, boolean initiatedByUser, FeedItem... feedItems) throws DownloadRequestException { - downloadMedia(true, context, generatedBySystem, feedItems); + downloadMedia(true, context, initiatedByUser, feedItems); } @VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE) - public synchronized void downloadMedia(boolean performAutoCleanup, @NonNull Context context, boolean generatedBySystem, + public synchronized void downloadMedia(boolean performAutoCleanup, @NonNull Context context, boolean initiatedByUser, FeedItem... items) throws DownloadRequestException { Log.d(TAG, "downloadMedia() called with: performAutoCleanup = [" + performAutoCleanup @@ -231,7 +231,7 @@ public class DownloadRequester implements DownloadStateProvider { List requests = new ArrayList<>(items.length); for (FeedItem item : items) { try { - DownloadRequest request = createRequest(item.getMedia(), generatedBySystem); + DownloadRequest request = createRequest(item.getMedia(), initiatedByUser); if (request != null) { requests.add(request); } @@ -247,7 +247,7 @@ public class DownloadRequester implements DownloadStateProvider { .getMedia() .getHumanReadableIdentifier(), DownloadError.ERROR_REQUEST_ERROR, - false, e.getMessage(), generatedBySystem + false, e.getMessage(), initiatedByUser ) ); } @@ -257,7 +257,7 @@ public class DownloadRequester implements DownloadStateProvider { } @Nullable - private DownloadRequest createRequest(@Nullable FeedMedia feedmedia, boolean generatedBySystem) + private DownloadRequest createRequest(@Nullable FeedMedia feedmedia, boolean initiatedByUser) throws DownloadRequestException { if (!feedFileValid(feedmedia)) { return null; @@ -279,8 +279,7 @@ public class DownloadRequester implements DownloadStateProvider { } else { dest = new File(getMediafilePath(feedmedia), getMediafilename(feedmedia)); } - return createRequest(feedmedia, feed, - dest, false, username, password, null, false, null, generatedBySystem); + return createRequest(feedmedia, feed, dest, false, username, password, null, false, null, initiatedByUser); } /** diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java b/core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java index f091874c6..a1ce183cc 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java +++ b/core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java @@ -110,7 +110,7 @@ public class PodDBAdapter { public static final String KEY_INCLUDE_FILTER = "include_filter"; public static final String KEY_EXCLUDE_FILTER = "exclude_filter"; public static final String KEY_FEED_PLAYBACK_SPEED = "feed_playback_speed"; - public static final String KEY_GENERATED_BY_SYSTEM = "generated_by_system"; + public static final String KEY_INITIATED_BY_USER = "initiated_by_user"; // Table names static final String TABLE_NAME_FEEDS = "Feeds"; -- cgit v1.2.3