Closed Skullper closed 2 years ago
Hi, I am facing the same issue in my app. But the sample given in the repo is working well... Still trying to understand why. Any suggestion apreciated :) Best
same here
I added OTP View Dialog.I want when dialog.open,keyboard open but cann't
Working for me if I add android:focusableInTouchMode="true"
@jonasgsvensson not working for me. Here is my setup:
<style name="OtpWidget.OtpView.TfaPinViewStyle">
<item name="android:cursorVisible">false</item>
<item name="android:fontFamily">@font/roboto_regular</item>
<item name="android:inputType">numberSigned</item>
<item name="android:focusable">true</item>
<item name="android:focusableInTouchMode">true</item>
<item name="android:textColor">@color/text_primary</item>
<item name="android:textSize">40sp</item>
<item name="android:importantForAutofill" tools:targetApi="o">no</item>
<item name="lineColor">@color/text_primary</item>
<item name="lineWidth">@dimen/divider_height</item>
<item name="itemCount">6</item>
<item name="itemHeight">100dp</item>
<item name="itemRadius">12dp</item>
<item name="itemSpacing">0dp</item>
<item name="viewType">rectangle</item>
</style>
NOBODY HELP
I added android:focusableInTouchMode="true"
and it worked for me too
not work for me
not working for me either
i got same issue. I cannot focus even through touch on view
tried all solutions. Not working either.
someone can solved
I resolved using
Handler().postDelayed({
otpView.dispatchTouchEvent(MotionEvent.obtain(uptimeMillis(), uptimeMillis(), MotionEvent.ACTION_DOWN, 0f, 0f, 0))
otpView.dispatchTouchEvent(MotionEvent.obtain(uptimeMillis(), uptimeMillis(), MotionEvent.ACTION_UP, 0f, 0f, 0))
}, 200)
@Nikunj2505 I dunno why and how but it works)
But I suppose it is still an issue
Just add this line to your OtpView in xml code:
style="@style/OtpWidget.OtpView"
I know it is weird.
@techwizard1 Nope, not working for my case :(
@Nikunj2505 thanks you so much, that works for me
Can anyone send me a working example of this one?? I'll try to fix the issue if I have an example to work with
@mukeshsolanki Hi, here is my xml:
<com.mukesh.OtpView
android:id="@+id/pin_view_confirm"
style="@style/OtpWidget.OtpView.TfaPinViewStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/view_margin_12dp"/>
This is style which I'm using:
<style name="OtpWidget.OtpView.TfaPinViewStyle">
<item name="android:cursorVisible">false</item>
<item name="android:fontFamily">@font/roboto_regular</item>
<item name="android:inputType">numberSigned</item>
<item name="android:focusable">true</item>
<item name="android:focusableInTouchMode">true</item>
<item name="android:textColor">@color/text_primary</item>
<item name="android:textSize">40sp</item>
<item name="android:importantForAutofill" tools:targetApi="o">no</item>
<item name="lineColor">@color/text_primary</item>
<item name="lineWidth">@dimen/divider_height</item>
<item name="itemCount">6</item>
<item name="itemHeight">100dp</item>
<item name="itemRadius">12dp</item>
<item name="itemSpacing">0dp</item>
<item name="viewType">rectangle</item>
</style>
And code:
pin_view_confirm?.apply {
hint = "0".repeat(PIN_CODE_SIZE)
updateItemWidth(PIN_CODE_SIZE)
setOnDoneActionListener {
sendPin(email, pass)
true
}
textWatcher = InputTextTextWatcher {
this.setLineColor(ContextCompat.getColor(this@TfaActivity, R.color.text_primary))
}
addTextChangedListener(textWatcher)
}
Hope it helps to reproduce.
Have you tried adding <item name="otpViewStyle">@style/OtpWidget.OtpView</item>
inside your apptheme??
@Nikunj2505 He is my Hero.
@mukeshsolanki Yes. It is overridden in my app theme. But I have overridden @style/OtpWidget.OtpView
, not my custom one. I will try with my custom and comment here
@mukeshsolanki Nope :( I added my custom style(attached above) into app theme:
<item name="otpViewStyle">@style/OtpWidget.OtpView.TfaPinViewStyle</item>
And requested focus for otpView during initialization, but it didn't help. As I understand you cannot reproduce this bug, yes?
Yes I'm unable to reproduce this issue could you send a sample app?
@Skullper any update?
@mukeshsolanki Sorry, I was busy at work. Yeah, I will send you sample in a few days. Thanks
OtpView by default uses otpViewStyle
attribute which have to be defined in theme. It overrides editTextStyle
attribute from AppCompatEditText
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 :)
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 :)
Interesting but how it should help?
And what if I don't want to make my activity exported or my screenOrientation
is not locked for portrait?
Maybe the key is android:windowSoftInputMode="stateVisible"
?
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 :)Interesting but how it should help? And what if I don't want to make my activity exported or my
screenOrientation
is not locked for portrait?Maybe the key is
android:windowSoftInputMode="stateVisible"
?
Yes.
Please check the latest version of the lib
Subject of the issue
None of the existing methods for requesting focus not working, even perform click didn't help
Steps to reproduce
Open screen with otpView and try to request focus and show digit keyboard
Expected behaviour
The screen opens with digit keyboard(set in xml) and otpView has focused
Actual behaviour
The screen opens without keyboard and request focus not working