Skip to content

Commit

Permalink
Merge pull request #10 from ChaosLeong/develop
Browse files Browse the repository at this point in the history
1.3.0
  • Loading branch information
ChaosLeung authored Jan 28, 2018
2 parents 55589f5 + 4b33e6d commit 0ffd37d
Show file tree
Hide file tree
Showing 12 changed files with 358 additions and 200 deletions.
41 changes: 32 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# PinView

Provides a widget for enter PIN/OTP/password etc.
Provides a widget for enter PIN/OTP/password etc on Android 4.1+ (API 16).

<p><img src="screenshots/styles.png" width="35%" />
<img src="screenshots/input.gif" width="35%" /></p>
Expand All @@ -15,7 +15,7 @@ repositories {
}
dependencies {
compile 'com.chaos.view:pinview:1.2.0'
compile 'com.chaos.view:pinview:1.3.0'
}
```

Expand All @@ -38,6 +38,9 @@ Add PinView in your layout.
android:padding="@dimen/common_padding"
android:textColor="@color/text_colors"
android:textSize="18sp"
android:cursorVisible="true"
app:cursorColor="@color/line_selected"
app:cursorWidth="2dp"
app:itemCount="5"
app:itemHeight="48dp"
app:itemRadius="4dp"
Expand All @@ -55,18 +58,22 @@ PinView pinView = (PinView) findViewById(R.id.secondPinView);
pinView.setTextColor(
ResourcesCompat.getColor(getResources(), R.color.colorAccent, getTheme()));
pinView.setTextColor(
ResourcesCompat.getColorStateList(getResources(), R.color.line_colors, getTheme()));
ResourcesCompat.getColorStateList(getResources(), R.color.text_colors, getTheme()));
pinView.setLineColor(
ResourcesCompat.getColor(getResources(), R.color.colorPrimary, getTheme()));
pinView.setLineColor(
ResourcesCompat.getColorStateList(getResources(), R.color.text_colors, getTheme()));
ResourcesCompat.getColorStateList(getResources(), R.color.line_colors, getTheme()));
pinView.setItemCount(4);
pinView.setItemHeight(getResources().getDimensionPixelSize(R.dimen.pv_pin_view_item_size));
pinView.setItemWidth(getResources().getDimensionPixelSize(R.dimen.pv_pin_view_item_size));
pinView.setItemRadius(getResources().getDimensionPixelSize(R.dimen.pv_pin_view_item_radius));
pinView.setItemSpacing(getResources().getDimensionPixelSize(R.dimen.pv_pin_view_item_spacing));
pinView.setLineWidth(getResources().getDimensionPixelSize(R.dimen.pv_pin_view_item_line_width));
pinView.setAnimationEnable(true);// start animation when adding text
pinView.setCursorVisible(false);
pinView.setCursorColor(
ResourcesCompat.getColor(getResources(), R.color.line_selected, getTheme()));
pinView.setCursorWidth(getResources().getDimensionPixelSize(R.dimen.pv_pin_view_cursor_width));
```

### Step 2:
Expand All @@ -90,18 +97,34 @@ or use the `PinWidget.PinView` style.
style="@style/PinWidget.PinView" />
```

### Step 3 (Optional):

To highlight current item,

add `android:state_selected="true"` to `app:lineColor`

``` xml
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Use for the item to be input, set the value as the default to disable it -->
<item android:color="@color/line_selected" android:state_selected="true" />
<item android:color="@color/line_focused" android:state_focused="true" />
<item android:color="@color/line_default" />
</selector>
```

or add `android:cursorVisible="true"`.

## Attributes

* **itemSize**, @deprecated use itemWidth or itemHeight instead.
* **borderWidth**, @deprecated use lineWidth instead.
* **borderColor**, @deprecated use lineColor instead.
* **itemCount**, the length of your pin code.
* **itemWidth**, the width of each item.
* **itemHeight**, the height of each item.
* **itemSpacing**, the spacing between two items.
* **lineWidth**, the line(border) width.
* **lineColor**, the line(border) colors.
* **lineWidth**, the line (border) width.
* **lineColor**, the line (border) colors.
* **viewType**, the view type of PinView, currently this will be one of `rectangle` or `line`.
* **cursorColor**, the cursor color.
* **cursorWidth**, the width of cursor.

## Thanks

Expand Down
11 changes: 5 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Expand All @@ -16,9 +17,7 @@ buildscript {
allprojects {
repositories {
jcenter()
maven {
url 'https://maven.google.com'
}
google()
}
}

Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sat Apr 01 18:57:08 CST 2017
#Fri Oct 27 10:32:58 CST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
12 changes: 6 additions & 6 deletions pinview/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
compileSdkVersion 27
buildToolsVersion "27.0.3"

defaultConfig {
minSdkVersion 14
targetSdkVersion 26
minSdkVersion 16
targetSdkVersion 27
versionCode 0
versionName ""

Expand All @@ -39,10 +39,10 @@ android {

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
androidTestCompile('com.android.support.test.espresso:espresso-core:3.0.1', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.0.0'
compile 'com.android.support:appcompat-v7:27.0.2'
testCompile 'junit:junit:4.12'
}

Expand Down
Loading

0 comments on commit 0ffd37d

Please sign in to comment.