package chat.rocket.android.layouthelper.chatroom;

import chat.rocket.android.widget.message.MessageFormLayout;

/**
 * handling MessageForm.
 */
public class MessageFormManager {
  private final MessageFormLayout messageFormLayout;
  private SendMessageCallback sendMessageCallback;

  public MessageFormManager(MessageFormLayout messageFormLayout,
                            MessageFormLayout.ExtraActionSelectionClickListener callback) {
    this.messageFormLayout = messageFormLayout;
    init(callback);
  }

  private void init(MessageFormLayout.ExtraActionSelectionClickListener listener) {
    messageFormLayout.setExtraActionSelectionClickListener(listener);
    messageFormLayout.setSubmitTextListener(this::sendMessage);
  }

  public void setSendMessageCallback(SendMessageCallback sendMessageCallback) {
    this.sendMessageCallback = sendMessageCallback;
  }

  public void clearComposingText() {
    messageFormLayout.setText("");
  }

  public void onMessageSend() {
    clearComposingText();
    messageFormLayout.setEnabled(true);
  }

  public void setEditMessage(String message) {
    clearComposingText();
    messageFormLayout.setText(message);
  }

  private void sendMessage(String message) {
    if (sendMessageCallback == null) {
      return;
    }

    messageFormLayout.setEnabled(false);
    sendMessageCallback.onSubmitText(message);
  }

  public interface SendMessageCallback {
    void onSubmitText(String messageText);
  }
}

@@ -118,16 +118,15 @@
 %0A * 
-h
+H
 andl
-ing
+es
  Mes
@@ -346,36 +346,8 @@
 out,
-%0A                           
  Mes
@@ -844,85 +844,8 @@
  %7D%0A%0A
-  public void clearComposingText() %7B%0A    messageFormLayout.setText(%22%22);%0A  %7D%0A%0A
   pu
@@ -902,48 +902,8 @@
 ();%0A
-    messageFormLayout.setEnabled(true);%0A
   %7D%0A
@@ -1013,32 +1013,109 @@
 (message);%0A  %7D%0A%0A
+  public void clearComposingText() %7B%0A    messageFormLayout.setText(%22%22);%0A  %7D%0A%0A
   private void s
@@ -1205,50 +1205,8 @@
    %7D
-%0A%0A    messageFormLayout.setEnabled(false);
 %0A   
@@ -1342,10 +1342,9 @@
 t);%0A  %7D%0A
+
 %7D
-%0A

Update MessageFormManager.java