summaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
authorcyBerta <cyberta@riseup.net>2021-03-27 15:44:57 +0100
committercyberta <cyberta@riseup.net>2021-04-22 22:53:01 +0200
commit299dee25b134805114e8a9580716607bd338f30b (patch)
tree01ac7b3676a6d65e507f6a8d93bf4dc3670f73ae /app/src/main
parent93e66fa7bca76c4fd6c77159a9cb71c1687d4881 (diff)
disable 'turn on' button if automatic gateway selection is disabled but no location is manually selected
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/base/fragments/GatewaySelectionFragment.java8
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/base/views/IconSwitchEntry.java4
2 files changed, 12 insertions, 0 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/base/fragments/GatewaySelectionFragment.java b/app/src/main/java/se/leap/bitmaskclient/base/fragments/GatewaySelectionFragment.java
index b7d5831c..30a167fc 100644
--- a/app/src/main/java/se/leap/bitmaskclient/base/fragments/GatewaySelectionFragment.java
+++ b/app/src/main/java/se/leap/bitmaskclient/base/fragments/GatewaySelectionFragment.java
@@ -54,6 +54,7 @@ import static android.content.Context.MODE_PRIVATE;
import static android.view.View.INVISIBLE;
import static android.view.View.VISIBLE;
import static se.leap.bitmaskclient.base.MainActivity.ACTION_SHOW_VPN_FRAGMENT;
+import static se.leap.bitmaskclient.base.models.Constants.PREFERRED_CITY;
import static se.leap.bitmaskclient.base.models.Constants.SHARED_PREFERENCES;
import static se.leap.bitmaskclient.base.models.Constants.USE_PLUGGABLE_TRANSPORTS;
import static se.leap.bitmaskclient.base.utils.PreferenceHelper.getPreferredCity;
@@ -133,6 +134,7 @@ public class GatewaySelectionFragment extends Fragment implements SharedPreferen
PreferenceHelper.setPreferredCity(getContext(), null);
locationListAdapter.resetSelection();
}
+ setVpnButtonState();
});
}
@@ -154,12 +156,18 @@ public class GatewaySelectionFragment extends Fragment implements SharedPreferen
} else {
vpnButton.setText(R.string.reconnect);
}
+ vpnButton.setEnabled(
+ (locationListAdapter.selectedLocation != null && locationListAdapter.selectedLocation.selected) ||
+ autoSelectionSwitch.isChecked());
}
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
if (USE_PLUGGABLE_TRANSPORTS.equals(key)) {
locationListAdapter.updateData(gatewaysManager.getGatewayLocations());
+ setVpnButtonState();
+ } else if (PREFERRED_CITY.equals(key)) {
+ setVpnButtonState();
}
}
diff --git a/app/src/main/java/se/leap/bitmaskclient/base/views/IconSwitchEntry.java b/app/src/main/java/se/leap/bitmaskclient/base/views/IconSwitchEntry.java
index 628b4c15..b6d72ab6 100644
--- a/app/src/main/java/se/leap/bitmaskclient/base/views/IconSwitchEntry.java
+++ b/app/src/main/java/se/leap/bitmaskclient/base/views/IconSwitchEntry.java
@@ -131,6 +131,10 @@ public class IconSwitchEntry extends LinearLayout {
switchView.setOnCheckedChangeListener(checkedChangeListener);
}
+ public boolean isChecked() {
+ return switchView.isChecked();
+ }
+
@Override
public void setEnabled(boolean enabled) {
super.setEnabled(enabled);