]> git.ktnx.net Git - mobile-ledger.git/commitdiff
showSoftKeyboard: act only of no hardware keyboard is present and open
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Mon, 11 Nov 2019 06:28:41 +0000 (08:28 +0200)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Mon, 11 Nov 2019 06:28:41 +0000 (08:28 +0200)
app/src/main/java/net/ktnx/mobileledger/utils/Misc.java

index 16ad9e2c3c933cc769077031170fce86d899101c..8698e0bc346f58d1763f3c5f658387eeb0102c2e 100644 (file)
@@ -18,6 +18,7 @@
 package net.ktnx.mobileledger.utils;
 
 import android.app.Activity;
+import android.content.res.Configuration;
 import android.view.WindowManager;
 
 import androidx.fragment.app.Fragment;
@@ -28,8 +29,11 @@ public class Misc {
     }
     public static void showSoftKeyboard(Activity activity) {
         // make the keyboard appear
-        activity.getWindow()
-                .setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
+        Configuration cf = activity.getResources()
+                                   .getConfiguration();
+        if (cf.keyboardHidden == Configuration.KEYBOARDHIDDEN_YES)
+            activity.getWindow()
+                    .setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
     }
     public static void showSoftKeyboard(Fragment fragment) {
         showSoftKeyboard(fragment.getActivity());