summaryrefslogtreecommitdiffhomepage
path: root/app
diff options
context:
space:
mode:
authorHarsh Shandilya <me@msfjarvis.dev>2020-02-23 15:04:05 +0530
committerHarsh Shandilya <me@msfjarvis.dev>2020-02-23 15:07:39 +0530
commit6f6602ddd1ef74c474900be4aa8a3b2dff923bea (patch)
tree2928121e6a9101d178be38eb800ede870018a469 /app
parent33e69db436c01c252781a01d169857a69867c6c3 (diff)
AppListDialogFragment: Revamp toggle logic
Rather than always toggle all elements, elect to unselect all if any are selected. This allows returning to a clean state in at most two clicks. Suggested-by: Jason A. Donenfeld <Jason@zx2c4.com> Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
Diffstat (limited to 'app')
-rw-r--r--app/src/main/java/com/wireguard/android/fragment/AppListDialogFragment.java8
1 files changed, 7 insertions, 1 deletions
diff --git a/app/src/main/java/com/wireguard/android/fragment/AppListDialogFragment.java b/app/src/main/java/com/wireguard/android/fragment/AppListDialogFragment.java
index fc01e86f..43178665 100644
--- a/app/src/main/java/com/wireguard/android/fragment/AppListDialogFragment.java
+++ b/app/src/main/java/com/wireguard/android/fragment/AppListDialogFragment.java
@@ -31,6 +31,8 @@ import java.util.Collections;
import java.util.List;
import java9.util.Comparators;
+import java9.util.stream.Collectors;
+import java9.util.stream.StreamSupport;
public class AppListDialogFragment extends DialogFragment {
@@ -109,8 +111,12 @@ public class AppListDialogFragment extends DialogFragment {
final AlertDialog dialog = alertDialogBuilder.create();
dialog.setOnShowListener(d -> dialog.getButton(DialogInterface.BUTTON_NEUTRAL).setOnClickListener(view -> {
+ final List<ApplicationData> selectedItems = StreamSupport.stream(appData)
+ .filter(ApplicationData::isExcludedFromTunnel)
+ .collect(Collectors.toList());
+ final boolean excludeAll = selectedItems.isEmpty();
for (final ApplicationData app : appData)
- app.setExcludedFromTunnel(!app.isExcludedFromTunnel());
+ app.setExcludedFromTunnel(excludeAll);
}));
return dialog;
}