diff --git a/app/src/main/java/com/wireguard/android/backends/VpnService.java b/app/src/main/java/com/wireguard/android/backends/VpnService.java
index 25eb4ade..275b719c 100644
--- a/app/src/main/java/com/wireguard/android/backends/VpnService.java
+++ b/app/src/main/java/com/wireguard/android/backends/VpnService.java
@@ -241,9 +241,9 @@ public class VpnService extends Service
@Override
protected void onPostExecute(final Boolean result) {
+ config.setIsEnabled(!result);
if (!result)
return;
- config.setIsEnabled(false);
enabledConfigs.remove(config.getName());
preferences.edit().putStringSet(KEY_ENABLED_CONFIGS, enabledConfigs).apply();
if (config.getName().equals(primaryName))
@@ -267,9 +267,9 @@ public class VpnService extends Service
@Override
protected void onPostExecute(final Boolean result) {
+ config.setIsEnabled(result);
if (!result)
return;
- config.setIsEnabled(true);
enabledConfigs.add(config.getName());
preferences.edit().putStringSet(KEY_ENABLED_CONFIGS, enabledConfigs).apply();
if (config.getName().equals(primaryName))
diff --git a/app/src/main/res/layout/config_list_item.xml b/app/src/main/res/layout/config_list_item.xml
index 578db833..87380dee 100644
--- a/app/src/main/res/layout/config_list_item.xml
+++ b/app/src/main/res/layout/config_list_item.xml
@@ -20,6 +20,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/list_item_background_anim"
+ android:descendantFocusability="blocksDescendants"
android:padding="16dp">
-
+ android:checked="@{item.enabled}"
+ android:onCheckedChanged="@{(v, checked) -> checked ? VpnService.instance.enable(item.name) : VpnService.instance.disable(item.name)}" />