]> git.ktnx.net Git - mobile-ledger-staging.git/blobdiff - app/src/main/java/net/ktnx/mobileledger/utils/Misc.java
showSoftKeyboard: show also when the present keyboard has no keys (e.g. there is...
[mobile-ledger-staging.git] / app / src / main / java / net / ktnx / mobileledger / utils / Misc.java
index 3fae49f1665a6e28bd583a67d5564e351b9878b7..bbfa828baa449467bbfe53b71cf05badc97aa93d 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,13 +29,14 @@ 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.keyboard == Configuration.KEYBOARD_NOKEYS ||
+            cf.keyboardHidden == Configuration.KEYBOARDHIDDEN_YES)
+            activity.getWindow()
+                    .setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
     }
     public static void showSoftKeyboard(Fragment fragment) {
-        // make the keyboard appear
-        fragment.getActivity()
-                .getWindow()
-                .setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
+        showSoftKeyboard(fragment.getActivity());
     }
 }