diff --git a/app/src/main/java/io/legado/app/ui/association/ImportBookSourceDialog.kt b/app/src/main/java/io/legado/app/ui/association/ImportBookSourceDialog.kt
index 191b786c3..7b7f7310a 100644
--- a/app/src/main/java/io/legado/app/ui/association/ImportBookSourceDialog.kt
+++ b/app/src/main/java/io/legado/app/ui/association/ImportBookSourceDialog.kt
@@ -74,7 +74,7 @@ class ImportBookSourceDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickList
dismiss()
}
}
- binding.tvFooterLeft.setText(R.string.select_all)
+ upSelectText()
binding.tvFooterLeft.setOnClickListener {
val selectAll = viewModel.isSelectAll()
viewModel.selectStatus.forEachIndexed { index, b ->
@@ -83,6 +83,23 @@ class ImportBookSourceDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickList
}
}
adapter.notifyDataSetChanged()
+ upSelectText()
+ }
+ }
+
+ private fun upSelectText() {
+ if (viewModel.isSelectAll()) {
+ binding.tvFooterLeft.text = getString(
+ R.string.select_cancel_count,
+ viewModel.selectCount(),
+ viewModel.allSources.size
+ )
+ } else {
+ binding.tvFooterLeft.text = getString(
+ R.string.select_all_count,
+ viewModel.selectCount(),
+ viewModel.allSources.size
+ )
}
}
@@ -162,6 +179,7 @@ class ImportBookSourceDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickList
cbSourceName.setOnCheckedChangeListener { buttonView, isChecked ->
if (buttonView.isPressed) {
viewModel.selectStatus[holder.layoutPosition] = isChecked
+ upSelectText()
}
}
}
diff --git a/app/src/main/java/io/legado/app/ui/association/ImportBookSourceViewModel.kt b/app/src/main/java/io/legado/app/ui/association/ImportBookSourceViewModel.kt
index 2b782040a..35072f651 100644
--- a/app/src/main/java/io/legado/app/ui/association/ImportBookSourceViewModel.kt
+++ b/app/src/main/java/io/legado/app/ui/association/ImportBookSourceViewModel.kt
@@ -36,6 +36,16 @@ class ImportBookSourceViewModel(app: Application) : BaseViewModel(app) {
return true
}
+ fun selectCount(): Int {
+ var count = 0
+ selectStatus.forEach {
+ if (it) {
+ count++
+ }
+ }
+ return count
+ }
+
fun importSelect(finally: () -> Unit) {
execute {
val keepName = AppConfig.importKeepName
diff --git a/app/src/main/java/io/legado/app/ui/association/ImportRssSourceDialog.kt b/app/src/main/java/io/legado/app/ui/association/ImportRssSourceDialog.kt
index 37ac59bf1..d3d443640 100644
--- a/app/src/main/java/io/legado/app/ui/association/ImportRssSourceDialog.kt
+++ b/app/src/main/java/io/legado/app/ui/association/ImportRssSourceDialog.kt
@@ -72,7 +72,7 @@ class ImportRssSourceDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListe
dismiss()
}
}
- binding.tvFooterLeft.setText(R.string.select_all)
+ upSelectText()
binding.tvFooterLeft.setOnClickListener {
val selectAll = viewModel.isSelectAll()
viewModel.selectStatus.forEachIndexed { index, b ->
@@ -81,6 +81,23 @@ class ImportRssSourceDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListe
}
}
adapter.notifyDataSetChanged()
+ upSelectText()
+ }
+ }
+
+ private fun upSelectText() {
+ if (viewModel.isSelectAll()) {
+ binding.tvFooterLeft.text = getString(
+ R.string.select_cancel_count,
+ viewModel.selectCount(),
+ viewModel.allSources.size
+ )
+ } else {
+ binding.tvFooterLeft.text = getString(
+ R.string.select_all_count,
+ viewModel.selectCount(),
+ viewModel.allSources.size
+ )
}
}
@@ -158,6 +175,7 @@ class ImportRssSourceDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListe
cbSourceName.setOnCheckedChangeListener { buttonView, isChecked ->
if (buttonView.isPressed) {
viewModel.selectStatus[holder.layoutPosition] = isChecked
+ upSelectText()
}
}
}
diff --git a/app/src/main/java/io/legado/app/ui/association/ImportRssSourceViewModel.kt b/app/src/main/java/io/legado/app/ui/association/ImportRssSourceViewModel.kt
index 5bff81753..06cf2da11 100644
--- a/app/src/main/java/io/legado/app/ui/association/ImportRssSourceViewModel.kt
+++ b/app/src/main/java/io/legado/app/ui/association/ImportRssSourceViewModel.kt
@@ -35,6 +35,16 @@ class ImportRssSourceViewModel(app: Application) : BaseViewModel(app) {
return true
}
+ fun selectCount(): Int {
+ var count = 0
+ selectStatus.forEach {
+ if (it) {
+ count++
+ }
+ }
+ return count
+ }
+
fun importSelect(finally: () -> Unit) {
execute {
val keepName = AppConfig.importKeepName
diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml
index e4336c98a..2f9956a23 100644
--- a/app/src/main/res/values-zh-rHK/strings.xml
+++ b/app/src/main/res/values-zh-rHK/strings.xml
@@ -212,7 +212,7 @@
選擇操作
全選
全選 (%1$d/%2$d)
- 取消 (%1$d/%2$d)
+ 取消全選 (%1$d/%2$d)
深色模式
啟動頁
開始下載
diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml
index 73f4ea493..33f623d32 100644
--- a/app/src/main/res/values-zh-rTW/strings.xml
+++ b/app/src/main/res/values-zh-rTW/strings.xml
@@ -214,7 +214,7 @@
選擇操作
全選
全選(%1$d/%2$d)
- 取消(%1$d/%2$d)
+ 取消全選(%1$d/%2$d)
深色模式
啟動頁
開始下載
diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml
index 6ff4b0be6..a4f670bc6 100644
--- a/app/src/main/res/values-zh/strings.xml
+++ b/app/src/main/res/values-zh/strings.xml
@@ -214,7 +214,7 @@
选择操作
全选
全选(%1$d/%2$d)
- 取消(%1$d/%2$d)
+ 取消全选(%1$d/%2$d)
深色模式
启动页
开始下载
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 2472dbe3c..b2ba15475 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -215,7 +215,7 @@
Selection action
Select all
Select all(%1$d/%2$d)
- Cancel(%1$d/%2$d)
+ Cancel select all(%1$d/%2$d)
Dark mode
Welcome page
Download start