From 7078162c690abdf618d801035dd3b940ffcfd0fc Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Fri, 6 Jul 2018 04:50:51 +0200 Subject: [PATCH] AppListDialogFragment: add deselect all button Signed-off-by: Jason A. Donenfeld --- .../android/fragment/AppListDialogFragment.java | 9 ++++++++- app/src/main/res/values/strings.xml | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) 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 1c11bd41..15571297 100644 --- a/app/src/main/java/com/wireguard/android/fragment/AppListDialogFragment.java +++ b/app/src/main/java/com/wireguard/android/fragment/AppListDialogFragment.java @@ -9,6 +9,7 @@ package com.wireguard.android.fragment; import android.app.Activity; import android.app.Dialog; import android.content.Context; +import android.content.DialogInterface; import android.content.Intent; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; @@ -73,13 +74,19 @@ public class AppListDialogFragment extends DialogFragment { alertDialogBuilder.setPositiveButton(R.string.set_exclusions, (dialog, which) -> setExclusionsAndDismiss()); alertDialogBuilder.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss()); + alertDialogBuilder.setNeutralButton(R.string.deselect_all, (dialog, which) -> { }); binding.setFragment(this); binding.setAppData(appData); loadData(); - return alertDialogBuilder.create(); + final AlertDialog dialog = alertDialogBuilder.create(); + dialog.setOnShowListener(d -> dialog.getButton(DialogInterface.BUTTON_NEUTRAL).setOnClickListener(view -> { + for (final ApplicationData app : appData) + app.setExcludedFromTunnel(false); + })); + return dialog; } private void loadData() { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index b4105d2d..defd4370 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -34,6 +34,7 @@ Currently using dark night theme Currently using light day theme Delete + Deselect All Select all DNS servers Edit