Commit fafaf8b3 authored by Leonardo Aramaki's avatar Leonardo Aramaki Committed by GitHub

Merge pull request #500 from HarveyDoom/develop

[NEW] Display Keyboard when launching dialog
parents 38b8792c caac8e2f
...@@ -6,6 +6,7 @@ import android.support.annotation.LayoutRes; ...@@ -6,6 +6,7 @@ import android.support.annotation.LayoutRes;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.view.View; import android.view.View;
import android.view.WindowManager;
import android.widget.Toast; import android.widget.Toast;
import com.trello.rxlifecycle2.components.support.RxAppCompatDialogFragment; import com.trello.rxlifecycle2.components.support.RxAppCompatDialogFragment;
...@@ -41,6 +42,12 @@ public abstract class AbstractAddRoomDialogFragment extends RxAppCompatDialogFra ...@@ -41,6 +42,12 @@ public abstract class AbstractAddRoomDialogFragment extends RxAppCompatDialogFra
realmHelper = RealmStore.get(hostname); realmHelper = RealmStore.get(hostname);
methodCall = new MethodCallHelper(getContext(), hostname); methodCall = new MethodCallHelper(getContext(), hostname);
} }
protected void requestFocus(View view) {
if (view.requestFocus()) {
getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
}
}
@Override @Override
public final void setupDialog(Dialog dialog, int style) { public final void setupDialog(Dialog dialog, int style) {
......
...@@ -2,6 +2,7 @@ package chat.rocket.android.fragment.sidebar.dialog; ...@@ -2,6 +2,7 @@ package chat.rocket.android.fragment.sidebar.dialog;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.os.Bundle; import android.os.Bundle;
import android.support.design.widget.TextInputEditText;
import android.view.View; import android.view.View;
import android.widget.CompoundButton; import android.widget.CompoundButton;
import android.widget.TextView; import android.widget.TextView;
...@@ -39,8 +40,9 @@ public class AddChannelDialogFragment extends AbstractAddRoomDialogFragment { ...@@ -39,8 +40,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 +51,9 @@ public class AddChannelDialogFragment extends AbstractAddRoomDialogFragment { ...@@ -49,8 +51,9 @@ public class AddChannelDialogFragment extends AbstractAddRoomDialogFragment {
); );
buttonAddChannel.setOnClickListener(view -> createRoom()); buttonAddChannel.setOnClickListener(view -> createRoom());
requestFocus(channelNameText);
} }
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();
......
...@@ -80,6 +80,7 @@ public class AddDirectMessageDialogFragment extends AbstractAddRoomDialogFragmen ...@@ -80,6 +80,7 @@ public class AddDirectMessageDialogFragment extends AbstractAddRoomDialogFragmen
); );
buttonAddDirectMessage.setOnClickListener(view -> createRoom()); buttonAddDirectMessage.setOnClickListener(view -> createRoom());
requestFocus(autoCompleteTextView);
} }
private void setupView(Optional<RocketChatAbsoluteUrl> rocketChatAbsoluteUrlOptional) { private void setupView(Optional<RocketChatAbsoluteUrl> rocketChatAbsoluteUrlOptional) {
......
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