]> git.ktnx.net Git - mobile-ledger.git/commitdiff
Misc: add routined for hiding the soft keyboard
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Mon, 25 Nov 2019 22:08:01 +0000 (00:08 +0200)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Mon, 25 Nov 2019 22:08:01 +0000 (00:08 +0200)
app/src/main/java/net/ktnx/mobileledger/utils/Misc.java

index b28900f9320850e7a0ccb88d6a80aa8f8e2f271a..9e0a3fec2cc66ae312103cd65b7b6adcd033a2a1 100644 (file)
@@ -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);
+
+    }
 }