Skip to content

Commit 25e45c5

Browse files
authored
Merge pull request #249 from wordpress-mobile/issue/fixing-block-quote-cursor-visisibility
Fixin visibility of cursor in quote
2 parents 5fe04ff + e4f1407 commit 25e45c5

File tree

5 files changed

+10
-3
lines changed

5 files changed

+10
-3
lines changed

aztec/src/main/kotlin/org/wordpress/aztec/AztecText.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ class AztecText : EditText, TextWatcher {
146146
BlockFormatter.QuoteStyle(
147147
array.getColor(R.styleable.AztecText_quoteBackground, 0),
148148
array.getColor(R.styleable.AztecText_quoteColor, 0),
149+
array.getFraction(R.styleable.AztecText_quoteBackgroundAlpha, 1, 1, 0f),
149150
array.getDimensionPixelSize(R.styleable.AztecText_quoteMargin, 0),
150151
array.getDimensionPixelSize(R.styleable.AztecText_quotePadding, 0),
151152
array.getDimensionPixelSize(R.styleable.AztecText_quoteWidth, 0),

aztec/src/main/kotlin/org/wordpress/aztec/formatting/BlockFormatter.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import java.util.*
1414
class BlockFormatter(editor: AztecText, listStyle: ListStyle, quoteStyle: QuoteStyle) : AztecFormatter(editor) {
1515

1616
data class ListStyle(val indicatorColor: Int, val indicatorMargin: Int, val indicatorPadding: Int, val indicatorWidth: Int, val verticalPadding: Int)
17-
data class QuoteStyle(val quoteBackground: Int, val quoteColor: Int, val quoteMargin: Int, val quotePadding: Int, val quoteWidth: Int, val verticalPadding: Int)
17+
data class QuoteStyle(val quoteBackground: Int, val quoteColor: Int, val quoteBackgroundAlpha: Float, val quoteMargin: Int, val quotePadding: Int, val quoteWidth: Int, val verticalPadding: Int)
1818

1919
val listStyle: ListStyle
2020
val quoteStyle: QuoteStyle

aztec/src/main/kotlin/org/wordpress/aztec/spans/AztecQuoteSpan.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
package org.wordpress.aztec.spans
1919

2020
import android.graphics.Canvas
21+
import android.graphics.Color
2122
import android.graphics.Paint
2223
import android.graphics.Rect
2324
import 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)

aztec/src/main/res/values/attrs.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
<attr name="linkUnderline" format="reference|boolean" />
2121
<attr name="quoteBackground" format="reference|color" />
2222
<attr name="quoteColor" format="reference|color" />
23+
<attr name="quoteBackgroundAlpha" format="reference|fraction" />
2324
<attr name="quoteMargin" format="reference|dimension" />
2425
<attr name="quotePadding" format="reference|dimension" />
2526
<attr name="quoteWidth" format="reference|dimension" />

aztec/src/main/res/values/styles.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
<item name="linkUnderline">false</item>
3939
<item name="quoteBackground">@color/blue_wordpress</item>
4040
<item name="quoteColor">@color/blue_medium</item>
41+
<item name="quoteBackgroundAlpha">75%</item>
4142
<item name="quoteMargin">@dimen/quote_margin</item>
4243
<item name="quotePadding">@dimen/quote_padding</item>
4344
<item name="quoteWidth">@dimen/quote_width</item>

0 commit comments

Comments
 (0)