Request focus in wifi screen in add network and secure wifi

Request focus from parent view in controller. Based on framework
patch, it can be placed in a parent and focus will go to whatever view
is the default focusable in that hierarchy.

Fixes: 68776177
Fixes: 72882629
Test: RunSettingsRobotests and Manual test
Change-Id: I3bcdc4ec814f68079a00e40435f46bdfa53f4425
This commit is contained in:
Yuchen Chang
2018-03-14 17:16:05 +08:00
parent de08983dd2
commit 1bf069f839
3 changed files with 20 additions and 0 deletions

View File

@@ -21,6 +21,7 @@
android:scrollIndicators="top|bottom">
<LinearLayout
android:id="@+id/l_wifidialog"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"

View File

@@ -363,6 +363,9 @@ public class WifiConfigController implements TextWatcher,
if (mConfigUi.getSubmitButton() != null) {
enableSubmitIfAppropriate();
}
// After done view show and hide, request focus from parent view
mView.findViewById(R.id.l_wifidialog).requestFocus();
}
@VisibleForTesting

View File

@@ -230,6 +230,22 @@ public class WifiConfigControllerTest {
// No Crash
}
@Test
public void ssidGetFocus_addNewNetwork_shouldReturnTrue() {
mController = new TestWifiConfigController(mConfigUiBase, mView, null /* accessPoint */,
WifiConfigUiBase.MODE_CONNECT);
final TextView ssid = mView.findViewById(R.id.ssid);
// Verify ssid text get focus when add new network (accesspoint is null)
assertThat(ssid.isFocused()).isTrue();
}
@Test
public void passwordGetFocus_connectSecureWifi_shouldReturnTrue() {
final TextView password = mView.findViewById(R.id.password);
// Verify password get focus when connect to secure wifi without eap type
assertThat(password.isFocused()).isTrue();
}
public class TestWifiConfigController extends WifiConfigController {
private TestWifiConfigController(