Closed slavzilla closed 2 years ago
Oh and by the way, adding focusable in XML didn't help at all.
Oh and by the way, adding focusable in XML didn't help at all.
android:focusableInTouchMode="true" pretty work for me
@waihanko but it doesn't for me. @mukeshsolanki buddy, are you going to fix this? I am sad that I can't help but I need your answer. I rely on your view.
Can you provide me a sample project with the issue the issue is not reproduce-able on my end
Sorry, but I can't. This is the corporate code I am using and it is not open source. This library works very well, it is nice and I grew to love it but it simply doesn't function as it should. I don't know how to help you but if I can I would be glad to try. I just need this working as I am going to spend hours and hours making it myself.
What actually works for me is this. I call show keyboard function
fun Context.showKeyboard(
view: View?
) {
val imm =
this.getSystemService(Activity.INPUT_METHOD_SERVICE) as InputMethodManager
imm.toggleSoftInputFromWindow(view?.windowToken, 0, 0)
view?.clearFocus()
}
And then just after that, I do:
otpView.requestFocus()
And it works!
The other good thing to do is this:
KeyboardVisibilityEvent.setEventListener(
requireActivity(),
viewLifecycleOwner,
object : KeyboardVisibilityEventListener {
override fun onVisibilityChanged(isOpen: Boolean) {
isKeyboardVisible = isOpen
}
})
Where this listener is part of the library https://github.com/yshrsmz/KeyboardVisibilityEvent
And then:
otpView.setOnClickListener {
if (!isKeyboardVisible){
context?.showKeyboard(otpView)
otpView.requestFocus()
}
}
And this ensures that keyboard gets shown on click if the keyboard is not already opened :)
this worked for me
added following lines of code in onCodeSent() InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0); binding.otpView.requestFocus();
and in xml set android:focusableInTouchMode="true"
the same for me (Android 10) adding android:focusableInTouchMode="true"
fixes this issue
1. Add this property (android:windowSoftInputMode="stateVisible") into your manifest's activity tag like this:
<activity android:name=".ui.AuthActivity" android:exported="true" android:screenOrientation="portrait" android:windowSoftInputMode="stateVisible" />
2. Add this line into your Activity class when you want to open keyboard:
mBinding.otpView.requestFocus()
That's all you need to do :)
Please try the latest version of the library
Subject of the issue
OtpView is not getting focus. I have been using it in several other projects and it worked properly. I've added style to my AppTheme but it is still not functioning correctly. When I click several times on it, sometimes but not always, it manages to get focus but even then the keyboard does not show. Most of the time it stays dead for good.
Steps to reproduce
I will leave my XML here just so you can see:
Expected behaviour
Tell us what should happen
Actual behaviour
I can say that I've tried changing this
BlurView
toConstraintLayout
and it didn't help. I also tried callingrequestFocus()
it gets focus but the keyboard won't popup.