From bf80dd622c9ebbdd27500f210858231a74ac3f4f Mon Sep 17 00:00:00 2001
From: Ivan Iskandar <12537387+ivaniskandar@users.noreply.github.com>
Date: Sun, 25 Apr 2021 22:36:13 +0700
Subject: [PATCH] Fix download error icon color tint (#4959)
* Fix download error color tint
* Use progress indicator as download icon border
* Resolve feedback
* Use extension function to set tinted drawable
---
.../ui/manga/chapter/ChapterDownloadView.kt | 31 ++++++++++---------
app/src/main/res/drawable/border_circle.xml | 12 -------
.../res/drawable/ic_error_outline_24dp.xml | 3 +-
.../main/res/layout/chapter_download_view.xml | 14 +--------
4 files changed, 18 insertions(+), 42 deletions(-)
delete mode 100644 app/src/main/res/drawable/border_circle.xml
diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChapterDownloadView.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChapterDownloadView.kt
index 59a0c53670..e53ab627ee 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChapterDownloadView.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChapterDownloadView.kt
@@ -5,11 +5,11 @@ import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import android.widget.FrameLayout
-import androidx.core.content.ContextCompat
import androidx.core.view.isVisible
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.download.model.Download
import eu.kanade.tachiyomi.databinding.ChapterDownloadViewBinding
+import eu.kanade.tachiyomi.util.view.setVectorCompat
class ChapterDownloadView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
FrameLayout(context, attrs) {
@@ -28,18 +28,12 @@ class ChapterDownloadView @JvmOverloads constructor(context: Context, attrs: Att
fun setState(state: Download.State, progress: Int = 0) {
val isDirty = this.state.value != state.value || this.progress != progress
-
- this.state = state
- this.progress = progress
-
if (isDirty) {
- updateLayout()
+ updateLayout(state, progress)
}
}
- private fun updateLayout() {
- binding.downloadIconBorder.isVisible = state == Download.State.NOT_DOWNLOADED || state == Download.State.QUEUE
-
+ private fun updateLayout(state: Download.State, progress: Int) {
binding.downloadIcon.isVisible = state == Download.State.NOT_DOWNLOADED ||
state == Download.State.DOWNLOADING || state == Download.State.QUEUE
if (state == Download.State.DOWNLOADING || state == Download.State.QUEUE) {
@@ -59,21 +53,28 @@ class ChapterDownloadView @JvmOverloads constructor(context: Context, attrs: Att
binding.downloadIcon.alpha = 1f
}
- binding.downloadProgress.isVisible = state == Download.State.DOWNLOADING
- binding.downloadProgress.setProgressCompat(progress, true)
+ binding.downloadProgress.isVisible = state == Download.State.DOWNLOADING ||
+ state == Download.State.NOT_DOWNLOADED || state == Download.State.QUEUE
+ if (state == Download.State.DOWNLOADING) {
+ binding.downloadProgress.setProgressCompat(progress, true)
+ } else {
+ binding.downloadProgress.setProgressCompat(100, true)
+ }
binding.downloadStatusIcon.apply {
if (state == Download.State.DOWNLOADED || state == Download.State.ERROR) {
isVisible = true
- val drawable = if (state == Download.State.DOWNLOADED) {
- ContextCompat.getDrawable(context, R.drawable.ic_check_circle_24dp)
+ if (state == Download.State.DOWNLOADED) {
+ setVectorCompat(R.drawable.ic_check_circle_24dp, android.R.attr.textColorPrimary)
} else {
- ContextCompat.getDrawable(context, R.drawable.ic_error_outline_24dp)
+ setVectorCompat(R.drawable.ic_error_outline_24dp, R.attr.colorError)
}
- setImageDrawable(drawable)
} else {
isVisible = false
}
}
+
+ this.state = state
+ this.progress = progress
}
}
diff --git a/app/src/main/res/drawable/border_circle.xml b/app/src/main/res/drawable/border_circle.xml
deleted file mode 100644
index 4dbe8c7bdc..0000000000
--- a/app/src/main/res/drawable/border_circle.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
diff --git a/app/src/main/res/drawable/ic_error_outline_24dp.xml b/app/src/main/res/drawable/ic_error_outline_24dp.xml
index 74e6527945..5ea6b9db16 100644
--- a/app/src/main/res/drawable/ic_error_outline_24dp.xml
+++ b/app/src/main/res/drawable/ic_error_outline_24dp.xml
@@ -2,8 +2,7 @@
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
- android:viewportHeight="24"
- android:tint="?colorError">
+ android:viewportHeight="24">
diff --git a/app/src/main/res/layout/chapter_download_view.xml b/app/src/main/res/layout/chapter_download_view.xml
index 9b5d5c6dd8..f1bb020d9f 100644
--- a/app/src/main/res/layout/chapter_download_view.xml
+++ b/app/src/main/res/layout/chapter_download_view.xml
@@ -7,16 +7,6 @@
android:padding="8dp"
android:background="?selectableItemBackgroundBorderless">
-
-