Hush lite wallet for Android
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
1.3 KiB

package cash.z.ecc.android.ui.util
import android.text.TextPaint
import android.text.style.MetricAffectingSpan
import androidx.core.content.ContextCompat
import cash.z.ecc.android.R
import cash.z.ecc.android.ZcashWalletApp
/**
* A span used for numbering the parts of an address. It combines a [android.text.style.RelativeSizeSpan],
* [android.text.style.SuperscriptSpan], and a [android.text.style.ForegroundColorSpan] into one class for efficiency.
*/
class AddressPartNumberSpan(
val proportion: Float = 0.5f,
val color: Int = ContextCompat.getColor(ZcashWalletApp.instance, R.color.colorPrimary)
) : MetricAffectingSpan() {
override fun updateMeasureState(textPaint: TextPaint) {
textPaint.baselineShift += (textPaint.ascent() / 2).toInt() // from SuperscriptSpan
textPaint.textSize = textPaint.textSize * proportion // from RelativeSizeSpan
}
override fun updateDrawState(textPaint: TextPaint) {
textPaint.baselineShift += (textPaint.ascent() / 2).toInt() // from SuperscriptSpan (baseline must shift before resizing or else it will not properly align to the top of the text)
textPaint.textSize = textPaint.textSize * proportion // from RelativeSizeSpan
textPaint.color = color // from ForegroundColorSpan
}
}