Skip to content

Fix message inset calculation for InAppMessages #778

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

Merged
merged 3 commits into from
Jul 21, 2025

Conversation

prudrabhat
Copy link
Contributor

Description

Problem
Inset calculation for in-app messages has regressed in v3.1.1-core.
TheMessageOffsetMapper methods expect the full screen view dimensions as the third parameter to calculate the offset percentage correctly, but now being calculated incorrectly according to the dimensions of the in-app message rather than the dimensions of the view.

val horizontalOffset = MessageOffsetMapper.getHorizontalOffset(
    inAppMessageSettings.horizontalAlignment,
    inAppMessageSettings.horizontalInset,
    widthDp.value  // ❌ This is the MESSAGE width, not content view/screen width
)
val verticalOffset = MessageOffsetMapper.getVerticalOffset(
    inAppMessageSettings.verticalAlignment,
    inAppMessageSettings.verticalInset,
    heightDp.value  // ❌ This is the MESSAGE height, not content view/screen height
)

This results in the following behavior:

  • When inAppMessageSettings.height is 100: heightDp.value equals contentHeightDp (full screen height) the, offset calculation works correctly.
  • When inAppMessageSettings.height is 30: heightDp.value equals contentHeightDp * 30 / 100 (30% of screen height) Offset percentage is calculated against this smaller value, making the actual offset much smaller than intended.

Solution
Ensure that verticalInset percentage is always calculated against the enclosing activity height (contentHeightDp) and horizontalInset against the enclosing activity width (contentWidthDp), regardless of the message's actual size.

Related Issue

PLATIR-51482

How Has This Been Tested?

  • Fixed UI tests
  • Manual verification

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Copy link

codecov bot commented Jun 30, 2025

Codecov Report

Attention: Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.

Project coverage is 63.72%. Comparing base (48edbd2) to head (98fd502).
Report is 8 commits behind head on dev.

Files with missing lines Patch % Lines
...g/mobile/services/ui/message/views/MessageFrame.kt 0.00% 3 Missing ⚠️

❌ Your patch status has failed because the patch coverage (0.00%) is below the target coverage (75.00%). You can increase the patch coverage or adjust the target coverage.
❌ Your project status has failed because the head coverage (63.72%) is below the target coverage (75.00%). You can increase the head coverage or adjust the target coverage.

❗ There is a different number of reports uploaded between BASE (48edbd2) and HEAD (98fd502). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (48edbd2) HEAD (98fd502)
android-functional-tests 1 0
Additional details and impacted files
@@              Coverage Diff              @@
##                dev     #778       +/-   ##
=============================================
- Coverage     74.91%   63.72%   -11.19%     
+ Complexity     2309     2101      -208     
=============================================
  Files           217      217               
  Lines         10699    10701        +2     
  Branches       1390     1390               
=============================================
- Hits           8015     6819     -1196     
- Misses         2046     3342     +1296     
+ Partials        638      540       -98     
Flag Coverage Δ
android-functional-tests ?
android-unit-tests 63.72% <0.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...g/mobile/services/ui/message/views/MessageFrame.kt 0.00% <0.00%> (-81.08%) ⬇️

... and 42 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@prudrabhat prudrabhat merged commit d058d30 into adobe:dev Jul 21, 2025
21 of 23 checks passed
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.

3 participants