dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.criminact:OTPView:Tag'
}
<com.noobcode.otpview.OTPView
android:id="@+id/otpView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:textColor="@color/white"
app:borderThickness="2"
app:otpLength="6"
app:otpLayoutColor="@color/teal_200"
app:otpLayoutType="0"
app:spaceBetween="16"
/>
var otpView = findViewById<OTPView>(R.id.otpView)
otpView.setOTPListener(object : OTPView.OTPListener {
override fun onOTPCompleted(otp: String) {
Toast.makeText(this@MainActivity, "OTP Completed", Toast.LENGTH_LONG).show()
//compare the OTP submitted by user to your generated one. Handle success and failure accordingly
if(otp == "123456"){
otpView.showSuccess()
}else{
otpView.showFailure()
}
}
}