Include login/alwayson in legacy VPN editor dialog
A little more consistent with the new app VPNs' dialogs. To make this work it was also necessary to restart the lockdown VPN every time it is edited, which makes sense because the expected action after editing a VPN is that it reconnects with the new settings. Bug: 28072644 Change-Id: I4b6a6f0a6ed96d2ec6f62889fdae4abb60d0646c
This commit is contained in:
@@ -119,8 +119,7 @@
|
|||||||
<LinearLayout android:id="@+id/login"
|
<LinearLayout android:id="@+id/login"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical">
|
||||||
android:visibility="gone">
|
|
||||||
|
|
||||||
<TextView style="@style/vpn_label" android:text="@string/vpn_username"/>
|
<TextView style="@style/vpn_label" android:text="@string/vpn_username"/>
|
||||||
<EditText style="@style/vpn_value" android:id="@+id/username"/>
|
<EditText style="@style/vpn_value" android:id="@+id/username"/>
|
||||||
|
@@ -170,6 +170,9 @@ class ConfigDialog extends AlertDialog implements TextWatcher,
|
|||||||
// Show type-specific fields.
|
// Show type-specific fields.
|
||||||
changeType(mProfile.type);
|
changeType(mProfile.type);
|
||||||
|
|
||||||
|
// Hide 'save login' when we are editing.
|
||||||
|
mSaveLogin.setVisibility(View.GONE);
|
||||||
|
|
||||||
// Switch to advanced view immediately if any advanced options are on
|
// Switch to advanced view immediately if any advanced options are on
|
||||||
if (!mProfile.searchDomains.isEmpty() || !mProfile.dnsServers.isEmpty() ||
|
if (!mProfile.searchDomains.isEmpty() || !mProfile.dnsServers.isEmpty() ||
|
||||||
!mProfile.routes.isEmpty()) {
|
!mProfile.routes.isEmpty()) {
|
||||||
@@ -188,9 +191,6 @@ class ConfigDialog extends AlertDialog implements TextWatcher,
|
|||||||
} else {
|
} else {
|
||||||
setTitle(context.getString(R.string.vpn_connect_to, mProfile.name));
|
setTitle(context.getString(R.string.vpn_connect_to, mProfile.name));
|
||||||
|
|
||||||
// Not editing, just show username and password.
|
|
||||||
mView.findViewById(R.id.login).setVisibility(View.VISIBLE);
|
|
||||||
|
|
||||||
// Create a button to connect the network.
|
// Create a button to connect the network.
|
||||||
setButton(DialogInterface.BUTTON_POSITIVE,
|
setButton(DialogInterface.BUTTON_POSITIVE,
|
||||||
context.getString(R.string.vpn_connect), mListener);
|
context.getString(R.string.vpn_connect), mListener);
|
||||||
@@ -259,6 +259,7 @@ class ConfigDialog extends AlertDialog implements TextWatcher,
|
|||||||
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
|
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
|
||||||
if (compoundButton == mAlwaysOnVpn) {
|
if (compoundButton == mAlwaysOnVpn) {
|
||||||
updateSaveLoginStatus();
|
updateSaveLoginStatus();
|
||||||
|
getButton(DialogInterface.BUTTON_POSITIVE).setEnabled(validate(mEditing));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -318,6 +319,9 @@ class ConfigDialog extends AlertDialog implements TextWatcher,
|
|||||||
if (!editing) {
|
if (!editing) {
|
||||||
return mUsername.getText().length() != 0 && mPassword.getText().length() != 0;
|
return mUsername.getText().length() != 0 && mPassword.getText().length() != 0;
|
||||||
}
|
}
|
||||||
|
if (mAlwaysOnVpn.isChecked() && !getProfile().isValidLockdownProfile()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (mName.getText().length() == 0 || mServer.getText().length() == 0 ||
|
if (mName.getText().length() == 0 || mServer.getText().length() == 0 ||
|
||||||
!validateAddresses(mDnsServers.getText().toString(), false) ||
|
!validateAddresses(mDnsServers.getText().toString(), false) ||
|
||||||
!validateAddresses(mRoutes.getText().toString(), true)) {
|
!validateAddresses(mRoutes.getText().toString(), true)) {
|
||||||
@@ -441,7 +445,8 @@ class ConfigDialog extends AlertDialog implements TextWatcher,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
profile.saveLogin = mSaveLogin.isChecked();
|
final boolean hasLogin = !profile.username.isEmpty() || !profile.password.isEmpty();
|
||||||
|
profile.saveLogin = mSaveLogin.isChecked() || (mEditing && hasLogin);
|
||||||
return profile;
|
return profile;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -152,12 +152,9 @@ public class ConfigDialogFragment extends DialogFragment implements
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update only if lockdown vpn has been changed
|
|
||||||
if (!VpnUtils.isVpnLockdown(profile.key)) {
|
|
||||||
final ConnectivityManager conn = ConnectivityManager.from(getActivity());
|
final ConnectivityManager conn = ConnectivityManager.from(getActivity());
|
||||||
conn.setAlwaysOnVpnPackageForUser(UserHandle.myUserId(), null);
|
conn.setAlwaysOnVpnPackageForUser(UserHandle.myUserId(), null);
|
||||||
VpnUtils.setLockdownVpn(getContext(), profile.key);
|
VpnUtils.setLockdownVpn(getContext(), profile.key);
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// update only if lockdown vpn has been changed
|
// update only if lockdown vpn has been changed
|
||||||
if (VpnUtils.isVpnLockdown(profile.key)) {
|
if (VpnUtils.isVpnLockdown(profile.key)) {
|
||||||
|
Reference in New Issue
Block a user