summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorByteHamster <ByteHamster@users.noreply.github.com>2023-02-19 11:48:48 +0100
committerGitHub <noreply@github.com>2023-02-19 11:48:48 +0100
commitc98194f519c66e5af1575b1c6ffac5af16594141 (patch)
tree20ee8accada974c3b1f30cf130c1d782ef5dac17 /core
parentcfb974524652c16d96a8f804a525826fad27aee7 (diff)
downloadAntennaPod-c98194f519c66e5af1575b1c6ffac5af16594141.zip
Remove another global callback object (#6316)
Diffstat (limited to 'core')
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/ClientConfig.java2
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/DownloadServiceCallbacks.java54
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadServiceNotification.java36
3 files changed, 31 insertions, 61 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/ClientConfig.java b/core/src/main/java/de/danoeh/antennapod/core/ClientConfig.java
index 9dab98939..360c8c9e2 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/ClientConfig.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/ClientConfig.java
@@ -11,6 +11,4 @@ public class ClientConfig {
public static String USER_AGENT;
public static ApplicationCallbacks applicationCallbacks;
-
- public static DownloadServiceCallbacks downloadServiceCallbacks;
}
diff --git a/core/src/main/java/de/danoeh/antennapod/core/DownloadServiceCallbacks.java b/core/src/main/java/de/danoeh/antennapod/core/DownloadServiceCallbacks.java
deleted file mode 100644
index 53ed63c2d..000000000
--- a/core/src/main/java/de/danoeh/antennapod/core/DownloadServiceCallbacks.java
+++ /dev/null
@@ -1,54 +0,0 @@
-package de.danoeh.antennapod.core;
-
-import android.app.PendingIntent;
-import android.content.Context;
-
-import de.danoeh.antennapod.net.download.serviceinterface.DownloadRequest;
-
-/**
- * Callbacks for the DownloadService of the core module.
- */
-public interface DownloadServiceCallbacks {
-
- /**
- * Returns a PendingIntent for a notification the main notification of the DownloadService.
- * <p/>
- * The PendingIntent takes the users to a screen where they can observe all currently running
- * downloads.
- *
- * @return A non-null PendingIntent for the notification.
- */
- PendingIntent getNotificationContentIntent(Context context);
-
- /**
- * Returns a PendingIntent for a notification that tells the user to enter a username
- * or a password for a requested download.
- * <p/>
- * The PendingIntent takes users to an Activity that lets the user enter their username
- * and password to retry the download.
- *
- * @return A non-null PendingIntent for the notification.
- */
- PendingIntent getAuthentificationNotificationContentIntent(Context context, DownloadRequest request);
-
- /**
- * Returns a PendingIntent for notification that notifies the user about the completion of downloads
- * along with information about failed and successful downloads.
- * <p/>
- * The PendingIntent takes users to an activity where they can look at all successful and failed downloads.
- *
- * @return A non-null PendingIntent for the notification
- */
- PendingIntent getReportNotificationContentIntent(Context context);
-
- /**
- * Returns a PendingIntent for notification that notifies the user about the episodes that have been automatically
- * downloaded.
- * <p/>
- * The PendingIntent takes users to an activity where they can look at their episode queue.
- *
- * @return A non-null PendingIntent for the notification
- */
- PendingIntent getAutoDownloadReportNotificationContentIntent(Context context);
-}
-
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 fd24a716e..c06b0e31d 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
@@ -4,9 +4,10 @@ import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
+import android.content.Intent;
+import android.os.Build;
import android.util.Log;
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;
@@ -14,6 +15,8 @@ import de.danoeh.antennapod.model.feed.Feed;
import de.danoeh.antennapod.model.feed.FeedMedia;
import de.danoeh.antennapod.core.util.gui.NotificationUtils;
import de.danoeh.antennapod.net.download.serviceinterface.DownloadRequest;
+import de.danoeh.antennapod.ui.appstartintent.DownloadAuthenticationActivityStarter;
+import de.danoeh.antennapod.ui.appstartintent.MainActivityStarter;
import java.util.List;
@@ -34,7 +37,7 @@ public class DownloadServiceNotification {
.setWhen(0)
.setOnlyAlertOnce(true)
.setShowWhen(false)
- .setContentIntent(ClientConfig.downloadServiceCallbacks.getNotificationContentIntent(context))
+ .setContentIntent(getNotificationContentIntent(context))
.setSmallIcon(R.drawable.ic_notification_sync);
notificationCompatBuilder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC);
@@ -185,14 +188,14 @@ public class DownloadServiceNotification {
channelId = NotificationUtils.CHANNEL_ID_AUTO_DOWNLOAD;
titleId = R.string.auto_download_report_title;
iconId = R.drawable.ic_notification_new;
- intent = ClientConfig.downloadServiceCallbacks.getAutoDownloadReportNotificationContentIntent(context);
+ intent = getAutoDownloadReportNotificationContentIntent(context);
id = R.id.notification_auto_download_report;
content = createAutoDownloadNotificationContent(reportQueue);
} else {
channelId = NotificationUtils.CHANNEL_ID_DOWNLOAD_ERROR;
titleId = R.string.download_report_title;
iconId = R.drawable.ic_notification_sync_error;
- intent = ClientConfig.downloadServiceCallbacks.getReportNotificationContentIntent(context);
+ intent = getReportNotificationContentIntent(context);
id = R.id.notification_download_report;
content = createFailedDownloadNotificationContent(reportQueue);
}
@@ -226,9 +229,32 @@ public class DownloadServiceNotification {
+ ": " + resourceTitle))
.setSmallIcon(R.drawable.ic_notification_key)
.setAutoCancel(true)
- .setContentIntent(ClientConfig.downloadServiceCallbacks.getAuthentificationNotificationContentIntent(context, downloadRequest));
+ .setContentIntent(new DownloadAuthenticationActivityStarter(
+ context, downloadRequest.getFeedfileId(), downloadRequest).getPendingIntent());
builder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC);
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify(downloadRequest.getSource().hashCode(), builder.build());
}
+
+ public PendingIntent getReportNotificationContentIntent(Context context) {
+ Intent intent = new MainActivityStarter(context)
+ .withFragmentLoaded("DownloadsFragment")
+ .withFragmentArgs("show_logs", true)
+ .getIntent();
+ return PendingIntent.getActivity(context, R.id.pending_intent_download_service_report, intent,
+ PendingIntent.FLAG_UPDATE_CURRENT | (Build.VERSION.SDK_INT >= 23 ? PendingIntent.FLAG_IMMUTABLE : 0));
+ }
+
+ public PendingIntent getAutoDownloadReportNotificationContentIntent(Context context) {
+ Intent intent = new MainActivityStarter(context).withFragmentLoaded("QueueFragment").getIntent();
+ return PendingIntent.getActivity(context, R.id.pending_intent_download_service_autodownload_report, intent,
+ PendingIntent.FLAG_UPDATE_CURRENT | (Build.VERSION.SDK_INT >= 23 ? PendingIntent.FLAG_IMMUTABLE : 0));
+ }
+
+ public PendingIntent getNotificationContentIntent(Context context) {
+ Intent intent = new MainActivityStarter(context).withFragmentLoaded("DownloadsFragment").getIntent();
+ return PendingIntent.getActivity(context,
+ R.id.pending_intent_download_service_notification, intent,
+ PendingIntent.FLAG_UPDATE_CURRENT | (Build.VERSION.SDK_INT >= 23 ? PendingIntent.FLAG_IMMUTABLE : 0));
+ }
}