diff --git a/android/android_framework/res/src/main/res/values-ar/app_strings.xml b/android/android_framework/res/src/main/res/values-ar/app_strings.xml
index b7199c44e..1a1dbacc5 100644
--- a/android/android_framework/res/src/main/res/values-ar/app_strings.xml
+++ b/android/android_framework/res/src/main/res/values-ar/app_strings.xml
@@ -345,6 +345,8 @@
اختيار الدفعة
الكل
لا على الاطلاق
+ Yes in this page
+ No in this page
بحث
إعادة تسمية
إزالة
diff --git a/android/android_framework/res/src/main/res/values-zh-rCN/app_strings.xml b/android/android_framework/res/src/main/res/values-zh-rCN/app_strings.xml
index 3fc66bb4c..6013b5a89 100644
--- a/android/android_framework/res/src/main/res/values-zh-rCN/app_strings.xml
+++ b/android/android_framework/res/src/main/res/values-zh-rCN/app_strings.xml
@@ -361,6 +361,8 @@
批量选择
全部
全不
+ 当前页全部
+ 当前页全不
搜索
重命名
移除
diff --git a/android/android_framework/res/src/main/res/values-zh-rTW/app_strings.xml b/android/android_framework/res/src/main/res/values-zh-rTW/app_strings.xml
index ab30e5657..1a7bbbc21 100644
--- a/android/android_framework/res/src/main/res/values-zh-rTW/app_strings.xml
+++ b/android/android_framework/res/src/main/res/values-zh-rTW/app_strings.xml
@@ -361,6 +361,8 @@
批量选择
全部
全不
+ 当前页全部
+ 当前页全不
搜索
移除
卸载
diff --git a/android/android_framework/res/src/main/res/values/app_strings.xml b/android/android_framework/res/src/main/res/values/app_strings.xml
index dfe874662..1069974a8 100644
--- a/android/android_framework/res/src/main/res/values/app_strings.xml
+++ b/android/android_framework/res/src/main/res/values/app_strings.xml
@@ -358,6 +358,8 @@
Batch select
All yes
All no
+ Yes in this page
+ No in this page
search
Rename
Remove
diff --git a/android/modules/module_common/src/main/res/values/dashboard.xml b/android/modules/module_common/src/main/res/values/dashboard.xml
index 4ddf82568..a23f6de0a 100644
--- a/android/modules/module_common/src/main/res/values/dashboard.xml
+++ b/android/modules/module_common/src/main/res/values/dashboard.xml
@@ -67,7 +67,7 @@
diff --git a/android/modules/module_component_manager/src/main/java/github/tornaco/thanos/module/component/manager/ComponentListActivity.kt b/android/modules/module_component_manager/src/main/java/github/tornaco/thanos/module/component/manager/ComponentListActivity.kt
index 9c970ade5..f5e6b0dee 100644
--- a/android/modules/module_component_manager/src/main/java/github/tornaco/thanos/module/component/manager/ComponentListActivity.kt
+++ b/android/modules/module_component_manager/src/main/java/github/tornaco/thanos/module/component/manager/ComponentListActivity.kt
@@ -1,5 +1,6 @@
package github.tornaco.thanos.module.component.manager
+import android.annotation.SuppressLint
import android.os.Bundle
import android.view.LayoutInflater
import android.view.Menu
@@ -12,6 +13,7 @@ import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.fragment.app.FragmentActivity
import androidx.recyclerview.widget.LinearLayoutManager
+import androidx.recyclerview.widget.RecyclerView
import com.elvishew.xlog.XLog
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.miguelcatalan.materialsearchview.MaterialSearchView
@@ -24,6 +26,8 @@ import github.tornaco.android.thanos.theme.ThemeActivity
import github.tornaco.android.thanos.widget.ModernProgressDialog
import github.tornaco.thanos.module.component.manager.databinding.ModuleComponentManagerComponentListActivityBinding
import github.tornaco.thanos.module.component.manager.model.ComponentModel
+import kotlin.math.max
+import kotlin.math.min
abstract class ComponentListActivity : ThemeActivity() {
@@ -174,7 +178,7 @@ abstract class ComponentListActivity : ThemeActivity() {
.setPositiveButton(
android.R.string.ok
) { _, _ ->
- onRequestSelectAll(true)
+ onRequestSelectAll(viewModel.componentModels, true)
}.show()
return true
}
@@ -184,19 +188,53 @@ abstract class ComponentListActivity : ThemeActivity() {
.setMessage(github.tornaco.android.thanos.res.R.string.common_dialog_message_are_you_sure)
.setPositiveButton(
android.R.string.ok
- ) { _, _ -> onRequestSelectAll(false) }
+ ) { _, _ -> onRequestSelectAll(viewModel.componentModels, false) }
+ .show()
+ return true
+ }
+ if (github.tornaco.thanos.module.component.manager.R.id.action_select_all_in_this_page == item.itemId) {
+ MaterialAlertDialogBuilder(thisActivity())
+ .setTitle(github.tornaco.android.thanos.res.R.string.common_menu_title_select_all_in_this_page)
+ .setMessage(github.tornaco.android.thanos.res.R.string.common_dialog_message_are_you_sure)
+ .setPositiveButton(
+ android.R.string.ok
+ ) { _, _ -> onRequestSelectAllInThisPage(binding.componentListView, true) }
+ .show()
+ return true
+ }
+ if (github.tornaco.thanos.module.component.manager.R.id.action_un_select_all_in_this_page == item.itemId) {
+ MaterialAlertDialogBuilder(thisActivity())
+ .setTitle(github.tornaco.android.thanos.res.R.string.common_menu_title_un_select_all_in_this_page)
+ .setMessage(github.tornaco.android.thanos.res.R.string.common_dialog_message_are_you_sure)
+ .setPositiveButton(
+ android.R.string.ok
+ ) { _, _ -> onRequestSelectAllInThisPage(binding.componentListView, false) }
.show()
return true
}
return super.onOptionsItemSelected(item)
}
- private fun onRequestSelectAll(isSelectAll: Boolean) {
+ private fun onRequestSelectAllInThisPage(recyclerView: RecyclerView, isSelectAll: Boolean) {
+ val models = viewModel.componentModels
+ val lm = recyclerView.layoutManager as LinearLayoutManager
+ val f = max(0, lm.findFirstVisibleItemPosition())
+ val l = min(models.size, lm.findLastVisibleItemPosition())
+ XLog.d("onRequestSelectAllInThisPage $f - $l")
+ val items = viewModel.componentModels.subList(f, l)
+ XLog.d("onRequestSelectAllInThisPage ${models.map { it.componentName.className }}")
+ XLog.d("onRequestSelectAllInThisPage ${items.map { it.componentName.className }}")
+ onRequestSelectAll(items, isSelectAll)
+ }
+
+ @SuppressLint("NotifyDataSetChanged")
+ private fun onRequestSelectAll(modelList: List, isSelectAll: Boolean) {
val progressDialog = ModernProgressDialog(thisActivity())
progressDialog.setTitle(getString(github.tornaco.android.thanos.res.R.string.common_text_wait_a_moment))
progressDialog.show()
viewModel.selectAll(
appInfo,
+ modelList,
isSelectAll,
{
runOnUiThread {
@@ -207,7 +245,7 @@ abstract class ComponentListActivity : ThemeActivity() {
runOnUiThread {
XLog.d("onRequestSelectAll, onComplete")
progressDialog.dismiss()
- viewModel.start()
+ binding.componentListView.adapter?.notifyDataSetChanged()
}
})
}
diff --git a/android/modules/module_component_manager/src/main/java/github/tornaco/thanos/module/component/manager/ComponentListViewModel.java b/android/modules/module_component_manager/src/main/java/github/tornaco/thanos/module/component/manager/ComponentListViewModel.java
index 9f892ac87..4d90ee3ad 100644
--- a/android/modules/module_component_manager/src/main/java/github/tornaco/thanos/module/component/manager/ComponentListViewModel.java
+++ b/android/modules/module_component_manager/src/main/java/github/tornaco/thanos/module/component/manager/ComponentListViewModel.java
@@ -83,10 +83,13 @@ private void loadComponents() {
protected abstract ComponentsLoader onCreateLoader();
- public void toggleComponentState(AppInfo appInfo, @Nullable ComponentModel componentModel, boolean checked) {
- if (componentModel == null) return;
+ public boolean toggleComponentState(AppInfo appInfo, @Nullable ComponentModel componentModel, boolean checked) {
+ if (componentModel == null) return false;
ThanosManager thanox = ThanosManager.from(getApplication());
int newState = checked ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED : PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
+ if (newState == componentModel.getEnableSetting()) {
+ return false;
+ }
if (thanox.isServiceInstalled()) {
componentModel.setEnableSetting(newState);
thanox.getPkgManager().setComponentEnabledSetting(
@@ -94,7 +97,9 @@ public void toggleComponentState(AppInfo appInfo, @Nullable ComponentModel compo
componentModel.getComponentName(),
newState
, 0 /* Kill it */);
+ return true;
}
+ return false;
}
private void registerEventReceivers() {
@@ -121,21 +126,23 @@ public void clearSearchText() {
loadComponents();
}
- public void selectAll(AppInfo appInfo, boolean enabled, Consumer onUpdate, Runnable onComplete) {
- int totalCount = componentModels.size();
+ public void selectAll(AppInfo appInfo, List modelList,
+ boolean enabled, Consumer onUpdate,
+ Runnable onComplete) {
+ int totalCount = modelList.size();
ThanosManager.from(getApplication()).getActivityManager().forceStopPackage(Pkg.fromAppInfo(appInfo), "ComponentList UI selectAll");
-
// Wait 1s.
disposables.add(Completable.fromAction(() -> {
- for (int i = 0; i < componentModels.size(); i++) {
- ComponentModel componentModel = componentModels.get(i);
+ for (int i = 0; i < modelList.size(); i++) {
+ ComponentModel componentModel = modelList.get(i);
onUpdate.accept((i + 1) + "/" + totalCount);
- toggleComponentState(appInfo, componentModel, enabled);
- try {
- // Maybe a short delay will make it safer.
- Thread.sleep(100);
- } catch (InterruptedException ignored) {
+ if (toggleComponentState(appInfo, componentModel, enabled)) {
+ try {
+ // Maybe a short delay will make it safer.
+ Thread.sleep(100);
+ } catch (InterruptedException ignored) {
+ }
}
}
}).subscribeOn(Schedulers.io())
diff --git a/android/modules/module_component_manager/src/main/res/layout/module_component_manager_component_list_item.xml b/android/modules/module_component_manager/src/main/res/layout/module_component_manager_component_list_item.xml
index 062c11d1e..89758becc 100755
--- a/android/modules/module_component_manager/src/main/res/layout/module_component_manager_component_list_item.xml
+++ b/android/modules/module_component_manager/src/main/res/layout/module_component_manager_component_list_item.xml
@@ -56,13 +56,24 @@
android:layout_alignParentStart="true"
android:layout_marginTop="@dimen/common_view_margin_small"
android:layout_marginEnd="@dimen/common_view_margin_default"
- android:layout_toStartOf="@id/state_container"
android:ellipsize="middle"
android:fadingEdge="horizontal"
android:text="@{component.label}"
android:textAppearance="@style/TextAppearance.TileTitle"
tools:text="Service Name" />
+
+
-
-
diff --git a/android/modules/module_component_manager/src/main/res/menu/module_component_manager_component_list_menu.xml b/android/modules/module_component_manager/src/main/res/menu/module_component_manager_component_list_menu.xml
index af0b19fa1..c4728475a 100644
--- a/android/modules/module_component_manager/src/main/res/menu/module_component_manager_component_list_menu.xml
+++ b/android/modules/module_component_manager/src/main/res/menu/module_component_manager_component_list_menu.xml
@@ -1,28 +1,35 @@
\ No newline at end of file