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:
Antony Sargent
2018-03-20 16:15:44 -07:00
parent baaf1fdfe8
commit 5a1587526b
2 changed files with 88 additions and 2 deletions

View File

@@ -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;
}