From 9cbb06995b2dd8b01ed417ec06d5ebb0a5f12dd1 Mon Sep 17 00:00:00 2001 From: gedoor Date: Sat, 13 Feb 2021 23:50:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=B8=BB=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../book/source/manage/BookSourceAdapter.kt | 3 ++- .../main/bookshelf/books/BooksAdapterGrid.kt | 15 ++++++----- .../main/bookshelf/books/BooksAdapterList.kt | 27 ++++++++++--------- .../app/ui/replace/ReplaceRuleAdapter.kt | 3 ++- .../ui/rss/source/manage/RssSourceAdapter.kt | 3 ++- .../app/ui/widget/prefs/PreferenceCategory.kt | 10 +++++-- 6 files changed, 36 insertions(+), 25 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceAdapter.kt b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceAdapter.kt index 2b17c3189..84885bc3d 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceAdapter.kt @@ -18,6 +18,7 @@ import io.legado.app.databinding.ItemBookSourceBinding import io.legado.app.lib.theme.backgroundColor import io.legado.app.ui.widget.recycler.DragSelectTouchHelper import io.legado.app.ui.widget.recycler.ItemTouchCallback.Callback +import io.legado.app.utils.ColorUtils import io.legado.app.utils.invisible import io.legado.app.utils.visible @@ -86,7 +87,7 @@ class BookSourceAdapter(context: Context, val callBack: CallBack) : with(binding) { val payload = payloads.getOrNull(0) as? Bundle if (payload == null) { - root.setBackgroundColor(context.backgroundColor) + root.setBackgroundColor(ColorUtils.withAlpha(context.backgroundColor, 0.5f)) if (item.bookSourceGroup.isNullOrEmpty()) { cbBookSource.text = item.bookSourceName } else { diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksAdapterGrid.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksAdapterGrid.kt index f8897ca9e..286c13b74 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksAdapterGrid.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksAdapterGrid.kt @@ -7,7 +7,8 @@ import io.legado.app.base.adapter.ItemViewHolder import io.legado.app.constant.BookType import io.legado.app.data.entities.Book import io.legado.app.databinding.ItemBookshelfGridBinding -import io.legado.app.lib.theme.ATH +import io.legado.app.lib.theme.backgroundColor +import io.legado.app.utils.ColorUtils import io.legado.app.utils.invisible import splitties.views.onLongClick @@ -23,18 +24,18 @@ class BooksAdapterGrid(context: Context, private val callBack: CallBack) : binding: ItemBookshelfGridBinding, item: Book, payloads: MutableList - ) { + ) = with(binding) { val bundle = payloads.getOrNull(0) as? Bundle if (bundle == null) { - ATH.applyBackgroundTint(binding.root) - binding.tvName.text = item.name - binding.ivCover.load(item.getDisplayCover(), item.name, item.author) + root.setBackgroundColor(ColorUtils.withAlpha(context.backgroundColor, 0.5f)) + tvName.text = item.name + ivCover.load(item.getDisplayCover(), item.name, item.author) upRefresh(binding, item) } else { bundle.keySet().forEach { when (it) { - "name" -> binding.tvName.text = item.name - "cover" -> binding.ivCover.load(item.getDisplayCover(), item.name, item.author) + "name" -> tvName.text = item.name + "cover" -> ivCover.load(item.getDisplayCover(), item.name, item.author) "refresh" -> upRefresh(binding, item) } } diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksAdapterList.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksAdapterList.kt index 343ba19fd..95d027042 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksAdapterList.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksAdapterList.kt @@ -7,7 +7,8 @@ import io.legado.app.base.adapter.ItemViewHolder import io.legado.app.constant.BookType import io.legado.app.data.entities.Book import io.legado.app.databinding.ItemBookshelfListBinding -import io.legado.app.lib.theme.ATH +import io.legado.app.lib.theme.backgroundColor +import io.legado.app.utils.ColorUtils import io.legado.app.utils.invisible import splitties.views.onLongClick @@ -23,24 +24,24 @@ class BooksAdapterList(context: Context, private val callBack: CallBack) : binding: ItemBookshelfListBinding, item: Book, payloads: MutableList - ) { + ) = with(binding) { val bundle = payloads.getOrNull(0) as? Bundle if (bundle == null) { - ATH.applyBackgroundTint(binding.root) - binding.tvName.text = item.name - binding.tvAuthor.text = item.author - binding.tvRead.text = item.durChapterTitle - binding.tvLast.text = item.latestChapterTitle - binding.ivCover.load(item.getDisplayCover(), item.name, item.author) + root.setBackgroundColor(ColorUtils.withAlpha(context.backgroundColor, 0.5f)) + tvName.text = item.name + tvAuthor.text = item.author + tvRead.text = item.durChapterTitle + tvLast.text = item.latestChapterTitle + ivCover.load(item.getDisplayCover(), item.name, item.author) upRefresh(binding, item) } else { - binding.tvRead.text = item.durChapterTitle - binding.tvLast.text = item.latestChapterTitle + tvRead.text = item.durChapterTitle + tvLast.text = item.latestChapterTitle bundle.keySet().forEach { when (it) { - "name" -> binding.tvName.text = item.name - "author" -> binding.tvAuthor.text = item.author - "cover" -> binding.ivCover.load(item.getDisplayCover(), item.name, item.author) + "name" -> tvName.text = item.name + "author" -> tvAuthor.text = item.author + "cover" -> ivCover.load(item.getDisplayCover(), item.name, item.author) "refresh" -> upRefresh(binding, item) } } diff --git a/app/src/main/java/io/legado/app/ui/replace/ReplaceRuleAdapter.kt b/app/src/main/java/io/legado/app/ui/replace/ReplaceRuleAdapter.kt index f4e68d9a2..1972674b1 100644 --- a/app/src/main/java/io/legado/app/ui/replace/ReplaceRuleAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/replace/ReplaceRuleAdapter.kt @@ -16,6 +16,7 @@ import io.legado.app.databinding.ItemReplaceRuleBinding import io.legado.app.lib.theme.backgroundColor import io.legado.app.ui.widget.recycler.DragSelectTouchHelper import io.legado.app.ui.widget.recycler.ItemTouchCallback +import io.legado.app.utils.ColorUtils import java.util.* @@ -110,7 +111,7 @@ class ReplaceRuleAdapter(context: Context, var callBack: CallBack) : with(binding) { val bundle = payloads.getOrNull(0) as? Bundle if (bundle == null) { - root.setBackgroundColor(context.backgroundColor) + root.setBackgroundColor(ColorUtils.withAlpha(context.backgroundColor, 0.5f)) if (item.group.isNullOrEmpty()) { cbName.text = item.name } else { diff --git a/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceAdapter.kt b/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceAdapter.kt index a0b8bdccf..3cc2db4bb 100644 --- a/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceAdapter.kt @@ -16,6 +16,7 @@ import io.legado.app.databinding.ItemRssSourceBinding import io.legado.app.lib.theme.backgroundColor import io.legado.app.ui.widget.recycler.DragSelectTouchHelper import io.legado.app.ui.widget.recycler.ItemTouchCallback +import io.legado.app.utils.ColorUtils class RssSourceAdapter(context: Context, val callBack: CallBack) : @@ -68,7 +69,7 @@ class RssSourceAdapter(context: Context, val callBack: CallBack) : with(binding) { val bundle = payloads.getOrNull(0) as? Bundle if (bundle == null) { - root.setBackgroundColor(context.backgroundColor) + root.setBackgroundColor(ColorUtils.withAlpha(context.backgroundColor, 0.5f)) if (item.sourceGroup.isNullOrEmpty()) { cbSource.text = item.sourceName } else { diff --git a/app/src/main/java/io/legado/app/ui/widget/prefs/PreferenceCategory.kt b/app/src/main/java/io/legado/app/ui/widget/prefs/PreferenceCategory.kt index c311e158c..9e168a4a0 100644 --- a/app/src/main/java/io/legado/app/ui/widget/prefs/PreferenceCategory.kt +++ b/app/src/main/java/io/legado/app/ui/widget/prefs/PreferenceCategory.kt @@ -33,9 +33,15 @@ class PreferenceCategory(context: Context, attrs: AttributeSet) : PreferenceCate val da = it.findViewById(R.id.preference_divider_above) val dividerColor = if (AppConfig.isNightTheme) { - ColorUtils.shiftColor(context.backgroundColor, 1.05f) + ColorUtils.withAlpha( + ColorUtils.shiftColor(context.backgroundColor, 1.05f), + 0.5f + ) } else { - ColorUtils.shiftColor(context.backgroundColor, 0.95f) + ColorUtils.withAlpha( + ColorUtils.shiftColor(context.backgroundColor, 0.95f), + 0.5f + ) } if (da is View) { da.setBackgroundColor(dividerColor)