Commit a3a9c9a2 authored by HarveyDoom's avatar HarveyDoom Committed by GitHub

#331 - Display Keyboard when launching dialog.

First ever pull request.
requestFocus() would not work on its own. Setting the Soft Input Mode gets keyboard to display.
parent 8d985b42
...@@ -39,8 +39,9 @@ public class AddChannelDialogFragment extends AbstractAddRoomDialogFragment { ...@@ -39,8 +39,9 @@ public class AddChannelDialogFragment extends AbstractAddRoomDialogFragment {
@Override @Override
protected void onSetupDialog() { protected void onSetupDialog() {
View buttonAddChannel = getDialog().findViewById(R.id.btn_add_channel); View buttonAddChannel = getDialog().findViewById(R.id.btn_add_channel);
TextInputEditText channelNameText = (TextInputEditText) getDialog().findViewById(R.id.editor_channel_name);
RxTextView.textChanges((TextView) getDialog().findViewById(R.id.editor_channel_name)) RxTextView.textChanges((TextView) channelNameText)
.map(text -> !TextUtils.isEmpty(text)) .map(text -> !TextUtils.isEmpty(text))
.compose(bindToLifecycle()) .compose(bindToLifecycle())
.subscribe( .subscribe(
...@@ -49,8 +50,15 @@ public class AddChannelDialogFragment extends AbstractAddRoomDialogFragment { ...@@ -49,8 +50,15 @@ public class AddChannelDialogFragment extends AbstractAddRoomDialogFragment {
); );
buttonAddChannel.setOnClickListener(view -> createRoom()); buttonAddChannel.setOnClickListener(view -> createRoom());
requestFocus(channelNameText);
} }
private void requestFocus(View view) {
if (view.requestFocus()) {
getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
}
}
private boolean isChecked(int viewId) { private boolean isChecked(int viewId) {
CompoundButton check = (CompoundButton) getDialog().findViewById(viewId); CompoundButton check = (CompoundButton) getDialog().findViewById(viewId);
return check.isChecked(); return check.isChecked();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment