diff options
author | Nicolas Araujo <63880378+nicoolasj@users.noreply.github.com> | 2022-04-24 17:36:37 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-24 22:36:37 +0200 |
commit | 9b78d4c3f39b085184ae54e88b22fb71f3fc13a3 (patch) | |
tree | bd1bdd4d03ed614dbae53801948364786c4344a4 /ui/app-start-intent | |
parent | 1b2102d753820f2934a8463e767865212efe2831 (diff) | |
download | AntennaPod-9b78d4c3f39b085184ae54e88b22fb71f3fc13a3.zip |
Put playback speed in widget (#5774)
Diffstat (limited to 'ui/app-start-intent')
-rw-r--r-- | ui/app-start-intent/src/main/java/de/danoeh/antennapod/ui/appstartintent/PlaybackSpeedActivityStarter.java | 40 | ||||
-rw-r--r-- | ui/app-start-intent/src/main/res/values/pending_intent.xml | 1 |
2 files changed, 41 insertions, 0 deletions
diff --git a/ui/app-start-intent/src/main/java/de/danoeh/antennapod/ui/appstartintent/PlaybackSpeedActivityStarter.java b/ui/app-start-intent/src/main/java/de/danoeh/antennapod/ui/appstartintent/PlaybackSpeedActivityStarter.java new file mode 100644 index 000000000..ac7e72a4e --- /dev/null +++ b/ui/app-start-intent/src/main/java/de/danoeh/antennapod/ui/appstartintent/PlaybackSpeedActivityStarter.java @@ -0,0 +1,40 @@ +package de.danoeh.antennapod.ui.appstartintent; + +import android.app.PendingIntent; +import android.content.Context; +import android.content.Intent; +import android.os.Build; + +/** + * Launches the playback speed dialog activity of the app with specific arguments. + * Does not require a dependency on the actual implementation of the activity. + */ +public class PlaybackSpeedActivityStarter { + public static final String INTENT = "de.danoeh.antennapod.intents.PLAYBACK_SPEED"; + private final Intent intent; + private final Context context; + + public PlaybackSpeedActivityStarter(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); + } else { + intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); + } + } + + public Intent getIntent() { + return intent; + } + + public PendingIntent getPendingIntent() { + return PendingIntent.getActivity(context, R.id.pending_intent_playback_speed, getIntent(), + PendingIntent.FLAG_UPDATE_CURRENT | (Build.VERSION.SDK_INT >= 23 ? PendingIntent.FLAG_IMMUTABLE : 0)); + } + + 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 index 1e426e954..ed7e9b2cd 100644 --- a/ui/app-start-intent/src/main/res/values/pending_intent.xml +++ b/ui/app-start-intent/src/main/res/values/pending_intent.xml @@ -6,6 +6,7 @@ <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_playback_speed" 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"/> |