-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1 parent
f17db74
commit ee7df0e
Showing
3 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
# OTP-view | ||
|
||
#### Library size is : Kb | ||
|
||
## Setup Project | ||
|
||
Add this to your project build.gradle | ||
``` gradle | ||
allprojects { | ||
repositories { | ||
maven { | ||
url "https://jitpack.io" | ||
} | ||
} | ||
} | ||
``` | ||
|
||
Add this to your project build.gradle | ||
|
||
#### Dependency | ||
[](https://jitpack.io/#appsfeature/otp-view) | ||
```gradle | ||
dependencies { | ||
implementation 'com.github.appsfeature:otp-view:1.0' | ||
} | ||
``` | ||
|
||
|
||
### Statistics Usage methods | ||
|
||
### 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() } | ||
} | ||
} | ||
``` | ||
|
||
### OTP Box implementation changes in layout.xml file | ||
```xml | ||
<com.otpview.OTPTextView | ||
android:id="@+id/otp_view" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:textColor="#ffffff" | ||
app:otp_box_background="@drawable/bg_otp_box" | ||
app:otp_box_background_active="@drawable/bg_otp_box_active" | ||
app:otp_box_background_inactive="@drawable/bg_otp_box_inactive" | ||
app:otp_box_background_error="@drawable/bg_otp_box_error" | ||
app:otp_box_background_success="@drawable/bg_otp_box_success" | ||
app:box_margin="0dp" | ||
app:height="40dp" | ||
app:hide_otp="false" | ||
app:length="6" | ||
app:otp="" | ||
app:otp_text_size="20dp" | ||
app:width="40dp" /> | ||
``` | ||
|
||
### Dash implementation changes in layout.xml file | ||
```xml | ||
<com.otpview.OTPTextView | ||
android:id="@+id/otp_view" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:textColor="#ffffff" | ||
app:bar_active_color="@color/white" | ||
app:bar_enabled="true" | ||
app:bar_error_color="@color/red" | ||
app:bar_height="1.5dp" | ||
app:bar_inactive_color="#606060" | ||
app:bar_margin_bottom="0dp" | ||
app:bar_margin_left="2dp" | ||
app:bar_margin_right="2dp" | ||
app:bar_success_color="#33cc33" | ||
app:box_margin="0dp" | ||
app:height="40dp" | ||
app:hide_otp="true" | ||
app:length="6" | ||
app:otp="" | ||
app:otp_text_size="20dp" | ||
app:width="40dp" /> | ||
``` |