From 102e7bd689eb51b88b3a4e094d44aa99e420cb22 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 30 Oct 2022 21:58:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/association/AddToBookshelfDialog.kt | 36 +++++++++++++++++++ .../ui/association/OnLineImportActivity.kt | 3 ++ .../res/layout/dialog_add_to_bookshelf.xml | 6 ++++ 3 files changed, 45 insertions(+) create mode 100644 app/src/main/java/io/legado/app/ui/association/AddToBookshelfDialog.kt create mode 100644 app/src/main/res/layout/dialog_add_to_bookshelf.xml 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 new file mode 100644 index 000000000..619e21d39 --- /dev/null +++ b/app/src/main/java/io/legado/app/ui/association/AddToBookshelfDialog.kt @@ -0,0 +1,36 @@ +package io.legado.app.ui.association + +import android.content.DialogInterface +import android.os.Bundle +import android.view.View +import android.view.ViewGroup +import io.legado.app.R +import io.legado.app.base.BaseDialogFragment +import io.legado.app.utils.setLayout + +class AddToBookshelfDialog() : BaseDialogFragment(R.layout.dialog_add_to_bookshelf) { + + constructor(bookUrl: String, finishOnDismiss: Boolean = false) : this() { + arguments = Bundle().apply { + putString("bookUrl", bookUrl) + putBoolean("finishOnDismiss", finishOnDismiss) + } + } + + override fun onStart() { + super.onStart() + setLayout(0.9f, ViewGroup.LayoutParams.WRAP_CONTENT) + } + + override fun onDismiss(dialog: DialogInterface) { + super.onDismiss(dialog) + if (arguments?.getBoolean("finishOnDismiss") == true) { + activity?.finish() + } + } + + override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) { + + } + +} \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/association/OnLineImportActivity.kt b/app/src/main/java/io/legado/app/ui/association/OnLineImportActivity.kt index ef9e739e5..c7092cdfb 100644 --- a/app/src/main/java/io/legado/app/ui/association/OnLineImportActivity.kt +++ b/app/src/main/java/io/legado/app/ui/association/OnLineImportActivity.kt @@ -73,6 +73,9 @@ class OnLineImportActivity : "/readConfig" -> viewModel.getBytes(url) { bytes -> viewModel.importReadConfig(bytes, this::finallyDialog) } + "addToBookshelf" -> showDialogFragment( + AddToBookshelfDialog(url) + ) "/importonline" -> when (it.host) { "booksource" -> showDialogFragment( ImportBookSourceDialog(url, true) diff --git a/app/src/main/res/layout/dialog_add_to_bookshelf.xml b/app/src/main/res/layout/dialog_add_to_bookshelf.xml new file mode 100644 index 000000000..77d9ef65f --- /dev/null +++ b/app/src/main/res/layout/dialog_add_to_bookshelf.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file