Fix IAM display rendering issues on foldable Android devices (Samsung Galaxy Fold/Flip)#2597
Draft
abdulraqeeb33 wants to merge 1 commit intomainfrom
Draft
Fix IAM display rendering issues on foldable Android devices (Samsung Galaxy Fold/Flip)#2597abdulraqeeb33 wants to merge 1 commit intomainfrom
abdulraqeeb33 wants to merge 1 commit intomainfrom
Conversation
This commit addresses rendering issues with In-App Messages (IAM) on foldable Android devices like Samsung Galaxy Fold/Flip. Root cause: - Foldable devices change screen size without triggering orientation changes - The SDK only listened for CONFIG_ORIENTATION changes, missing fold/unfold events - ViewUtils used deprecated APIs that don't properly handle multi-window scenarios Changes: 1. ViewUtils.kt: - Added API 30+ (Android 11+) implementation using WindowMetrics API - getWindowHeight() now uses currentWindowMetrics for accurate dimensions - getWindowWidth() and getFullbleedWindowWidth() updated similarly - Properly handles foldable device screen size changes 2. ApplicationService.kt: - Added screen size change detection via onConfigurationChanged - Tracks screenWidthDp/screenHeightDp to detect fold/unfold events - New onScreenSizeChanged() method triggers IAM view recreation - Fires onActivityStopped/onActivityAvailable to recalculate IAM dimensions 3. WebViewManager.kt: - Updated comment to clarify fold/unfold handling alongside rotation The fix ensures IAMs are properly resized and repositioned when users fold/unfold their devices, preventing cut-off content and mispositioned messages. Co-authored-by: abdul <abdul@onesignal.com>
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 In-App Message (IAM) display rendering issues on foldable Android devices by detecting screen size changes and using modern WindowMetrics API.
Details
Motivation
Foldable Android devices like Samsung Galaxy Fold and Flip experience IAM rendering issues when users fold/unfold their devices. The IAM content may appear cut-off, mispositioned, or incorrectly sized because:
Screen size changes without orientation change: When a foldable device transitions between its cover screen and main screen (or vice versa), the screen dimensions change dramatically without triggering an orientation change event.
Deprecated APIs: The SDK was using deprecated
defaultDisplay.getSize()APIs that don't properly handle multi-window and foldable device scenarios on Android 11+.Missing configuration detection: The SDK only listened for
CONFIG_ORIENTATIONchanges, missing theCONFIG_SCREEN_SIZEchanges that foldable devices trigger.Scope
What is affected:
What is NOT affected:
Technical Changes
ViewUtils.kt:
getWindowHeightAPI30Plus()usingWindowMetricsAPI for accurate dimensionsgetWindowWidthAPI30Plus()for consistent width calculationsgetFullbleedWindowWidth()to useWindowMetricson API 30+@Suppress("DEPRECATION")annotation for backward-compatible code pathsApplicationService.kt:
onConfigurationChangedcallbackscreenWidthDpandscreenHeightDpto detect fold/unfold eventsonScreenSizeChanged()method triggers IAM view recreationonActivityStopped/onActivityAvailablelifecycle events to recalculate IAM dimensionsWebViewManager.kt:
Testing
Unit testing
Existing
ApplicationServiceTestspass. The screen size change detection is triggered through the same lifecycle events that are already tested for orientation changes.Manual testing
Recommended testing scenarios:
Affected code checklist
Checklist
Overview
Testing
Final pass