├── .gitignore
├── README.md
├── README_zh.md
├── app
├── .gitignore
├── apk
│ └── NumberCodeViewDemo.apk
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── linkaipeng
│ │ └── numbercodeview
│ │ └── ApplicationTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── linkaipeng
│ │ │ └── example
│ │ │ ├── MainActivity.java
│ │ │ └── NormalNumberCodeViewExampleActivity.java
│ └── res
│ │ ├── drawable
│ │ ├── bg_button.xml
│ │ ├── bg_button_n.xml
│ │ └── bg_button_p.xml
│ │ ├── layout
│ │ ├── activity_main.xml
│ │ └── activity_normal_example.xml
│ │ ├── menu
│ │ └── menu_main.xml
│ │ ├── mipmap-hdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-mdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_avatar.png
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxxhdpi
│ │ └── ic_launcher.png
│ │ ├── values-w820dp
│ │ └── dimens.xml
│ │ └── values
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ └── strings.xml
│ └── test
│ └── java
│ └── com
│ └── linkaipeng
│ └── numbercodeview
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── numbercodeview-lib
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── lkp
│ │ └── numbercodeview
│ │ └── ApplicationTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── lkp
│ │ │ └── numbercodeview
│ │ │ ├── BaseNumberCodeView.java
│ │ │ ├── ExpandGridView.java
│ │ │ ├── bottomsheet
│ │ │ ├── BottomSheetNumberCodeView.java
│ │ │ └── BottomSheetNumberCodeViewActivity.java
│ │ │ └── normal
│ │ │ └── NumberCodeView.java
│ └── res
│ │ ├── anim
│ │ ├── push_bottom_to_top.xml
│ │ └── push_top_to_bottom.xml
│ │ ├── drawable
│ │ ├── bg_gray_back_button.xml
│ │ ├── bg_numbers_layout.xml
│ │ ├── item_border.xml
│ │ ├── item_border_selected.xml
│ │ └── list_selector.xml
│ │ ├── layout
│ │ ├── activity_bottom_sheet_number_code_view.xml
│ │ ├── item_view_input_group_code.xml
│ │ ├── view_bottom_sheet_input_code.xml
│ │ ├── view_input_group_code.xml
│ │ ├── view_number_edit.xml
│ │ └── view_number_input_layout.xml
│ │ ├── mipmap-xhdpi
│ │ ├── ic_back_gray_n.png
│ │ ├── ic_back_gray_p.png
│ │ └── ic_input_code_delete.png
│ │ └── values
│ │ ├── attr.xml
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── lkp
│ └── numbercodeview
│ └── ExampleUnitTest.java
├── screenshots
├── screenshot01.png
├── screenshot02.png
├── screenshot03.png
├── screenshot04.png
└── screenshot05.png
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | .gradle
2 | .idea
3 | /*.iml
4 | /local.properties
5 | /.idea/workspace.xml
6 | /.idea/libraries
7 | .DS_Store
8 | /build
9 | /captures
10 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | #### [中文文档](https://github.com/linkaipeng/NumberCodeView/blob/master/README_zh.md)
2 |
3 | # NumberCodeView
4 | A number input view which like input password in alipay or wechat pay.
5 |
6 | # Usage
7 |
8 | ### Normal Style
9 |
10 | Normal, start to an activity which include the NumberCodeView.
11 |
12 | Add to your '.xml' file.
13 |
14 | ```
15 |
21 | ```
22 |
23 | Use the `numbercodeview:isPassword` attribute.
24 |
25 | ### BottomSheet Style
26 |
27 | Bottom sheet style, an activity with dialog style. Popup from bottom of screen.
28 |
29 | Call Bottom sheet style NumberCodeView with a single line code. Like this:
30 |
31 | ```
32 | BottomSheetNumberCodeViewActivity.show(this, mIsPassword);
33 | ```
34 |
35 | ### `isPassword` Attribute
36 |
37 | If it is password, the number will be replaced with symbol ●
38 |
39 |
40 | # Screenshots
41 |
42 | 
43 | 
44 | 
45 | 
46 | 
47 |
48 | ## LICENSE
49 |
50 | ```
51 | Copyright 2015 linkaipeng
52 |
53 | Licensed under the Apache License, Version 2.0 (the "License");
54 | you may not use this file except in compliance with the License.
55 | You may obtain a copy of the License at
56 |
57 |
58 |
59 | Unless required by applicable law or agreed to in writing, software
60 | distributed under the License is distributed on an "AS IS" BASIS,
61 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
62 | See the License for the specific language governing permissions and
63 | limitations under the License.
64 |
65 | ```
66 |
--------------------------------------------------------------------------------
/README_zh.md:
--------------------------------------------------------------------------------
1 | # NumberCodeView
2 | 一个类似微信支付和支付宝支付的时候输入密码面板的控件。
3 |
4 | # 使用方式
5 |
6 | ### 普通样式
7 |
8 | 正常情况下,你可以把控件的声明写到你的 '.xml' 文件里面。
9 |
10 | ```
11 |
17 | ```
18 |
19 | 可以使用 `numbercodeview:isPassword` 这个属性去控制是否是密码,密码的话会用黑点替代数字。
20 |
21 | ### 底部面板样式
22 |
23 | 使用底部样式,那么久可以从界面的底部弹出来。
24 |
25 | 可以通过以下代码进行调用:
26 |
27 | ```
28 | BottomSheetNumberCodeViewActivity.show(this, mIsPassword);
29 | ```
30 |
31 | ### `isPassword` 属性
32 |
33 | 如果是密码,那么输入框里面的数字将会用 ● 取代。
34 |
35 |
36 | # 截屏
37 |
38 | 
39 | 
40 | 
41 | 
42 | 
43 |
44 | ## LICENSE
45 |
46 | ```
47 | Copyright 2015 linkaipeng
48 |
49 | Licensed under the Apache License, Version 2.0 (the "License");
50 | you may not use this file except in compliance with the License.
51 | You may obtain a copy of the License at
52 |
53 |
54 |
55 | Unless required by applicable law or agreed to in writing, software
56 | distributed under the License is distributed on an "AS IS" BASIS,
57 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
58 | See the License for the specific language governing permissions and
59 | limitations under the License.
60 |
61 | ```
62 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 | /*.iml
3 |
--------------------------------------------------------------------------------
/app/apk/NumberCodeViewDemo.apk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linkaipeng/NumberCodeView/30148ca4d497615d70bee0b244409ab67424be7c/app/apk/NumberCodeViewDemo.apk
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion "23.0.1"
6 |
7 | defaultConfig {
8 | applicationId "com.linkaipeng.numbercodeview"
9 | minSdkVersion 15
10 | targetSdkVersion 23
11 | versionCode 1
12 | versionName "1.0"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | testCompile 'junit:junit:4.12'
25 | compile 'com.android.support:appcompat-v7:23.0.1'
26 | compile 'com.android.support:design:23.0.1'
27 | compile project(':numbercodeview-lib')
28 | }
29 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in D:\Program Files (x86)\android\android-sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/linkaipeng/numbercodeview/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.linkaipeng.numbercodeview;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/app/src/main/java/com/linkaipeng/example/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.linkaipeng.example;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.support.annotation.Nullable;
6 | import android.support.v7.app.AppCompatActivity;
7 | import android.support.v7.widget.Toolbar;
8 | import android.view.View;
9 | import android.widget.Button;
10 | import android.widget.CheckBox;
11 | import android.widget.CompoundButton;
12 | import android.widget.TextView;
13 | import android.widget.Toast;
14 |
15 | import com.linkaipeng.numbercodeview.R;
16 | import com.lkp.numbercodeview.bottomsheet.BottomSheetNumberCodeViewActivity;
17 |
18 | public class MainActivity extends AppCompatActivity implements View.OnClickListener {
19 |
20 | private Button mShowBottomButton;
21 | private Button mShowNormalButton;
22 |
23 | private CheckBox mIsPasswordCheckBox;
24 | private TextView mIsPasswordTextView;
25 |
26 | private boolean mIsPassword = true;
27 |
28 | @Override
29 | protected void onCreate(@Nullable Bundle savedInstanceState) {
30 | super.onCreate(savedInstanceState);
31 | setContentView(R.layout.activity_main);
32 | initView();
33 | }
34 |
35 | private void initView(){
36 | getSupportActionBar();
37 | mIsPasswordCheckBox = (CheckBox) findViewById(R.id.is_password_box);
38 | mIsPasswordTextView = (TextView) findViewById(R.id.is_password_textView);
39 | mShowBottomButton = (Button) findViewById(R.id.show_bottom_button);
40 | mShowNormalButton = (Button) findViewById(R.id.normal_button);
41 | mShowBottomButton.setOnClickListener(this);
42 | mShowNormalButton.setOnClickListener(this);
43 | mIsPasswordCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
44 | @Override
45 | public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
46 | mIsPassword = isChecked;
47 | if (isChecked) {
48 | mIsPasswordTextView.setText("Now it is password.");
49 | } else {
50 | mIsPasswordTextView.setText("Now it is not password.");
51 | }
52 | }
53 | });
54 | }
55 |
56 | @Override
57 | protected void onActivityResult(int requestCode, int resultCode, Intent data) {
58 | if (resultCode == RESULT_OK && requestCode ==
59 | BottomSheetNumberCodeViewActivity.REQUEST_CODE_SHOW_BOTTOM_NUMBER_VIEW) {
60 | String code = data.getStringExtra(BottomSheetNumberCodeViewActivity.KEY_DATA_NUMBER);
61 | Toast.makeText(this, code, Toast.LENGTH_SHORT).show();
62 | }
63 | }
64 |
65 | @Override
66 | public void onClick(View v) {
67 | int viewId = v.getId();
68 | switch (viewId) {
69 | case R.id.show_bottom_button:
70 | BottomSheetNumberCodeViewActivity.show(this, mIsPassword);
71 | break;
72 |
73 | case R.id.normal_button:
74 | NormalNumberCodeViewExampleActivity.start(this, mIsPassword);
75 | break;
76 | default:
77 | break;
78 | }
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/app/src/main/java/com/linkaipeng/example/NormalNumberCodeViewExampleActivity.java:
--------------------------------------------------------------------------------
1 | package com.linkaipeng.example;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.support.v7.app.ActionBar;
7 | import android.support.v7.app.AppCompatActivity;
8 | import android.view.MenuItem;
9 | import android.widget.Toast;
10 |
11 | import com.linkaipeng.numbercodeview.R;
12 | import com.lkp.numbercodeview.normal.NumberCodeView;
13 |
14 | /**
15 | * Created by linkaipeng on 16/8/2.
16 | */
17 | public class NormalNumberCodeViewExampleActivity extends AppCompatActivity {
18 |
19 | private static final String KEY_DATA_IS_PASSWORD = "KeyDataIsPassword";
20 |
21 | public static void start(Context context, boolean isPassword) {
22 | Intent starter = new Intent(context, NormalNumberCodeViewExampleActivity.class);
23 | starter.putExtra(KEY_DATA_IS_PASSWORD, isPassword);
24 | context.startActivity(starter);
25 | }
26 |
27 | private NumberCodeView mNumberCodeView;
28 |
29 | @Override
30 | protected void onCreate(Bundle savedInstanceState) {
31 | super.onCreate(savedInstanceState);
32 | setContentView(R.layout.activity_normal_example);
33 | initView();
34 | }
35 |
36 | private void initView(){
37 | ActionBar actionBar = getSupportActionBar();
38 | actionBar.setTitle("NormalNumberCodeView");
39 | actionBar.setDisplayHomeAsUpEnabled(true);
40 |
41 | boolean isPassword = getIntent().getBooleanExtra(KEY_DATA_IS_PASSWORD, true);
42 | mNumberCodeView = (NumberCodeView) findViewById(R.id.numberCodeView);
43 | mNumberCodeView.setIsPassword(isPassword);
44 | mNumberCodeView.setNumberCodeCallback(new NumberCodeView.OnInputNumberCodeCallback() {
45 | @Override
46 | public void onResult(String code) {
47 | Toast.makeText(NormalNumberCodeViewExampleActivity.this, code, Toast.LENGTH_LONG).show();
48 | }
49 | });
50 | }
51 |
52 | @Override
53 | public boolean onOptionsItemSelected(MenuItem item) {
54 | if (item.getItemId() == android.R.id.home) {
55 | finish();
56 | return true;
57 | }
58 | return super.onOptionsItemSelected(item);
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_button.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_button_n.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_button_p.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
17 |
18 |
23 |
24 |
29 |
30 |
38 |
39 |
40 |
41 |
42 |
43 |
52 |
53 |
64 |
65 |
66 |
67 |
76 |
77 |
88 |
89 |
90 |
91 |
98 |
99 |
103 |
104 |
111 |
112 |
113 |
114 |
115 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_normal_example.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
14 |
15 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_main.xml:
--------------------------------------------------------------------------------
1 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linkaipeng/NumberCodeView/30148ca4d497615d70bee0b244409ab67424be7c/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linkaipeng/NumberCodeView/30148ca4d497615d70bee0b244409ab67424be7c/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_avatar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linkaipeng/NumberCodeView/30148ca4d497615d70bee0b244409ab67424be7c/app/src/main/res/mipmap-xhdpi/ic_avatar.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linkaipeng/NumberCodeView/30148ca4d497615d70bee0b244409ab67424be7c/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linkaipeng/NumberCodeView/30148ca4d497615d70bee0b244409ab67424be7c/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linkaipeng/NumberCodeView/30148ca4d497615d70bee0b244409ab67424be7c/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #1488cf
4 | #126294
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 | 16dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | NumberCodeView
3 | Settings
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/test/java/com/linkaipeng/numbercodeview/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.linkaipeng.numbercodeview;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:1.3.0'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | }
19 | }
20 |
21 | task clean(type: Delete) {
22 | delete rootProject.buildDir
23 | }
24 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linkaipeng/NumberCodeView/30148ca4d497615d70bee0b244409ab67424be7c/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Oct 26 18:45:31 CST 2015
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # For Cygwin, ensure paths are in UNIX format before anything is touched.
46 | if $cygwin ; then
47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48 | fi
49 |
50 | # Attempt to set APP_HOME
51 | # Resolve links: $0 may be a link
52 | PRG="$0"
53 | # Need this for relative symlinks.
54 | while [ -h "$PRG" ] ; do
55 | ls=`ls -ld "$PRG"`
56 | link=`expr "$ls" : '.*-> \(.*\)$'`
57 | if expr "$link" : '/.*' > /dev/null; then
58 | PRG="$link"
59 | else
60 | PRG=`dirname "$PRG"`"/$link"
61 | fi
62 | done
63 | SAVED="`pwd`"
64 | cd "`dirname \"$PRG\"`/" >&-
65 | APP_HOME="`pwd -P`"
66 | cd "$SAVED" >&-
67 |
68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
69 |
70 | # Determine the Java command to use to start the JVM.
71 | if [ -n "$JAVA_HOME" ] ; then
72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
73 | # IBM's JDK on AIX uses strange locations for the executables
74 | JAVACMD="$JAVA_HOME/jre/sh/java"
75 | else
76 | JAVACMD="$JAVA_HOME/bin/java"
77 | fi
78 | if [ ! -x "$JAVACMD" ] ; then
79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
80 |
81 | Please set the JAVA_HOME variable in your environment to match the
82 | location of your Java installation."
83 | fi
84 | else
85 | JAVACMD="java"
86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
87 |
88 | Please set the JAVA_HOME variable in your environment to match the
89 | location of your Java installation."
90 | fi
91 |
92 | # Increase the maximum file descriptors if we can.
93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
94 | MAX_FD_LIMIT=`ulimit -H -n`
95 | if [ $? -eq 0 ] ; then
96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
97 | MAX_FD="$MAX_FD_LIMIT"
98 | fi
99 | ulimit -n $MAX_FD
100 | if [ $? -ne 0 ] ; then
101 | warn "Could not set maximum file descriptor limit: $MAX_FD"
102 | fi
103 | else
104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
105 | fi
106 | fi
107 |
108 | # For Darwin, add options to specify how the application appears in the dock
109 | if $darwin; then
110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111 | fi
112 |
113 | # For Cygwin, switch paths to Windows format before running java
114 | if $cygwin ; then
115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158 | function splitJvmOpts() {
159 | JVM_OPTS=("$@")
160 | }
161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
163 |
164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
165 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/numbercodeview-lib/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 | *.iml
--------------------------------------------------------------------------------
/numbercodeview-lib/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion "24.0.0"
6 |
7 | defaultConfig {
8 | minSdkVersion 15
9 | targetSdkVersion 23
10 | versionCode 1
11 | versionName "1.0"
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 | }
20 |
21 | dependencies {
22 | compile fileTree(dir: 'libs', include: ['*.jar'])
23 | testCompile 'junit:junit:4.12'
24 | compile 'com.android.support:appcompat-v7:23.4.0'
25 | }
26 |
--------------------------------------------------------------------------------
/numbercodeview-lib/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/linkaipeng/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/numbercodeview-lib/src/androidTest/java/com/lkp/numbercodeview/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.lkp.numbercodeview;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/numbercodeview-lib/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
7 |
8 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/numbercodeview-lib/src/main/java/com/lkp/numbercodeview/BaseNumberCodeView.java:
--------------------------------------------------------------------------------
1 | package com.lkp.numbercodeview;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.util.AttributeSet;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 | import android.widget.AdapterView;
10 | import android.widget.BaseAdapter;
11 | import android.widget.ImageView;
12 | import android.widget.RelativeLayout;
13 | import android.widget.TextView;
14 |
15 | import java.util.ArrayList;
16 | import java.util.List;
17 | import java.util.Stack;
18 |
19 | /**
20 | * Created by linkaipeng on 16/8/2.
21 | */
22 | public abstract class BaseNumberCodeView extends RelativeLayout implements AdapterView.OnItemClickListener {
23 |
24 | private final static int NUMBER_BUTTON_DELETE = 11;
25 | private final static int NUMBER_BUTTON_ZERO = 10;//0号按键
26 | private final static int NUMBER_BUTTON_CLEAR = 9;//清除按键
27 | private final static int NUMBER_COUNT = 6;
28 |
29 | private final static String PASSWORD_NUMBER_SYMBOL = "●";
30 |
31 | protected Context mContext;
32 | private ExpandGridView mNumbersGridView;
33 |
34 | private boolean mIsPassword;
35 |
36 | private TextView mNumber1TextView;
37 | private TextView mNumber2TextView;
38 | private TextView mNumber3TextView;
39 | private TextView mNumber4TextView;
40 | private TextView mNumber5TextView;
41 | private TextView mNumber6TextView;
42 |
43 | private Stack mNumberStack;
44 | private List mNumberViewList;
45 |
46 | protected OnInputNumberCodeCallback mCallback;
47 |
48 |
49 | public BaseNumberCodeView(Context context) {
50 | super(context, null);
51 | }
52 |
53 | public BaseNumberCodeView(Context context, AttributeSet attrs) {
54 | super(context, attrs);
55 | mContext = context;
56 | mNumberStack = new Stack();
57 | mNumberViewList = new ArrayList();
58 | initView();
59 |
60 | TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.NumberCodeView);
61 | mIsPassword = array.getBoolean(R.styleable.NumberCodeView_isPassword, false);
62 | }
63 |
64 | private void initView(){
65 | View view = createView();
66 | addView(view);
67 | mNumbersGridView = (ExpandGridView) view.findViewById(R.id.numbers_gridView);
68 | mNumbersGridView.setAdapter(new NumbersAdapter());
69 | mNumbersGridView.setOnItemClickListener(this);
70 | mNumber1TextView = (TextView) findViewById(R.id.number_1_textView);
71 | mNumber2TextView = (TextView) findViewById(R.id.number_2_textView);
72 | mNumber3TextView = (TextView) findViewById(R.id.number_3_textView);
73 | mNumber4TextView = (TextView) findViewById(R.id.number_4_textView);
74 | mNumber5TextView = (TextView) findViewById(R.id.number_5_textView);
75 | mNumber6TextView = (TextView) findViewById(R.id.number_6_textView);
76 | mNumberViewList.add(mNumber1TextView);
77 | mNumberViewList.add(mNumber2TextView);
78 | mNumberViewList.add(mNumber3TextView);
79 | mNumberViewList.add(mNumber4TextView);
80 | mNumberViewList.add(mNumber5TextView);
81 | mNumberViewList.add(mNumber6TextView);
82 | }
83 |
84 | public void setIsPassword(boolean isPassword){
85 | mIsPassword = isPassword;
86 | }
87 |
88 | @Override
89 | public void onItemClick(AdapterView> parent, View view, int position, long id) {
90 | if (position == NUMBER_BUTTON_CLEAR) {
91 | restoreViews();
92 | return;
93 | }
94 | if (position == NUMBER_BUTTON_DELETE) {
95 | if (mNumberStack.empty() || mNumberStack.size() > NUMBER_COUNT) {
96 | return;
97 | }
98 | mNumberStack.pop();
99 | } else {
100 | if (position == NUMBER_BUTTON_ZERO) {
101 | mNumberStack.push(0);
102 | } else {
103 | mNumberStack.push(++position);
104 | }
105 | }
106 | refreshNumberViews();
107 | //input 6 numbers complete
108 | if (mNumberStack.size() == NUMBER_COUNT) {
109 | StringBuilder codeBuilder = new StringBuilder();
110 | for (int number : mNumberStack) {
111 | codeBuilder.append(number);
112 | }
113 | onResult(codeBuilder.toString());
114 | }
115 | }
116 |
117 | protected void restoreViews(){
118 | mNumberStack.clear();
119 | refreshNumberViews();
120 | }
121 |
122 | private void refreshNumberViews(){
123 | for (int i = 0, size = mNumberViewList.size(); i < size; i++) {
124 | int numSize = mNumberStack.size();
125 | if (i < numSize) {
126 | if (mIsPassword) {
127 | mNumberViewList.get(i).setText(PASSWORD_NUMBER_SYMBOL);
128 | } else {
129 | mNumberViewList.get(i).setText(String.valueOf(mNumberStack.get(i)));
130 | }
131 |
132 | } else {
133 | mNumberViewList.get(i).setText("");
134 | }
135 | }
136 | }
137 |
138 | public void setNumberCodeCallback(OnInputNumberCodeCallback callback){
139 | this.mCallback = callback;
140 | }
141 |
142 | public interface OnInputNumberCodeCallback {
143 | void onResult(String code);
144 | }
145 |
146 | abstract protected View createView();
147 | abstract protected void onResult(String code);
148 |
149 | private class NumbersAdapter extends BaseAdapter {
150 |
151 | private static final String NUMBERS = "123456789C0#";
152 |
153 | @Override
154 | public int getCount() {
155 | return NUMBERS.length();
156 | }
157 |
158 | @Override
159 | public String getItem(int position) {
160 | return String.valueOf(NUMBERS.charAt(position));
161 | }
162 |
163 | @Override
164 | public long getItemId(int position) {
165 | return position;
166 | }
167 |
168 | @Override
169 | public View getView(int position, View convertView, ViewGroup parent) {
170 | ItemHolder itemHolder;
171 | if (convertView == null) {
172 | itemHolder = new ItemHolder();
173 | convertView = LayoutInflater.from(mContext).inflate(R.layout.item_view_input_group_code, null);
174 | itemHolder.mRootView = (RelativeLayout) convertView.findViewById(R.id.number_root_view);
175 | itemHolder.mNumberTextView = (TextView) convertView.findViewById(R.id.number_textView);
176 | itemHolder.mDeleteImageView = (ImageView) convertView.findViewById(R.id.number_delete_imageView);
177 | convertView.setTag(itemHolder);
178 | } else {
179 | itemHolder = (ItemHolder) convertView.getTag();
180 | }
181 | String curNumber = getItem(position);
182 | if ("C".equals(curNumber)) {
183 | itemHolder.mDeleteImageView.setVisibility(GONE);
184 | itemHolder.mNumberTextView.setVisibility(VISIBLE);
185 | itemHolder.mNumberTextView.setText(curNumber);
186 | itemHolder.mRootView.setBackgroundColor(getResources().getColor(R.color.gray));
187 | } else if ("#".equals(curNumber)) {
188 | itemHolder.mRootView.setBackgroundColor(getResources().getColor(R.color.gray));
189 | itemHolder.mNumberTextView.setVisibility(GONE);
190 | itemHolder.mDeleteImageView.setVisibility(VISIBLE);
191 | } else {
192 | itemHolder.mRootView.setBackgroundResource(R.drawable.list_selector);
193 | itemHolder.mDeleteImageView.setVisibility(GONE);
194 | itemHolder.mNumberTextView.setVisibility(VISIBLE);
195 | itemHolder.mNumberTextView.setText(curNumber);
196 | }
197 | return convertView;
198 | }
199 | }
200 |
201 | private static class ItemHolder{
202 | RelativeLayout mRootView;
203 | TextView mNumberTextView;
204 | ImageView mDeleteImageView;
205 | }
206 | }
207 |
--------------------------------------------------------------------------------
/numbercodeview-lib/src/main/java/com/lkp/numbercodeview/ExpandGridView.java:
--------------------------------------------------------------------------------
1 | package com.lkp.numbercodeview;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.widget.GridView;
6 |
7 | public class ExpandGridView extends GridView {
8 |
9 | public ExpandGridView(Context context) {
10 | super(context);
11 | }
12 |
13 | public ExpandGridView(Context context, AttributeSet attrs) {
14 | super(context, attrs);
15 | }
16 |
17 |
18 | @Override
19 | public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
20 | int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);
21 | super.onMeasure(widthMeasureSpec, expandSpec);
22 | }
23 |
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/numbercodeview-lib/src/main/java/com/lkp/numbercodeview/bottomsheet/BottomSheetNumberCodeView.java:
--------------------------------------------------------------------------------
1 | package com.lkp.numbercodeview.bottomsheet;
2 |
3 | import android.animation.Animator;
4 | import android.animation.ObjectAnimator;
5 | import android.content.Context;
6 | import android.util.AttributeSet;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.widget.ImageView;
10 | import android.widget.LinearLayout;
11 |
12 | import com.lkp.numbercodeview.BaseNumberCodeView;
13 | import com.lkp.numbercodeview.R;
14 |
15 | /**
16 | * Created by linkaipeng on 16/8/2.
17 | */
18 | public class BottomSheetNumberCodeView extends BaseNumberCodeView implements View.OnClickListener {
19 |
20 | private LinearLayout mBottomNumberCodeLayout;
21 | private ImageView mCloseImageView;
22 | private OnHideBottomLayoutListener mOnHideBottomLayoutListener;
23 | private float mDisplayHeight;
24 |
25 | public BottomSheetNumberCodeView(Context context) {
26 | super(context, null);
27 | }
28 |
29 | public BottomSheetNumberCodeView(Context context, AttributeSet attrs) {
30 | super(context, attrs);
31 | mDisplayHeight = context.getResources().getDisplayMetrics().heightPixels;
32 | }
33 |
34 | @Override
35 | protected View createView() {
36 | View view = LayoutInflater.from(mContext).inflate(R.layout.view_bottom_sheet_input_code, null);
37 | mBottomNumberCodeLayout = (LinearLayout) view.findViewById(R.id.bottom_number_code_layout);
38 | mCloseImageView = (ImageView) view.findViewById(R.id.close_bottom_number_code_view);
39 | mCloseImageView.setOnClickListener(this);
40 | return view;
41 | }
42 |
43 | @Override
44 | protected void onResult(String code) {
45 | if (mCallback != null) {
46 | mCallback.onResult(code);
47 | }
48 | hideNumberCodeLayout();
49 | }
50 |
51 | public boolean isNumberCodeLayoutShowing(){
52 | if (mBottomNumberCodeLayout != null) {
53 | return mBottomNumberCodeLayout.getVisibility() == View.VISIBLE;
54 | } else {
55 | return false;
56 | }
57 | }
58 |
59 | public void showNumberCodeLayout(){
60 | if (mBottomNumberCodeLayout == null) {
61 | return;
62 | }
63 | mBottomNumberCodeLayout.setVisibility(VISIBLE);
64 | float yTranslation = mBottomNumberCodeLayout.getTranslationY();
65 | ObjectAnimator yTranslationAnimator = ObjectAnimator.ofFloat(mBottomNumberCodeLayout, "translationY", mDisplayHeight, yTranslation);
66 | yTranslationAnimator.setDuration(500);
67 | yTranslationAnimator.start();
68 | }
69 |
70 | public void hideNumberCodeLayout(){
71 | if (mBottomNumberCodeLayout == null) {
72 | return;
73 | }
74 | float yTranslation = mBottomNumberCodeLayout.getTranslationY();
75 | ObjectAnimator yTranslationAnimator = ObjectAnimator.ofFloat(mBottomNumberCodeLayout, "translationY", yTranslation, mDisplayHeight);
76 | yTranslationAnimator.setDuration(400);
77 | yTranslationAnimator.addListener(new Animator.AnimatorListener() {
78 | @Override
79 | public void onAnimationStart(Animator animation) {
80 |
81 | }
82 |
83 | @Override
84 | public void onAnimationEnd(Animator animation) {
85 | mBottomNumberCodeLayout.setVisibility(GONE);
86 | if (mOnHideBottomLayoutListener != null) {
87 | mOnHideBottomLayoutListener.onHide();
88 | }
89 | }
90 |
91 | @Override
92 | public void onAnimationCancel(Animator animation) {
93 |
94 | }
95 |
96 | @Override
97 | public void onAnimationRepeat(Animator animation) {
98 |
99 | }
100 | });
101 | yTranslationAnimator.start();
102 | }
103 |
104 | public void setOnHideBottomLayoutListener(OnHideBottomLayoutListener onHideLayoutListener){
105 | mOnHideBottomLayoutListener = onHideLayoutListener;
106 | }
107 |
108 | @Override
109 | public void onClick(View v) {
110 | int viewId = v.getId();
111 | if (viewId == R.id.close_bottom_number_code_view) {
112 | hideNumberCodeLayout();
113 | }
114 | }
115 |
116 | public interface OnHideBottomLayoutListener {
117 | void onHide();
118 | }
119 | }
120 |
--------------------------------------------------------------------------------
/numbercodeview-lib/src/main/java/com/lkp/numbercodeview/bottomsheet/BottomSheetNumberCodeViewActivity.java:
--------------------------------------------------------------------------------
1 | package com.lkp.numbercodeview.bottomsheet;
2 |
3 | import android.app.Activity;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.support.annotation.Nullable;
7 | import android.support.v7.app.AppCompatActivity;
8 |
9 | import com.lkp.numbercodeview.BaseNumberCodeView;
10 | import com.lkp.numbercodeview.R;
11 |
12 |
13 | /**
14 | * Created by linkaipeng on 16/8/2.
15 | */
16 | public class BottomSheetNumberCodeViewActivity extends AppCompatActivity
17 | implements BaseNumberCodeView.OnInputNumberCodeCallback,
18 | BottomSheetNumberCodeView.OnHideBottomLayoutListener {
19 |
20 | public static final int REQUEST_CODE_SHOW_BOTTOM_NUMBER_VIEW = 1001;
21 | public static final String KEY_DATA_NUMBER = "KeyDataNumber";
22 | private static final String KEY_DATA_IS_PASSWORD = "KeyDataIsPassword";
23 |
24 | public static void show(Activity activity, boolean isPassword){
25 | Intent intent = new Intent(activity, BottomSheetNumberCodeViewActivity.class);
26 | intent.putExtra(KEY_DATA_IS_PASSWORD, isPassword);
27 | activity.startActivityForResult(intent, REQUEST_CODE_SHOW_BOTTOM_NUMBER_VIEW);
28 | }
29 |
30 | private BottomSheetNumberCodeView mNumberCodeView;
31 |
32 | @Override
33 | protected void onCreate(@Nullable Bundle savedInstanceState) {
34 | super.onCreate(savedInstanceState);
35 | overridePendingTransition(R.anim.push_bottom_to_top, 0);
36 | setContentView(R.layout.activity_bottom_sheet_number_code_view);
37 | initView();
38 | }
39 |
40 | private void initView(){
41 | boolean isPassword = getIntent().getBooleanExtra(KEY_DATA_IS_PASSWORD, true);
42 | mNumberCodeView = (BottomSheetNumberCodeView) findViewById(R.id.bottom_sheet_number_code_view);
43 | mNumberCodeView.setNumberCodeCallback(this);
44 | mNumberCodeView.setOnHideBottomLayoutListener(this);
45 | mNumberCodeView.setIsPassword(isPassword);
46 | mNumberCodeView.showNumberCodeLayout();
47 | }
48 |
49 | @Override
50 | public void onResult(String code) {
51 | Intent resultIntent = new Intent();
52 | resultIntent.putExtra(KEY_DATA_NUMBER, code);
53 | setResult(RESULT_OK, resultIntent);
54 | }
55 |
56 | @Override
57 | public void onHide() {
58 | finish();
59 | }
60 |
61 | @Override
62 | public void onBackPressed() {
63 | if (mNumberCodeView.isNumberCodeLayoutShowing()) {
64 | mNumberCodeView.hideNumberCodeLayout();
65 | } else {
66 | super.onBackPressed();
67 | }
68 | }
69 |
70 | @Override
71 | public void finish() {
72 | super.finish();
73 | overridePendingTransition(0, R.anim.push_top_to_bottom);
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/numbercodeview-lib/src/main/java/com/lkp/numbercodeview/normal/NumberCodeView.java:
--------------------------------------------------------------------------------
1 | package com.lkp.numbercodeview.normal;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.widget.TextView;
8 |
9 | import com.lkp.numbercodeview.BaseNumberCodeView;
10 | import com.lkp.numbercodeview.R;
11 |
12 | /**
13 | * Created by linkaipeng on 2015/10/26.
14 | */
15 | public class NumberCodeView extends BaseNumberCodeView {
16 |
17 | private TextView mResultTextView;
18 |
19 | public NumberCodeView(Context context) {
20 | super(context, null);
21 | }
22 |
23 | public NumberCodeView(Context context, AttributeSet attrs) {
24 | super(context, attrs);
25 | }
26 |
27 | @Override
28 | protected View createView() {
29 | return LayoutInflater.from(mContext).inflate(R.layout.view_input_group_code, null);
30 | }
31 |
32 | @Override
33 | protected void onResult(String code) {
34 | if (mCallback != null) {
35 | mCallback.onResult(code);
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/numbercodeview-lib/src/main/res/anim/push_bottom_to_top.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
7 |
--------------------------------------------------------------------------------
/numbercodeview-lib/src/main/res/anim/push_top_to_bottom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
--------------------------------------------------------------------------------
/numbercodeview-lib/src/main/res/drawable/bg_gray_back_button.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/numbercodeview-lib/src/main/res/drawable/bg_numbers_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
--------------------------------------------------------------------------------
/numbercodeview-lib/src/main/res/drawable/item_border.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
--------------------------------------------------------------------------------
/numbercodeview-lib/src/main/res/drawable/item_border_selected.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
--------------------------------------------------------------------------------
/numbercodeview-lib/src/main/res/drawable/list_selector.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/numbercodeview-lib/src/main/res/layout/activity_bottom_sheet_number_code_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/numbercodeview-lib/src/main/res/layout/item_view_input_group_code.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
16 |
17 |
24 |
25 |
--------------------------------------------------------------------------------
/numbercodeview-lib/src/main/res/layout/view_bottom_sheet_input_code.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
15 |
16 |
19 |
20 |
28 |
29 |
36 |
37 |
38 |
39 |
41 |
42 |
49 |
50 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/numbercodeview-lib/src/main/res/layout/view_input_group_code.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
14 |
22 |
23 |
28 |
29 |
--------------------------------------------------------------------------------
/numbercodeview-lib/src/main/res/layout/view_number_edit.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
13 |
14 |
15 |
16 |
19 |
20 |
21 |
22 |
25 |
26 |
27 |
28 |
31 |
32 |
33 |
34 |
37 |
38 |
39 |
40 |
43 |
44 |
--------------------------------------------------------------------------------
/numbercodeview-lib/src/main/res/layout/view_number_input_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/numbercodeview-lib/src/main/res/mipmap-xhdpi/ic_back_gray_n.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linkaipeng/NumberCodeView/30148ca4d497615d70bee0b244409ab67424be7c/numbercodeview-lib/src/main/res/mipmap-xhdpi/ic_back_gray_n.png
--------------------------------------------------------------------------------
/numbercodeview-lib/src/main/res/mipmap-xhdpi/ic_back_gray_p.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linkaipeng/NumberCodeView/30148ca4d497615d70bee0b244409ab67424be7c/numbercodeview-lib/src/main/res/mipmap-xhdpi/ic_back_gray_p.png
--------------------------------------------------------------------------------
/numbercodeview-lib/src/main/res/mipmap-xhdpi/ic_input_code_delete.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linkaipeng/NumberCodeView/30148ca4d497615d70bee0b244409ab67424be7c/numbercodeview-lib/src/main/res/mipmap-xhdpi/ic_input_code_delete.png
--------------------------------------------------------------------------------
/numbercodeview-lib/src/main/res/values/attr.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/numbercodeview-lib/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 | #FFFFFF
8 | #303030
9 | #e0e0e0
10 | #dadada
11 | #FF4444
12 | #1de192
13 | #a1a4a4
14 |
15 | #32000000
16 |
17 |
--------------------------------------------------------------------------------
/numbercodeview-lib/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | NumberCodeViewLib
3 |
4 |
--------------------------------------------------------------------------------
/numbercodeview-lib/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
14 |
15 |
16 |
17 |
24 |
25 |
31 |
32 |
37 |
38 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/numbercodeview-lib/src/test/java/com/lkp/numbercodeview/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.lkp.numbercodeview;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
--------------------------------------------------------------------------------
/screenshots/screenshot01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linkaipeng/NumberCodeView/30148ca4d497615d70bee0b244409ab67424be7c/screenshots/screenshot01.png
--------------------------------------------------------------------------------
/screenshots/screenshot02.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linkaipeng/NumberCodeView/30148ca4d497615d70bee0b244409ab67424be7c/screenshots/screenshot02.png
--------------------------------------------------------------------------------
/screenshots/screenshot03.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linkaipeng/NumberCodeView/30148ca4d497615d70bee0b244409ab67424be7c/screenshots/screenshot03.png
--------------------------------------------------------------------------------
/screenshots/screenshot04.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linkaipeng/NumberCodeView/30148ca4d497615d70bee0b244409ab67424be7c/screenshots/screenshot04.png
--------------------------------------------------------------------------------
/screenshots/screenshot05.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linkaipeng/NumberCodeView/30148ca4d497615d70bee0b244409ab67424be7c/screenshots/screenshot05.png
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':numbercodeview-lib'
2 |
--------------------------------------------------------------------------------