Skip to content

Use InAppMessage dimensions relative to host activity #696

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 4 commits into from
Jul 17, 2024

Conversation

rymorale
Copy link
Contributor

@rymorale rymorale commented Jul 15, 2024

Implementation of fix in #618. The description from that pr is:

Description

Problem : Currently, the size of the InAppMessage is based on the screen height and width. This displays the IAM ass desired for all single activity cases. However, this is not always the case when the activity is not occupying the entire screen.
Such cases will see a full screen message within the activity irrespective of the dimensions of the actual content size of
the activity. So 70% height would be 70% screen height and exceed the activity content view height where as it should have been 70% of the height within the activity.

Solution: Use the Use InAppMessage dimensions relative to host activity and not the entire screen.

Related Issue

Motivation and Context

Problem : Currently, the size of the InAppMessage is based on the screen height and width. This displays the IAM ass desired for all single activity cases. However, this is not always the case when the activity is not occupying the entire screen.
Such cases will see a full screen message within the activity irrespective of the dimensions of the actual content size of
the activity. So 70% height would be 70% screen height and exceed the activity content view height where as it should have been 70% of the height within the activity.

Solution: Use the Use InAppMessage dimensions relative to host activity and not the entire screen.

How Has This Been Tested?

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.

Comment on lines 71 to 75
val currentActivity = LocalContext.current as? Activity ?: run {
onDisposed()
Log.debug(ServiceConstants.LOG_TAG, "MessageFrame", "Unable to get the current activity. Dismissing the message.")
return
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 19 to 28
* An extension for finding the activity from a context.
*/
internal fun Context.findActivity(): Activity? {
var context = this
while (context is ContextWrapper) {
if (context is Activity) return context
context = context.baseContext
}
return null
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is only used in the UI area, can we make this a file private function inside MessageFrame.kt for now? We can move this to broader utils later when we find its uses at other places.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good, will move it

prudrabhat
prudrabhat previously approved these changes Jul 16, 2024
Copy link
Contributor

@prudrabhat prudrabhat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Can we share this patch with the issue reporter to see if it fixes their issue?

@prudrabhat prudrabhat dismissed their stale review July 16, 2024 20:40

Failing tests needs fixes.

@rymorale
Copy link
Contributor Author

I'll share a snapshot once I get the android tests fixed

// multi-window modes.
val contentView = currentActivity.findViewById<View>(android.R.id.content)
val contentHeightDp = with(LocalDensity.current) { contentView.height.toDp() }
val contentWidthDp = with(LocalDensity.current) { contentView.width.toDp() }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a bunch of tests in MessageScreenTests which assert for the IAM height and width based on the screen height and width. Could you please check if those need to be fixed?

@rymorale rymorale force-pushed the MOB-21325-iam-edge-to-edge-fix branch from fedafac to 3da2923 Compare July 17, 2024 20:56
Copy link

codecov bot commented Jul 17, 2024

Codecov Report

Attention: Patch coverage is 55.55556% with 8 lines in your changes missing coverage. Please review.

Project coverage is 81.60%. Comparing base (c946c70) to head (3da2923).

Additional details and impacted files
@@             Coverage Diff              @@
##                dev     #696      +/-   ##
============================================
- Coverage     81.66%   81.60%   -0.06%     
  Complexity     2150     2150              
============================================
  Files           192      192              
  Lines          8936     8944       +8     
  Branches       1118     1122       +4     
============================================
+ Hits           7297     7298       +1     
- Misses         1085     1089       +4     
- Partials        554      557       +3     
Flag Coverage Δ
functional-tests 27.64% <55.56%> (-<0.01%) ⬇️
unit-tests 69.45% <0.00%> (-0.06%) ⬇️

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

Files Coverage Δ
...mobile/services/ui/message/views/MessageContent.kt 90.91% <100.00%> (-1.68%) ⬇️
...g/mobile/services/ui/message/views/MessageFrame.kt 84.88% <52.94%> (-6.90%) ⬇️

@rymorale rymorale merged commit b82355e into adobe:dev Jul 17, 2024
7 of 8 checks passed
@rymorale
Copy link
Contributor Author

I'm releasing a snapshot from the dev branch to share with the issue reporter

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