Appboy / appboy-android-sdk

Public repo for the Braze Android SDK
https://www.braze.com
Other
152 stars 102 forks source link

[Bug]: Custom html in app messages do not consider insets #236

Closed gabrielittner closed 2 years ago

gabrielittner commented 2 years ago

Braze Android SDK Version

23.1.1

Steps To Reproduce

Send a full screen html in app message to an Android app where the Activity has WindowCompat.setDecorFitsSystemWindows(window, false) set to draw under the status and navigation bars

Expected Behavior

The in app message content does not go under the system bars

Actual Incorrect Behavior

The in app message draws under status and navigation bars and content is cut off. This especially affects interactive elements like a close button in the upper right corner.

Verbose Logs

No response

Additional Information

We currently work around this by having a custom factory like this

class FixInsetsInAppMessageViewWrapperFactory @Inject constructor() : IInAppMessageViewWrapperFactory {

    override fun createInAppMessageViewWrapper(...): IInAppMessageViewWrapper {
        if (inAppMessage.isHtmlMessage()) {
            return FixInsetsInAppMessageViewWrapper(...)
        } else {
            return DefaultInAppMessageViewWrapper(...)
        }
    }

    override fun createInAppMessageViewWrapper(...): IInAppMessageViewWrapper {
        if (inAppMessage.isHtmlMessage()) {
            return FixInsetsInAppMessageViewWrapper(...)
        } else {
            return DefaultInAppMessageViewWrapper(...)
        }
    }

    private fun IInAppMessage.isHtmlMessage(): Boolean {
        return messageType == MessageType.HTML || messageType == MessageType.HTML_FULL
    }
}

The custom wrapper then looks like this

internal class FixInsetsInAppMessageViewWrapper : DefaultInAppMessageViewWrapper {

    // constructors omitted

    override fun open(activity: Activity) {
        super.open(activity)
        // apply insets as margin to the view so that it won't draw under system bars
        inAppMessageView.applyInsetter {
            type(navigationBars = true, statusBars = true) { margin() }
        }
    }
}
chshapiro commented 2 years ago

Hey @gabrielittner , We are looking into this issue and will provide an update as soon as we have one. Thanks for reporting!

radixdev commented 2 years ago

Hi @gabrielittner ,

We have a fix written and should have it available in the next SDK release. We'll update this issue once that is released. Thanks for your patience.

radixdev commented 2 years ago

Hi @gabrielittner ,

This can be enabled in 23.2.0 via setting https://appboy.github.io/appboy-android-sdk/kdoc/braze-android-sdk/com.braze.configuration/-braze-config/-builder/set-is-html-in-app-message-apply-window-insets-enabled.html to true.

gabrielittner commented 2 years ago

I've tested it and it works as expected. Thanks for addressing this so quickly.