From f8e4f94f6025451741af2bba2e437b0030870827 Mon Sep 17 00:00:00 2001 From: gedoor Date: Mon, 9 Aug 2021 23:25:43 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E7=BB=84=E6=B7=BB=E5=8A=A0=E5=B0=81?= =?UTF-8?q?=E9=9D=A2=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../legado/app/ui/book/group/GroupEditDialog.kt | 16 +++++++++++++--- .../ui/main/bookshelf/style2/BooksAdapterGrid.kt | 1 + .../ui/main/bookshelf/style2/BooksAdapterList.kt | 1 + .../main/res/layout/dialog_book_group_edit.xml | 3 ++- app/src/main/res/layout/item_bookshelf_grid.xml | 3 ++- .../res/layout/item_bookshelf_grid_group.xml | 3 ++- app/src/main/res/layout/item_bookshelf_list.xml | 8 +++++--- .../res/layout/item_bookshelf_list_group.xml | 8 +++++--- 8 files changed, 31 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/group/GroupEditDialog.kt b/app/src/main/java/io/legado/app/ui/book/group/GroupEditDialog.kt index 2bee351c8..8079c853d 100644 --- a/app/src/main/java/io/legado/app/ui/book/group/GroupEditDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/group/GroupEditDialog.kt @@ -12,10 +12,8 @@ import io.legado.app.data.entities.BookGroup import io.legado.app.databinding.DialogBookGroupEditBinding import io.legado.app.lib.dialogs.alert import io.legado.app.lib.theme.primaryColor -import io.legado.app.utils.gone -import io.legado.app.utils.toastOnUi +import io.legado.app.utils.* import io.legado.app.utils.viewbindingdelegate.viewBinding -import io.legado.app.utils.windowSize import splitties.views.onClick class GroupEditDialog : BaseDialogFragment() { @@ -35,6 +33,15 @@ class GroupEditDialog : BaseDialogFragment() { private val binding by viewBinding(DialogBookGroupEditBinding::bind) private val viewModel by viewModels() private var bookGroup: BookGroup? = null + val selectImage = registerForActivityResult(ActivityResultContractUtils.SelectImage()) { + it?.second?.let { uri -> + if (uri.isContentScheme()) { + binding.ivCover.load(uri.toString()) + } else { + binding.ivCover.load(uri.path) + } + } + } override fun onStart() { super.onStart() @@ -64,6 +71,9 @@ class GroupEditDialog : BaseDialogFragment() { binding.btnDelete.gone() } binding.run { + ivCover.onClick { + selectImage.launch(null) + } btnCancel.onClick { dismiss() } diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/style2/BooksAdapterGrid.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/style2/BooksAdapterGrid.kt index fa1957ba5..3ac98ea46 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/style2/BooksAdapterGrid.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/style2/BooksAdapterGrid.kt @@ -56,6 +56,7 @@ class BooksAdapterGrid(context: Context, callBack: CallBack) : binding.run { val item = callBack.getItem(position) as BookGroup tvName.text = item.groupName + ivCover.load(item.cover) } } diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/style2/BooksAdapterList.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/style2/BooksAdapterList.kt index 962bfd0e9..fccddaf35 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/style2/BooksAdapterList.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/style2/BooksAdapterList.kt @@ -55,6 +55,7 @@ class BooksAdapterList(context: Context, callBack: CallBack) : binding.run { val item = callBack.getItem(position) as BookGroup tvName.text = item.groupName + ivCover.load(item.cover) } } diff --git a/app/src/main/res/layout/dialog_book_group_edit.xml b/app/src/main/res/layout/dialog_book_group_edit.xml index 13240a0d4..d74f687f6 100644 --- a/app/src/main/res/layout/dialog_book_group_edit.xml +++ b/app/src/main/res/layout/dialog_book_group_edit.xml @@ -30,7 +30,8 @@ android:src="@drawable/image_cover_default" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintLeft_toLeftOf="parent" - app:layout_constraintTop_toBottomOf="@+id/tool_bar" /> + app:layout_constraintTop_toBottomOf="@+id/tool_bar" + tools:ignore="ImageContrastCheck" /> + tools:ignore="UnusedAttribute,ImageContrastCheck" + tools:layout_editor_absoluteX="8dp" /> + tools:ignore="UnusedAttribute,ImageContrastCheck" + tools:layout_editor_absoluteX="8dp" /> + tools:ignore="RtlSymmetry,TextContrastCheck" /> + app:layout_constraintTop_toBottomOf="@+id/tv_author" + tools:ignore="TextContrastCheck" /> + app:layout_constraintTop_toBottomOf="@+id/tv_read" + tools:ignore="TextContrastCheck" /> + tools:ignore="RtlSymmetry,TextContrastCheck" /> + app:layout_constraintTop_toBottomOf="@+id/tv_author" + tools:ignore="TextContrastCheck" /> + app:layout_constraintTop_toBottomOf="@+id/tv_read" + tools:ignore="TextContrastCheck" />