diff --git a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt index ac748d6c4..1b36fed1c 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt @@ -84,11 +84,11 @@ class BookSourceActivity : VMBaseActivity startActivity() R.id.menu_import_qr -> qrResult.launch(null) - R.id.menu_share_source -> viewModel.shareSelection(adapter.getSelection()) { + R.id.menu_share_source -> viewModel.shareSelection(adapter.selection) { startActivity(Intent.createChooser(it, getString(R.string.share_selected_source))) } R.id.menu_group_manage -> @@ -302,7 +302,7 @@ class BookSourceActivity : VMBaseActivity viewModel.enableSelection(adapter.getSelection()) - R.id.menu_disable_selection -> viewModel.disableSelection(adapter.getSelection()) - R.id.menu_enable_explore -> viewModel.enableSelectExplore(adapter.getSelection()) - R.id.menu_disable_explore -> viewModel.disableSelectExplore(adapter.getSelection()) + R.id.menu_enable_selection -> viewModel.enableSelection(adapter.selection) + R.id.menu_disable_selection -> viewModel.disableSelection(adapter.selection) + R.id.menu_enable_explore -> viewModel.enableSelectExplore(adapter.selection) + R.id.menu_disable_explore -> viewModel.disableSelectExplore(adapter.selection) R.id.menu_check_source -> checkSource() - R.id.menu_top_sel -> viewModel.topSource(*adapter.getSelection().toTypedArray()) - R.id.menu_bottom_sel -> viewModel.bottomSource(*adapter.getSelection().toTypedArray()) + R.id.menu_top_sel -> viewModel.topSource(*adapter.selection.toTypedArray()) + R.id.menu_bottom_sel -> viewModel.bottomSource(*adapter.selection.toTypedArray()) R.id.menu_add_group -> selectionAddToGroups() R.id.menu_remove_group -> selectionRemoveFromGroups() R.id.menu_export_selection -> exportDir.launch(null) @@ -343,7 +343,7 @@ class BookSourceActivity : VMBaseActivity() + val selection: List + get() { + val selection = arrayListOf() + getItems().map { + if (selected.contains(it)) { + selection.add(it) + } + } + return selection.sortedBy { it.customOrder } + } + val diffItemCallback: DiffUtil.ItemCallback get() = object : DiffUtil.ItemCallback() { @@ -213,16 +224,6 @@ class BookSourceAdapter(context: Context, val callBack: CallBack) : callBack.upCountView() } - fun getSelection(): List { - val selection = arrayListOf() - getItems().map { - if (selected.contains(it)) { - selection.add(it) - } - } - return selection.sortedBy { it.customOrder } - } - override fun swap(srcPosition: Int, targetPosition: Int): Boolean { val srcItem = getItem(srcPosition) val targetItem = getItem(targetPosition) diff --git a/app/src/main/java/io/legado/app/ui/replace/ReplaceRuleActivity.kt b/app/src/main/java/io/legado/app/ui/replace/ReplaceRuleActivity.kt index 5b17433da..d21a0d147 100644 --- a/app/src/main/java/io/legado/app/ui/replace/ReplaceRuleActivity.kt +++ b/app/src/main/java/io/legado/app/ui/replace/ReplaceRuleActivity.kt @@ -89,11 +89,11 @@ class ReplaceRuleActivity : VMBaseActivity GroupManageDialog().show(supportFragmentManager, "groupManage") - R.id.menu_del_selection -> viewModel.delSelection(adapter.getSelection()) + R.id.menu_del_selection -> viewModel.delSelection(adapter.selection) R.id.menu_import_onLine -> showImportDialog() R.id.menu_import_local -> importDoc.launch( FilePickerParam( @@ -237,8 +237,10 @@ class ReplaceRuleActivity : VMBaseActivity viewModel.enableSelection(adapter.getSelection()) - R.id.menu_disable_selection -> viewModel.disableSelection(adapter.getSelection()) + R.id.menu_enable_selection -> viewModel.enableSelection(adapter.selection) + R.id.menu_disable_selection -> viewModel.disableSelection(adapter.selection) + R.id.menu_top_sel -> viewModel.topSelect(adapter.selection) + R.id.menu_bottom_sel -> viewModel.bottomSelect(adapter.selection) R.id.menu_export_selection -> exportDir.launch(null) } return false @@ -304,7 +306,7 @@ class ReplaceRuleActivity : VMBaseActivity() + val selection: LinkedHashSet + get() { + val selection = linkedSetOf() + getItems().map { + if (selected.contains(it)) { + selection.add(it) + } + } + return selection + } + val diffItemCallBack = object : DiffUtil.ItemCallback() { override fun areItemsTheSame(oldItem: ReplaceRule, newItem: ReplaceRule): Boolean { @@ -84,16 +95,6 @@ class ReplaceRuleAdapter(context: Context, var callBack: CallBack) : callBack.upCountView() } - fun getSelection(): LinkedHashSet { - val selection = linkedSetOf() - getItems().map { - if (selected.contains(it)) { - selection.add(it) - } - } - return selection - } - override fun getViewBinding(parent: ViewGroup): ItemReplaceRuleBinding { return ItemReplaceRuleBinding.inflate(inflater, parent, false) } diff --git a/app/src/main/java/io/legado/app/ui/replace/ReplaceRuleViewModel.kt b/app/src/main/java/io/legado/app/ui/replace/ReplaceRuleViewModel.kt index b0f18067d..48a9abc2e 100644 --- a/app/src/main/java/io/legado/app/ui/replace/ReplaceRuleViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/replace/ReplaceRuleViewModel.kt @@ -30,6 +30,16 @@ class ReplaceRuleViewModel(application: Application) : BaseViewModel(application } } + fun topSelect(rules: LinkedHashSet) { + execute { + var minOrder = appDb.replaceRuleDao.minOrder - rules.size + rules.forEach { + it.order = ++minOrder + } + appDb.replaceRuleDao.update(*rules.toTypedArray()) + } + } + fun toBottom(rule: ReplaceRule) { execute { rule.order = appDb.replaceRuleDao.maxOrder + 1 @@ -37,6 +47,16 @@ class ReplaceRuleViewModel(application: Application) : BaseViewModel(application } } + fun bottomSelect(rules: LinkedHashSet) { + execute { + var maxOrder = appDb.replaceRuleDao.maxOrder + rules.forEach { + it.order = maxOrder++ + } + appDb.replaceRuleDao.update(*rules.toTypedArray()) + } + } + fun upOrder() { execute { val rules = appDb.replaceRuleDao.all diff --git a/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt b/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt index c16cf2667..889acc8c8 100644 --- a/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt +++ b/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt @@ -77,11 +77,11 @@ class RssSourceActivity : VMBaseActivity qrCodeResult.launch(null) R.id.menu_group_manage -> GroupManageDialog() .show(supportFragmentManager, "rssGroupManage") - R.id.menu_share_source -> viewModel.shareSelection(adapter.getSelection()) { + R.id.menu_share_source -> viewModel.shareSelection(adapter.selection) { startActivity(Intent.createChooser(it, getString(R.string.share_selected_source))) } R.id.menu_import_default -> viewModel.importDefault() @@ -133,12 +133,12 @@ class RssSourceActivity : VMBaseActivity viewModel.enableSelection(adapter.getSelection()) - R.id.menu_disable_selection -> viewModel.disableSelection(adapter.getSelection()) - R.id.menu_del_selection -> viewModel.delSelection(adapter.getSelection()) + R.id.menu_enable_selection -> viewModel.enableSelection(adapter.selection) + R.id.menu_disable_selection -> viewModel.disableSelection(adapter.selection) + R.id.menu_del_selection -> viewModel.delSelection(adapter.selection) R.id.menu_export_selection -> exportDir.launch(null) - R.id.menu_top_sel -> viewModel.topSource(*adapter.getSelection().toTypedArray()) - R.id.menu_bottom_sel -> viewModel.bottomSource(*adapter.getSelection().toTypedArray()) + R.id.menu_top_sel -> viewModel.topSource(*adapter.selection.toTypedArray()) + R.id.menu_bottom_sel -> viewModel.bottomSource(*adapter.selection.toTypedArray()) } return true } @@ -215,7 +215,7 @@ class RssSourceActivity : VMBaseActivity() + val selection: List + get() { + val selection = arrayListOf() + getItems().forEach { + if (selected.contains(it)) { + selection.add(it) + } + } + return selection.sortedBy { it.customOrder } + } + val diffItemCallback: DiffUtil.ItemCallback get() = object : DiffUtil.ItemCallback() { @@ -149,16 +160,6 @@ class RssSourceAdapter(context: Context, val callBack: CallBack) : callBack.upCountView() } - fun getSelection(): List { - val selection = arrayListOf() - getItems().forEach { - if (selected.contains(it)) { - selection.add(it) - } - } - return selection.sortedBy { it.customOrder } - } - private fun showMenu(view: View, position: Int) { val source = getItem(position) ?: return val popupMenu = PopupMenu(context, view) diff --git a/app/src/main/res/menu/book_source_sel.xml b/app/src/main/res/menu/book_source_sel.xml index 02a6178ba..7d947d35e 100644 --- a/app/src/main/res/menu/book_source_sel.xml +++ b/app/src/main/res/menu/book_source_sel.xml @@ -34,12 +34,12 @@ + + + + Espacio entre líneas Espacio entre párrafos Encima + Selection To Top Debajo + Selection To Bottom Autoexpandir Descubrir Expande por defecto la primera parte de Descubrir. Líneas actuales %s diff --git a/app/src/main/res/values-ja-rJP/strings.xml b/app/src/main/res/values-ja-rJP/strings.xml index 7ae49bac5..2f4a156d4 100644 --- a/app/src/main/res/values-ja-rJP/strings.xml +++ b/app/src/main/res/values-ja-rJP/strings.xml @@ -317,7 +317,9 @@ Line spacing Paragraph spacing To Top + Selection To Top To Bottom + Selection To Bottom Auto expand Discovery Default expand the first Discovery. Current threads %s diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index 6bb5db968..98de0cd26 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -317,7 +317,9 @@ Espaço entre linhas Espaço entre parágrafos Ao parte superior + Selection To Top Ao fundo + Selection To Bottom Expansão automática de Descoberta A expansão padrão da primeira Descoberta. Linhas atuais %s diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index 0aaccd421..64ccf92dc 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -314,6 +314,9 @@ 行距 段距 置頂 + 置頂所選 + 置底 + 置底所選 自動展開發現 默認展開第一組發現 當前線程數 %s @@ -698,7 +701,6 @@ 夜間,背景色 夜間,導航欄顏色 自動換源 - 置底 文字兩端對齊 自動翻頁速度 地址排序 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index e042521bc..27edbfd8f 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -316,7 +316,9 @@ 行距 段距 置頂 + 置頂所選 置底 + 置底所選 自動展開發現 預設展開第一組發現 目前執行緒數 %s diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml index 321411476..20e9b1fc8 100644 --- a/app/src/main/res/values-zh/strings.xml +++ b/app/src/main/res/values-zh/strings.xml @@ -316,7 +316,9 @@ 行距 段距 置顶 + 置顶所选 置底 + 置底所选 自动展开发现 默认展开第一组发现 当前线程数 %s diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index b3c6e628f..32a68ce50 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -317,7 +317,9 @@ Line spacing Paragraph spacing To Top + Selection To Top To Bottom + Selection To Bottom Auto expand Discovery Default expand the first Discovery. Current threads %s