summaryrefslogtreecommitdiff
path: root/ui/app-start-intent
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 /ui/app-start-intent
parentcfb974524652c16d96a8f804a525826fad27aee7 (diff)
downloadAntennaPod-c98194f519c66e5af1575b1c6ffac5af16594141.zip
Remove another global callback object (#6316)
Diffstat (limited to 'ui/app-start-intent')
-rw-r--r--ui/app-start-intent/src/main/java/de/danoeh/antennapod/ui/appstartintent/DownloadAuthenticationActivityStarter.java39
-rw-r--r--ui/app-start-intent/src/main/java/de/danoeh/antennapod/ui/appstartintent/MainActivityStarter.java15
2 files changed, 52 insertions, 2 deletions
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
new file mode 100644
index 000000000..03c5e915e
--- /dev/null
+++ b/ui/app-start-intent/src/main/java/de/danoeh/antennapod/ui/appstartintent/DownloadAuthenticationActivityStarter.java
@@ -0,0 +1,39 @@
+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 e8686f6ad..1463978ee 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
@@ -4,6 +4,7 @@ import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
+import android.os.Bundle;
/**
* Launches the main activity of the app with specific arguments.
@@ -16,9 +17,11 @@ 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_FRAGMENT_ARGS = "fragment_args";
private final Intent intent;
private final Context context;
+ private Bundle fragmentArgs = null;
public MainActivityStarter(Context context) {
this.context = context;
@@ -56,11 +59,19 @@ public class MainActivityStarter {
public MainActivityStarter withFragmentLoaded(String fragmentName) {
intent.putExtra(EXTRA_FRAGMENT_TAG, fragmentName);
- return withDrawerOpen();
+ return this;
}
- private MainActivityStarter withDrawerOpen() {
+ public MainActivityStarter withDrawerOpen() {
intent.putExtra(EXTRA_OPEN_DRAWER, true);
return this;
}
+
+ public MainActivityStarter withFragmentArgs(String name, boolean value) {
+ if (fragmentArgs == null) {
+ fragmentArgs = new Bundle();
+ }
+ fragmentArgs.putBoolean(name, value);
+ return this;
+ }
}