添加所有书签界面

pull/1751/head
kunfei 3 years ago
parent 246019df60
commit 9a2ba5650c
  1. 4
      app/src/main/AndroidManifest.xml
  2. 2
      app/src/main/java/io/legado/app/data/dao/BookmarkDao.kt
  3. 29
      app/src/main/java/io/legado/app/ui/book/bookmark/AllBookmarkActivity.kt
  4. 19
      app/src/main/java/io/legado/app/ui/book/bookmark/AllBookmarkViewModel.kt
  5. 32
      app/src/main/java/io/legado/app/ui/book/bookmark/BookmarkAdapter.kt
  6. 2
      app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt
  7. 22
      app/src/main/res/layout/activity_all_bookmark.xml
  8. 1
      app/src/main/res/values-es-rES/strings.xml
  9. 1
      app/src/main/res/values-ja-rJP/strings.xml
  10. 1
      app/src/main/res/values-pt-rBR/strings.xml
  11. 1
      app/src/main/res/values-zh-rHK/strings.xml
  12. 1
      app/src/main/res/values-zh-rTW/strings.xml
  13. 1
      app/src/main/res/values-zh/strings.xml
  14. 1
      app/src/main/res/values/strings.xml
  15. 7
      app/src/main/res/xml/pref_main.xml

@ -293,6 +293,10 @@
<activity
android:name=".ui.rss.favorites.RssFavoritesActivity"
android:launchMode="singleTop" />
<!-- 书签 -->
<activity
android:name=".ui.book.bookmark.AllBookmarkActivity"
android:launchMode="singleTop" />
<!-- 缓存界面 -->
<activity
android:name=".ui.book.cache.CacheActivity"

@ -7,7 +7,7 @@ import io.legado.app.data.entities.Bookmark
@Dao
interface BookmarkDao {
@get:Query("select * from bookmarks")
@get:Query("select * from bookmarks order by bookName, bookAuthor, chapterIndex, chapterPos")
val all: List<Bookmark>
@Query(

@ -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<ActivityAllBookmarkBinding, AllBookmarkViewModel>() {
override val viewModel by viewModels<AllBookmarkViewModel>()
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
}
}

@ -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<Bookmark>) -> Unit) {
execute {
appDb.bookmarkDao.all
}.onSuccess {
onSuccess.invoke(it)
}
}
}

@ -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<Bookmark, ItemBookmarkBinding>(context) {
override fun getViewBinding(parent: ViewGroup): ItemBookmarkBinding {
return ItemBookmarkBinding.inflate(inflater, parent, false)
}
override fun convert(
holder: ItemViewHolder,
binding: ItemBookmarkBinding,
item: Bookmark,
payloads: MutableList<Any>
) {
binding.tvChapterName.text = item.chapterName
binding.tvBookText.text = item.bookText
binding.tvContent.text = item.content
}
override fun registerListener(holder: ItemViewHolder, binding: ItemBookmarkBinding) {
}
}

@ -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<BookSourceActivity>()
"replaceManage" -> startActivity<ReplaceRuleActivity>()
"bookmark" -> startActivity<AllBookmarkActivity>()
"setting" -> startActivity<ConfigActivity> {
putExtra("configTag", ConfigTag.OTHER_CONFIG)
}

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<io.legado.app.ui.widget.TitleBar
android:id="@+id/title_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:title="@string/all_bookmark"
app:layout_constraintTop_toTopOf="parent" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_constraintTop_toBottomOf="@+id/title_bar"
app:layout_constraintBottom_toBottomOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

@ -965,5 +965,6 @@
<string name="sys_tts_config">系统tts设置</string>
<string name="sys_tts_config_summary">打开系统tts设置界面</string>
<string name="cannot_timed_non_playback">非播放状态无法定时</string>
<string name="all_bookmark">所有书签</string>
<!-- string end -->
</resources>

@ -968,5 +968,6 @@
<string name="sys_tts_config">系统tts设置</string>
<string name="sys_tts_config_summary">打开系统tts设置界面</string>
<string name="cannot_timed_non_playback">非播放状态无法定时</string>
<string name="all_bookmark">所有书签</string>
<!-- string end -->
</resources>

@ -968,5 +968,6 @@
<string name="sys_tts_config">系统tts设置</string>
<string name="sys_tts_config_summary">打开系统tts设置界面</string>
<string name="cannot_timed_non_playback">非播放状态无法定时</string>
<string name="all_bookmark">所有书签</string>
<!-- string end -->
</resources>

@ -965,5 +965,6 @@
<string name="sys_tts_config">系统tts设置</string>
<string name="sys_tts_config_summary">打开系统tts设置界面</string>
<string name="cannot_timed_non_playback">非播放状态无法定时</string>
<string name="all_bookmark">所有书签</string>
<!-- string end -->
</resources>

@ -967,5 +967,6 @@
<string name="sys_tts_config">系统tts设置</string>
<string name="sys_tts_config_summary">打开系统tts设置界面</string>
<string name="cannot_timed_non_playback">非播放状态无法定时</string>
<string name="all_bookmark">所有书签</string>
<!-- string end -->
</resources>

@ -967,5 +967,6 @@
<string name="sys_tts_config">系统tts设置</string>
<string name="sys_tts_config_summary">打开系统tts设置界面</string>
<string name="cannot_timed_non_playback">非播放状态无法定时</string>
<string name="all_bookmark">所有书签</string>
<!-- string end -->
</resources>

@ -968,5 +968,6 @@
<string name="sys_tts_config">系统tts设置</string>
<string name="sys_tts_config_summary">打开系统tts设置界面</string>
<string name="cannot_timed_non_playback">非播放状态无法定时</string>
<string name="all_bookmark">所有书签</string>
<!-- string end -->
</resources>

@ -19,6 +19,13 @@
android:icon="@drawable/ic_cfg_replace"
app:iconSpaceReserved="false" />
<io.legado.app.ui.widget.prefs.Preference
android:key="bookmark"
android:title="@string/bookmark"
android:summary="@string/all_bookmark"
android:icon="@drawable/ic_bookmark"
app:iconSpaceReserved="false" />
<io.legado.app.ui.widget.prefs.NameListPreference
android:defaultValue="0"
android:entries="@array/theme_mode"

Loading…
Cancel
Save