diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser
new file mode 100644
index 0000000..f243210
Binary files /dev/null and b/.idea/caches/build_file_checksums.ser differ
diff --git a/.idea/caches/gradle_models.ser b/.idea/caches/gradle_models.ser
new file mode 100644
index 0000000..8cafca8
Binary files /dev/null and b/.idea/caches/gradle_models.ser differ
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
new file mode 100644
index 0000000..15a15b2
--- /dev/null
+++ b/.idea/encodings.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
index 5be0e93..f970f39 100644
--- a/.idea/gradle.xml
+++ b/.idea/gradle.xml
@@ -3,6 +3,9 @@
-
+
diff --git a/.idea/modules.xml b/.idea/modules.xml
index 42cf26c..6297153 100644
--- a/.idea/modules.xml
+++ b/.idea/modules.xml
@@ -2,8 +2,11 @@
+
+
+
diff --git a/build.gradle b/build.gradle
index 68ac0f0..fede1ac 100644
--- a/build.gradle
+++ b/build.gradle
@@ -7,7 +7,7 @@ buildscript {
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:3.0.0'
+ classpath 'com.android.tools.build:gradle:3.4.1'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.2'
// NOTE: Do not place your application dependencies here; they belong
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 23bb66e..d25a67d 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
diff --git a/simple/build.gradle b/simple/build.gradle
index ecb61c1..b50132b 100644
--- a/simple/build.gradle
+++ b/simple/build.gradle
@@ -1,11 +1,11 @@
apply plugin: 'com.android.application'
android {
- compileSdkVersion 26
+ compileSdkVersion 29
defaultConfig {
applicationId "com.jyn.verificationcodeview.simple"
minSdkVersion 15
- targetSdkVersion 26
+ targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
@@ -20,11 +20,8 @@ android {
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
- implementation 'com.android.support:appcompat-v7:26.1.0'
- implementation 'com.android.support.constraint:constraint-layout:1.0.2'
+ implementation 'androidx.appcompat:appcompat:1.0.2'
testImplementation 'junit:junit:4.12'
- androidTestImplementation 'com.android.support.test:runner:1.0.1'
- androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
// compile 'com.jyn.verificationcodeview:verificationcodeview:1.0.0'
implementation project(':verificationcodeview')
}
diff --git a/simple/src/main/java/com/jyn/vcview/simple/MainActivity.java b/simple/src/main/java/com/jyn/vcview/simple/MainActivity.java
index b41f8e7..c85fdeb 100644
--- a/simple/src/main/java/com/jyn/vcview/simple/MainActivity.java
+++ b/simple/src/main/java/com/jyn/vcview/simple/MainActivity.java
@@ -1,20 +1,23 @@
package com.jyn.vcview.simple;
-import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
+import android.view.View;
import android.widget.TextView;
+import androidx.appcompat.app.AppCompatActivity;
+
import com.jyn.vcview.VerificationCodeView;
public class MainActivity extends AppCompatActivity {
private TextView textView;
+ private VerificationCodeView verificationcodeview;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
- VerificationCodeView verificationcodeview = findViewById(R.id.verificationcodeview);
+ verificationcodeview = findViewById(R.id.verificationcodeview);
textView = findViewById(R.id.text);
verificationcodeview.setOnCodeFinishListener(new VerificationCodeView.OnCodeFinishListener() {
@Override
@@ -23,4 +26,8 @@ public class MainActivity extends AppCompatActivity {
}
});
}
+
+ public void clear(View view) {
+ verificationcodeview.setEmpty();
+ }
}
diff --git a/simple/src/main/res/layout/activity_main.xml b/simple/src/main/res/layout/activity_main.xml
index d27057b..4dd6101 100644
--- a/simple/src/main/res/layout/activity_main.xml
+++ b/simple/src/main/res/layout/activity_main.xml
@@ -27,5 +27,14 @@
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="20dp"
+ android:text="验证码"
android:textSize="20sp" />
+
+
diff --git a/verificationcodeview/build.gradle b/verificationcodeview/build.gradle
index 50e0f22..f8b4dba 100644
--- a/verificationcodeview/build.gradle
+++ b/verificationcodeview/build.gradle
@@ -1,11 +1,11 @@
apply plugin: 'com.android.library'
android {
- compileSdkVersion 26
+ compileSdkVersion 29
defaultConfig {
minSdkVersion 15
- targetSdkVersion 26
+ targetSdkVersion 29
versionCode 1
versionName "1.0"
@@ -25,10 +25,8 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
- implementation 'com.android.support:appcompat-v7:26.1.0'
+ implementation 'androidx.appcompat:appcompat:1.0.2'
testImplementation 'junit:junit:4.12'
- androidTestImplementation 'com.android.support.test:runner:1.0.1'
- androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
apply plugin: 'com.github.dcendents.android-maven'
diff --git a/verificationcodeview/src/main/java/com/jyn/vcview/VerificationCodeView.java b/verificationcodeview/src/main/java/com/jyn/vcview/VerificationCodeView.java
index c601ffd..9de91e0 100644
--- a/verificationcodeview/src/main/java/com/jyn/vcview/VerificationCodeView.java
+++ b/verificationcodeview/src/main/java/com/jyn/vcview/VerificationCodeView.java
@@ -20,9 +20,9 @@ import java.lang.reflect.Field;
/**
* jiaoyaning
- * com.b2cf.nonghe.widget
* VerificationCodeView
* 2017/10/31
+ * update 2019/8/8
*/
public class VerificationCodeView extends LinearLayout implements TextWatcher, View.OnKeyListener, View.OnFocusChangeListener {
@@ -313,4 +313,19 @@ public class VerificationCodeView extends LinearLayout implements TextWatcher, V
public interface OnCodeFinishListener {
void onComplete(String content);
}
+
+ /**
+ * 清空验证码输入框
+ */
+ public void setEmpty() {
+ EditText editText;
+ for (int i = mEtNumber - 1; i >= 0; i--) {
+ editText = (EditText) getChildAt(i);
+ editText.setText("");
+ if (i == 0) {
+ editText.setCursorVisible(true);
+ editText.requestFocus();
+ }
+ }
+ }
}