Conversation
The notification background image would not show if the app has `android:supportsRtl="true"` the `AndroidManifest.xml` AND the device has a RTL language set. This would result in the notification becoming a sold color (all known instances have been a white background) and only the title and body text showing. Setting `android:layoutDirection="ltr"` ensures the layout, only used for images, isn't influenced by the language direction. This does NOT affect most notifications, only those that use `android_background_layout` in their notification payload. This change does NOT affect the rending of the title or body text in any way.
nan-li
approved these changes
Oct 28, 2021
Contributor
nan-li
left a comment
There was a problem hiding this comment.
Reviewed 1 of 1 files at r1, all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @adamschlesinger and @emawby)
nan-li
approved these changes
Oct 28, 2021
Contributor
nan-li
left a comment
There was a problem hiding this comment.
Reviewable status:
complete! all files reviewed, all discussions resolved (waiting on @adamschlesinger and @emawby)
Jeasmine
approved these changes
Oct 28, 2021
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Fix notification background image not showing on when the device has a RTL language set and the app's
AndroidManifest.xmlhas RTL support enabled.Details
Motivation
Setting a custom background image for notifications is a supported feature only through the REST API, is limited in features, and Android 12 has limited customizability. However OneSignal currently supports this feature and it should remind free of common/high impact bugs.
Scope
Only affects the display of notifications when the following is true:
android_background_layoutin the payload.AndroidManifest.xmlhasandroid:supportsRtl="true"This PR only affects the background image render. Changes / fixes to the title or body text is out of scope for this PR.
Android 4.1 (API 16) is out of scope, since
android:layoutDirectionwas introduced in Android API level 17.What was the bug?
When the a notification background image is set and the RTL conditions are meet, notifications becoming a sold color (all known instances have been a white background). The text may or not be visible, but depends on the text color and that the resulting background.
On LTR devices notifications looks like this:

On RTL devices notifications looks like this:

Why the bug was happening?
When RTL is set it moves all elements to the right, not just text elements.
How the bug was fixed?
Set
android:layoutDirection="ltr"on the layout used for the background image so it isn't influenced by the language direction.Testing
Unit testing
N/A, only a visual layout change.
Manual testing
Tested the Example app included in this repo (it has
android:supportsRtl="true") and set "Force RTL layout direction" on the device. Also tested w/o "Force RTL layout direction", to make sure it remained working.Test on:
Screenshot after fix
Android 10 Emulator with English with "Force RTL layout direction" enabled:

Affected code checklist
Checklist
Overview
Testing
Final pass
This change is