From abccf99f558ddbc95212a06248b8d77c98a587d5 Mon Sep 17 00:00:00 2001 From: SpiritCroc Date: Sun, 25 Jul 2021 10:34:27 +0200 Subject: [PATCH] Theme color of quotation bar Change-Id: Ia9d9c34c1bb276fea42b00131ea1915f93f23263 --- library/ui-styles/src/main/res/values/attrs_sc.xml | 1 + .../ui-styles/src/main/res/values/theme_dark.xml | 1 + .../ui-styles/src/main/res/values/theme_light.xml | 1 + library/ui-styles/src/main/res/values/theme_sc.xml | 1 + .../src/main/res/values/theme_sc_light.xml | 1 + .../vector/app/features/html/EventHtmlRenderer.kt | 13 +++++++++++++ 6 files changed, 18 insertions(+) diff --git a/library/ui-styles/src/main/res/values/attrs_sc.xml b/library/ui-styles/src/main/res/values/attrs_sc.xml index e952c7f092..4ccf77fa79 100644 --- a/library/ui-styles/src/main/res/values/attrs_sc.xml +++ b/library/ui-styles/src/main/res/values/attrs_sc.xml @@ -17,6 +17,7 @@ + diff --git a/library/ui-styles/src/main/res/values/theme_dark.xml b/library/ui-styles/src/main/res/values/theme_dark.xml index bfedc419c3..63e4211dd4 100644 --- a/library/ui-styles/src/main/res/values/theme_dark.xml +++ b/library/ui-styles/src/main/res/values/theme_dark.xml @@ -126,6 +126,7 @@ @style/Widget.Vector.TextInputLayout.Dense.ExposedDropdownMenu.Dark.SC ?vctr_header_background #19ffffff + ?code_block_bg_color @color/user_color_element_pl_0 @color/user_color_element_pl_1 @color/user_color_element_pl_50 diff --git a/library/ui-styles/src/main/res/values/theme_light.xml b/library/ui-styles/src/main/res/values/theme_light.xml index c01c725b4a..68e0eff991 100644 --- a/library/ui-styles/src/main/res/values/theme_light.xml +++ b/library/ui-styles/src/main/res/values/theme_light.xml @@ -126,6 +126,7 @@ @style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense.ExposedDropdownMenu ?vctr_header_background #19000000 + ?code_block_bg_color @color/user_color_element_pl_0 @color/user_color_element_pl_1 @color/user_color_element_pl_50 diff --git a/library/ui-styles/src/main/res/values/theme_sc.xml b/library/ui-styles/src/main/res/values/theme_sc.xml index 33bb89ff4f..4ae5942b2c 100644 --- a/library/ui-styles/src/main/res/values/theme_sc.xml +++ b/library/ui-styles/src/main/res/values/theme_sc.xml @@ -87,6 +87,7 @@ @color/accent_sc_pale @color/accent_sc_alpha25 @color/code_background_sc + ?vctr_content_quaternary @color/user_color_sc_pl_0 @color/user_color_sc_pl_1 @color/user_color_sc_pl_50 diff --git a/library/ui-styles/src/main/res/values/theme_sc_light.xml b/library/ui-styles/src/main/res/values/theme_sc_light.xml index 89049c4f24..61a0da6bfe 100644 --- a/library/ui-styles/src/main/res/values/theme_sc_light.xml +++ b/library/ui-styles/src/main/res/values/theme_sc_light.xml @@ -87,6 +87,7 @@ @color/accent_sc_pale #ffe0e0e0 @color/code_background_sc_light + ?vctr_content_quaternary @color/user_color_sc_pl_0 @color/user_color_sc_pl_1 @color/user_color_sc_pl_50 diff --git a/vector/src/main/java/im/vector/app/features/html/EventHtmlRenderer.kt b/vector/src/main/java/im/vector/app/features/html/EventHtmlRenderer.kt index 5bdac9e34d..865606fae1 100644 --- a/vector/src/main/java/im/vector/app/features/html/EventHtmlRenderer.kt +++ b/vector/src/main/java/im/vector/app/features/html/EventHtmlRenderer.kt @@ -37,8 +37,11 @@ class EventHtmlRenderer @Inject constructor(private val htmlConfigure: MatrixHtm private fun resolveCodeBlockBackground() = ThemeUtils.getColor(context, R.attr.code_block_bg_color) + private fun resolveQuoteBarColor() = + ThemeUtils.getColor(context, R.attr.quote_bar_color) private var codeBlockBackground: Int = resolveCodeBlockBackground() + private var quoteBarColor: Int = resolveQuoteBarColor() interface PostProcessor { fun afterRender(renderedText: Spannable) @@ -52,6 +55,7 @@ class EventHtmlRenderer @Inject constructor(private val htmlConfigure: MatrixHtm super.configureTheme(builder) builder.codeBlockBackgroundColor(codeBlockBackground) .codeBackgroundColor(codeBlockBackground) + .blockQuoteColor(quoteBarColor) } } )) @@ -60,8 +64,17 @@ class EventHtmlRenderer @Inject constructor(private val htmlConfigure: MatrixHtm private var markwon: Markwon = buildMarkwon() get() { val newCodeBlockBackground = resolveCodeBlockBackground() + val newQuoteBarColor = resolveQuoteBarColor() + var changed = false if (codeBlockBackground != newCodeBlockBackground) { codeBlockBackground = newCodeBlockBackground + changed = true + } + if (quoteBarColor != newQuoteBarColor) { + quoteBarColor = newQuoteBarColor + changed = true + } + if (changed) { field = buildMarkwon() } return field