Fix renaming for Bluetooth devices when rotating to landscape
The bug here is that when renaming a Bluetooth device (either the local adapter or a paired device), if you click on the text edit field of the alert dialog and then rotate the screen, the text shown in the soft input will disappear. Also it's a usability problem that you even needed to click in the first place. This CL fixes both problems - now the soft input will be shown immediately when the dialog comes up, and the content doesn't disappear on rotation. Change-Id: Id29d11c834bf98c01b5c1208159537a8fd36a64f Fixes: 72551780 Test: make -j RunSettingsRoboTests
This commit is contained in:
@@ -31,6 +31,7 @@ import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
@@ -89,8 +90,15 @@ abstract class BluetoothNameDialogFragment extends InstrumentedDialogFragment
|
||||
})
|
||||
.setNegativeButton(android.R.string.cancel, null);
|
||||
mAlertDialog = builder.create();
|
||||
mAlertDialog.getWindow().setSoftInputMode(
|
||||
WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
|
||||
mAlertDialog.setOnShowListener(d -> {
|
||||
if (mDeviceNameView != null && mDeviceNameView.requestFocus()) {
|
||||
InputMethodManager imm = (InputMethodManager) getContext().getSystemService(
|
||||
Context.INPUT_METHOD_SERVICE);
|
||||
if (imm != null) {
|
||||
imm.showSoftInput(mDeviceNameView, InputMethodManager.SHOW_IMPLICIT);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return mAlertDialog;
|
||||
}
|
||||
|
Reference in New Issue
Block a user