diff options
author | ByteHamster <info@bytehamster.com> | 2021-02-07 11:29:39 +0100 |
---|---|---|
committer | ByteHamster <info@bytehamster.com> | 2021-02-12 18:08:58 +0100 |
commit | 24ea4708ea318e923eafdc222c89a158567d1f52 (patch) | |
tree | 8ce1e0f0066915f211e3a5d5c951c5c3e93f3e98 /ui/app-start-intent | |
parent | 60968089ae4afe13ba48d64346ea39c542ad457b (diff) | |
download | AntennaPod-24ea4708ea318e923eafdc222c89a158567d1f52.zip |
Remove PlaybackServiceCallbacks
Diffstat (limited to 'ui/app-start-intent')
6 files changed, 145 insertions, 0 deletions
diff --git a/ui/app-start-intent/README.md b/ui/app-start-intent/README.md new file mode 100644 index 000000000..b796a56cc --- /dev/null +++ b/ui/app-start-intent/README.md @@ -0,0 +1,3 @@ +# :ui:app-start-intent + +This module provides classes that can start the main activities of the app with specific arguments. It does not require a dependency on the actual implementation of the activities, so it can be used to decouple the services from the UI. diff --git a/ui/app-start-intent/build.gradle b/ui/app-start-intent/build.gradle new file mode 100644 index 000000000..fabd8937f --- /dev/null +++ b/ui/app-start-intent/build.gradle @@ -0,0 +1,50 @@ +apply plugin: "com.android.library" + +android { + compileSdkVersion rootProject.ext.compileSdkVersion + + defaultConfig { + minSdkVersion rootProject.ext.minSdkVersion + targetSdkVersion rootProject.ext.targetSdkVersion + + multiDexEnabled false + + testApplicationId "de.danoeh.antennapod.core.tests" + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile("proguard-android.txt") + } + debug { + // debug build has method count over 64k single-dex threshold. + // For building debug build to use on Android < 21 (pre-Android 5) devices, + // you need to manually change class + // de.danoeh.antennapod.PodcastApp to extend MultiDexApplication . + // See Issue #2813 + multiDexEnabled true + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + testOptions { + unitTests { + includeAndroidResources = true + } + } + + lintOptions { + warningsAsErrors true + abortOnError true + } +} + +dependencies { + annotationProcessor "androidx.annotation:annotation:$annotationVersion" + implementation "androidx.appcompat:appcompat:$appcompatVersion" +} diff --git a/ui/app-start-intent/src/main/AndroidManifest.xml b/ui/app-start-intent/src/main/AndroidManifest.xml new file mode 100644 index 000000000..9296616f9 --- /dev/null +++ b/ui/app-start-intent/src/main/AndroidManifest.xml @@ -0,0 +1 @@ +<manifest package="de.danoeh.antennapod.ui.appstartintent" /> 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 new file mode 100644 index 000000000..33f96f141 --- /dev/null +++ b/ui/app-start-intent/src/main/java/de/danoeh/antennapod/ui/appstartintent/MainActivityStarter.java @@ -0,0 +1,41 @@ +package de.danoeh.antennapod.ui.appstartintent; + +import android.app.PendingIntent; +import android.content.Context; +import android.content.Intent; + +/** + * Launches the main activity of the app with specific arguments. + * Does not require a dependency on the actual implementation of the activity. + */ +public class MainActivityStarter { + public static final String INTENT = "de.danoeh.antennapod.intents.MAIN_ACTIVITY"; + public static final String EXTRA_OPEN_PLAYER = "open_player"; + + private final Intent intent; + private final Context context; + + public MainActivityStarter(Context context) { + this.context = context; + intent = new Intent(INTENT); + intent.setPackage(context.getPackageName()); + } + + public Intent getIntent() { + return intent; + } + + public PendingIntent getPendingIntent() { + return PendingIntent.getActivity(context, R.id.pending_intent_player_activity, + getIntent(), PendingIntent.FLAG_UPDATE_CURRENT); + } + + public void start() { + context.startActivity(getIntent()); + } + + public MainActivityStarter withOpenPlayer() { + intent.putExtra(EXTRA_OPEN_PLAYER, true); + return this; + } +} diff --git a/ui/app-start-intent/src/main/java/de/danoeh/antennapod/ui/appstartintent/VideoPlayerActivityStarter.java b/ui/app-start-intent/src/main/java/de/danoeh/antennapod/ui/appstartintent/VideoPlayerActivityStarter.java new file mode 100644 index 000000000..7536d34b6 --- /dev/null +++ b/ui/app-start-intent/src/main/java/de/danoeh/antennapod/ui/appstartintent/VideoPlayerActivityStarter.java @@ -0,0 +1,38 @@ +package de.danoeh.antennapod.ui.appstartintent; + +import android.app.PendingIntent; +import android.content.Context; +import android.content.Intent; +import android.os.Build; + +/** + * Launches the video player activity of the app with specific arguments. + * Does not require a dependency on the actual implementation of the activity. + */ +public class VideoPlayerActivityStarter { + public static final String INTENT = "de.danoeh.antennapod.intents.VIDEO_PLAYER"; + private final Intent intent; + private final Context context; + + public VideoPlayerActivityStarter(Context context) { + this.context = context; + intent = new Intent(INTENT); + intent.setPackage(context.getPackageName()); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT); + } + } + + public Intent getIntent() { + return intent; + } + + public PendingIntent getPendingIntent() { + return PendingIntent.getActivity(context, R.id.pending_intent_video_player, + getIntent(), PendingIntent.FLAG_UPDATE_CURRENT); + } + + public void start() { + context.startActivity(getIntent()); + } +} diff --git a/ui/app-start-intent/src/main/res/values/pending_intent.xml b/ui/app-start-intent/src/main/res/values/pending_intent.xml new file mode 100644 index 000000000..1e426e954 --- /dev/null +++ b/ui/app-start-intent/src/main/res/values/pending_intent.xml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <item name="pending_intent_download_service_notification" type="id"/> + <item name="pending_intent_download_service_auth" type="id"/> + <item name="pending_intent_download_service_report" type="id"/> + <item name="pending_intent_download_service_autodownload_report" type="id"/> + <item name="pending_intent_allow_stream_always" type="id"/> + <item name="pending_intent_allow_stream_this_time" type="id"/> + <item name="pending_intent_player_activity" type="id"/> + <item name="pending_intent_video_player" type="id"/> + <item name="pending_intent_sync_error" type="id"/> +</resources> |