From 463f5ff9eadc6190198914c1c75375e60d979ed0 Mon Sep 17 00:00:00 2001 From: Prashanth Rudrabhat Date: Tue, 27 Feb 2024 09:54:59 -0800 Subject: [PATCH] Fix InAppMessage rounded corners for API <= 22 WebView does not support rounded corners or clipping in API 21, 22. This causes the `cornerRadius` setting not to be honoured in these devices. Place the AndroidWebView inside a Cardview with a clipped corner radius matching the WebView and an alpha of .99f. --- .../mobile/services/ui/message/views/MessageFrame.kt | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/code/core/src/phone/java/com/adobe/marketing/mobile/services/ui/message/views/MessageFrame.kt b/code/core/src/phone/java/com/adobe/marketing/mobile/services/ui/message/views/MessageFrame.kt index 7f19e53f9..eb75e6f35 100644 --- a/code/core/src/phone/java/com/adobe/marketing/mobile/services/ui/message/views/MessageFrame.kt +++ b/code/core/src/phone/java/com/adobe/marketing/mobile/services/ui/message/views/MessageFrame.kt @@ -18,10 +18,14 @@ import androidx.compose.foundation.background import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material.Card import androidx.compose.runtime.Composable import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.remember import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.alpha +import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.LocalConfiguration import androidx.compose.ui.platform.testTag @@ -73,8 +77,12 @@ internal fun MessageFrame( ), verticalAlignment = MessageAlignmentMapper.getVerticalAlignment(inAppMessageSettings.verticalAlignment) ) { - // The content of the InAppMessage - MessageContent(inAppMessageSettings, onCreated, gestureTracker) + // The content of the InAppMessage. This needs to be placed inside a Card with .99 alpha to ensure that + // the WebView message is clipped to the rounded corners for API versions 22 and below. This does not + // affect the appearance of the message on API versions 23 and above. + Card(modifier = Modifier.clip(RoundedCornerShape(inAppMessageSettings.cornerRadius.dp)).alpha(0.99f)) { + MessageContent(inAppMessageSettings, onCreated, gestureTracker) + } // This is a one-time effect that will be called when this composable is completely removed from the composition // (after any animations if any). Use this to clean up any resources that were created in onCreated.