[Wi-Fi] Hide SoftKeyboard temporary when user tap the advanced button.

When tapping on the advanced button during configuring a network, some items in the expanded list are covered by IME keyboard, which may cause user to ignore them accidently.

To improve it, hide the IME temporary to let user can see most of them.

Bug: 78441374
Test: Use ShadowInputMethodManager to check if the keyboard is hide or not after tapping on the advance button.
Change-Id: I0677d96febc90c66d1cf6f98555bbb436a654660
This commit is contained in:
govenliu
2019-08-18 16:31:13 +08:00
parent 31c7ac1017
commit c3eab6a9d9
2 changed files with 30 additions and 2 deletions

View File

@@ -35,7 +35,9 @@ import android.security.KeyStore;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.InputMethodManager;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.Spinner;
import android.widget.TextView;
@@ -51,7 +53,9 @@ import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.Shadows;
import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowInputMethodManager;
@RunWith(RobolectricTestRunner.class)
@Config(shadows = ShadowConnectivityManager.class)
@@ -509,4 +513,17 @@ public class WifiConfigControllerTest {
final int selectedItemPosition = eapMethodSpinner.getSelectedItemPosition();
assertThat(eapMethodSpinner.getSelectedItem().toString()).isEqualTo("TLS");
}
@Test
public void checkImeStatus_whenAdvancedToggled_shouldBeHide() {
final InputMethodManager inputMethodManager = mContext
.getSystemService(InputMethodManager.class);
final ShadowInputMethodManager shadowImm = Shadows.shadowOf(inputMethodManager);
final CheckBox advButton = mView.findViewById(R.id.wifi_advanced_togglebox);
inputMethodManager.showSoftInput(null /* view */, 0 /* flags */);
advButton.performClick();
assertThat(shadowImm.isSoftInputVisible()).isFalse();
}
}