From 794e2cb87241445a6fbb8c357e9c343f038b8b60 Mon Sep 17 00:00:00 2001 From: zaprice Date: Sun, 16 Oct 2016 21:09:44 -0400 Subject: [PATCH] Do not disable multiline input when enter key sends Fixes #5264 Closes #5783 --- .../securesms/components/ComposeText.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/org/thoughtcrime/securesms/components/ComposeText.java b/src/org/thoughtcrime/securesms/components/ComposeText.java index 4ef7db5412..df96e179e1 100644 --- a/src/org/thoughtcrime/securesms/components/ComposeText.java +++ b/src/org/thoughtcrime/securesms/components/ComposeText.java @@ -13,6 +13,7 @@ import android.text.TextUtils.TruncateAt; import android.text.style.RelativeSizeSpan; import android.util.AttributeSet; import android.view.inputmethod.EditorInfo; +import android.view.inputmethod.InputConnection; import org.thoughtcrime.securesms.R; import org.thoughtcrime.securesms.TransportOption; @@ -92,7 +93,6 @@ public class ComposeText extends EmojiEditText { } public void setTransport(TransportOption transport) { - final boolean enterSends = TextSecurePreferences.isEnterSendsEnabled(getContext()); final boolean useSystemEmoji = TextSecurePreferences.isSystemEmojiPreferred(getContext()); int imeOptions = (getImeOptions() & ~EditorInfo.IME_MASK_ACTION) | EditorInfo.IME_ACTION_SEND; @@ -105,14 +105,6 @@ public class ComposeText extends EmojiEditText { inputType = (inputType & ~InputType.TYPE_MASK_VARIATION) | InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE; } - inputType = !isLandscape() && enterSends - ? inputType & ~InputType.TYPE_TEXT_FLAG_MULTI_LINE - : inputType | InputType.TYPE_TEXT_FLAG_MULTI_LINE; - - imeOptions = enterSends - ? imeOptions & ~EditorInfo.IME_FLAG_NO_ENTER_ACTION - : imeOptions | EditorInfo.IME_FLAG_NO_ENTER_ACTION; - setInputType(inputType); setImeOptions(imeOptions); setHint(transport.getComposeHint(), @@ -120,4 +112,13 @@ public class ComposeText extends EmojiEditText { ? getContext().getString(R.string.conversation_activity__from_sim_name, transport.getSimName().get()) : null); } + + @Override + public InputConnection onCreateInputConnection(EditorInfo outAttrs) { + InputConnection conn = super.onCreateInputConnection(outAttrs); + if(TextSecurePreferences.isEnterSendsEnabled(getContext())) { + outAttrs.imeOptions &= ~EditorInfo.IME_FLAG_NO_ENTER_ACTION; + } + return conn; + } }