Skip to content

Commit

Permalink
Added alpha to quote background color method.
Browse files Browse the repository at this point in the history
  • Loading branch information
khaykov committed Feb 13, 2017
1 parent aa16828 commit e4f1407
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions aztec/src/main/kotlin/org/wordpress/aztec/AztecText.kt
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ class AztecText : EditText, TextWatcher {
BlockFormatter.QuoteStyle(
array.getColor(R.styleable.AztecText_quoteBackground, 0),
array.getColor(R.styleable.AztecText_quoteColor, 0),
array.getFraction(R.styleable.AztecText_quoteBackgroundAlpha, 1, 1, 0f),
array.getDimensionPixelSize(R.styleable.AztecText_quoteMargin, 0),
array.getDimensionPixelSize(R.styleable.AztecText_quotePadding, 0),
array.getDimensionPixelSize(R.styleable.AztecText_quoteWidth, 0),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import java.util.*
class BlockFormatter(editor: AztecText, listStyle: ListStyle, quoteStyle: QuoteStyle) : AztecFormatter(editor) {

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

val listStyle: ListStyle
val quoteStyle: QuoteStyle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.wordpress.aztec.spans

import android.graphics.Canvas
import android.graphics.Color
import android.graphics.Paint
import android.graphics.Rect
import android.text.Layout
Expand All @@ -42,6 +43,7 @@ class AztecQuoteSpan : QuoteSpan, LineBackgroundSpan, AztecBlockSpan, LineHeight
private var quoteMargin: Int = 0
private var quotePadding: Int = 0
private var quoteWidth: Int = 0
private var quoteBackgroundAlpha: Float = 0.0f

override var attributes: String = ""

Expand All @@ -57,6 +59,7 @@ class AztecQuoteSpan : QuoteSpan, LineBackgroundSpan, AztecBlockSpan, LineHeight
this.quoteMargin = quoteStyle.quoteMargin
this.quoteWidth = quoteStyle.quoteWidth
this.quotePadding = quoteStyle.quotePadding
this.quoteBackgroundAlpha = quoteStyle.quoteBackgroundAlpha
}

override fun chooseHeight(text: CharSequence, start: Int, end: Int, spanstartv: Int, v: Int, fm: Paint.FontMetricsInt) {
Expand Down Expand Up @@ -108,9 +111,10 @@ class AztecQuoteSpan : QuoteSpan, LineBackgroundSpan, AztecBlockSpan, LineHeight
top: Int, baseline: Int, bottom: Int,
text: CharSequence?, start: Int, end: Int,
lnum: Int) {
val paintColor = p.color
p.color = quoteBackground
val alpha: Int = (quoteBackgroundAlpha * 255).toInt()

val paintColor = p.color
p.color = Color.argb(alpha, Color.red(quoteBackground), Color.green(quoteBackground), Color.blue(quoteBackground))
rect.set(left + quoteMargin, top, right, bottom)

c.drawRect(rect, p)
Expand Down

0 comments on commit e4f1407

Please sign in to comment.