Fix Heads-Up Displaying Previous Notification When Grouped on some devices #1578
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
One Line Summary
Some devices would display the previous notification as a heads-up notification when they become grouped which this PR addresses.
Details
Motivation
The main motivation is to fix the bug noted above. Secondary is this changes the heads-up notification from showing the group summary to showing the most recent notification. This makes it much easier to see what is new instead of it being mixed with older notifications. Video below will show this behavior difference.
Scope
Only effects the display of grouped heads-up notifications for Android 7.0 and newer.
Background details - Android features
Google's documentation on specific Android Notification features referenced in this PR:
Details of the change
Using
GROUP_ALERT_CHILDREN
withsetGroupAlertBehavior
means the just receive notification will be used as the heads-up notification. BeforeGROUP_ALERT_SUMMARY
would result in seeing a summary of all notifications in the group.This also fixes a bug where the previous notification would be shown as the heads-up notification on some devices. Such as Samsung's OneUI 4 with the Brief style of notifications, as well as some other manufacturers.
Lastly the bug would sometimes happen on Android 7 and 8 AOSP since the summary and child notification are posted at the same time and these versions of Android would pick one at random. In this case it seemed to only be an issue when setting
android_group
and only on the 2nd notification display.Fixes #1574
Testing
Unit testing
None, this is a visual change
Manual testing
Tested on Android Studio Emulators:
Test on device:
Videos
Android 12 Emulator
Before
Android_headsup_as_summary.mp4
After
Android_headsup_set_as_child.mp4
Affected code checklist
Checklist
Overview
Testing
Final pass
This change is