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