mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-18 05:39:53 +01:00
[android] add SendAction to EmojiTextInputView
This commit is contained in:
@@ -26,6 +26,7 @@ import javax.inject.Inject;
|
|||||||
import static android.content.Context.INPUT_METHOD_SERVICE;
|
import static android.content.Context.INPUT_METHOD_SERVICE;
|
||||||
import static android.content.Context.LAYOUT_INFLATER_SERVICE;
|
import static android.content.Context.LAYOUT_INFLATER_SERVICE;
|
||||||
import static android.view.KeyEvent.KEYCODE_ENTER;
|
import static android.view.KeyEvent.KEYCODE_ENTER;
|
||||||
|
import static android.view.inputmethod.EditorInfo.IME_ACTION_SEND;
|
||||||
import static android.view.inputmethod.InputMethodManager.SHOW_IMPLICIT;
|
import static android.view.inputmethod.InputMethodManager.SHOW_IMPLICIT;
|
||||||
import static java.util.Objects.requireNonNull;
|
import static java.util.Objects.requireNonNull;
|
||||||
import static org.briarproject.bramble.util.StringUtils.utf8IsTooLong;
|
import static org.briarproject.bramble.util.StringUtils.utf8IsTooLong;
|
||||||
@@ -80,7 +81,15 @@ public class EmojiTextInputView extends KeyboardAwareLinearLayout implements
|
|||||||
if (maxLines > 0) editText.setMaxLines(maxLines);
|
if (maxLines > 0) editText.setMaxLines(maxLines);
|
||||||
editText.setOnClickListener(v -> showSoftKeyboard());
|
editText.setOnClickListener(v -> showSoftKeyboard());
|
||||||
editText.addTextChangedListener(this);
|
editText.addTextChangedListener(this);
|
||||||
// support sending with Ctrl+Enter
|
editText.setOnEditorActionListener((v, actionId, event) -> {
|
||||||
|
if (actionId == IME_ACTION_SEND) {
|
||||||
|
listener.onSendEvent();
|
||||||
|
hideSoftKeyboard();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
// also support sending with Ctrl+Enter
|
||||||
editText.setOnKeyListener((v, keyCode, event) -> {
|
editText.setOnKeyListener((v, keyCode, event) -> {
|
||||||
if (listener != null && keyCode == KEYCODE_ENTER &&
|
if (listener != null && keyCode == KEYCODE_ENTER &&
|
||||||
event.isCtrlPressed()) {
|
event.isCtrlPressed()) {
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="bottom"
|
android:layout_gravity="bottom"
|
||||||
android:background="@android:color/transparent"
|
android:background="@android:color/transparent"
|
||||||
|
android:imeOptions="actionSend"
|
||||||
android:inputType="textMultiLine|textCapSentences|textAutoCorrect"
|
android:inputType="textMultiLine|textCapSentences|textAutoCorrect"
|
||||||
android:minHeight="@dimen/text_input_height"
|
android:minHeight="@dimen/text_input_height"
|
||||||
android:textColor="?android:attr/textColorPrimary"
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
|
|||||||
Reference in New Issue
Block a user