Skip to content

Fix IAM display rendering issues on foldable Android devices (Samsung Galaxy Fold/Flip)#2597

Draft
abdulraqeeb33 wants to merge 1 commit intomainfrom
cursor/iam-display-foldable-devices-d6f1
Draft

Fix IAM display rendering issues on foldable Android devices (Samsung Galaxy Fold/Flip)#2597
abdulraqeeb33 wants to merge 1 commit intomainfrom
cursor/iam-display-foldable-devices-d6f1

Conversation

@abdulraqeeb33
Copy link
Copy Markdown
Contributor

@abdulraqeeb33 abdulraqeeb33 commented Mar 26, 2026

Description

One Line Summary

Fix In-App Message (IAM) display rendering issues on foldable Android devices, gated behind a remote feature flag.

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:

  1. 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.

  2. Deprecated APIs: The SDK was using deprecated defaultDisplay.getSize() APIs that don't properly handle multi-window and foldable device scenarios on Android 11+.

  3. Missing configuration detection: The SDK only listened for CONFIG_ORIENTATION changes, missing the CONFIG_SCREEN_SIZE changes that foldable devices trigger.

Feature Flag Implementation

All changes are gated behind a remote feature flag: SDK_050800_FOLDABLE_IAM_FIX

  • When OFF (default): Legacy behavior is used - no changes to existing functionality
  • When ON: New foldable-aware behavior is activated:
    • Uses WindowMetrics API for accurate window dimensions on API 30+
    • Detects screen size changes from fold/unfold events
    • Recalculates IAM dimensions when screen size changes

This allows for safe rollout and easy rollback if issues are discovered.

Scope

What is affected:

  • In-App Message display on foldable devices (Samsung Galaxy Fold, Flip, and similar devices)
  • Window dimension calculations on Android 11+ (API 30+)

What is NOT affected:

  • IAM behavior when feature flag is disabled (default)
  • IAM behavior on non-foldable devices when flag is enabled (no functional change expected)
  • Other SDK features (notifications, outcomes, sessions, etc.)

Technical Changes

  1. FoldableIAMFeature.kt (NEW):

    • Global feature switch object similar to ThreadingMode
    • isEnabled property controlled by FeatureManager
    • Provides centralized access to feature state from static utilities
  2. FeatureFlag.kt:

    • Added SDK_050800_FOLDABLE_IAM_FIX feature flag
    • Uses IMMEDIATE activation mode for instant toggling
  3. FeatureManager.kt:

    • Added side effect handler for the new feature flag
    • Updates FoldableIAMFeature.isEnabled when flag changes
  4. ViewUtils.kt:

    • getWindowHeight(): Uses WindowMetrics API (API 30+) when FF enabled
    • getWindowWidth(): Uses WindowMetrics API (API 30+) when FF enabled
    • getFullbleedWindowWidth(): Uses WindowMetrics API (API 30+) when FF enabled
    • Falls back to legacy behavior when FF disabled
  5. ApplicationService.kt:

    • Screen size change detection only runs when FF enabled
    • Detects fold/unfold via screenWidthDp/screenHeightDp changes
    • Triggers IAM view recreation on screen size change
  6. WebViewManager.kt:

    • Updated comment to clarify fold/unfold handling alongside rotation

Testing

Unit testing

  • Existing ApplicationServiceTests pass
  • Existing FeatureManagerTests pass
  • The feature flag integration follows the same pattern as SDK_050800_BACKGROUND_THREADING

Manual testing

Recommended testing scenarios:

  1. With flag OFF: Verify no change in behavior on any device
  2. With flag ON on foldable device: Display an IAM, then fold/unfold - IAM should resize correctly
  3. With flag ON on non-foldable device: Verify no regression
  4. Test all IAM positions (TOP_BANNER, BOTTOM_BANNER, CENTER_MODAL, FULL_SCREEN) during fold/unfold

Affected code checklist

  • Notifications
    • Display
    • Open
    • Push Processing
    • Confirm Deliveries
  • Outcomes
  • Sessions
  • In-App Messaging
  • REST API requests
  • Public API changes

Checklist

Overview

  • I have filled out all REQUIRED sections above
  • PR does one thing
  • Any Public API changes are explained in the PR details and conform to existing APIs

Testing

  • I have included test coverage for these changes, or explained why they are not needed
  • All automated tests pass, or I explained why that is not possible
  • I have personally tested this on my device, or explained why that is not possible

Final pass

  • Code is as readable as possible.
  • I have reviewed this PR myself, ensuring it meets each checklist item
Open in Web Open in Cursor 

This commit addresses rendering issues with In-App Messages (IAM) on
foldable Android devices like Samsung Galaxy Fold/Flip.

All changes are gated behind a feature flag (SDK_050800_FOLDABLE_IAM_FIX)
that can be enabled remotely. When the flag is OFF, the SDK uses legacy
behavior. When ON, the new foldable-aware behavior is activated.

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. FoldableIAMFeature.kt (NEW):
   - Global feature switch for foldable device IAM improvements
   - Controlled by FeatureManager via remote config

2. FeatureFlag.kt:
   - Added SDK_050800_FOLDABLE_IAM_FIX feature flag
   - Uses IMMEDIATE activation mode for instant toggling

3. FeatureManager.kt:
   - Added side effect handler for the new feature flag
   - Updates FoldableIAMFeature.isEnabled when flag changes

4. ViewUtils.kt:
   - getWindowHeight(): Uses WindowMetrics API (API 30+) when FF enabled
   - getWindowWidth(): Uses WindowMetrics API (API 30+) when FF enabled
   - getFullbleedWindowWidth(): Uses WindowMetrics API (API 30+) when FF enabled
   - Falls back to legacy behavior when FF disabled

5. ApplicationService.kt:
   - Screen size change detection only runs when FF enabled
   - Detects fold/unfold via screenWidthDp/screenHeightDp changes
   - Triggers IAM view recreation on screen size change

6. WebViewManager.kt:
   - Updated comment to clarify fold/unfold handling

The fix ensures IAMs are properly resized and repositioned when users
fold/unfold their devices, preventing cut-off content and mispositioned
messages - but only when the feature flag is enabled.

Co-authored-by: abdul <abdul@onesignal.com>
@cursor cursor bot force-pushed the cursor/iam-display-foldable-devices-d6f1 branch from 87d5ea4 to 3e55686 Compare April 2, 2026 20:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants