Update add network dialog to not make networks hidden by default
This CL updates the add network dialog to use the provided value for the hidden state (from androids perspective) of the network. The default selected value will always be not hidden and if the user selects to mark it as hidden a warning will appear to inform the user of the privacy implications. Test: Robotests Bug: 29003359 Change-Id: Ifd4511e4d0af6eb01f4e951c22a91fc560393e8d
This commit is contained in:
@@ -55,6 +55,7 @@ import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
|
||||
@@ -89,6 +90,10 @@ public class WifiConfigController implements TextWatcher,
|
||||
private static final int DHCP = 0;
|
||||
private static final int STATIC_IP = 1;
|
||||
|
||||
/* Constants used for referring to the hidden state of a network. */
|
||||
public static final int HIDDEN_NETWORK = 1;
|
||||
public static final int NOT_HIDDEN_NETWORK = 0;
|
||||
|
||||
/* These values come from "wifi_proxy_settings" resource array */
|
||||
public static final int PROXY_NONE = 0;
|
||||
public static final int PROXY_STATIC = 1;
|
||||
@@ -127,6 +132,7 @@ public class WifiConfigController implements TextWatcher,
|
||||
private String mDoNotProvideEapUserCertString;
|
||||
private String mDoNotValidateEapServerString;
|
||||
|
||||
private ScrollView mDialogContainer;
|
||||
private Spinner mSecuritySpinner;
|
||||
private Spinner mEapMethodSpinner;
|
||||
private Spinner mEapCaCertSpinner;
|
||||
@@ -147,6 +153,8 @@ public class WifiConfigController implements TextWatcher,
|
||||
|
||||
private Spinner mProxySettingsSpinner;
|
||||
private Spinner mMeteredSettingsSpinner;
|
||||
private Spinner mHiddenSettingsSpinner;
|
||||
private TextView mHiddenWarningView;
|
||||
private TextView mProxyHostView;
|
||||
private TextView mProxyPortView;
|
||||
private TextView mProxyExclusionListView;
|
||||
@@ -203,12 +211,20 @@ public class WifiConfigController implements TextWatcher,
|
||||
mDoNotValidateEapServerString =
|
||||
mContext.getString(R.string.wifi_do_not_validate_eap_server);
|
||||
|
||||
mDialogContainer = mView.findViewById(R.id.dialog_scrollview);
|
||||
mIpSettingsSpinner = (Spinner) mView.findViewById(R.id.ip_settings);
|
||||
mIpSettingsSpinner.setOnItemSelectedListener(this);
|
||||
mProxySettingsSpinner = (Spinner) mView.findViewById(R.id.proxy_settings);
|
||||
mProxySettingsSpinner.setOnItemSelectedListener(this);
|
||||
mSharedCheckBox = (CheckBox) mView.findViewById(R.id.shared);
|
||||
mMeteredSettingsSpinner = mView.findViewById(R.id.metered_settings);
|
||||
mHiddenSettingsSpinner = mView.findViewById(R.id.hidden_settings);
|
||||
mHiddenSettingsSpinner.setOnItemSelectedListener(this);
|
||||
mHiddenWarningView = mView.findViewById(R.id.hidden_settings_warning);
|
||||
mHiddenWarningView.setVisibility(
|
||||
mHiddenSettingsSpinner.getSelectedItemPosition() == NOT_HIDDEN_NETWORK
|
||||
? View.GONE
|
||||
: View.VISIBLE);
|
||||
|
||||
if (mAccessPoint == null) { // new network
|
||||
mConfigUi.setTitle(R.string.wifi_add_network);
|
||||
@@ -239,6 +255,9 @@ public class WifiConfigController implements TextWatcher,
|
||||
if (mAccessPoint.isSaved()) {
|
||||
WifiConfiguration config = mAccessPoint.getConfig();
|
||||
mMeteredSettingsSpinner.setSelection(config.meteredOverride);
|
||||
mHiddenSettingsSpinner.setSelection(config.hiddenSSID
|
||||
? HIDDEN_NETWORK
|
||||
: NOT_HIDDEN_NETWORK);
|
||||
if (config.getIpAssignment() == IpAssignment.STATIC) {
|
||||
mIpSettingsSpinner.setSelection(STATIC_IP);
|
||||
showAdvancedFields = true;
|
||||
@@ -514,7 +533,7 @@ public class WifiConfigController implements TextWatcher,
|
||||
config.SSID = AccessPoint.convertToQuotedString(
|
||||
mSsidView.getText().toString());
|
||||
// If the user adds a network manually, assume that it is hidden.
|
||||
config.hiddenSSID = true;
|
||||
config.hiddenSSID = mHiddenSettingsSpinner.getSelectedItemPosition() == HIDDEN_NETWORK;
|
||||
} else if (!mAccessPoint.isSaved()) {
|
||||
config.SSID = AccessPoint.convertToQuotedString(
|
||||
mAccessPoint.getSsidStr());
|
||||
@@ -1350,6 +1369,16 @@ public class WifiConfigController implements TextWatcher,
|
||||
showPeapFields();
|
||||
} else if (parent == mProxySettingsSpinner) {
|
||||
showProxyFields();
|
||||
} else if (parent == mHiddenSettingsSpinner) {
|
||||
mHiddenWarningView.setVisibility(
|
||||
position == NOT_HIDDEN_NETWORK
|
||||
? View.GONE
|
||||
: View.VISIBLE);
|
||||
if (position == HIDDEN_NETWORK) {
|
||||
mDialogContainer.post(() -> {
|
||||
mDialogContainer.fullScroll(View.FOCUS_DOWN);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
showIpConfigFields();
|
||||
}
|
||||
|
Reference in New Issue
Block a user