diff --git a/app/src/main/java/io/legado/app/ui/association/AddToBookshelfDialog.kt b/app/src/main/java/io/legado/app/ui/association/AddToBookshelfDialog.kt index 50ab7589a..a6b62439e 100644 --- a/app/src/main/java/io/legado/app/ui/association/AddToBookshelfDialog.kt +++ b/app/src/main/java/io/legado/app/ui/association/AddToBookshelfDialog.kt @@ -17,8 +17,10 @@ import io.legado.app.data.entities.Book import io.legado.app.databinding.DialogAddToBookshelfBinding import io.legado.app.exception.NoStackTraceException import io.legado.app.model.webBook.WebBook +import io.legado.app.ui.book.read.ReadBookActivity import io.legado.app.utils.NetworkUtils import io.legado.app.utils.setLayout +import io.legado.app.utils.startActivity import io.legado.app.utils.toastOnUi import io.legado.app.utils.viewbindingdelegate.viewBinding @@ -66,7 +68,9 @@ class AddToBookshelfDialog() : BaseDialogFragment(R.layout.dialog_add_to_bookshe dismiss() } viewModel.load(bookUrl) { - binding.tvMessage.text = "${it.name}(${it.author})" + binding.tvName.text = it.name + binding.tvAuthor.text = it.author + binding.tvOrigin.text = it.originName } binding.tvCancel.setOnClickListener { dismiss() @@ -76,6 +80,17 @@ class AddToBookshelfDialog() : BaseDialogFragment(R.layout.dialog_add_to_bookshe dismiss() } } + binding.tvRead.setOnClickListener { + viewModel.saveBook { + viewModel.book?.let { + startActivity { + putExtra("bookUrl", it.bookUrl) + putExtra("inBookshelf", false) + } + } + dismiss() + } + } } class ViewModel(application: Application) : BaseViewModel(application) { diff --git a/app/src/main/res/layout/dialog_add_to_bookshelf.xml b/app/src/main/res/layout/dialog_add_to_bookshelf.xml index 88bef49aa..142091030 100644 --- a/app/src/main/res/layout/dialog_add_to_bookshelf.xml +++ b/app/src/main/res/layout/dialog_add_to_bookshelf.xml @@ -8,7 +8,7 @@ android:id="@+id/tv_title" android:layout_width="match_parent" android:layout_height="wrap_content" - android:padding="16dp" + android:padding="18dp" android:text="@string/add_book_url" android:textColor="@color/primaryText" android:textSize="16sp" @@ -16,21 +16,34 @@ app:layout_constraintTop_toTopOf="parent" /> + + + + + app:layout_constraintTop_toTopOf="@id/tv_name" + app:layout_constraintBottom_toBottomOf="@+id/tv_origin" /> @@ -48,7 +61,17 @@ android:layout_height="wrap_content" android:padding="16dp" android:text="@string/cancel" + android:textColor="@color/secondaryText" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintRight_toLeftOf="@+id/tv_ok" /> + + \ No newline at end of file