Skip to content

Commit 0ffd37d

Browse files
authored
Merge pull request #10 from ChaosLeong/develop
1.3.0
2 parents 55589f5 + 4b33e6d commit 0ffd37d

File tree

12 files changed

+358
-200
lines changed

12 files changed

+358
-200
lines changed

README.md

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# PinView
22

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

55
<p><img src="screenshots/styles.png" width="35%" />
66
<img src="screenshots/input.gif" width="35%" /></p>
@@ -15,7 +15,7 @@ repositories {
1515
}
1616
1717
dependencies {
18-
compile 'com.chaos.view:pinview:1.2.0'
18+
compile 'com.chaos.view:pinview:1.3.0'
1919
}
2020
```
2121

@@ -38,6 +38,9 @@ Add PinView in your layout.
3838
android:padding="@dimen/common_padding"
3939
android:textColor="@color/text_colors"
4040
android:textSize="18sp"
41+
android:cursorVisible="true"
42+
app:cursorColor="@color/line_selected"
43+
app:cursorWidth="2dp"
4144
app:itemCount="5"
4245
app:itemHeight="48dp"
4346
app:itemRadius="4dp"
@@ -55,18 +58,22 @@ PinView pinView = (PinView) findViewById(R.id.secondPinView);
5558
pinView.setTextColor(
5659
ResourcesCompat.getColor(getResources(), R.color.colorAccent, getTheme()));
5760
pinView.setTextColor(
58-
ResourcesCompat.getColorStateList(getResources(), R.color.line_colors, getTheme()));
61+
ResourcesCompat.getColorStateList(getResources(), R.color.text_colors, getTheme()));
5962
pinView.setLineColor(
6063
ResourcesCompat.getColor(getResources(), R.color.colorPrimary, getTheme()));
6164
pinView.setLineColor(
62-
ResourcesCompat.getColorStateList(getResources(), R.color.text_colors, getTheme()));
65+
ResourcesCompat.getColorStateList(getResources(), R.color.line_colors, getTheme()));
6366
pinView.setItemCount(4);
6467
pinView.setItemHeight(getResources().getDimensionPixelSize(R.dimen.pv_pin_view_item_size));
6568
pinView.setItemWidth(getResources().getDimensionPixelSize(R.dimen.pv_pin_view_item_size));
6669
pinView.setItemRadius(getResources().getDimensionPixelSize(R.dimen.pv_pin_view_item_radius));
6770
pinView.setItemSpacing(getResources().getDimensionPixelSize(R.dimen.pv_pin_view_item_spacing));
6871
pinView.setLineWidth(getResources().getDimensionPixelSize(R.dimen.pv_pin_view_item_line_width));
6972
pinView.setAnimationEnable(true);// start animation when adding text
73+
pinView.setCursorVisible(false);
74+
pinView.setCursorColor(
75+
ResourcesCompat.getColor(getResources(), R.color.line_selected, getTheme()));
76+
pinView.setCursorWidth(getResources().getDimensionPixelSize(R.dimen.pv_pin_view_cursor_width));
7077
```
7178

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

100+
### Step 3 (Optional):
101+
102+
To highlight current item,
103+
104+
add `android:state_selected="true"` to `app:lineColor`
105+
106+
``` xml
107+
<selector xmlns:android="http://schemas.android.com/apk/res/android">
108+
<!-- Use for the item to be input, set the value as the default to disable it -->
109+
<item android:color="@color/line_selected" android:state_selected="true" />
110+
<item android:color="@color/line_focused" android:state_focused="true" />
111+
<item android:color="@color/line_default" />
112+
</selector>
113+
```
114+
115+
or add `android:cursorVisible="true"`.
116+
93117
## Attributes
94118

95-
* **itemSize**, @deprecated use itemWidth or itemHeight instead.
96-
* **borderWidth**, @deprecated use lineWidth instead.
97-
* **borderColor**, @deprecated use lineColor instead.
98119
* **itemCount**, the length of your pin code.
99120
* **itemWidth**, the width of each item.
100121
* **itemHeight**, the height of each item.
101122
* **itemSpacing**, the spacing between two items.
102-
* **lineWidth**, the line(border) width.
103-
* **lineColor**, the line(border) colors.
123+
* **lineWidth**, the line (border) width.
124+
* **lineColor**, the line (border) colors.
104125
* **viewType**, the view type of PinView, currently this will be one of `rectangle` or `line`.
126+
* **cursorColor**, the cursor color.
127+
* **cursorWidth**, the width of cursor.
105128

106129
## Thanks
107130

build.gradle

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
buildscript {
44
repositories {
55
jcenter()
6+
google()
67
}
78
dependencies {
8-
classpath 'com.android.tools.build:gradle:2.3.3'
9-
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
10-
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
9+
classpath 'com.android.tools.build:gradle:3.0.1'
10+
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
11+
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.0'
1112
// NOTE: Do not place your application dependencies here; they belong
1213
// in the individual module build.gradle files
1314
}
@@ -16,9 +17,7 @@ buildscript {
1617
allprojects {
1718
repositories {
1819
jcenter()
19-
maven {
20-
url 'https://maven.google.com'
21-
}
20+
google()
2221
}
2322
}
2423

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Sat Apr 01 18:57:08 CST 2017
1+
#Fri Oct 27 10:32:58 CST 2017
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip

pinview/build.gradle

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717
apply plugin: 'com.android.library'
1818

1919
android {
20-
compileSdkVersion 26
21-
buildToolsVersion "26.0.1"
20+
compileSdkVersion 27
21+
buildToolsVersion "27.0.3"
2222

2323
defaultConfig {
24-
minSdkVersion 14
25-
targetSdkVersion 26
24+
minSdkVersion 16
25+
targetSdkVersion 27
2626
versionCode 0
2727
versionName ""
2828

@@ -39,10 +39,10 @@ android {
3939

4040
dependencies {
4141
compile fileTree(dir: 'libs', include: ['*.jar'])
42-
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
42+
androidTestCompile('com.android.support.test.espresso:espresso-core:3.0.1', {
4343
exclude group: 'com.android.support', module: 'support-annotations'
4444
})
45-
compile 'com.android.support:appcompat-v7:26.0.0'
45+
compile 'com.android.support:appcompat-v7:27.0.2'
4646
testCompile 'junit:junit:4.12'
4747
}
4848

0 commit comments

Comments
 (0)