hide keyboard when stopping ConversationFragment

This commit is contained in:
Daniel Gultsch 2018-03-11 18:14:26 +01:00
parent c1135ad592
commit b2a9c63568
1 changed files with 11 additions and 3 deletions

View File

@ -350,9 +350,8 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
private AtomicBoolean mSendingPgpMessage = new AtomicBoolean(false);
private OnEditorActionListener mEditorActionListener = (v, actionId, event) -> {
if (actionId == EditorInfo.IME_ACTION_SEND) {
InputMethodManager imm = (InputMethodManager) v.getContext()
.getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm.isFullscreenMode()) {
InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm != null && imm.isFullscreenMode()) {
imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
}
sendMessage();
@ -963,6 +962,14 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
}
}
private static void hideSoftKeyboard(final Activity activity) {
InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
View view = activity.getCurrentFocus();
if (view != null && imm != null) {
imm.hideSoftInputFromWindow(view.getWindowToken(),0);
}
}
private void quoteMessage(Message message) {
quoteText(MessageUtils.prepareQuote(message));
}
@ -1720,6 +1727,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
super.onStop();
final Activity activity = getActivity();
if (activity == null || !activity.isChangingConfigurations()) {
hideSoftKeyboard(activity);
messageListAdapter.stopAudioPlayer();
}
if (this.conversation != null) {