diff --git a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeBookSourceAdapter.kt b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeBookSourceAdapter.kt
index 0ccfe3e41..e94f8671b 100644
--- a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeBookSourceAdapter.kt
+++ b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeBookSourceAdapter.kt
@@ -6,6 +6,7 @@ import android.os.Bundle
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.widget.PopupMenu
+import androidx.core.graphics.drawable.DrawableCompat
import androidx.core.view.isVisible
import androidx.recyclerview.widget.DiffUtil
import io.legado.app.R
@@ -13,9 +14,8 @@ import io.legado.app.base.adapter.DiffRecyclerAdapter
import io.legado.app.base.adapter.ItemViewHolder
import io.legado.app.data.entities.SearchBook
import io.legado.app.databinding.ItemChangeSourceBinding
-import io.legado.app.utils.gone
-import io.legado.app.utils.invisible
-import io.legado.app.utils.visible
+import io.legado.app.utils.*
+import splitties.init.appCtx
import splitties.views.onLongClick
@@ -75,16 +75,18 @@ class ChangeBookSourceAdapter(
if (score > 0) {
binding.ivBad.gone()
binding.ivGood.visible()
- binding.ivGood.drawable.setTint(Color.parseColor("#D50000"))
+ DrawableCompat.setTint(binding.ivGood.drawable, appCtx.getCompatColor(R.color.md_red_A200))
+ DrawableCompat.setTint(binding.ivBad.drawable, appCtx.getCompatColor(R.color.md_blue_100))
} else if (score < 0) {
binding.ivGood.gone()
binding.ivBad.visible()
- binding.ivBad.drawable.setTint(Color.parseColor("#2962FF"))
+ DrawableCompat.setTint(binding.ivGood.drawable, appCtx.getCompatColor(R.color.md_red_100))
+ DrawableCompat.setTint(binding.ivBad.drawable, appCtx.getCompatColor(R.color.md_blue_A200))
} else {
binding.ivGood.visible()
binding.ivBad.visible()
- binding.ivGood.drawable.setTint(Color.parseColor("#FF8A80"))
- binding.ivBad.drawable.setTint(Color.parseColor("#82B1FF"))
+ DrawableCompat.setTint(binding.ivGood.drawable, appCtx.getCompatColor(R.color.md_red_100))
+ DrawableCompat.setTint(binding.ivBad.drawable, appCtx.getCompatColor(R.color.md_blue_100))
}
}
}
@@ -92,13 +94,13 @@ class ChangeBookSourceAdapter(
override fun registerListener(holder: ItemViewHolder, binding: ItemChangeSourceBinding) {
binding.ivGood.setOnClickListener {
if (binding.ivBad.isVisible) {
- binding.ivGood.drawable.setTint(Color.parseColor("#D50000"))
+ DrawableCompat.setTint(binding.ivGood.drawable, appCtx.getCompatColor(R.color.md_red_A200))
binding.ivBad.gone()
getItem(holder.layoutPosition)?.let {
callBack.setBookScore(it, 1)
}
} else {
- binding.ivGood.drawable.setTint(Color.parseColor("#FF8A80"))
+ DrawableCompat.setTint(binding.ivGood.drawable, appCtx.getCompatColor(R.color.md_red_100))
binding.ivBad.visible()
getItem(holder.layoutPosition)?.let {
callBack.setBookScore(it, 0)
@@ -107,13 +109,13 @@ class ChangeBookSourceAdapter(
}
binding.ivBad.setOnClickListener {
if (binding.ivGood.isVisible) {
- binding.ivBad.drawable.setTint(Color.parseColor("#2962FF"))
+ DrawableCompat.setTint(binding.ivBad.drawable, appCtx.getCompatColor(R.color.md_blue_A200))
binding.ivGood.gone()
getItem(holder.layoutPosition)?.let {
callBack.setBookScore(it, -1)
}
} else {
- binding.ivBad.drawable.setTint(Color.parseColor("#82B1FF"))
+ DrawableCompat.setTint(binding.ivBad.drawable, appCtx.getCompatColor(R.color.md_blue_100))
binding.ivGood.visible()
getItem(holder.layoutPosition)?.let {
callBack.setBookScore(it, 0)
diff --git a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeChapterSourceAdapter.kt b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeChapterSourceAdapter.kt
index 7e1bef5a3..7a3ae7daf 100644
--- a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeChapterSourceAdapter.kt
+++ b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeChapterSourceAdapter.kt
@@ -5,14 +5,19 @@ import android.os.Bundle
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.widget.PopupMenu
+import androidx.core.graphics.drawable.DrawableCompat
+import androidx.core.view.isVisible
import androidx.recyclerview.widget.DiffUtil
import io.legado.app.R
import io.legado.app.base.adapter.DiffRecyclerAdapter
import io.legado.app.base.adapter.ItemViewHolder
import io.legado.app.data.entities.SearchBook
import io.legado.app.databinding.ItemChangeSourceBinding
+import io.legado.app.utils.getCompatColor
+import io.legado.app.utils.gone
import io.legado.app.utils.invisible
import io.legado.app.utils.visible
+import splitties.init.appCtx
import splitties.views.onLongClick
@@ -68,10 +73,57 @@ class ChangeChapterSourceAdapter(
}
}
}
+ val score = callBack.getBookScore(item)
+ if (score > 0) {
+ binding.ivBad.gone()
+ binding.ivGood.visible()
+ DrawableCompat.setTint(binding.ivGood.drawable, appCtx.getCompatColor(R.color.md_red_A200))
+ DrawableCompat.setTint(binding.ivBad.drawable, appCtx.getCompatColor(R.color.md_blue_100))
+ } else if (score < 0) {
+ binding.ivGood.gone()
+ binding.ivBad.visible()
+ DrawableCompat.setTint(binding.ivGood.drawable, appCtx.getCompatColor(R.color.md_red_100))
+ DrawableCompat.setTint(binding.ivBad.drawable, appCtx.getCompatColor(R.color.md_blue_A200))
+ } else {
+ binding.ivGood.visible()
+ binding.ivBad.visible()
+ DrawableCompat.setTint(binding.ivGood.drawable, appCtx.getCompatColor(R.color.md_red_100))
+ DrawableCompat.setTint(binding.ivBad.drawable, appCtx.getCompatColor(R.color.md_blue_100))
+ }
}
}
override fun registerListener(holder: ItemViewHolder, binding: ItemChangeSourceBinding) {
+ binding.ivGood.setOnClickListener {
+ if (binding.ivBad.isVisible) {
+ DrawableCompat.setTint(binding.ivGood.drawable, appCtx.getCompatColor(R.color.md_red_A200))
+ binding.ivBad.gone()
+ getItem(holder.layoutPosition)?.let {
+ callBack.setBookScore(it, 1)
+ }
+ } else {
+ DrawableCompat.setTint(binding.ivGood.drawable, appCtx.getCompatColor(R.color.md_red_100))
+ binding.ivBad.visible()
+ getItem(holder.layoutPosition)?.let {
+ callBack.setBookScore(it, 0)
+ }
+ }
+ }
+ binding.ivBad.setOnClickListener {
+ if (binding.ivGood.isVisible) {
+ DrawableCompat.setTint(binding.ivBad.drawable, appCtx.getCompatColor(R.color.md_blue_A200))
+ binding.ivGood.gone()
+ getItem(holder.layoutPosition)?.let {
+ callBack.setBookScore(it, -1)
+ }
+ } else {
+ DrawableCompat.setTint(binding.ivBad.drawable, appCtx.getCompatColor(R.color.md_blue_100))
+ binding.ivGood.visible()
+ getItem(holder.layoutPosition)?.let {
+ callBack.setBookScore(it, 0)
+ }
+ }
+ }
holder.itemView.setOnClickListener {
getItem(holder.layoutPosition)?.let {
callBack.openToc(it)
@@ -118,5 +170,7 @@ class ChangeChapterSourceAdapter(
fun editSource(searchBook: SearchBook)
fun disableSource(searchBook: SearchBook)
fun deleteSource(searchBook: SearchBook)
+ fun setBookScore(searchBook: SearchBook, score: Int)
+ fun getBookScore(searchBook: SearchBook): Int
}
}
\ No newline at end of file
diff --git a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeChapterSourceDialog.kt b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeChapterSourceDialog.kt
index aeafb27ba..f745b5c0b 100644
--- a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeChapterSourceDialog.kt
+++ b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeChapterSourceDialog.kt
@@ -314,6 +314,14 @@ class ChangeChapterSourceDialog() : BaseDialogFragment(R.layout.dialog_chapter_c
}
}
+ override fun setBookScore(searchBook: SearchBook, score: Int) {
+ viewModel.setBookScore(searchBook, score)
+ }
+
+ override fun getBookScore(searchBook: SearchBook): Int {
+ return viewModel.getBookScore(searchBook)
+ }
+
override fun clickChapter(bookChapter: BookChapter, nextChapterUrl: String?) {
searchBook?.let {
binding.loadingToc.show()
diff --git a/app/src/main/res/layout/item_change_source.xml b/app/src/main/res/layout/item_change_source.xml
index 1338fbae8..4be15d5b3 100644
--- a/app/src/main/res/layout/item_change_source.xml
+++ b/app/src/main/res/layout/item_change_source.xml
@@ -9,7 +9,7 @@
+ app:tint="@color/md_red_A200" />
+ app:tint="@color/md_blue_A200" />