diff options
author | 2022-10-04 22:13:11 +0000 | |
---|---|---|
committer | 2022-10-07 23:52:57 +0000 | |
commit | d8d6d1f0bf9f690a143818c2e278752e43a05726 (patch) | |
tree | e39e11a323708b60ddd42a9a4a8fa9fdeab45f1c /WifiDialog/src | |
parent | 6149291a7caa7ce53788da9625b546a6bef8de07 (diff) |
Do not auto-open keyboard on P2P pin in landscape
The P2P invitation dialog auto-opens the keyboard on the pin input, but
landscape mode on phones is not big enough to display both the P2P
dialog and the keyboard at same time. Thus we shouldn't auto-open the
keyboard in landscape mode for less-than-large sized screens (tablets),
and instead have the user manually tap on the pin field to use the
full-screen landscape mode keyboard.
Bug: 248187548
Test: adb shell cmd wifi launch-dialog-p2p-invitation-received
DeviceName -p, manually verify keyboard does not auto-open in landscape
mode
Change-Id: I5f20db226061e34205a146e4af238356e340d334
Diffstat (limited to 'WifiDialog/src')
-rw-r--r-- | WifiDialog/src/com/android/wifi/dialog/WifiDialogActivity.java | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/WifiDialog/src/com/android/wifi/dialog/WifiDialogActivity.java b/WifiDialog/src/com/android/wifi/dialog/WifiDialogActivity.java index 74f846a0fb..786741c361 100644 --- a/WifiDialog/src/com/android/wifi/dialog/WifiDialogActivity.java +++ b/WifiDialog/src/com/android/wifi/dialog/WifiDialogActivity.java @@ -78,6 +78,8 @@ public class WifiDialogActivity extends Activity { private static final String KEY_DIALOG_INTENTS = "KEY_DIALOG_INTENTS"; private static final String EXTRA_DIALOG_EXPIRATION_TIME_MS = "com.android.wifi.dialog.DIALOG_START_TIME_MS"; + private static final String EXTRA_DIALOG_P2P_PIN_INPUT = + "com.android.wifi.dialog.DIALOG_P2P_PIN_INPUT"; private @NonNull Handler mHandler = new Handler(Looper.getMainLooper()); private @Nullable WifiContext mWifiContext; @@ -670,7 +672,24 @@ public class WifiDialogActivity extends Activity { dialog.getWindow().setSoftInputMode( WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); dialog.setOnShowListener(dialogShow -> { - pinEditText.requestFocus(); + Intent intent = mLaunchIntentsPerId.get(dialogId); + if (intent != null) { + // Populate the pin EditText with the previous user input if we're recreating + // the dialog after a configuration change. + CharSequence previousPin = + intent.getCharSequenceExtra(EXTRA_DIALOG_P2P_PIN_INPUT); + if (previousPin != null) { + pinEditText.setText(previousPin); + } + } + if (getResources().getConfiguration().orientation + == Configuration.ORIENTATION_PORTRAIT + || (getResources().getConfiguration().screenLayout + & Configuration.SCREENLAYOUT_SIZE_MASK) + >= Configuration.SCREENLAYOUT_SIZE_LARGE) { + pinEditText.requestFocus(); + pinEditText.setSelection(pinEditText.getText().length()); + } dialog.getButton(Dialog.BUTTON_POSITIVE).setEnabled(false); }); pinEditText.addTextChangedListener(new TextWatcher() { @@ -686,6 +705,12 @@ public class WifiDialogActivity extends Activity { @Override public void afterTextChanged(Editable s) { + Intent intent = mLaunchIntentsPerId.get(dialogId); + if (intent != null) { + // Store the current input in the Intent in case we need to reload from a + // configuration change. + intent.putExtra(EXTRA_DIALOG_P2P_PIN_INPUT, s); + } if (s.length() == 4 || s.length() == 8) { dialog.getButton(Dialog.BUTTON_POSITIVE).setEnabled(true); } else { |