Change spoiler bg colors

This commit is contained in:
Benoit Marty 2019-11-04 16:46:30 +01:00
parent 3c4c0ed46a
commit b3233d3eb7
5 changed files with 11 additions and 4 deletions

View File

@ -28,7 +28,8 @@ class SpanHandler(context: Context) : TagHandler() {
override fun supportedTags() = listOf("span")
private val spoilerBgColor: Int = ThemeUtils.getColor(context, R.attr.vctr_markdown_block_background_color)
private val spoilerBgColorHidden: Int = ThemeUtils.getColor(context, R.attr.vctr_spoiler_background_color)
private val spoilerBgColorRevealed: Int = ThemeUtils.getColor(context, R.attr.vctr_markdown_block_background_color)
private val textColor: Int = ThemeUtils.getColor(context, R.attr.riotx_text_primary)
@ -37,7 +38,7 @@ class SpanHandler(context: Context) : TagHandler() {
if (mxSpoiler != null) {
SpannableBuilder.setSpans(
visitor.builder(),
SpoilerSpan(spoilerBgColor, textColor),
SpoilerSpan(spoilerBgColorHidden, spoilerBgColorRevealed, textColor),
tag.start(),
tag.end()
)

View File

@ -21,7 +21,9 @@ import android.text.TextPaint
import android.text.style.ClickableSpan
import android.view.View
class SpoilerSpan(private val bgColor: Int, private val textColor: Int) : ClickableSpan() {
class SpoilerSpan(private val bgColorHidden: Int,
private val bgColorRevealed: Int,
private val textColor: Int) : ClickableSpan() {
override fun onClick(widget: View) {
isHidden = !isHidden
@ -31,10 +33,11 @@ class SpoilerSpan(private val bgColor: Int, private val textColor: Int) : Clicka
private var isHidden = true
override fun updateDrawState(tp: TextPaint) {
tp.bgColor = bgColor
if (isHidden) {
tp.bgColor = bgColorHidden
tp.color = Color.TRANSPARENT
} else {
tp.bgColor = bgColorRevealed
tp.color = textColor
}
}

View File

@ -34,6 +34,7 @@
<attr name="vctr_unread_marker_line_color" format="color" />
<attr name="vctr_markdown_block_background_color" format="color" />
<attr name="vctr_room_activity_divider_color" format="color" />
<attr name="vctr_spoiler_background_color" format="color" />
<!-- tab bar colors -->
<attr name="vctr_tab_bar_inverted_background_color" format="color" />

View File

@ -101,6 +101,7 @@
<item name="vctr_search_mode_room_name_text_color">#CCC3C3C3</item>
<item name="vctr_unread_marker_line_color">@color/accent_color_dark</item>
<item name="vctr_markdown_block_background_color">@android:color/black</item>
<item name="vctr_spoiler_background_color">#FFFFFFFF</item>
<item name="vctr_room_activity_divider_color">#565656</item>
<!-- tab bar colors -->

View File

@ -101,6 +101,7 @@
<item name="vctr_search_mode_room_name_text_color">#333C3C3C</item>
<item name="vctr_unread_marker_line_color">@color/accent_color_light</item>
<item name="vctr_markdown_block_background_color">#FFEEEEEE</item>
<item name="vctr_spoiler_background_color">#FF000000</item>
<item name="vctr_room_activity_divider_color">#FFF2F2F2</item>
<!-- tab bar colors -->