From 6d7bfef8a5fe8180f13904739996bb2b8de8a0d4 Mon Sep 17 00:00:00 2001 From: ByteHamster Date: Fri, 5 May 2023 23:09:03 +0200 Subject: Download Service Rewrite (#6420) --- .../DownloadAuthenticationActivityStarter.java | 39 ---------------------- .../ui/appstartintent/MainActivityStarter.java | 9 +++++ .../antennapod/ui/common/CircularProgressBar.java | 11 +++++- ui/i18n/src/main/res/values/strings.xml | 18 ++++------ .../main/res/drawable/ic_notification_cancel.xml | 5 --- .../src/main/res/drawable/ic_notification_key.xml | 6 ---- 6 files changed, 25 insertions(+), 63 deletions(-) delete mode 100644 ui/app-start-intent/src/main/java/de/danoeh/antennapod/ui/appstartintent/DownloadAuthenticationActivityStarter.java delete mode 100644 ui/png-icons/src/main/res/drawable/ic_notification_cancel.xml delete mode 100644 ui/png-icons/src/main/res/drawable/ic_notification_key.xml (limited to 'ui') diff --git a/ui/app-start-intent/src/main/java/de/danoeh/antennapod/ui/appstartintent/DownloadAuthenticationActivityStarter.java b/ui/app-start-intent/src/main/java/de/danoeh/antennapod/ui/appstartintent/DownloadAuthenticationActivityStarter.java deleted file mode 100644 index 03c5e915e..000000000 --- a/ui/app-start-intent/src/main/java/de/danoeh/antennapod/ui/appstartintent/DownloadAuthenticationActivityStarter.java +++ /dev/null @@ -1,39 +0,0 @@ -package de.danoeh.antennapod.ui.appstartintent; - -import android.app.PendingIntent; -import android.content.Context; -import android.content.Intent; -import android.os.Build; -import android.os.Parcelable; - -/** - * Launches the download authentication activity of the app with specific arguments. - * Does not require a dependency on the actual implementation of the activity. - */ -public class DownloadAuthenticationActivityStarter { - public static final String INTENT = "de.danoeh.antennapod.intents.DOWNLOAD_AUTH_ACTIVITY"; - public static final String EXTRA_DOWNLOAD_REQUEST = "download_request"; - - private final Intent intent; - private final Context context; - private final long feedFileId; - - public DownloadAuthenticationActivityStarter(Context context, long feedFileId, Parcelable downloadRequest) { - this.context = context; - this.feedFileId = feedFileId; - intent = new Intent(INTENT); - intent.setAction("request" + feedFileId); - intent.putExtra(EXTRA_DOWNLOAD_REQUEST, downloadRequest); - intent.setPackage(context.getPackageName()); - } - - public Intent getIntent() { - return intent; - } - - public PendingIntent getPendingIntent() { - return PendingIntent.getActivity(context.getApplicationContext(), - ("downloadAuth" + feedFileId).hashCode(), getIntent(), - PendingIntent.FLAG_ONE_SHOT | (Build.VERSION.SDK_INT >= 23 ? PendingIntent.FLAG_IMMUTABLE : 0)); - } -} diff --git a/ui/app-start-intent/src/main/java/de/danoeh/antennapod/ui/appstartintent/MainActivityStarter.java b/ui/app-start-intent/src/main/java/de/danoeh/antennapod/ui/appstartintent/MainActivityStarter.java index 1463978ee..c635ff0cc 100644 --- a/ui/app-start-intent/src/main/java/de/danoeh/antennapod/ui/appstartintent/MainActivityStarter.java +++ b/ui/app-start-intent/src/main/java/de/danoeh/antennapod/ui/appstartintent/MainActivityStarter.java @@ -17,6 +17,7 @@ public class MainActivityStarter { public static final String EXTRA_ADD_TO_BACK_STACK = "add_to_back_stack"; public static final String EXTRA_FRAGMENT_TAG = "fragment_tag"; public static final String EXTRA_OPEN_DRAWER = "open_drawer"; + public static final String EXTRA_OPEN_DOWNLOAD_LOGS = "open_download_logs"; public static final String EXTRA_FRAGMENT_ARGS = "fragment_args"; private final Intent intent; @@ -30,6 +31,9 @@ public class MainActivityStarter { } public Intent getIntent() { + if (fragmentArgs != null) { + intent.putExtra(EXTRA_FRAGMENT_ARGS, fragmentArgs); + } return intent; } @@ -67,6 +71,11 @@ public class MainActivityStarter { return this; } + public MainActivityStarter withDownloadLogsOpen() { + intent.putExtra(EXTRA_OPEN_DOWNLOAD_LOGS, true); + return this; + } + public MainActivityStarter withFragmentArgs(String name, boolean value) { if (fragmentArgs == null) { fragmentArgs = new Bundle(); diff --git a/ui/common/src/main/java/de/danoeh/antennapod/ui/common/CircularProgressBar.java b/ui/common/src/main/java/de/danoeh/antennapod/ui/common/CircularProgressBar.java index a693c28b0..42f63bd9d 100644 --- a/ui/common/src/main/java/de/danoeh/antennapod/ui/common/CircularProgressBar.java +++ b/ui/common/src/main/java/de/danoeh/antennapod/ui/common/CircularProgressBar.java @@ -4,7 +4,9 @@ import android.content.Context; import android.content.res.TypedArray; import android.graphics.Canvas; import android.graphics.Color; +import android.graphics.DashPathEffect; import android.graphics.Paint; +import android.graphics.PathEffect; import android.graphics.RectF; import android.util.AttributeSet; import android.view.View; @@ -13,11 +15,13 @@ import androidx.annotation.Nullable; public class CircularProgressBar extends View { public static final float MINIMUM_PERCENTAGE = 0.005f; public static final float MAXIMUM_PERCENTAGE = 1 - MINIMUM_PERCENTAGE; + private static final PathEffect DASHED = new DashPathEffect(new float[] {5f, 5f}, 0f); private final Paint paintBackground = new Paint(); private final Paint paintProgress = new Paint(); private float percentage = 0; private float targetPercentage = 0; + private boolean isIndeterminate = false; private Object tag = null; private final RectF bounds = new RectF(); @@ -73,9 +77,10 @@ public class CircularProgressBar extends View { float padding = getHeight() * 0.07f; paintBackground.setStrokeWidth(getHeight() * 0.02f); + paintBackground.setPathEffect(isIndeterminate ? DASHED : null); paintProgress.setStrokeWidth(padding); bounds.set(padding, padding, getWidth() - padding, getHeight() - padding); - canvas.drawArc(bounds, 0, 360, false, paintBackground); + canvas.drawArc(bounds, -90, 360, false, paintBackground); if (MINIMUM_PERCENTAGE <= percentage && percentage <= MAXIMUM_PERCENTAGE) { canvas.drawArc(bounds, -90, percentage * 360, false, paintProgress); @@ -92,4 +97,8 @@ public class CircularProgressBar extends View { invalidate(); } } + + public void setIndeterminate(boolean indeterminate) { + isIndeterminate = indeterminate; + } } diff --git a/ui/i18n/src/main/res/values/strings.xml b/ui/i18n/src/main/res/values/strings.xml index 59fc8b4e5..1959a2252 100644 --- a/ui/i18n/src/main/res/values/strings.xml +++ b/ui/i18n/src/main/res/values/strings.xml @@ -130,7 +130,6 @@ Off Light Heavy - %1$d parallel downloads Always Never Add to Inbox @@ -239,7 +238,6 @@ %d episodes marked as unplayed. Add to Queue - Added to Queue %d episode added to queue. %d episodes added to queue. @@ -266,6 +264,8 @@ Download running Details %1$s \n\nTechnical reason: \n%2$s \n\nFile URL:\n%3$s + Download of \"%1$s\" failed. Will be retried later. + Download of \"%1$s\" failed. Tap to view details. Storage Device not found There is not enough space left on your device. @@ -277,7 +277,7 @@ The podcast host\'s server does not know where to find the file. It may have been deleted. Connection Error Cannot find the server. Check if the address is typed correctly and if you have a working network connection. - Authentication Error + Authentication Error. Make sure that username and password are correct. File Type Error The podcast host\'s server refuses to respond. Download canceled @@ -285,7 +285,6 @@ The download was blocked by another app on your device (like a VPN or ad blocker). Unable to establish a secure connection. This can mean that another app on your device (like a VPN or an ad blocker) blocked the download, or that something is wrong with the server certificates. Downloads completed with error(s) - Auto-downloads completed IO Error Request Error Database Access Error @@ -293,8 +292,6 @@ %d download left %d downloads left - Completing… - Downloading podcast data Refreshing podcasts Downloading episodes Unknown Title @@ -303,16 +300,14 @@ No podcast was provided that could be shown. The suggested podcast did not have an RSS link, AntennaPod found a podcast that could match Authentication required - The resource you requested requires a username and a password Confirm Mobile Download - Downloading over mobile data connection is disabled in the settings.\n\nYou can choose to either only add the episode to the queue or you can allow downloading temporarily.\n\nYour choice will be remembered for 10 minutes. - Downloading over mobile data connection is disabled in the settings.\n\nDo you want to allow downloading temporarily?\n\nYour choice will be remembered for 10 minutes. + Downloading over mobile data connection is disabled in the settings. AntennaPod can download the episode later automatically when Wi-Fi is available. + Download later + Download anyway Confirm Mobile streaming Streaming over mobile data connection is disabled in the settings. Tap to stream anyway. Always Once - Enqueue - Allow temporarily @@ -453,7 +448,6 @@ Allow automatic download only for selected Wi-Fi networks. Download when not charging Allow automatic download when the battery is not charging - Parallel Downloads Episode Cache Total number of downloaded episodes cached on the device. Automatic download will be suspended if this number is reached. Use Episode Cover diff --git a/ui/png-icons/src/main/res/drawable/ic_notification_cancel.xml b/ui/png-icons/src/main/res/drawable/ic_notification_cancel.xml deleted file mode 100644 index a5480c71f..000000000 --- a/ui/png-icons/src/main/res/drawable/ic_notification_cancel.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - diff --git a/ui/png-icons/src/main/res/drawable/ic_notification_key.xml b/ui/png-icons/src/main/res/drawable/ic_notification_key.xml deleted file mode 100644 index c8a817eeb..000000000 --- a/ui/png-icons/src/main/res/drawable/ic_notification_key.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - -- cgit v1.2.3