1818package org.wordpress.aztec.spans
1919
2020import android.graphics.Canvas
21+ import android.graphics.Color
2122import android.graphics.Paint
2223import android.graphics.Rect
2324import android.text.Layout
@@ -42,6 +43,7 @@ class AztecQuoteSpan : QuoteSpan, LineBackgroundSpan, AztecBlockSpan, LineHeight
4243 private var quoteMargin: Int = 0
4344 private var quotePadding: Int = 0
4445 private var quoteWidth: Int = 0
46+ private var quoteBackgroundAlpha: Float = 0.0f
4547
4648 override var attributes: String = " "
4749
@@ -57,6 +59,7 @@ class AztecQuoteSpan : QuoteSpan, LineBackgroundSpan, AztecBlockSpan, LineHeight
5759 this .quoteMargin = quoteStyle.quoteMargin
5860 this .quoteWidth = quoteStyle.quoteWidth
5961 this .quotePadding = quoteStyle.quotePadding
62+ this .quoteBackgroundAlpha = quoteStyle.quoteBackgroundAlpha
6063 }
6164
6265 override fun chooseHeight (text : CharSequence , start : Int , end : Int , spanstartv : Int , v : Int , fm : Paint .FontMetricsInt ) {
@@ -108,9 +111,10 @@ class AztecQuoteSpan : QuoteSpan, LineBackgroundSpan, AztecBlockSpan, LineHeight
108111 top : Int , baseline : Int , bottom : Int ,
109112 text : CharSequence? , start : Int , end : Int ,
110113 lnum : Int ) {
111- val paintColor = p.color
112- p.color = quoteBackground
114+ val alpha: Int = (quoteBackgroundAlpha * 255 ).toInt()
113115
116+ val paintColor = p.color
117+ p.color = Color .argb(alpha, Color .red(quoteBackground), Color .green(quoteBackground), Color .blue(quoteBackground))
114118 rect.set(left + quoteMargin, top, right, bottom)
115119
116120 c.drawRect(rect, p)
0 commit comments