Commit 693dea77 authored by Lucio Maciel's avatar Lucio Maciel Committed by GitHub

Merge pull request #435 from filipedelimabrito/iss417

[IMPROVEMENT] Prevents keyboard hiding after typing a message.
parents 0103fdb6 37a4b500
......@@ -20,7 +20,6 @@ import android.support.v7.app.AlertDialog;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import chat.rocket.core.models.User;
import java.lang.reflect.Field;
......@@ -327,7 +326,7 @@ public class RoomFragment extends AbstractChatRoomFragment implements
}
private boolean closeSideMenuIfNeeded() {
DrawerLayout drawerLayout = (DrawerLayout) rootView.findViewById(R.id.drawer_layout);
DrawerLayout drawerLayout = rootView.findViewById(R.id.drawer_layout);
if (drawerLayout != null && drawerLayout.isDrawerOpen(GravityCompat.END)) {
drawerLayout.closeDrawer(GravityCompat.END);
return true;
......@@ -336,12 +335,12 @@ public class RoomFragment extends AbstractChatRoomFragment implements
}
private void setupMessageComposer() {
final MessageFormLayout messageFormLayout = (MessageFormLayout) rootView.findViewById(R.id.messageComposer);
final MessageFormLayout messageFormLayout = rootView.findViewById(R.id.messageComposer);
messageFormManager = new MessageFormManager(messageFormLayout, this::showExtraActionSelectionDialog);
messageFormManager.setSendMessageCallback(this::sendMessage);
messageFormLayout.setEditTextCommitContentListener(this::onCommitContent);
autocompleteManager = new AutocompleteManager((ViewGroup) rootView.findViewById(R.id.messageListRelativeLayout));
autocompleteManager = new AutocompleteManager(rootView.findViewById(R.id.messageListRelativeLayout));
autocompleteManager.registerSource(
new ChannelSource(
......
......@@ -3,14 +3,13 @@ package chat.rocket.android.layouthelper.chatroom;
import chat.rocket.android.widget.message.MessageFormLayout;
/**
* handling MessageForm.
* Handles MessageForm.
*/
public class MessageFormManager {
private final MessageFormLayout messageFormLayout;
private SendMessageCallback sendMessageCallback;
public MessageFormManager(MessageFormLayout messageFormLayout,
MessageFormLayout.ExtraActionSelectionClickListener callback) {
public MessageFormManager(MessageFormLayout messageFormLayout, MessageFormLayout.ExtraActionSelectionClickListener callback) {
this.messageFormLayout = messageFormLayout;
init(callback);
}
......@@ -24,13 +23,8 @@ public class MessageFormManager {
this.sendMessageCallback = sendMessageCallback;
}
public void clearComposingText() {
messageFormLayout.setText("");
}
public void onMessageSend() {
clearComposingText();
messageFormLayout.setEnabled(true);
}
public void setEditMessage(String message) {
......@@ -38,16 +32,18 @@ public class MessageFormManager {
messageFormLayout.setText(message);
}
public void clearComposingText() {
messageFormLayout.setText("");
}
private void sendMessage(String message) {
if (sendMessageCallback == null) {
return;
}
messageFormLayout.setEnabled(false);
sendMessageCallback.onSubmitText(message);
}
public interface SendMessageCallback {
void onSubmitText(String messageText);
}
}
}
\ No newline at end of file
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