Skip to content

Commit

Permalink
Update Reademe 5
Browse files Browse the repository at this point in the history
  • Loading branch information
Droidhelios committed Mar 22, 2022
1 parent 306ebcd commit 97a0d85
Showing 1 changed file with 35 additions and 21 deletions.
56 changes: 35 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,27 +83,41 @@ dependencies {
### Activity class setup
```java
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_sample1)

val errorButton = findViewById<Button>(R.id.button)
val successButton = findViewById<Button>(R.id.button2)
val otpTextView = findViewById(R.id.otp_view) as OTPTextView
otpTextView.requestFocusOTP()
otpTextView.otpListener = object : OTPListener {
override fun onInteractionListener() {

}

override fun onOTPComplete(otp: String) {
Toast.makeText(this@SampleActivity1, "The OTP is $otp", Toast.LENGTH_SHORT).show()
}
}
errorButton.setOnClickListener { otpTextView.showError() }
successButton.setOnClickListener { otpTextView.showSuccess() }
}
}
private lateinit var otpTextView : OTPTextView

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_sample1)

val errorButton = findViewById<Button>(R.id.button)
val successButton = findViewById<Button>(R.id.button2)
otpTextView = findViewById(R.id.otp_view) as OTPTextView
otpTextView.requestFocusOTP()
otpTextView.otpListener = object : OTPListener {
override fun onInteractionListener() {

}

override fun onOTPComplete(otp: String) {
Toast.makeText(this@SampleActivity1, "The OTP is $otp", Toast.LENGTH_SHORT).show()
}
}
errorButton.setOnClickListener { otpTextView.showError() }
successButton.setOnClickListener { otpTextView.showSuccess() }

additionalMethods()
}

fun additionalMethods() {
otpTextView.getOtpListener(); // retrieves the current OTPListener (null if nothing is set)
otpTextView.requestFocusOTP(); //sets the focus to OTP box (does not open the keyboard)
otpTextView.setOTP(otpString); // sets the entered otpString in the Otp box (for case when otp is retrieved from SMS)
otpTextView.getOTP(); // retrieves the OTP entered by user (works for partial otp input too)
otpTextView.showSuccess(); // shows the success state to the user (can be set a bar color or drawable)
otpTextView.showError(); // shows the success state to the user (can be set a bar color or drawable)
otpTextView.resetState(); // brings the views back to default state (the state it was at input)
}
}
```


0 comments on commit 97a0d85

Please sign in to comment.