Fix read button coloring

master
Zakhar Timoshenko 2 years ago
parent 265fbc9f63
commit 44b71460ee
Signed by: Xtimms
SSH Key Fingerprint: SHA256:wH6spYepK/A5erBh7ZyAnr1ru9H4eaMVBEuiw6DSpxI

@ -35,8 +35,9 @@ class ProgressButton @JvmOverloads constructor(
private val paint = Paint(Paint.ANTI_ALIAS_FLAG) private val paint = Paint(Paint.ANTI_ALIAS_FLAG)
private var progress = 0f private var progress = 0f
private var colorBase = context.getThemeColor(materialR.attr.colorSecondaryContainer) private var colorBase = context.getThemeColor(materialR.attr.colorPrimaryContainer)
private var colorProgress = context.getThemeColor(materialR.attr.colorPrimary) private var colorProgress = context.getThemeColor(materialR.attr.colorPrimary)
private var colorText = context.getThemeColor(materialR.attr.colorOnPrimaryContainer)
private var progressAnimator: ValueAnimator? = null private var progressAnimator: ValueAnimator? = null
var title: CharSequence? var title: CharSequence?
@ -70,6 +71,9 @@ class ProgressButton @JvmOverloads constructor(
textViewSubtitle.text = getText(R.styleable.ProgressButton_subtitle) textViewSubtitle.text = getText(R.styleable.ProgressButton_subtitle)
colorBase = getColor(R.styleable.ProgressButton_baseColor, colorBase) colorBase = getColor(R.styleable.ProgressButton_baseColor, colorBase)
colorProgress = getColor(R.styleable.ProgressButton_progressColor, colorProgress) colorProgress = getColor(R.styleable.ProgressButton_progressColor, colorProgress)
colorText = getColor(R.styleable.ProgressButton_textColor, colorText)
textViewTitle.setTextColor(colorText)
textViewSubtitle.setTextColor(colorText)
progress = getInt(R.styleable.ProgressButton_android_progress, 0).toFloat() / progress = getInt(R.styleable.ProgressButton_android_progress, 0).toFloat() /
getInt(R.styleable.ProgressButton_android_max, 100).toFloat() getInt(R.styleable.ProgressButton_android_max, 100).toFloat()
} }
@ -84,6 +88,7 @@ class ProgressButton @JvmOverloads constructor(
paint.style = Paint.Style.FILL paint.style = Paint.Style.FILL
paint.color = colorProgress paint.color = colorProgress
paint.alpha = 84 // 255 * 0.33F
applyGravity() applyGravity()
setWillNotDraw(false) setWillNotDraw(false)
} }

@ -183,8 +183,9 @@
app:layout_constraintEnd_toStartOf="@id/button_chapters" app:layout_constraintEnd_toStartOf="@id/button_chapters"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/info_layout" app:layout_constraintTop_toBottomOf="@id/info_layout"
app:progressColor="?colorSecondaryFixedDim" app:progressColor="?colorPrimary"
app:subtitleTextAppearance="?textAppearanceBodySmall" app:subtitleTextAppearance="?textAppearanceBodySmall"
app:textColor="?colorOnPrimaryContainer"
app:titleTextAppearance="?textAppearanceButton" app:titleTextAppearance="?textAppearanceButton"
tools:max="100" tools:max="100"
tools:progress="40" tools:progress="40"

@ -153,6 +153,7 @@
<attr name="subtitleTextAppearance" /> <attr name="subtitleTextAppearance" />
<attr name="title" /> <attr name="title" />
<attr name="subtitle" /> <attr name="subtitle" />
<attr name="textColor" format="color" />
<attr name="android:max" /> <attr name="android:max" />
<attr name="android:progress" /> <attr name="android:progress" />
<attr name="baseColor" format="color" /> <attr name="baseColor" format="color" />

Loading…
Cancel
Save