Pressing return key when typing a message in the conversation system request the message to be sent.

This commit is contained in:
Pierre 2018-04-25 17:27:19 +02:00
parent d68755f4fe
commit fcf25c8da5
2 changed files with 32 additions and 0 deletions

View File

@ -13,9 +13,11 @@ import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.ArrayMap;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ListView;
@ -246,6 +248,35 @@ public class ConversationFragment extends Fragment
}
});
//Make message input act like send button on enter key press
new_message_content.setOnKeyListener(new View.OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if(event.getAction() == KeyEvent.ACTION_DOWN && keyCode == KeyEvent.KEYCODE_ENTER) {
send_message();
return false;
}
return false;
}
});
/*setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if(event != null){
if(event.getKeyCode() == KeyEvent.KEYCODE_ENTER &&
//actionId == EditorInfo.IME_NULL &&
event.getAction() == KeyEvent.ACTION_DOWN)
send_message();
}
return false;
}
});*/
//Make pick image button lives
pick_image_button.setOnClickListener(new View.OnClickListener() {
@Override

View File

@ -42,6 +42,7 @@
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:inputType="text"
android:hint="@string/fragment_conversation_new_message_placeholder"/>
<ImageButton