From e0a0823e0084b51cc5252f9f2f230efa956dc097 Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Mon, 11 Nov 2019 08:28:41 +0200 Subject: [PATCH] showSoftKeyboard: act only of no hardware keyboard is present and open --- app/src/main/java/net/ktnx/mobileledger/utils/Misc.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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()); -- 2.39.5