From: Damyan Ivanov Date: Mon, 25 Nov 2019 22:08:01 +0000 (+0200) Subject: Misc: add routined for hiding the soft keyboard X-Git-Tag: v0.11.0~24 X-Git-Url: https://git.ktnx.net/?a=commitdiff_plain;h=0b6ae8f4d7241ce917da5308721cc36303964af4;p=mobile-ledger.git Misc: add routined for hiding the soft keyboard --- diff --git a/app/src/main/java/net/ktnx/mobileledger/utils/Misc.java b/app/src/main/java/net/ktnx/mobileledger/utils/Misc.java index b28900f9..9e0a3fec 100644 --- a/app/src/main/java/net/ktnx/mobileledger/utils/Misc.java +++ b/app/src/main/java/net/ktnx/mobileledger/utils/Misc.java @@ -42,4 +42,18 @@ public class Misc { if (activity != null) showSoftKeyboard(activity); } + public static void hideSoftKeyboard(Fragment fragment) { + final FragmentActivity activity = fragment.getActivity(); + if (activity != null) + hideSoftKeyboard(activity); + } + public static void hideSoftKeyboard(Activity activity) { + Configuration cf = activity.getResources() + .getConfiguration(); + if (cf.keyboard == Configuration.KEYBOARD_NOKEYS || + cf.keyboardHidden == Configuration.KEYBOARDHIDDEN_NO) + activity.getWindow() + .setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); + + } }