-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Android 13+ custom notification actions #10580
Conversation
Kudos, SonarCloud Quality Gate passed! |
Is 5 still the max number of buttons allowed?
When does this happen? Upon the first time the app is opened after a system version upgrade? Or as part of the upgrade process somehow? |
On Android 13+ it's 4 customizable buttons instead of 5, but at the moment the settings still show 5 actions.
Yes, but as I said it's not implemented yet and will be done in a separate PR. This way we can merge this into the RC and at least provide something that works to the user, and later cleanup the settings for Android 13+. |
Use a workaround initially suggested in TeamNewPipe#10567 Basically tell the system that we're not able to handle "prev" and "next", in order to have 4 customizable action slots instead of just 2 On Android 13+ normal notification actions are useless, so they are not set into the notification builder anymore, to save battery The opposite happens on Android 12-, where media session actions are not set because they don't seem to do anything
126b430
to
6d8669a
Compare
Quality Gate passedThe SonarCloud Quality Gate passed, but some issues were introduced. 1 New issue |
// As documented in | ||
// https://developer.android.com/about/versions/13/behavior-changes-13#playback-controls | ||
// starting with android 13, setting ACTION_SKIP_TO_PREVIOUS and ACTION_SKIP_TO_NEXT forces | ||
// buttons 2 and 3 to be the system provided "Previous" and "Next". | ||
// Thus, we pretend to not support those actions to have the ability to customize them in | ||
// MediaSessionPlayerUi.updateMediaSessionActions(). | ||
return ACTION_SKIP_TO_QUEUE_ITEM | ||
| (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU | ||
? ACTION_SKIP_TO_NEXT | ACTION_SKIP_TO_PREVIOUS | ||
: 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this going to hurt Bluetooth media controls like double pressing the pause button on a headset to skip to the next item?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this change prevents to do the action you described, I just tested the artifact built by the CI with a Bluetooth speaker.
If it is possible, the app shouldn't generate a notification until it has all the metadata it needs. The user ends up getting an "Unknown - Unknown" notification for several seconds, which then eventually gets turned into the proper media notification. |
Oh, nevermind then, this approach is not really usable unfortunately. I will open a PR which just allows customizing the 2 remaining buttons. |
What is it?
Description of the changes in your PR
NotificationActionData
and move there (fromNotificationUtil
) the function that turns actions from the enum format (i.e. the number stored into preferences) into the triple (action string, name, icon). This allows deduplication of such function, instead of passing arrays around like in Android 13 notification action buttons #10567.Before/After Screenshots/Screen Record
Fixes the following issue(s)
APK testing
The APK can be found by going to the "Checks" tab below the title. On the left pane, click on "CI", scroll down to "artifacts" and click "app" to download the zip file which contains the debug APK of this PR. You can find more info and a video demonstration on this wiki page.
Due diligence