mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-09 19:55:11 +01:00
Download button now matches accent when downloaded
This commit is contained in:
parent
9cde6a5eaa
commit
3977b2a67a
@ -6,6 +6,7 @@ import android.graphics.Color
|
|||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.widget.FrameLayout
|
import android.widget.FrameLayout
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
|
import androidx.core.graphics.ColorUtils
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.download.model.Download
|
import eu.kanade.tachiyomi.data.download.model.Download
|
||||||
import eu.kanade.tachiyomi.databinding.DownloadButtonBinding
|
import eu.kanade.tachiyomi.databinding.DownloadButtonBinding
|
||||||
@ -16,7 +17,14 @@ import eu.kanade.tachiyomi.util.view.visible
|
|||||||
class DownloadButton @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
|
class DownloadButton @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
|
||||||
FrameLayout(context, attrs) {
|
FrameLayout(context, attrs) {
|
||||||
|
|
||||||
private val activeColor = context.getResourceColor(R.attr.colorAccent)
|
private val activeColor = ColorUtils.blendARGB(
|
||||||
|
context.getResourceColor(R.attr.colorAccent),
|
||||||
|
ContextCompat.getColor(
|
||||||
|
context,
|
||||||
|
R.color.download
|
||||||
|
),
|
||||||
|
0.3f
|
||||||
|
)
|
||||||
private val progressBGColor = ContextCompat.getColor(
|
private val progressBGColor = ContextCompat.getColor(
|
||||||
context,
|
context,
|
||||||
R.color.divider
|
R.color.divider
|
||||||
@ -25,10 +33,8 @@ class DownloadButton @JvmOverloads constructor(context: Context, attrs: Attribut
|
|||||||
context,
|
context,
|
||||||
R.color.material_on_surface_disabled
|
R.color.material_on_surface_disabled
|
||||||
)
|
)
|
||||||
private val downloadedColor = ContextCompat.getColor(
|
private val downloadedColor = context.getResourceColor(R.attr.colorAccent)
|
||||||
context,
|
private val downloadedTextColor = context.getResourceColor(R.attr.colorOnAccent)
|
||||||
R.color.download
|
|
||||||
)
|
|
||||||
private val errorColor = ContextCompat.getColor(
|
private val errorColor = ContextCompat.getColor(
|
||||||
context,
|
context,
|
||||||
R.color.material_red_500
|
R.color.material_red_500
|
||||||
@ -120,7 +126,7 @@ class DownloadButton @JvmOverloads constructor(context: Context, attrs: Attribut
|
|||||||
binding.downloadProgressIndeterminate.gone()
|
binding.downloadProgressIndeterminate.gone()
|
||||||
binding.downloadBorder.setImageDrawable(filledCircle)
|
binding.downloadBorder.setImageDrawable(filledCircle)
|
||||||
binding.downloadBorder.drawable.setTint(downloadedColor)
|
binding.downloadBorder.drawable.setTint(downloadedColor)
|
||||||
binding.downloadIcon.drawable.setTint(Color.WHITE)
|
binding.downloadIcon.drawable.setTint(downloadedTextColor)
|
||||||
}
|
}
|
||||||
Download.ERROR -> {
|
Download.ERROR -> {
|
||||||
binding.downloadProgress.gone()
|
binding.downloadProgress.gone()
|
||||||
|
Loading…
Reference in New Issue
Block a user