diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/core/ui/widgets/ProgressButton.kt b/app/src/main/kotlin/org/koitharu/kotatsu/core/ui/widgets/ProgressButton.kt
index 16ff3449d..d95b1dd63 100644
--- a/app/src/main/kotlin/org/koitharu/kotatsu/core/ui/widgets/ProgressButton.kt
+++ b/app/src/main/kotlin/org/koitharu/kotatsu/core/ui/widgets/ProgressButton.kt
@@ -2,7 +2,9 @@ package org.koitharu.kotatsu.core.ui.widgets
import android.animation.ValueAnimator
import android.content.Context
+import android.content.res.ColorStateList
import android.graphics.Canvas
+import android.graphics.Color
import android.graphics.Outline
import android.graphics.Paint
import android.util.AttributeSet
@@ -19,6 +21,7 @@ import androidx.core.widget.TextViewCompat
import org.koitharu.kotatsu.R
import org.koitharu.kotatsu.core.util.ext.getAnimationDuration
import org.koitharu.kotatsu.core.util.ext.getThemeColor
+import org.koitharu.kotatsu.core.util.ext.getThemeColorStateList
import org.koitharu.kotatsu.core.util.ext.resolveDp
import org.koitharu.kotatsu.core.util.ext.setTextAndVisible
import org.koitharu.kotatsu.core.util.ext.textAndVisible
@@ -35,9 +38,8 @@ class ProgressButton @JvmOverloads constructor(
private val paint = Paint(Paint.ANTI_ALIAS_FLAG)
private var progress = 0f
- private var colorBase = context.getThemeColor(materialR.attr.colorPrimaryContainer)
- private var colorProgress = context.getThemeColor(materialR.attr.colorPrimary)
- private var colorText = context.getThemeColor(materialR.attr.colorOnPrimaryContainer)
+ private var colorBase: ColorStateList = ColorStateList.valueOf(Color.TRANSPARENT)
+ private var colorProgress: ColorStateList = ColorStateList.valueOf(Color.TRANSPARENT)
private var progressAnimator: ValueAnimator? = null
var title: CharSequence?
@@ -69,9 +71,12 @@ class ProgressButton @JvmOverloads constructor(
)
textViewTitle.text = getText(R.styleable.ProgressButton_title)
textViewSubtitle.text = getText(R.styleable.ProgressButton_subtitle)
- colorBase = getColor(R.styleable.ProgressButton_baseColor, colorBase)
- colorProgress = getColor(R.styleable.ProgressButton_progressColor, colorProgress)
- colorText = getColor(R.styleable.ProgressButton_textColor, colorText)
+ colorBase = getColorStateList(R.styleable.ProgressButton_baseColor)
+ ?: context.getThemeColorStateList(materialR.attr.colorPrimaryContainer) ?: colorBase
+ colorProgress = getColorStateList(R.styleable.ProgressButton_progressColor)
+ ?: context.getThemeColorStateList(materialR.attr.colorPrimary) ?: colorProgress
+ val colorText = getColorStateList(R.styleable.ProgressButton_android_textColor)
+ ?: context.getThemeColorStateList(materialR.attr.colorOnPrimaryContainer) ?: textViewTitle.textColors
textViewTitle.setTextColor(colorText)
textViewSubtitle.setTextColor(colorText)
progress = getInt(R.styleable.ProgressButton_android_progress, 0).toFloat() /
@@ -87,15 +92,15 @@ class ProgressButton @JvmOverloads constructor(
)
paint.style = Paint.Style.FILL
- paint.color = colorProgress
- paint.alpha = 84 // 255 * 0.33F
applyGravity()
setWillNotDraw(false)
}
override fun onDraw(canvas: Canvas) {
super.onDraw(canvas)
- canvas.drawColor(colorBase)
+ canvas.drawColor(colorBase.getColorForState(drawableState, colorBase.defaultColor))
+ paint.color = colorProgress.getColorForState(drawableState, colorProgress.defaultColor)
+ paint.alpha = 84 // 255 * 0.33F
canvas.drawRect(0f, 0f, width * progress, height.toFloat(), paint)
}
diff --git a/app/src/main/res/layout/activity_details_new.xml b/app/src/main/res/layout/activity_details_new.xml
index 830a59794..25803c384 100644
--- a/app/src/main/res/layout/activity_details_new.xml
+++ b/app/src/main/res/layout/activity_details_new.xml
@@ -105,8 +105,8 @@
android:id="@+id/imageView_state"
android:layout_width="0dp"
android:layout_height="0dp"
- android:layout_marginStart="16dp"
android:layout_marginVertical="0.5dp"
+ android:layout_marginStart="16dp"
app:layout_constraintBottom_toBottomOf="@id/textView_state"
app:layout_constraintDimensionRatio="1"
app:layout_constraintStart_toEndOf="@id/imageView_cover"
@@ -180,12 +180,13 @@
android:gravity="center"
android:paddingHorizontal="6dp"
android:paddingVertical="8dp"
+ android:textColor="?colorOnPrimaryContainer"
+ app:baseColor="?colorSecondaryContainer"
app:layout_constraintEnd_toStartOf="@id/button_chapters"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/info_layout"
app:progressColor="?colorPrimary"
app:subtitleTextAppearance="?textAppearanceBodySmall"
- app:textColor="?colorOnPrimaryContainer"
app:titleTextAppearance="?textAppearanceButton"
tools:max="100"
tools:progress="40"
diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml
index 66d8d775d..82605a208 100644
--- a/app/src/main/res/values/attrs.xml
+++ b/app/src/main/res/values/attrs.xml
@@ -153,7 +153,7 @@
-
+