From 2de48461731828e8df4d146eb55520c1b41543ed Mon Sep 17 00:00:00 2001 From: Ioana Alexandru Date: Tue, 7 Mar 2023 19:31:22 +0000 Subject: [PATCH] Use backgroundColor for the old toast layout. Some history necessary to understand why this is needed: - From Android R, we started rendering text toasts in System UI instead of having them rendered by the app. As a result, we have two separate layouts for toasts: * targetSdk < 30: transient_notification.xml (rendered by the app) * targetSdg >= 30: text_toast.xml (rendered by SystemUI) - We previously used backgroundColor for the toast background (toastFrameBackground), but we moved to using surfaceColor (a system color which matches the device theme). The problem is that surfaceColor isn't available when the toast is rendered by the app though, leading to weird behaviors like showing light grey text on a white background if the app's theme is material dark. To fix this, we should still use backgroundColor (like before) for toasts that are rendered by the app. Fix: 245678793 Test: manually triggered toast from app targeting SDK 29, observed color is correct Change-Id: I7ab1991c628b85f01391e41b6a03b3bd7f219058 --- core/res/res/layout/transient_notification.xml | 2 +- core/res/res/layout/transient_notification_with_icon.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/res/res/layout/transient_notification.xml b/core/res/res/layout/transient_notification.xml index 3259201f6e9bf..8bedb897dc196 100644 --- a/core/res/res/layout/transient_notification.xml +++ b/core/res/res/layout/transient_notification.xml @@ -25,7 +25,7 @@ android:orientation="horizontal" android:gravity="center_vertical" android:maxWidth="@dimen/toast_width" - android:background="?android:attr/toastFrameBackground" + android:background="?android:attr/colorBackground" android:elevation="@dimen/toast_elevation" android:layout_marginEnd="16dp" android:layout_marginStart="16dp" diff --git a/core/res/res/layout/transient_notification_with_icon.xml b/core/res/res/layout/transient_notification_with_icon.xml index e9b17df75333b..0dfb3adc8364a 100644 --- a/core/res/res/layout/transient_notification_with_icon.xml +++ b/core/res/res/layout/transient_notification_with_icon.xml @@ -22,7 +22,7 @@ android:orientation="horizontal" android:gravity="center_vertical" android:maxWidth="@dimen/toast_width" - android:background="?android:attr/toastFrameBackground" + android:background="?android:attr/colorBackground" android:elevation="@dimen/toast_elevation" android:layout_marginEnd="16dp" android:layout_marginStart="16dp"