From: Damyan Ivanov Date: Mon, 11 Nov 2019 06:28:41 +0000 (+0200) Subject: showSoftKeyboard: act only of no hardware keyboard is present and open X-Git-Tag: v0.11.0~78 X-Git-Url: https://git.ktnx.net/?a=commitdiff_plain;h=e0a0823e0084b51cc5252f9f2f230efa956dc097;p=mobile-ledger.git showSoftKeyboard: act only of no hardware keyboard is present and open --- 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 16ad9e2c..8698e0bc 100644 --- a/app/src/main/java/net/ktnx/mobileledger/utils/Misc.java +++ b/app/src/main/java/net/ktnx/mobileledger/utils/Misc.java @@ -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());