From d0791c574f975dddab4f9fc6d147762d4e99ba5b Mon Sep 17 00:00:00 2001 From: osodebailar Date: Thu, 22 Sep 2022 08:46:51 +0200 Subject: [PATCH] fix toast text color especially on android 11 and above --- .../info/nightscout/androidaps/utils/ToastUtils.kt | 11 ++++++++++- core/src/main/res/layout/toast.xml | 4 ++-- core/src/main/res/values-night/colors.xml | 2 +- core/src/main/res/values-night/styles.xml | 1 + core/src/main/res/values/attrs.xml | 1 + core/src/main/res/values/colors.xml | 2 +- core/src/main/res/values/styles.xml | 1 + 7 files changed, 17 insertions(+), 5 deletions(-) diff --git a/core/src/main/java/info/nightscout/androidaps/utils/ToastUtils.kt b/core/src/main/java/info/nightscout/androidaps/utils/ToastUtils.kt index 1a6043723d..b0fcf672d3 100644 --- a/core/src/main/java/info/nightscout/androidaps/utils/ToastUtils.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/ToastUtils.kt @@ -16,6 +16,7 @@ import info.nightscout.androidaps.core.R import info.nightscout.androidaps.plugins.bus.RxBus import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification import info.nightscout.androidaps.plugins.general.overview.notifications.Notification +import info.nightscout.androidaps.utils.resources.getThemeColor object ToastUtils { @@ -76,7 +77,15 @@ object ToastUtils { fun showToastInUiThread(ctx: Context?, string: String?) { val mainThread = Handler(Looper.getMainLooper()) - mainThread.post { Toast.makeText(ctx, string, Toast.LENGTH_SHORT).show() } + mainThread.post { + val toast: Toast = + Toast.makeText( + ctx, + HtmlHelper.fromHtml("" + string + ""), + Toast.LENGTH_SHORT + ) + toast.show() + } } fun showToastInUiThread( diff --git a/core/src/main/res/layout/toast.xml b/core/src/main/res/layout/toast.xml index 8b79189760..a3831a8e83 100644 --- a/core/src/main/res/layout/toast.xml +++ b/core/src/main/res/layout/toast.xml @@ -4,7 +4,7 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:background="@drawable/toast_border_ok"> + android:background="?attr/toastBackgroundColor"> diff --git a/core/src/main/res/values-night/colors.xml b/core/src/main/res/values-night/colors.xml index 3b47049571..3821d1e840 100644 --- a/core/src/main/res/values-night/colors.xml +++ b/core/src/main/res/values-night/colors.xml @@ -109,7 +109,7 @@ #666666 - #ffffff + #000000 #77dd77 #ff0400 #FF8C00 diff --git a/core/src/main/res/values-night/styles.xml b/core/src/main/res/values-night/styles.xml index dfd244db24..76ebef4e7d 100644 --- a/core/src/main/res/values-night/styles.xml +++ b/core/src/main/res/values-night/styles.xml @@ -95,6 +95,7 @@ @color/defaultBackground @color/toastBase + @color/buttonBackground @style/DialogTheme @style/DialogTheme diff --git a/core/src/main/res/values/attrs.xml b/core/src/main/res/values/attrs.xml index 5c5146e42d..49670026d9 100644 --- a/core/src/main/res/values/attrs.xml +++ b/core/src/main/res/values/attrs.xml @@ -65,6 +65,7 @@ + diff --git a/core/src/main/res/values/colors.xml b/core/src/main/res/values/colors.xml index 27c6d20db9..e83c322785 100644 --- a/core/src/main/res/values/colors.xml +++ b/core/src/main/res/values/colors.xml @@ -111,7 +111,7 @@ #666666 - #ffffff + #000000 #77dd77 #ff0400 #FF8C00 diff --git a/core/src/main/res/values/styles.xml b/core/src/main/res/values/styles.xml index a471a947dc..318c420aa1 100644 --- a/core/src/main/res/values/styles.xml +++ b/core/src/main/res/values/styles.xml @@ -100,6 +100,7 @@ @color/white @color/toastBase + @color/colorLightGray @style/DialogTheme @style/DialogTheme