show an send button instead of the enter key in softkeyboards when enterIsSend and showEnterKey are both set

This commit is contained in:
Daniel Gultsch 2015-09-04 14:48:00 +02:00
parent b265341848
commit 204cee4a17
2 changed files with 10 additions and 7 deletions

View File

@ -969,6 +969,7 @@ public class ConversationActivity extends XmppActivity
} else { } else {
this.mConversationFragment.messageListAdapter.updatePreferences(); this.mConversationFragment.messageListAdapter.updatePreferences();
this.mConversationFragment.messagesView.invalidateViews(); this.mConversationFragment.messagesView.invalidateViews();
this.mConversationFragment.setupIme();
} }
if(!forbidProcessingPendings) { if(!forbidProcessingPendings) {

View File

@ -345,21 +345,24 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
} }
} }
private void setupIme() { public void setupIme() {
if (((ConversationActivity) getActivity()).usingEnterKey()) { if (activity.usingEnterKey() && activity.enterIsSend()) {
mEditMessage.setInputType(mEditMessage.getInputType() & (~InputType.TYPE_TEXT_FLAG_MULTI_LINE));
mEditMessage.setInputType(mEditMessage.getInputType() & (~InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE));
} else if (activity.usingEnterKey()) {
mEditMessage.setInputType(mEditMessage.getInputType() | InputType.TYPE_TEXT_FLAG_MULTI_LINE);
mEditMessage.setInputType(mEditMessage.getInputType() & (~InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE)); mEditMessage.setInputType(mEditMessage.getInputType() & (~InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE));
} else { } else {
mEditMessage.setInputType(mEditMessage.getInputType() | InputType.TYPE_TEXT_FLAG_MULTI_LINE);
mEditMessage.setInputType(mEditMessage.getInputType() | InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE); mEditMessage.setInputType(mEditMessage.getInputType() | InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE);
} }
} }
@Override @Override
public View onCreateView(final LayoutInflater inflater, public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
ViewGroup container, Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.fragment_conversation, container, false); final View view = inflater.inflate(R.layout.fragment_conversation, container, false);
view.setOnClickListener(null); view.setOnClickListener(null);
mEditMessage = (EditMessage) view.findViewById(R.id.textinput); mEditMessage = (EditMessage) view.findViewById(R.id.textinput);
setupIme();
mEditMessage.setOnClickListener(new OnClickListener() { mEditMessage.setOnClickListener(new OnClickListener() {
@Override @Override
@ -639,9 +642,8 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
if (conversation == null) { if (conversation == null) {
return; return;
} }
this.activity = (ConversationActivity) getActivity(); this.activity = (ConversationActivity) getActivity();
setupIme();
if (this.conversation != null) { if (this.conversation != null) {
final String msg = mEditMessage.getText().toString(); final String msg = mEditMessage.getText().toString();
this.conversation.setNextMessage(msg); this.conversation.setNextMessage(msg);