mirror of
https://github.com/AntennaPod/AntennaPod.git
synced 2026-08-18 11:05:49 +00:00
Fix widget buttons on new playback service (#8510)
### Description Fix widget buttons on new playback service Closes #8454 ### Checklist <!-- To help us keep the issue tracker clean and work as efficient as possible, please make sure that you have done all of the following. You can tick the boxes below by placing an x inside the brackets like this: [x] --> - [x] I have read the contribution guidelines: https://github.com/AntennaPod/AntennaPod/blob/develop/CONTRIBUTING.md#submit-a-pull-request - [x] I have performed a self-review of my code, going through my changes line by line and carefully considering why this line change is necessary - [x] I have run the automated code checks using `./gradlew checkstyle lint` - [x] My code follows the style guidelines of the AntennaPod project: https://antennapod.org/contribute/develop/app/code-style - [x] I have mentioned the corresponding issue and the relevant keyword (e.g., "Closes: #xy") in the description (see https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue) - [x] If it is a core feature, I have added automated tests
This commit is contained in:
committed by
GitHub
parent
0207527d9d
commit
ca86fec2c2
@ -1,12 +1,17 @@
|
||||
package de.danoeh.antennapod.ui.appstartintent;
|
||||
|
||||
import android.app.PendingIntent;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.view.KeyEvent;
|
||||
|
||||
public abstract class MediaButtonStarter {
|
||||
private static final String INTENT = "de.danoeh.antennapod.NOTIFY_BUTTON_RECEIVER";
|
||||
private static final String MEDIA3_PLAYBACK_SERVICE =
|
||||
"de.danoeh.antennapod.playback.service.Media3PlaybackService";
|
||||
public static final String EXTRA_MEDIA_BUTTON_SOURCE = "media_button_source";
|
||||
public static final String MEDIA_BUTTON_SOURCE_WIDGET = "widget";
|
||||
|
||||
public static Intent createIntent(Context context, int eventCode) {
|
||||
KeyEvent event = new KeyEvent(KeyEvent.ACTION_DOWN, eventCode);
|
||||
@ -18,6 +23,12 @@ public abstract class MediaButtonStarter {
|
||||
}
|
||||
|
||||
public static PendingIntent createPendingIntent(Context context, int eventCode) {
|
||||
if (BuildConfig.USE_MEDIA3_PLAYBACK_SERVICE) {
|
||||
Intent intent = createIntent(context, eventCode)
|
||||
.setComponent(new ComponentName(context, MEDIA3_PLAYBACK_SERVICE))
|
||||
.putExtra(EXTRA_MEDIA_BUTTON_SOURCE, MEDIA_BUTTON_SOURCE_WIDGET);
|
||||
return PendingIntent.getService(context, eventCode, intent, PendingIntent.FLAG_IMMUTABLE);
|
||||
}
|
||||
return PendingIntent.getBroadcast(context, eventCode, createIntent(context, eventCode),
|
||||
PendingIntent.FLAG_IMMUTABLE);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user