diff options
author | Christian Schneppe <christian@pix-art.de> | 2018-04-07 23:33:41 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2018-04-07 23:33:41 +0200 |
commit | 2545982aae8830b652f64c625babbc49d94538e5 (patch) | |
tree | 9af7df4945863825fc4ed8408b0049dc907cb954 /src | |
parent | db59b15ed94eaebe6932d7bc9eaceadf9bc1a4f3 (diff) |
hide keyboard when stopping ConversationFragment
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/ConversationFragment.java | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java index 04cef92b9..97e8bb5f0 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java @@ -398,9 +398,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(); @@ -1225,6 +1224,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)); } @@ -1990,6 +1997,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) { |