From bd3f952108cf51a4b063fdac8b803d4409c64916 Mon Sep 17 00:00:00 2001 From: HuanCheng65 <22636177+HuanCheng65@users.noreply.github.com> Date: Fri, 6 Oct 2023 18:13:41 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=90=AF=E5=8A=A8=E6=97=B6=E9=97=AA?= =?UTF-8?q?=E9=80=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/com/huanchengfly/tieba/post/App.kt | 8 +++++++- .../java/com/huanchengfly/tieba/post/utils/ThemeUtil.kt | 7 +++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/huanchengfly/tieba/post/App.kt b/app/src/main/java/com/huanchengfly/tieba/post/App.kt index 8e7781aa..011e6a70 100644 --- a/app/src/main/java/com/huanchengfly/tieba/post/App.kt +++ b/app/src/main/java/com/huanchengfly/tieba/post/App.kt @@ -743,7 +743,13 @@ class App : Application(), IApp, SketchFactory { } override fun getColorByAttr(context: Context, attrId: Int): Int { - return getColorByAttr(context, attrId, ThemeUtil.getCurrentTheme()) + return when (attrId) { + R.attr.colorPrimary, R.attr.colorNewPrimary, R.attr.colorAccent -> { + getColorByAttr(context, attrId, ThemeUtil.getCurrentTheme(checkDynamic = true)) + } + + else -> getColorByAttr(context, attrId, ThemeUtil.getCurrentTheme()) + } } override fun getColorById(context: Context, colorId: Int): Int { diff --git a/app/src/main/java/com/huanchengfly/tieba/post/utils/ThemeUtil.kt b/app/src/main/java/com/huanchengfly/tieba/post/utils/ThemeUtil.kt index 9542018a..89049e46 100644 --- a/app/src/main/java/com/huanchengfly/tieba/post/utils/ThemeUtil.kt +++ b/app/src/main/java/com/huanchengfly/tieba/post/utils/ThemeUtil.kt @@ -279,7 +279,10 @@ object ThemeUtil { } @JvmOverloads - fun getCurrentTheme(theme: String = getRawTheme()): String { + fun getCurrentTheme( + theme: String = getRawTheme(), + checkDynamic: Boolean = false, + ): String { var nowTheme = theme if (isTranslucentTheme(nowTheme)) { val colorTheme = @@ -289,7 +292,7 @@ object ThemeUtil { } else { THEME_TRANSLUCENT_LIGHT } - } else if (isUsingDynamicTheme() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { + } else if (checkDynamic && isUsingDynamicTheme() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { nowTheme = "${nowTheme}_dynamic" } return nowTheme