-->
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/dialog_scrollview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fadeScrollbars="false"
android:checked="true" />
</LinearLayout>
</LinearLayout>
+
+ <LinearLayout android:id="@+id/hidden_settings_field"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ style="@style/wifi_item">
+
+ <TextView android:id="@+id/hidden_settings_title"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ style="@style/wifi_item_label"
+ android:text="@string/wifi_hidden_network" />
+
+ <Spinner android:id="@+id/hidden_settings"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ style="@style/wifi_item_spinner"
+ android:prompt="@string/wifi_hidden_network"
+ android:entries="@array/wifi_hidden_entries"/>
+
+ <TextView android:id="@+id/hidden_settings_warning"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="8dp"
+ android:text="@string/wifi_hidden_network_warning"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:visibility="gone"/>
+ </LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
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;
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;
private String mDoNotProvideEapUserCertString;
private String mDoNotValidateEapServerString;
+ private ScrollView mDialogContainer;
private Spinner mSecuritySpinner;
private Spinner mEapMethodSpinner;
private Spinner mEapCaCertSpinner;
private Spinner mProxySettingsSpinner;
private Spinner mMeteredSettingsSpinner;
+ private Spinner mHiddenSettingsSpinner;
+ private TextView mHiddenWarningView;
private TextView mProxyHostView;
private TextView mProxyPortView;
private TextView mProxyExclusionListView;
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);
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;
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());
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();
}
private AccessPoint mAccessPoint;
@Mock
private KeyStore mKeyStore;
+ private Spinner mHiddenSettingsSpinner;
public WifiConfigController mController;
private static final String HEX_PSK = "01234567012345670123456701234567012345670123456701234567"
when(mAccessPoint.getSecurity()).thenReturn(AccessPoint.SECURITY_PSK);
mView = LayoutInflater.from(mContext).inflate(R.layout.wifi_dialog, null);
final Spinner ipSettingsSpinner = mView.findViewById(R.id.ip_settings);
+ mHiddenSettingsSpinner = mView.findViewById(R.id.hidden_settings);
ipSettingsSpinner.setSelection(DHCP);
mController = new TestWifiConfigController(mConfigUiBase, mView, mAccessPoint,
assertThat(password.isFocused()).isTrue();
}
+ @Test
+ public void hiddenWarning_warningVisibilityProperlyUpdated() {
+ View warningView = mView.findViewById(R.id.hidden_settings_warning);
+ mController.onItemSelected(mHiddenSettingsSpinner, null, mController.HIDDEN_NETWORK, 0);
+ assertThat(warningView.getVisibility()).isEqualTo(View.VISIBLE);
+
+ mController.onItemSelected(mHiddenSettingsSpinner, null, mController.NOT_HIDDEN_NETWORK, 0);
+ assertThat(warningView.getVisibility()).isEqualTo(View.GONE);
+ }
+
public class TestWifiConfigController extends WifiConfigController {
private TestWifiConfigController(