Skip to content

Commit

Permalink
Updating to 0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinSchildhorn committed Mar 26, 2021
1 parent 0c46f0b commit 604654b
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ OTPView is meant to be a highly customizable OTP / Pin View for android. It supp

Each type can be customized separately, with the empty item being the default.

The OTPView also supports `android:inputType`, so you can easily set options like numbers/string, allcaps, etc.
The OTPView also supports some android standards such as `android:inputType`, `android:importantForAutofill` and `android:autofillHints` so you can easily set options like numbers/string, allcaps, etc.

## Install

Expand All @@ -25,7 +25,7 @@ allprojects {
}
dependencies {
implementation 'com.github.KevinSchildhorn:OTPView:0.1.9'
implementation 'com.github.KevinSchildhorn:OTPView:0.2.0'
}
```

Expand Down
4 changes: 3 additions & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
android:id="@+id/otp_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textCapCharacters"
android:inputType="textCapCharacters|textNoSuggestions"
android:autofillHints=""
android:importantForAutofill="no"
app:otp_itemCount="6"
app:otp_showCursor="true"
app:otp_textSize="24sp"
Expand Down
4 changes: 2 additions & 2 deletions otpView/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ android {
minSdkVersion 15
targetSdkVersion 29
versionCode 19
versionName "0.1.9"
versionName "0.2.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
Expand All @@ -40,7 +40,7 @@ afterEvaluate {
release(MavenPublication) {
from components.release
groupId = 'com.kevinschildhorn.otpview'
version = '0.1.9'
version = '0.2.0'
}
}
}
Expand Down
9 changes: 9 additions & 0 deletions otpView/src/main/java/com/kevinschildhorn/otpview/OTPView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import android.graphics.Color
import android.graphics.Typeface
import android.graphics.drawable.Drawable
import android.graphics.drawable.GradientDrawable
import android.os.Build
import android.text.method.PasswordTransformationMethod
import android.util.AttributeSet
import android.util.DisplayMetrics
Expand Down Expand Up @@ -58,6 +59,8 @@ class OTPView @JvmOverloads constructor(
private val itemCount:Int
private val showCursor:Boolean
private val inputType:Int
private val importantForAutofillLocal:Int
private val autofillHints:String?
private var itemWidth:Int
private var itemHeight:Int
private val cursorColor:Int
Expand Down Expand Up @@ -107,6 +110,8 @@ class OTPView @JvmOverloads constructor(
itemCount = getInteger(R.styleable.OTPView_otp_itemCount, 1)
showCursor = getBoolean(R.styleable.OTPView_otp_showCursor, false)
inputType = getInteger(R.styleable.OTPView_android_inputType, 0)
importantForAutofillLocal = getInteger(R.styleable.OTPView_android_importantForAutofill, 0)
autofillHints = getString(R.styleable.OTPView_android_autofillHints)
itemWidth = getDimensionPixelSize(R.styleable.OTPView_otp_itemWidth, 44)
itemHeight = getDimensionPixelSize(R.styleable.OTPView_otp_itemHeight, 44)
cursorColor = getColor(R.styleable.OTPView_otp_cursorColor, Color.BLACK)
Expand Down Expand Up @@ -247,6 +252,10 @@ class OTPView @JvmOverloads constructor(

et.isCursorVisible = showCursor
et.inputType = inputType
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
et.importantForAutofill = importantForAutofillLocal
et.setAutofillHints(autofillHints)
}
val params = LayoutParams(
itemWidth,
itemHeight
Expand Down
3 changes: 2 additions & 1 deletion otpView/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
<resources>
<declare-styleable name="OTPView">
<attr name="android:inputType"/>

<attr name="android:importantForAutofill"/>
<attr name="android:autofillHints"/>
<attr name="otp_itemCount" format="integer" />
<attr name="otp_showCursor" format="boolean" />
<attr name="otp_itemWidth" format="dimension" />
Expand Down

0 comments on commit 604654b

Please sign in to comment.