From 9a2ba5650c4d48ef09b42586d1f78e430304ab5a Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 2 Apr 2022 09:09:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=89=80=E6=9C=89=E4=B9=A6?= =?UTF-8?q?=E7=AD=BE=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/AndroidManifest.xml | 4 +++ .../io/legado/app/data/dao/BookmarkDao.kt | 2 +- .../ui/book/bookmark/AllBookmarkActivity.kt | 29 +++++++++++++++++ .../ui/book/bookmark/AllBookmarkViewModel.kt | 19 +++++++++++ .../app/ui/book/bookmark/BookmarkAdapter.kt | 32 +++++++++++++++++++ .../io/legado/app/ui/main/my/MyFragment.kt | 2 ++ .../main/res/layout/activity_all_bookmark.xml | 22 +++++++++++++ app/src/main/res/values-es-rES/strings.xml | 1 + app/src/main/res/values-ja-rJP/strings.xml | 1 + app/src/main/res/values-pt-rBR/strings.xml | 1 + app/src/main/res/values-zh-rHK/strings.xml | 1 + app/src/main/res/values-zh-rTW/strings.xml | 1 + app/src/main/res/values-zh/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + app/src/main/res/xml/pref_main.xml | 7 ++++ 15 files changed, 123 insertions(+), 1 deletion(-) create mode 100644 app/src/main/java/io/legado/app/ui/book/bookmark/AllBookmarkActivity.kt create mode 100644 app/src/main/java/io/legado/app/ui/book/bookmark/AllBookmarkViewModel.kt create mode 100644 app/src/main/java/io/legado/app/ui/book/bookmark/BookmarkAdapter.kt create mode 100644 app/src/main/res/layout/activity_all_bookmark.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index f1624fe82..6c95c79ce 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -293,6 +293,10 @@ + + @Query( diff --git a/app/src/main/java/io/legado/app/ui/book/bookmark/AllBookmarkActivity.kt b/app/src/main/java/io/legado/app/ui/book/bookmark/AllBookmarkActivity.kt new file mode 100644 index 000000000..09bfd5944 --- /dev/null +++ b/app/src/main/java/io/legado/app/ui/book/bookmark/AllBookmarkActivity.kt @@ -0,0 +1,29 @@ +package io.legado.app.ui.book.bookmark + +import android.os.Bundle +import androidx.activity.viewModels +import io.legado.app.base.VMBaseActivity +import io.legado.app.databinding.ActivityAllBookmarkBinding +import io.legado.app.utils.viewbindingdelegate.viewBinding + +class AllBookmarkActivity : VMBaseActivity() { + + override val viewModel by viewModels() + override val binding by viewBinding(ActivityAllBookmarkBinding::inflate) + private val adapter by lazy { + BookmarkAdapter(this) + } + + override fun onActivityCreated(savedInstanceState: Bundle?) { + initView() + viewModel.initData { + adapter.setItems(it) + } + } + + private fun initView() { + binding.recyclerView.adapter = adapter + } + + +} \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/book/bookmark/AllBookmarkViewModel.kt b/app/src/main/java/io/legado/app/ui/book/bookmark/AllBookmarkViewModel.kt new file mode 100644 index 000000000..274598ee8 --- /dev/null +++ b/app/src/main/java/io/legado/app/ui/book/bookmark/AllBookmarkViewModel.kt @@ -0,0 +1,19 @@ +package io.legado.app.ui.book.bookmark + +import android.app.Application +import io.legado.app.base.BaseViewModel +import io.legado.app.data.appDb +import io.legado.app.data.entities.Bookmark + +class AllBookmarkViewModel(application: Application) : BaseViewModel(application) { + + + fun initData(onSuccess: (bookmarks: List) -> Unit) { + execute { + appDb.bookmarkDao.all + }.onSuccess { + onSuccess.invoke(it) + } + } + +} \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/book/bookmark/BookmarkAdapter.kt b/app/src/main/java/io/legado/app/ui/book/bookmark/BookmarkAdapter.kt new file mode 100644 index 000000000..2febd314c --- /dev/null +++ b/app/src/main/java/io/legado/app/ui/book/bookmark/BookmarkAdapter.kt @@ -0,0 +1,32 @@ +package io.legado.app.ui.book.bookmark + +import android.content.Context +import android.view.ViewGroup +import io.legado.app.base.adapter.ItemViewHolder +import io.legado.app.base.adapter.RecyclerAdapter +import io.legado.app.data.entities.Bookmark +import io.legado.app.databinding.ItemBookmarkBinding + +class BookmarkAdapter(context: Context) : RecyclerAdapter(context) { + + override fun getViewBinding(parent: ViewGroup): ItemBookmarkBinding { + return ItemBookmarkBinding.inflate(inflater, parent, false) + } + + override fun convert( + holder: ItemViewHolder, + binding: ItemBookmarkBinding, + item: Bookmark, + payloads: MutableList + ) { + binding.tvChapterName.text = item.chapterName + binding.tvBookText.text = item.bookText + binding.tvContent.text = item.content + } + + override fun registerListener(holder: ItemViewHolder, binding: ItemBookmarkBinding) { + + } + + +} \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt b/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt index e4464a17c..92c31c288 100644 --- a/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt @@ -20,6 +20,7 @@ import io.legado.app.service.WebService import io.legado.app.ui.about.AboutActivity import io.legado.app.ui.about.DonateActivity import io.legado.app.ui.about.ReadRecordActivity +import io.legado.app.ui.book.bookmark.AllBookmarkActivity import io.legado.app.ui.book.source.manage.BookSourceActivity import io.legado.app.ui.config.ConfigActivity import io.legado.app.ui.config.ConfigTag @@ -135,6 +136,7 @@ class MyFragment : BaseFragment(R.layout.fragment_my_config) { when (preference.key) { "bookSourceManage" -> startActivity() "replaceManage" -> startActivity() + "bookmark" -> startActivity() "setting" -> startActivity { putExtra("configTag", ConfigTag.OTHER_CONFIG) } diff --git a/app/src/main/res/layout/activity_all_bookmark.xml b/app/src/main/res/layout/activity_all_bookmark.xml new file mode 100644 index 000000000..614f5baf6 --- /dev/null +++ b/app/src/main/res/layout/activity_all_bookmark.xml @@ -0,0 +1,22 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values-es-rES/strings.xml b/app/src/main/res/values-es-rES/strings.xml index 9143354c7..332819c1e 100644 --- a/app/src/main/res/values-es-rES/strings.xml +++ b/app/src/main/res/values-es-rES/strings.xml @@ -965,5 +965,6 @@ 系统tts设置 打开系统tts设置界面 非播放状态无法定时 + 所有书签 diff --git a/app/src/main/res/values-ja-rJP/strings.xml b/app/src/main/res/values-ja-rJP/strings.xml index ab67846fc..7c99e8984 100644 --- a/app/src/main/res/values-ja-rJP/strings.xml +++ b/app/src/main/res/values-ja-rJP/strings.xml @@ -968,5 +968,6 @@ 系统tts设置 打开系统tts设置界面 非播放状态无法定时 + 所有书签 diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index fcd5e4613..238a31750 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -968,5 +968,6 @@ 系统tts设置 打开系统tts设置界面 非播放状态无法定时 + 所有书签 diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index 7be8fcc22..ce066bef4 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -965,5 +965,6 @@ 系统tts设置 打开系统tts设置界面 非播放状态无法定时 + 所有书签 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index dabf42176..ac07fea01 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -967,5 +967,6 @@ 系统tts设置 打开系统tts设置界面 非播放状态无法定时 + 所有书签 diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml index ee43e4273..94701470d 100644 --- a/app/src/main/res/values-zh/strings.xml +++ b/app/src/main/res/values-zh/strings.xml @@ -967,5 +967,6 @@ 系统tts设置 打开系统tts设置界面 非播放状态无法定时 + 所有书签 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 8ad3e0b0a..1912143fe 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -968,5 +968,6 @@ 系统tts设置 打开系统tts设置界面 非播放状态无法定时 + 所有书签 diff --git a/app/src/main/res/xml/pref_main.xml b/app/src/main/res/xml/pref_main.xml index e4e3d3cee..9a89f17ef 100644 --- a/app/src/main/res/xml/pref_main.xml +++ b/app/src/main/res/xml/pref_main.xml @@ -19,6 +19,13 @@ android:icon="@drawable/ic_cfg_replace" app:iconSpaceReserved="false" /> + +