From b67f68e2a66dc4436b8cdd7c2c2feceff7ec7d1b Mon Sep 17 00:00:00 2001 From: Andraz Date: Tue, 26 May 2026 00:43:58 +0200 Subject: [PATCH] Fix in-app message dark mode pinning on Android 13+ (#1056) In-app HTML messages always rendered the prefers-color-scheme: dark variant regardless of the system theme on API 33+. Two fixes: - Switch DialogFragment style from Theme.AppCompat.NoActionBar (a dark theme: extends Theme.AppCompat, not Theme.AppCompat.Light) to Theme.AppCompat.DayNight.NoActionBar, so isLightTheme tracks the system mode. - Build the WebView with the dialog's themed context instead of Fragment.getContext(), which returns the host activity context. On API 33+ WebView derives prefers-color-scheme from the hosting theme's isLightTheme attribute, so the DayNight fix only takes effect when the WebView is constructed under the dialog context. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../iterableapi/IterableInAppFragmentHTMLNotification.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iterableapi/src/main/java/com/iterable/iterableapi/IterableInAppFragmentHTMLNotification.java b/iterableapi/src/main/java/com/iterable/iterableapi/IterableInAppFragmentHTMLNotification.java index e88e47f1a..60da9b197 100644 --- a/iterableapi/src/main/java/com/iterable/iterableapi/IterableInAppFragmentHTMLNotification.java +++ b/iterableapi/src/main/java/com/iterable/iterableapi/IterableInAppFragmentHTMLNotification.java @@ -120,7 +120,7 @@ public IterableInAppFragmentHTMLNotification() { this.backgroundAlpha = 0; this.messageId = ""; insetPadding = new Rect(); - this.setStyle(DialogFragment.STYLE_NO_FRAME, androidx.appcompat.R.style.Theme_AppCompat_NoActionBar); + this.setStyle(DialogFragment.STYLE_NO_FRAME, androidx.appcompat.R.style.Theme_AppCompat_DayNight_NoActionBar); } @Override @@ -194,7 +194,7 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c applyWindowGravity(getDialog().getWindow(), "onCreateView"); } - webView = createWebViewSafely(getContext()); + webView = createWebViewSafely(getDialog().getContext()); if (webView == null) { dismissAllowingStateLoss(); return null;