Merge branch 'gedoor:master' into epublazy

pull/1754/head
ag2s20150909 3 years ago committed by GitHub
commit cc37b9e855
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      app/src/main/AndroidManifest.xml
  2. 1
      app/src/main/java/io/legado/app/constant/AppConst.kt
  3. 4
      app/src/main/java/io/legado/app/ui/book/manage/BookAdapter.kt
  4. 24
      app/src/main/java/io/legado/app/ui/book/manage/BookshelfManageActivity.kt
  5. 4
      app/src/main/java/io/legado/app/ui/book/manage/BookshelfManageViewModel.kt
  6. 2
      app/src/main/java/io/legado/app/ui/book/manage/ComposeView.kt
  7. 2
      app/src/main/java/io/legado/app/ui/book/manage/SourcePickerDialog.kt
  8. 4
      app/src/main/java/io/legado/app/ui/main/bookshelf/BaseBookshelfFragment.kt
  9. 11
      app/src/main/java/io/legado/app/ui/main/bookshelf/style2/BookshelfFragment2.kt
  10. 2
      app/src/main/res/layout/activity_arrange_book.xml
  11. 12
      app/src/main/res/menu/main_bookshelf.xml
  12. 2
      app/src/main/res/values-es-rES/strings.xml
  13. 2
      app/src/main/res/values-ja-rJP/strings.xml
  14. 2
      app/src/main/res/values-pt-rBR/strings.xml
  15. 2
      app/src/main/res/values-zh-rHK/strings.xml
  16. 2
      app/src/main/res/values-zh-rTW/strings.xml
  17. 2
      app/src/main/res/values-zh/strings.xml
  18. 2
      app/src/main/res/values/strings.xml

@ -249,7 +249,7 @@
android:screenOrientation="behind" /> android:screenOrientation="behind" />
<!-- 书籍管理 --> <!-- 书籍管理 -->
<activity <activity
android:name=".ui.book.arrange.ArrangeBookActivity" android:name=".ui.book.manage.BookshelfManageActivity"
android:launchMode="singleTop" android:launchMode="singleTop"
android:screenOrientation="behind" /> android:screenOrientation="behind" />
<!-- 书源调试 --> <!-- 书源调试 -->

@ -39,6 +39,7 @@ object AppConst {
SimpleDateFormat("yy-MM-dd-HH-mm-ss") SimpleDateFormat("yy-MM-dd-HH-mm-ss")
} }
const val rootGroupId = -100L
const val bookGroupAllId = -1L const val bookGroupAllId = -1L
const val bookGroupLocalId = -2L const val bookGroupLocalId = -2L
const val bookGroupAudioId = -3L const val bookGroupAudioId = -3L

@ -1,4 +1,4 @@
package io.legado.app.ui.book.arrange package io.legado.app.ui.book.manage
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.content.Context import android.content.Context
@ -15,7 +15,7 @@ import io.legado.app.lib.theme.backgroundColor
import io.legado.app.ui.widget.recycler.DragSelectTouchHelper import io.legado.app.ui.widget.recycler.DragSelectTouchHelper
import io.legado.app.ui.widget.recycler.ItemTouchCallback import io.legado.app.ui.widget.recycler.ItemTouchCallback
class ArrangeBookAdapter(context: Context, val callBack: CallBack) : class BookAdapter(context: Context, val callBack: CallBack) :
RecyclerAdapter<Book, ItemArrangeBookBinding>(context), RecyclerAdapter<Book, ItemArrangeBookBinding>(context),
ItemTouchCallback.Callback { ItemTouchCallback.Callback {

@ -1,4 +1,4 @@
package io.legado.app.ui.book.arrange package io.legado.app.ui.book.manage
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.os.Bundle import android.os.Bundle
@ -39,19 +39,20 @@ import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
class ArrangeBookActivity : VMBaseActivity<ActivityArrangeBookBinding, ArrangeBookViewModel>(), class BookshelfManageActivity :
VMBaseActivity<ActivityArrangeBookBinding, BookshelfManageViewModel>(),
PopupMenu.OnMenuItemClickListener, PopupMenu.OnMenuItemClickListener,
SelectActionBar.CallBack, SelectActionBar.CallBack,
ArrangeBookAdapter.CallBack, BookAdapter.CallBack,
SourcePickerDialog.Callback, SourcePickerDialog.Callback,
GroupSelectDialog.CallBack { GroupSelectDialog.CallBack {
override val binding by viewBinding(ActivityArrangeBookBinding::inflate) override val binding by viewBinding(ActivityArrangeBookBinding::inflate)
override val viewModel by viewModels<ArrangeBookViewModel>() override val viewModel by viewModels<BookshelfManageViewModel>()
override val groupList: ArrayList<BookGroup> = arrayListOf() override val groupList: ArrayList<BookGroup> = arrayListOf()
private val groupRequestCode = 22 private val groupRequestCode = 22
private val addToGroupRequestCode = 34 private val addToGroupRequestCode = 34
private val adapter by lazy { ArrangeBookAdapter(this, this) } private val adapter by lazy { BookAdapter(this, this) }
private var booksFlowJob: Job? = null private var booksFlowJob: Job? = null
private var menu: Menu? = null private var menu: Menu? = null
private var groupId: Long = -1 private var groupId: Long = -1
@ -139,6 +140,7 @@ class ArrangeBookActivity : VMBaseActivity<ActivityArrangeBookBinding, ArrangeBo
booksFlowJob?.cancel() booksFlowJob?.cancel()
booksFlowJob = launch { booksFlowJob = launch {
when (groupId) { when (groupId) {
AppConst.rootGroupId -> appDb.bookDao.flowNoGroup()
AppConst.bookGroupAllId -> appDb.bookDao.flowAll() AppConst.bookGroupAllId -> appDb.bookDao.flowAll()
AppConst.bookGroupLocalId -> appDb.bookDao.flowLocal() AppConst.bookGroupLocalId -> appDb.bookDao.flowLocal()
AppConst.bookGroupAudioId -> appDb.bookDao.flowAudio() AppConst.bookGroupAudioId -> appDb.bookDao.flowAudio()
@ -146,12 +148,18 @@ class ArrangeBookActivity : VMBaseActivity<ActivityArrangeBookBinding, ArrangeBo
else -> appDb.bookDao.flowByGroup(groupId) else -> appDb.bookDao.flowByGroup(groupId)
}.conflate().map { books -> }.conflate().map { books ->
when (getPrefInt(PreferKey.bookshelfSort)) { when (getPrefInt(PreferKey.bookshelfSort)) {
1 -> books.sortedByDescending { it.latestChapterTime } 1 -> books.sortedByDescending {
it.latestChapterTime
}
2 -> books.sortedWith { o1, o2 -> 2 -> books.sortedWith { o1, o2 ->
o1.name.cnCompare(o2.name) o1.name.cnCompare(o2.name)
} }
3 -> books.sortedBy { it.order } 3 -> books.sortedBy {
else -> books.sortedByDescending { it.durChapterTime } it.order
}
else -> books.sortedByDescending {
it.durChapterTime
}
} }
}.conflate().collect { books -> }.conflate().collect { books ->
adapter.setItems(books) adapter.setItems(books)

@ -1,4 +1,4 @@
package io.legado.app.ui.book.arrange package io.legado.app.ui.book.manage
import android.app.Application import android.app.Application
import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.mutableStateOf
@ -10,7 +10,7 @@ import io.legado.app.help.coroutine.Coroutine
import io.legado.app.model.webBook.WebBook import io.legado.app.model.webBook.WebBook
class ArrangeBookViewModel(application: Application) : BaseViewModel(application) { class BookshelfManageViewModel(application: Application) : BaseViewModel(application) {
val batchChangeSourceState = mutableStateOf(false) val batchChangeSourceState = mutableStateOf(false)
val batchChangeSourceSize = mutableStateOf(0) val batchChangeSourceSize = mutableStateOf(0)

@ -1,4 +1,4 @@
package io.legado.app.ui.book.arrange package io.legado.app.ui.book.manage
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
import androidx.compose.material.AlertDialog import androidx.compose.material.AlertDialog

@ -1,4 +1,4 @@
package io.legado.app.ui.book.arrange package io.legado.app.ui.book.manage
import android.content.Context import android.content.Context
import android.os.Bundle import android.os.Bundle

@ -19,10 +19,10 @@ import io.legado.app.help.DirectLinkUpload
import io.legado.app.help.config.AppConfig import io.legado.app.help.config.AppConfig
import io.legado.app.lib.dialogs.alert import io.legado.app.lib.dialogs.alert
import io.legado.app.ui.about.AppLogDialog import io.legado.app.ui.about.AppLogDialog
import io.legado.app.ui.book.arrange.ArrangeBookActivity
import io.legado.app.ui.book.cache.CacheActivity import io.legado.app.ui.book.cache.CacheActivity
import io.legado.app.ui.book.group.GroupManageDialog import io.legado.app.ui.book.group.GroupManageDialog
import io.legado.app.ui.book.local.ImportBookActivity import io.legado.app.ui.book.local.ImportBookActivity
import io.legado.app.ui.book.manage.BookshelfManageActivity
import io.legado.app.ui.book.search.SearchActivity import io.legado.app.ui.book.search.SearchActivity
import io.legado.app.ui.document.HandleFileContract import io.legado.app.ui.document.HandleFileContract
import io.legado.app.ui.main.MainViewModel import io.legado.app.ui.main.MainViewModel
@ -80,7 +80,7 @@ abstract class BaseBookshelfFragment(layoutId: Int) : VMBaseFragment<BookshelfVi
R.id.menu_group_manage -> showDialogFragment<GroupManageDialog>() R.id.menu_group_manage -> showDialogFragment<GroupManageDialog>()
R.id.menu_add_local -> startActivity<ImportBookActivity>() R.id.menu_add_local -> startActivity<ImportBookActivity>()
R.id.menu_add_url -> addBookByUrl() R.id.menu_add_url -> addBookByUrl()
R.id.menu_arrange_bookshelf -> startActivity<ArrangeBookActivity> { R.id.menu_bookshelf_manage -> startActivity<BookshelfManageActivity> {
putExtra("groupId", groupId) putExtra("groupId", groupId)
} }
R.id.menu_download -> startActivity<CacheActivity> { R.id.menu_download -> startActivity<CacheActivity> {

@ -43,7 +43,6 @@ class BookshelfFragment2 : BaseBookshelfFragment(R.layout.fragment_bookshelf1),
BaseBooksAdapter.CallBack { BaseBooksAdapter.CallBack {
private val binding by viewBinding(FragmentBookshelf1Binding::bind) private val binding by viewBinding(FragmentBookshelf1Binding::bind)
private val rootGroupId = -100L
private val bookshelfLayout by lazy { private val bookshelfLayout by lazy {
getPrefInt(PreferKey.bookshelfLayout) getPrefInt(PreferKey.bookshelfLayout)
} }
@ -56,7 +55,7 @@ class BookshelfFragment2 : BaseBookshelfFragment(R.layout.fragment_bookshelf1),
} }
private var bookGroups: List<BookGroup> = emptyList() private var bookGroups: List<BookGroup> = emptyList()
private var booksFlowJob: Job? = null private var booksFlowJob: Job? = null
override var groupId = rootGroupId override var groupId = AppConst.rootGroupId
override var books: List<Book> = emptyList() override var books: List<Book> = emptyList()
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) { override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) {
@ -121,7 +120,7 @@ class BookshelfFragment2 : BaseBookshelfFragment(R.layout.fragment_bookshelf1),
booksFlowJob?.cancel() booksFlowJob?.cancel()
booksFlowJob = launch { booksFlowJob = launch {
when (groupId) { when (groupId) {
rootGroupId -> appDb.bookDao.flowRoot() AppConst.rootGroupId -> appDb.bookDao.flowRoot()
AppConst.bookGroupAllId -> appDb.bookDao.flowAll() AppConst.bookGroupAllId -> appDb.bookDao.flowAll()
AppConst.bookGroupLocalId -> appDb.bookDao.flowLocal() AppConst.bookGroupLocalId -> appDb.bookDao.flowLocal()
AppConst.bookGroupAudioId -> appDb.bookDao.flowAudio() AppConst.bookGroupAudioId -> appDb.bookDao.flowAudio()
@ -212,7 +211,7 @@ class BookshelfFragment2 : BaseBookshelfFragment(R.layout.fragment_bookshelf1),
} }
override fun getItemCount(): Int { override fun getItemCount(): Int {
return if (groupId == rootGroupId) { return if (groupId == AppConst.rootGroupId) {
bookGroups.size + books.size bookGroups.size + books.size
} else { } else {
books.size books.size
@ -220,7 +219,7 @@ class BookshelfFragment2 : BaseBookshelfFragment(R.layout.fragment_bookshelf1),
} }
override fun getItemType(position: Int): Int { override fun getItemType(position: Int): Int {
if (groupId != rootGroupId) { if (groupId != AppConst.rootGroupId) {
return 0 return 0
} }
if (position < bookGroups.size) { if (position < bookGroups.size) {
@ -230,7 +229,7 @@ class BookshelfFragment2 : BaseBookshelfFragment(R.layout.fragment_bookshelf1),
} }
override fun getItem(position: Int): Any? { override fun getItem(position: Int): Any? {
if (groupId != rootGroupId) { if (groupId != AppConst.rootGroupId) {
return books.getOrNull(position) return books.getOrNull(position)
} }
if (position < bookGroups.size) { if (position < bookGroups.size) {

@ -9,7 +9,7 @@
android:id="@+id/title_bar" android:id="@+id/title_bar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:title="@string/arrange_bookshelf" app:title="@string/bookshelf_management"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView

@ -28,6 +28,12 @@
android:title="@string/add_url" android:title="@string/add_url"
app:showAsAction="never" /> app:showAsAction="never" />
<item
android:id="@+id/menu_bookshelf_manage"
android:icon="@drawable/ic_arrange"
android:title="@string/bookshelf_management"
app:showAsAction="never" />
<item <item
android:id="@+id/menu_download" android:id="@+id/menu_download"
android:icon="@drawable/ic_download_line" android:icon="@drawable/ic_download_line"
@ -46,12 +52,6 @@
android:title="@string/bookshelf_layout" android:title="@string/bookshelf_layout"
app:showAsAction="never" /> app:showAsAction="never" />
<item
android:id="@+id/menu_arrange_bookshelf"
android:icon="@drawable/ic_arrange"
android:title="@string/arrange_bookshelf"
app:showAsAction="never" />
<item <item
android:id="@+id/menu_export_bookshelf" android:id="@+id/menu_export_bookshelf"
android:icon="@drawable/ic_export" android:icon="@drawable/ic_export"

@ -267,7 +267,7 @@
<string name="load_over_time">Tiempo límite de carga</string> <string name="load_over_time">Tiempo límite de carga</string>
<string name="join_group">Siga:%s</string> <string name="join_group">Siga:%s</string>
<string name="copy_complete">Copiado con éxito</string> <string name="copy_complete">Copiado con éxito</string>
<string name="arrange_bookshelf">Organización de estantería</string> <string name="bookshelf_management">Organización de estantería</string>
<string name="clear_bookshelf_s">Esto borrará a todos los libros. Por favor, tenga cuidado.</string> <string name="clear_bookshelf_s">Esto borrará a todos los libros. Por favor, tenga cuidado.</string>
<string name="search_book_source">Buscar fuentes de libros</string> <string name="search_book_source">Buscar fuentes de libros</string>
<string name="search_rss_source">Buscar fuentes de suscripción</string> <string name="search_rss_source">Buscar fuentes de suscripción</string>

@ -271,7 +271,7 @@
<string name="load_over_time">Loading timeout</string> <string name="load_over_time">Loading timeout</string>
<string name="join_group">Follow:%s</string> <string name="join_group">Follow:%s</string>
<string name="copy_complete">Copied successfully</string> <string name="copy_complete">Copied successfully</string>
<string name="arrange_bookshelf">Bookshelf arrangement</string> <string name="bookshelf_management">Bookshelf management</string>
<string name="clear_bookshelf_s">It will delete all books. Be careful,please.</string> <string name="clear_bookshelf_s">It will delete all books. Be careful,please.</string>
<string name="search_book_source">Search book sources</string> <string name="search_book_source">Search book sources</string>
<string name="search_rss_source">Search subscription sources</string> <string name="search_rss_source">Search subscription sources</string>

@ -271,7 +271,7 @@
<string name="load_over_time">Tempo limite de carregamento</string> <string name="load_over_time">Tempo limite de carregamento</string>
<string name="join_group">Siga:%s</string> <string name="join_group">Siga:%s</string>
<string name="copy_complete">Copiado com sucesso</string> <string name="copy_complete">Copiado com sucesso</string>
<string name="arrange_bookshelf">A organização da estante</string> <string name="bookshelf_management">A organização da estante</string>
<string name="clear_bookshelf_s">Isto excluirá todos os livros. Por favor, tenha cuidado.</string> <string name="clear_bookshelf_s">Isto excluirá todos os livros. Por favor, tenha cuidado.</string>
<string name="search_book_source">Pesquisar fontes de livros</string> <string name="search_book_source">Pesquisar fontes de livros</string>
<string name="search_rss_source">Buscar fontes de assinatura</string> <string name="search_rss_source">Buscar fontes de assinatura</string>

@ -268,7 +268,7 @@
<string name="load_over_time">加載超時</string> <string name="load_over_time">加載超時</string>
<string name="join_group">關注: %s</string> <string name="join_group">關注: %s</string>
<string name="copy_complete">拷貝咗</string> <string name="copy_complete">拷貝咗</string>
<string name="arrange_bookshelf">整理書架</string> <string name="bookshelf_management">書架管理</string>
<string name="clear_bookshelf_s">這將會刪除所有書籍,請謹慎操作。</string> <string name="clear_bookshelf_s">這將會刪除所有書籍,請謹慎操作。</string>
<string name="search_book_source">搜索書源</string> <string name="search_book_source">搜索書源</string>
<string name="search_rss_source">搜索訂閲源</string> <string name="search_rss_source">搜索訂閲源</string>

@ -270,7 +270,7 @@
<string name="load_over_time">載入超時</string> <string name="load_over_time">載入超時</string>
<string name="join_group">關注:%s</string> <string name="join_group">關注:%s</string>
<string name="copy_complete">已複製</string> <string name="copy_complete">已複製</string>
<string name="arrange_bookshelf">整理書架</string> <string name="bookshelf_management">書架管理</string>
<string name="clear_bookshelf_s">這將會刪除所有書籍,請謹慎操作。</string> <string name="clear_bookshelf_s">這將會刪除所有書籍,請謹慎操作。</string>
<string name="search_book_source">搜尋書源</string> <string name="search_book_source">搜尋書源</string>
<string name="search_rss_source">搜尋訂閱源</string> <string name="search_rss_source">搜尋訂閱源</string>

@ -270,7 +270,7 @@
<string name="load_over_time">加载超时</string> <string name="load_over_time">加载超时</string>
<string name="join_group">关注:%s</string> <string name="join_group">关注:%s</string>
<string name="copy_complete">已拷贝</string> <string name="copy_complete">已拷贝</string>
<string name="arrange_bookshelf">整理书架</string> <string name="bookshelf_management">书架管理</string>
<string name="clear_bookshelf_s">这将会删除所有书籍,请谨慎操作。</string> <string name="clear_bookshelf_s">这将会删除所有书籍,请谨慎操作。</string>
<string name="search_book_source">搜索书源</string> <string name="search_book_source">搜索书源</string>
<string name="search_rss_source">搜索订阅源</string> <string name="search_rss_source">搜索订阅源</string>

@ -271,7 +271,7 @@
<string name="load_over_time">Loading timeout</string> <string name="load_over_time">Loading timeout</string>
<string name="join_group">Follow:%s</string> <string name="join_group">Follow:%s</string>
<string name="copy_complete">Copied successfully</string> <string name="copy_complete">Copied successfully</string>
<string name="arrange_bookshelf">Bookshelf arrangement</string> <string name="bookshelf_management">Bookshelf management</string>
<string name="clear_bookshelf_s">It will delete all books. Be careful,please.</string> <string name="clear_bookshelf_s">It will delete all books. Be careful,please.</string>
<string name="search_book_source">Search book sources</string> <string name="search_book_source">Search book sources</string>
<string name="search_rss_source">Search subscription sources</string> <string name="search_rss_source">Search subscription sources</string>

Loading…
Cancel
Save