From 39fc040286802a2772fb6dc203929bc002eeffd5 Mon Sep 17 00:00:00 2001 From: gedoor Date: Wed, 30 Dec 2020 21:27:46 +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 --- .../app/ui/book/read/ReadBookActivity.kt | 2 +- .../app/ui/book/read/ReadBookBaseActivity.kt | 15 +++--- app/src/main/res/layout/dialog_bookmark.xml | 46 +++++++++++++++++++ 3 files changed, 55 insertions(+), 8 deletions(-) create mode 100644 app/src/main/res/layout/dialog_bookmark.xml diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt index 926bc8d1e..02040e26d 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt @@ -215,7 +215,7 @@ class ReadBookActivity : ReadBookBaseActivity(), chapterIndex = ReadBook.durChapterIndex, chapterPos = ReadBook.durChapterPos, chapterName = page.title, - bookText = page.text + bookText = page.text.trim() ) showBookMark(bookmark) } diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookBaseActivity.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookBaseActivity.kt index 56165f6ee..6a305f928 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookBaseActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookBaseActivity.kt @@ -13,6 +13,7 @@ import io.legado.app.base.VMBaseActivity import io.legado.app.constant.PreferKey import io.legado.app.data.entities.Bookmark import io.legado.app.databinding.ActivityBookReadBinding +import io.legado.app.databinding.DialogBookmarkBinding import io.legado.app.databinding.DialogDownloadChoiceBinding import io.legado.app.databinding.DialogEditTextBinding import io.legado.app.help.AppConfig @@ -200,18 +201,18 @@ abstract class ReadBookBaseActivity : @SuppressLint("InflateParams") fun showBookMark(bookmark: Bookmark) { - val book = ReadBook.book ?: return - val textChapter = ReadBook.curTextChapter ?: return alert(title = getString(R.string.bookmark_add)) { - val alertBinding = DialogEditTextBinding.inflate(layoutInflater).apply { - editView.setHint(R.string.note_content) + message = bookmark.chapterName + val alertBinding = DialogBookmarkBinding.inflate(layoutInflater).apply { + editBookText.setText(bookmark.bookText) + editView.setText(bookmark.content) } - message = bookmark.bookText customView = alertBinding.root yesButton { - alertBinding.editView.text?.toString()?.let { editContent -> + alertBinding.apply { Coroutine.async { - bookmark.content = editContent + bookmark.bookText = editBookText.text.toString() + bookmark.content = editView.text.toString() App.db.bookmarkDao.insert(bookmark) } } diff --git a/app/src/main/res/layout/dialog_bookmark.xml b/app/src/main/res/layout/dialog_bookmark.xml new file mode 100644 index 000000000..af68de721 --- /dev/null +++ b/app/src/main/res/layout/dialog_bookmark.xml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file