├── .gitattributes
├── .gitignore
├── .idea
├── .name
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── encodings.xml
├── gradle.xml
├── misc.xml
├── modules.xml
├── runConfigurations.xml
└── vcs.xml
├── README.md
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── mylibrary
├── .gitignore
├── build.gradle
├── mylibrary.iml
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── js
│ │ └── mylibrary
│ │ └── ApplicationTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── js
│ │ │ └── mylibrary
│ │ │ └── AnimDownloadProgressButton.java
│ └── res
│ │ ├── layout
│ │ └── activity_main.xml
│ │ └── values
│ │ ├── attrs.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── js
│ └── mylibrary
│ └── ExampleUnitTest.java
├── progressbutton
├── .gitignore
├── build.gradle
├── progressbutton.iml
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── js
│ │ └── work1
│ │ └── ApplicationTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── js
│ │ │ └── work1
│ │ │ └── MainActivity.java
│ └── res
│ │ ├── layout
│ │ ├── activity_main.xml
│ │ └── content_main.xml
│ │ ├── menu
│ │ └── menu_main.xml
│ │ ├── mipmap-hdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-mdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xhdpi
│ │ ├── a.jpg
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxxhdpi
│ │ └── ic_launcher.png
│ │ ├── values-v21
│ │ └── styles.xml
│ │ ├── values-w820dp
│ │ └── dimens.xml
│ │ └── values
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── js
│ └── work1
│ └── ExampleUnitTest.java
├── settings.gradle
└── work.iml
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 |
7 | # Standard to msysgit
8 | *.doc diff=astextplain
9 | *.DOC diff=astextplain
10 | *.docx diff=astextplain
11 | *.DOCX diff=astextplain
12 | *.dot diff=astextplain
13 | *.DOT diff=astextplain
14 | *.pdf diff=astextplain
15 | *.PDF diff=astextplain
16 | *.rtf diff=astextplain
17 | *.RTF diff=astextplain
18 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .gradle
2 | /local.properties
3 | /.idea/workspace.xml
4 | /.idea/libraries
5 | .DS_Store
6 | /build
7 | /captures
8 |
--------------------------------------------------------------------------------
/.idea/.name:
--------------------------------------------------------------------------------
1 | work1
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
18 |
19 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # ProgressRoundButton [](https://android-arsenal.com/details/1/2660)
2 |
3 | A Smooth Download Button with Progress.
4 |
5 | ## Demo
6 |
7 | 
8 |
9 | ## Usage
10 |
11 | ### step1
12 |
13 | #### gradle
14 |
15 | ```groovy
16 | dependencies {
17 | compile fileTree(dir: 'libs', include: ['*.jar'])
18 | compile 'com.android.support:appcompat-v7:23.0.1'
19 | compile project(':mylibrary')
20 | }
21 | ```
22 | #### step2
23 |
24 | you can define the button in xml like this:
25 |
26 | ```xml
27 |
33 | ```
34 |
35 | the Customized properties are in the follow table:
36 |
37 | | Property | Format | Default |
38 | | ------------- |:-------------:| :-----:|
39 | |progressbtn_radius |float |half of the button height |
40 | |progressbtn_backgroud_color|color | #6699ff |
41 | |progressbtn_backgroud_second_color|color|Color.LTGRAY|
42 | |progressbtn_text_color|color|progressbtn_backgroud_color|
43 | |progressbtn_text_covercolor|color|Color.WHITE|
44 |
45 | The follow picture make a clear explanation:
46 |
47 | 
48 |
49 | ## Version
50 |
51 | * 0.9.1 Compatible with Android 4.0
52 |
53 | ## About me
54 |
55 | I am a developer in China,If you have any idea about this project,please [contact me](mailto:1130397686@qq.com)
56 | ,Thank you!
57 |
58 | ## License
59 |
60 | Copyright 2015 cctanfujun
61 |
62 | Licensed under the Apache License, Version 2.0 (the "License");
63 | you may not use this file except in compliance with the License.
64 | You may obtain a copy of the License at
65 |
66 | http://www.apache.org/licenses/LICENSE-2.0
67 |
68 | Unless required by applicable law or agreed to in writing, software
69 | distributed under the License is distributed on an "AS IS" BASIS,
70 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
71 | See the License for the specific language governing permissions and
72 | limitations under the License.
73 |
--------------------------------------------------------------------------------
/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/chenli3238/progressbutton/332bcafaddcee1c96b790121889d788c0a5a3423/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Tue Dec 15 17:17:43 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 |
--------------------------------------------------------------------------------
/mylibrary/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/mylibrary/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion "23.0.2"
6 |
7 | defaultConfig {
8 | minSdkVersion 19
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.1.1'
25 | }
26 |
--------------------------------------------------------------------------------
/mylibrary/mylibrary.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | generateDebugAndroidTestSources
19 | generateDebugSources
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
--------------------------------------------------------------------------------
/mylibrary/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 F:\AndroidIde\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 |
--------------------------------------------------------------------------------
/mylibrary/src/androidTest/java/com/js/mylibrary/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.js.mylibrary;
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 | }
--------------------------------------------------------------------------------
/mylibrary/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/mylibrary/src/main/java/com/js/mylibrary/AnimDownloadProgressButton.java:
--------------------------------------------------------------------------------
1 | package com.js.mylibrary;
2 |
3 | import android.animation.Animator;
4 | import android.animation.AnimatorSet;
5 | import android.animation.TimeInterpolator;
6 | import android.animation.ValueAnimator;
7 | import android.annotation.TargetApi;
8 | import android.content.Context;
9 | import android.content.res.TypedArray;
10 | import android.graphics.Canvas;
11 | import android.graphics.Color;
12 | import android.graphics.LinearGradient;
13 | import android.graphics.Paint;
14 | import android.graphics.RectF;
15 | import android.graphics.Shader;
16 | import android.os.Build;
17 | import android.os.Parcel;
18 | import android.os.Parcelable;
19 | import android.support.v4.view.animation.PathInterpolatorCompat;
20 | import android.util.AttributeSet;
21 | import android.widget.TextView;
22 |
23 | /**
24 | * Created by tanfujun on 15/9/4.
25 | */
26 | public class AnimDownloadProgressButton extends TextView {
27 |
28 | private Context mContext;
29 |
30 | //背景画笔
31 | private Paint mBackgroundPaint;
32 | //按钮文字画笔
33 | private volatile Paint mTextPaint;
34 | //第一个点画笔
35 | private Paint mDot1Paint;
36 | //第二个点画笔
37 | private Paint mDot2Paint;
38 |
39 |
40 | //背景颜色
41 | private int mBackgroundColor;
42 | //下载中后半部分后面背景颜色
43 | private int mBackgroundSecondColor;
44 | //文字颜色
45 | private int mTextColor;
46 | //覆盖后颜色
47 | private int mTextCoverColor;
48 |
49 |
50 | private float mProgress = -1;
51 | private float mToProgress;
52 | private int mMaxProgress;
53 | private int mMinProgress;
54 | private float mProgressPercent;
55 |
56 | private float mButtonRadius;
57 |
58 | //两个点向右移动距离
59 | private float mDot1transX;
60 | private float mDot2transX;
61 |
62 | private RectF mBackgroundBounds;
63 | private LinearGradient mProgressBgGradient;
64 | private LinearGradient mProgressTextGradient;
65 |
66 | //点运动动画
67 | private AnimatorSet mDotAnimationSet;
68 | //下载平滑动画
69 | private ValueAnimator mProgressAnimation;
70 |
71 | //记录当前文字
72 | private CharSequence mCurrentText;
73 |
74 | //普通状态
75 | public static final int NORMAL = 0;
76 | //下载中
77 | public static final int DOWNLOADING = 1;
78 | //有点运动状态
79 | public static final int INSTALLING = 2;
80 |
81 |
82 | private int mState;
83 |
84 | public AnimDownloadProgressButton(Context context) {
85 | this(context, null);
86 |
87 | }
88 |
89 | public AnimDownloadProgressButton(Context context, AttributeSet attrs) {
90 | super(context, attrs);
91 | if (!isInEditMode()) {
92 | mContext = context;
93 | initAttrs(context, attrs);
94 | init();
95 | setupAnimations();
96 | }
97 |
98 | }
99 |
100 | private void initAttrs(Context context, AttributeSet attrs) {
101 |
102 | TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.AnimDownloadProgressButton);
103 | mBackgroundColor = a.getColor(R.styleable.AnimDownloadProgressButton_progressbtn_backgroud_color, Color.parseColor("#6699ff"));
104 | mBackgroundSecondColor = a.getColor(R.styleable.AnimDownloadProgressButton_progressbtn_backgroud_second_color, Color.LTGRAY);
105 | mButtonRadius = a.getFloat(R.styleable.AnimDownloadProgressButton_progressbtn_radius, getMeasuredHeight() / 2);
106 | mTextColor = a.getColor(R.styleable.AnimDownloadProgressButton_progressbtn_text_color, mBackgroundColor);
107 | mTextCoverColor = a.getColor(R.styleable.AnimDownloadProgressButton_progressbtn_text_covercolor, Color.WHITE);
108 | a.recycle();
109 | }
110 |
111 | private void init() {
112 |
113 | mMaxProgress = 100;
114 | mMinProgress = 0;
115 | mProgress = 0;
116 |
117 |
118 | //设置背景画笔
119 | mBackgroundPaint = new Paint();
120 | mBackgroundPaint.setAntiAlias(true);
121 | mBackgroundPaint.setStyle(Paint.Style.FILL);
122 |
123 | //设置文字画笔
124 | mTextPaint = new Paint();
125 | mTextPaint.setAntiAlias(true);
126 | mTextPaint.setTextSize(50f);
127 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
128 | //解决文字有时候画不出问题
129 | setLayerType(LAYER_TYPE_SOFTWARE, mTextPaint);
130 | }
131 |
132 | //设置第一个点画笔
133 | mDot1Paint = new Paint();
134 | mDot1Paint.setAntiAlias(true);
135 | mDot1Paint.setTextSize(50f);
136 |
137 | //设置第二个点画笔
138 | mDot2Paint = new Paint();
139 | mDot2Paint.setAntiAlias(true);
140 | mDot2Paint.setTextSize(50f);
141 |
142 | //初始化状态设为NORMAL
143 | mState = NORMAL;
144 | invalidate();
145 |
146 | }
147 |
148 |
149 | private void setupAnimations() {
150 |
151 | //两个点向右移动动画
152 | ValueAnimator dotMoveAnimation = ValueAnimator.ofFloat(0, 20);
153 | TimeInterpolator pathInterpolator = PathInterpolatorCompat.create(0.11f, 0f, 0.12f, 1f);
154 | dotMoveAnimation.setInterpolator(pathInterpolator);
155 | dotMoveAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
156 | @Override
157 | public void onAnimationUpdate(ValueAnimator animation) {
158 | float transX = (float) animation.getAnimatedValue();
159 | mDot1transX = transX;
160 | mDot2transX = transX;
161 | invalidate();
162 | }
163 | });
164 | dotMoveAnimation.setDuration(1243);
165 | dotMoveAnimation.setRepeatMode(ValueAnimator.RESTART);
166 | dotMoveAnimation.setRepeatCount(ValueAnimator.INFINITE);
167 |
168 |
169 | //两个点渐显渐隐动画
170 | final ValueAnimator dotAlphaAnim = ValueAnimator.ofInt(0, 1243).setDuration(1243);
171 | dotAlphaAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
172 | @Override
173 | public void onAnimationUpdate(ValueAnimator animation) {
174 | int time = (int) dotAlphaAnim.getAnimatedValue();
175 | int dot1Alpha = calculateDot1AlphaByTime(time);
176 | int dot2Alpha = calculateDot2AlphaByTime(time);
177 | mDot1Paint.setColor(mTextCoverColor);
178 | mDot2Paint.setColor(mTextCoverColor);
179 | mDot1Paint.setAlpha(dot1Alpha);
180 | mDot2Paint.setAlpha(dot2Alpha);
181 | }
182 |
183 | });
184 |
185 |
186 | dotAlphaAnim.addListener(new Animator.AnimatorListener() {
187 | @Override
188 | public void onAnimationStart(Animator animation) {
189 | mDot1Paint.setAlpha(0);
190 | mDot2Paint.setAlpha(0);
191 | }
192 |
193 | @Override
194 | public void onAnimationEnd(Animator animation) {
195 | }
196 |
197 | @Override
198 | public void onAnimationCancel(Animator animation) {
199 |
200 | }
201 |
202 | @Override
203 | public void onAnimationRepeat(Animator animation) {
204 |
205 | }
206 | });
207 | dotAlphaAnim.setRepeatMode(ValueAnimator.RESTART);
208 | dotAlphaAnim.setRepeatCount(ValueAnimator.INFINITE);
209 | //两个点的动画集合
210 | mDotAnimationSet = new AnimatorSet();
211 | mDotAnimationSet.playTogether(dotAlphaAnim, dotMoveAnimation);
212 |
213 | //ProgressBar的动画
214 | mProgressAnimation = ValueAnimator.ofFloat(0, 1).setDuration(500);
215 | mProgressAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
216 | @Override
217 | public void onAnimationUpdate(ValueAnimator animation) {
218 | float timepercent = (float) animation.getAnimatedValue();
219 | mProgress = ((mToProgress - mProgress) * timepercent + mProgress);
220 | invalidate();
221 | }
222 | });
223 |
224 |
225 | }
226 |
227 | //第一个点透明度计算函数
228 | private int calculateDot2AlphaByTime(int time) {
229 | int alpha;
230 | if (0 <= time && time <= 83) {
231 | double DAlpha = 255.0 / 83.0 * time;
232 | alpha = (int) DAlpha;
233 | } else if (83 < time && time <= 1000) {
234 | alpha = 255;
235 | } else if (1000 < time && time <= 1083) {
236 | double DAlpha = -255.0 / 83.0 * (time - 1083);
237 | alpha = (int) DAlpha;
238 | } else if (1083 < time && time <= 1243) {
239 | alpha = 0;
240 | } else {
241 | alpha = 255;
242 | }
243 | return alpha;
244 | }
245 |
246 | //第二个点透明度计算函数
247 | private int calculateDot1AlphaByTime(int time) {
248 | int alpha;
249 | if (0 <= time && time <= 160) {
250 | alpha = 0;
251 | } else if (160 < time && time <= 243) {
252 | double DAlpha = 255.0 / 83.0 * (time - 160);
253 | alpha = (int) DAlpha;
254 | } else if (243 < time && time <= 1160) {
255 | alpha = 255;
256 | } else if (1160 < time && time <= 1243) {
257 | double DAlpha = -255.0 / 83.0 * (time - 1243);
258 | alpha = (int) DAlpha;
259 | } else {
260 | alpha = 255;
261 | }
262 | return alpha;
263 | }
264 |
265 |
266 | private ValueAnimator createDotAlphaAnimation(int i, Paint mDot1Paint, int i1, int i2, int i3) {
267 |
268 | return new ValueAnimator();
269 | }
270 |
271 | @Override
272 | protected void onDraw(Canvas canvas) {
273 | super.onDraw(canvas);
274 | if (!isInEditMode()) {
275 | drawing(canvas);
276 | }
277 | }
278 |
279 | private void drawing(Canvas canvas) {
280 | drawBackground(canvas);
281 | drawTextAbove(canvas);
282 | }
283 |
284 | private void drawBackground(Canvas canvas) {
285 | mBackgroundBounds = new RectF();
286 | if (mButtonRadius == 0) {
287 | mButtonRadius = getMeasuredHeight() / 2;
288 | }
289 | mBackgroundBounds.left = 2;
290 | mBackgroundBounds.top = 2;
291 | mBackgroundBounds.right = getMeasuredWidth() - 2;
292 | mBackgroundBounds.bottom = getMeasuredHeight() - 2;
293 |
294 | //color
295 | switch (mState) {
296 | case NORMAL:
297 | if (mBackgroundPaint.getShader() != null) {
298 | mBackgroundPaint.setShader(null);
299 | }
300 | mBackgroundPaint.setColor(mBackgroundColor);
301 | canvas.drawRoundRect(mBackgroundBounds, mButtonRadius, mButtonRadius, mBackgroundPaint);
302 | break;
303 | case DOWNLOADING:
304 | mProgressPercent = mProgress / (mMaxProgress + 0f);
305 | mProgressBgGradient = new LinearGradient(0, 0, getMeasuredWidth(), 0,
306 | new int[]{mBackgroundColor, mBackgroundSecondColor},
307 | new float[]{mProgressPercent, mProgressPercent + 0.001f},
308 | Shader.TileMode.CLAMP
309 | );
310 | mBackgroundPaint.setColor(mBackgroundColor);
311 | mBackgroundPaint.setShader(mProgressBgGradient);
312 | canvas.drawRoundRect(mBackgroundBounds, mButtonRadius, mButtonRadius, mBackgroundPaint);
313 | break;
314 | case INSTALLING:
315 | mBackgroundPaint.setShader(null);
316 | mBackgroundPaint.setColor(mBackgroundColor);
317 | canvas.drawRoundRect(mBackgroundBounds, mButtonRadius, mButtonRadius, mBackgroundPaint);
318 | break;
319 | }
320 | }
321 |
322 | private void drawTextAbove(Canvas canvas) {
323 | final float y = canvas.getHeight() / 2 - (mTextPaint.descent() / 2 + mTextPaint.ascent() / 2);
324 | if (mCurrentText == null) {
325 | mCurrentText = "";
326 | }
327 | final float textWidth = mTextPaint.measureText(mCurrentText.toString());
328 | //color
329 | switch (mState) {
330 | case NORMAL:
331 | mTextPaint.setShader(null);
332 | mTextPaint.setColor(mTextCoverColor);
333 | canvas.drawText(mCurrentText.toString(), (getMeasuredWidth() - textWidth) / 2, y, mTextPaint);
334 | break;
335 | case DOWNLOADING:
336 |
337 | //进度条压过距离
338 | float coverlength = getMeasuredWidth() * mProgressPercent;
339 | //开始渐变指示器
340 | float indicator1 = getMeasuredWidth() / 2 - textWidth / 2;
341 | //结束渐变指示器
342 | float indicator2 = getMeasuredWidth() / 2 + textWidth / 2;
343 | //文字变色部分的距离
344 | float coverTextLength = textWidth / 2 - getMeasuredWidth() / 2 + coverlength;
345 | float textProgress = coverTextLength / textWidth;
346 | if (coverlength <= indicator1) {
347 | mTextPaint.setShader(null);
348 | mTextPaint.setColor(mTextColor);
349 | } else if (indicator1 < coverlength && coverlength <= indicator2) {
350 | mProgressTextGradient = new LinearGradient((getMeasuredWidth() - textWidth) / 2, 0, (getMeasuredWidth() + textWidth) / 2, 0,
351 | new int[]{mTextCoverColor, mTextColor},
352 | new float[]{textProgress, textProgress + 0.001f},
353 | Shader.TileMode.CLAMP);
354 | mTextPaint.setColor(mTextColor);
355 | mTextPaint.setShader(mProgressTextGradient);
356 | } else {
357 | mTextPaint.setShader(null);
358 | mTextPaint.setColor(mTextCoverColor);
359 | }
360 | canvas.drawText(mCurrentText.toString(), (getMeasuredWidth() - textWidth) / 2, y, mTextPaint);
361 | break;
362 | case INSTALLING:
363 | mTextPaint.setColor(mTextCoverColor);
364 | canvas.drawText(mCurrentText.toString(), (getMeasuredWidth() - textWidth) / 2, y, mTextPaint);
365 | canvas.drawCircle((getMeasuredWidth() + textWidth) / 2 + 4 + mDot1transX, y, 4, mDot1Paint);
366 | canvas.drawCircle((getMeasuredWidth() + textWidth) / 2 + 24 + mDot2transX, y, 4, mDot2Paint);
367 | break;
368 |
369 | }
370 |
371 | }
372 |
373 | public int getState() {
374 | return mState;
375 | }
376 |
377 | public void setState(int state) {
378 | if (mState != state) {//状态确实有改变
379 | this.mState = state;
380 | invalidate();
381 | if (state == AnimDownloadProgressButton.INSTALLING) {
382 | //开启两个点动画
383 | mDotAnimationSet.start();
384 | } else if (state == NORMAL) {
385 | mDotAnimationSet.cancel();
386 | } else if (state == DOWNLOADING) {
387 | mDotAnimationSet.cancel();
388 | }
389 | }
390 |
391 | }
392 |
393 | /**
394 | * 设置按钮文字
395 | */
396 | public void setCurrentText(CharSequence charSequence) {
397 | mCurrentText = charSequence;
398 | invalidate();
399 | }
400 |
401 |
402 | /**
403 | * 设置带下载进度的文字
404 | */
405 | @TargetApi(Build.VERSION_CODES.KITKAT)
406 | public void setProgressText(String text, float progress) {
407 | if (progress >= mMinProgress && progress <= mMaxProgress) {
408 | mCurrentText = text + getResources().getString(R.string.downloaded, (int) progress);
409 | mToProgress = progress;
410 | if (mProgressAnimation.isRunning()) {
411 | mProgressAnimation.resume();
412 | mProgressAnimation.start();
413 | } else {
414 | mProgressAnimation.start();
415 | }
416 | } else if (progress < mMinProgress) {
417 | mProgress = 0;
418 | } else if (progress > mMaxProgress) {
419 | mProgress = 100;
420 | mCurrentText = text + getResources().getString(R.string.downloaded, (int) mProgress);
421 | invalidate();
422 | }
423 | }
424 |
425 | public float getProgress() {
426 | return mProgress;
427 | }
428 |
429 | public void setProgress(float progress) {
430 | this.mProgress = progress;
431 |
432 | }
433 |
434 | public float getButtonRadius() {
435 | return mButtonRadius;
436 | }
437 |
438 | public void setButtonRadius(float buttonRadius) {
439 | mButtonRadius = buttonRadius;
440 | }
441 |
442 | public int getTextColor() {
443 | return mTextColor;
444 | }
445 |
446 | @Override
447 | public void setTextColor(int textColor) {
448 | mTextColor = textColor;
449 | }
450 |
451 | public int getTextCoverColor() {
452 | return mTextCoverColor;
453 | }
454 |
455 | public void setTextCoverColor(int textCoverColor) {
456 | mTextCoverColor = textCoverColor;
457 | }
458 |
459 | public int getMinProgress() {
460 | return mMinProgress;
461 | }
462 |
463 | public void setMinProgress(int minProgress) {
464 | mMinProgress = minProgress;
465 | }
466 |
467 | public int getMaxProgress() {
468 | return mMaxProgress;
469 | }
470 |
471 | public void setMaxProgress(int maxProgress) {
472 | mMaxProgress = maxProgress;
473 | }
474 |
475 | @Override
476 | public void onRestoreInstanceState(Parcelable state) {
477 | SavedState ss = (SavedState) state;
478 | super.onRestoreInstanceState(ss.getSuperState());
479 | mState = ss.state;
480 | mProgress = ss.progress;
481 | mCurrentText = ss.currentText;
482 | }
483 |
484 | @Override
485 | public Parcelable onSaveInstanceState() {
486 | Parcelable superState = super.onSaveInstanceState();
487 | return new SavedState(superState, (int) mProgress, mState, mCurrentText.toString());
488 | }
489 |
490 | public static class SavedState extends BaseSavedState {
491 |
492 | private int progress;
493 | private int state;
494 | private String currentText;
495 |
496 | public SavedState(Parcelable parcel, int progress, int state, String currentText) {
497 | super(parcel);
498 | this.progress = progress;
499 | this.state = state;
500 | this.currentText = currentText;
501 | }
502 |
503 | private SavedState(Parcel in) {
504 | super(in);
505 | progress = in.readInt();
506 | state = in.readInt();
507 | currentText = in.readString();
508 | }
509 |
510 | @Override
511 | public void writeToParcel(Parcel out, int flags) {
512 | super.writeToParcel(out, flags);
513 | out.writeInt(progress);
514 | out.writeInt(state);
515 | out.writeString(currentText);
516 | }
517 |
518 | public static final Creator CREATOR = new Creator() {
519 |
520 | @Override
521 | public SavedState createFromParcel(Parcel in) {
522 | return new SavedState(in);
523 | }
524 |
525 | @Override
526 | public SavedState[] newArray(int size) {
527 | return new SavedState[size];
528 | }
529 | };
530 | }
531 |
532 |
533 | }
534 |
--------------------------------------------------------------------------------
/mylibrary/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/mylibrary/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/mylibrary/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/mylibrary/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | ProgressRoundButton
3 |
4 | Hello world!
5 | Settings
6 | %s %%
7 |
8 |
--------------------------------------------------------------------------------
/mylibrary/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/mylibrary/src/test/java/com/js/mylibrary/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.js.mylibrary;
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 | }
--------------------------------------------------------------------------------
/progressbutton/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/progressbutton/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion "23.0.2"
6 |
7 | defaultConfig {
8 | applicationId "com.js.work1"
9 | minSdkVersion 19
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(include: ['*.jar'], dir: 'libs')
24 | testCompile 'junit:junit:4.12'
25 | compile 'com.android.support:appcompat-v7:23.1.1'
26 | compile 'com.android.support:design:23.1.1'
27 | compile project(':mylibrary')
28 | }
29 |
--------------------------------------------------------------------------------
/progressbutton/progressbutton.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | generateDebugAndroidTestSources
19 | generateDebugSources
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
--------------------------------------------------------------------------------
/progressbutton/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 F:\AndroidIde\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 |
--------------------------------------------------------------------------------
/progressbutton/src/androidTest/java/com/js/work1/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.js.work1;
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 | }
--------------------------------------------------------------------------------
/progressbutton/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
10 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/progressbutton/src/main/java/com/js/work1/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.js.work1;
2 |
3 |
4 | import android.os.Bundle;
5 | import android.os.Handler;
6 | import android.support.v7.app.AppCompatActivity;
7 | import android.view.View;
8 | import android.widget.Button;
9 | import android.widget.SeekBar;
10 | import android.widget.TextView;
11 |
12 | import com.js.mylibrary.AnimDownloadProgressButton;
13 |
14 |
15 | public class MainActivity extends AppCompatActivity {
16 | AnimDownloadProgressButton mAnimDownloadProgressButton;
17 | Button mReset;
18 | TextView mDescription;
19 | SeekBar mSeekBar;
20 |
21 | @Override
22 | protected void onCreate(Bundle savedInstanceState) {
23 | super.onCreate(savedInstanceState);
24 | setContentView(R.layout.activity_main);
25 | mReset = (Button) findViewById(R.id.reset);
26 | mSeekBar = (SeekBar) findViewById(R.id.seekBar);
27 | mDescription = (TextView) findViewById(R.id.description);
28 | mAnimDownloadProgressButton = (AnimDownloadProgressButton) findViewById(R.id.anim_btn);
29 | mAnimDownloadProgressButton.setCurrentText("安装");
30 | mAnimDownloadProgressButton.setOnClickListener(new View.OnClickListener() {
31 | @Override
32 | public void onClick(View v) {
33 | showTheButton();
34 | }
35 | });
36 |
37 | mReset.setOnClickListener(new View.OnClickListener() {
38 | @Override
39 | public void onClick(View v) {
40 | mAnimDownloadProgressButton.setState(AnimDownloadProgressButton.NORMAL);
41 | mAnimDownloadProgressButton.setCurrentText("安装");
42 | mAnimDownloadProgressButton.setProgress(0);
43 | }
44 | });
45 |
46 | mSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
47 | @Override
48 | public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
49 | mAnimDownloadProgressButton.setButtonRadius((progress / 100.0f) * mAnimDownloadProgressButton.getHeight() / 2);
50 | mAnimDownloadProgressButton.postInvalidate();
51 | }
52 |
53 | @Override
54 | public void onStartTrackingTouch(SeekBar seekBar) {
55 |
56 | }
57 |
58 | @Override
59 | public void onStopTrackingTouch(SeekBar seekBar) {
60 |
61 | }
62 | });
63 |
64 | mDescription.setText(" This is a DownloadProgressButton library with Animation," +
65 | "you can change radius,textColor,coveredTextColor,BackgroudColor,etc in" +
66 | " your code or just in xml.\n\n" +
67 | "The library is open source in github https://github.com/cctanfujun/ProgressRoundButton .\n" +
68 | "Hope you like it ");
69 | }
70 |
71 | private void showTheButton() {
72 | mAnimDownloadProgressButton.setState(AnimDownloadProgressButton.DOWNLOADING);
73 | mAnimDownloadProgressButton.setProgressText("下载中", mAnimDownloadProgressButton.getProgress() + 8);
74 |
75 | if (mAnimDownloadProgressButton.getProgress() + 10 > 100) {
76 | mAnimDownloadProgressButton.setState(AnimDownloadProgressButton.INSTALLING);
77 | mAnimDownloadProgressButton.setCurrentText("安装中");
78 | new Handler().postDelayed(new Runnable() {
79 | public void run() {
80 | mAnimDownloadProgressButton.setState(AnimDownloadProgressButton.NORMAL);
81 | mAnimDownloadProgressButton.setCurrentText("打开");
82 | }
83 | }, 2000); //2秒
84 | }
85 | }
86 |
87 |
88 | }
89 |
--------------------------------------------------------------------------------
/progressbutton/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
12 |
13 |
19 |
20 |
26 |
27 |
33 |
34 |
38 |
39 |
44 |
45 |
46 |
52 |
53 |
59 |
60 |
61 |
62 |
63 |
--------------------------------------------------------------------------------
/progressbutton/src/main/res/layout/content_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
14 |
15 |
--------------------------------------------------------------------------------
/progressbutton/src/main/res/menu/menu_main.xml:
--------------------------------------------------------------------------------
1 |
7 |
--------------------------------------------------------------------------------
/progressbutton/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenli3238/progressbutton/332bcafaddcee1c96b790121889d788c0a5a3423/progressbutton/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/progressbutton/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenli3238/progressbutton/332bcafaddcee1c96b790121889d788c0a5a3423/progressbutton/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/progressbutton/src/main/res/mipmap-xhdpi/a.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenli3238/progressbutton/332bcafaddcee1c96b790121889d788c0a5a3423/progressbutton/src/main/res/mipmap-xhdpi/a.jpg
--------------------------------------------------------------------------------
/progressbutton/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenli3238/progressbutton/332bcafaddcee1c96b790121889d788c0a5a3423/progressbutton/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/progressbutton/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenli3238/progressbutton/332bcafaddcee1c96b790121889d788c0a5a3423/progressbutton/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/progressbutton/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenli3238/progressbutton/332bcafaddcee1c96b790121889d788c0a5a3423/progressbutton/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/progressbutton/src/main/res/values-v21/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
--------------------------------------------------------------------------------
/progressbutton/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/progressbutton/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/progressbutton/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 | 180dp
6 | 16dp
7 |
8 |
--------------------------------------------------------------------------------
/progressbutton/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | work1
3 | Settings
4 |
5 |
--------------------------------------------------------------------------------
/progressbutton/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/progressbutton/src/test/java/com/js/work1/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.js.work1;
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 | }
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':progressbutton', ':mylibrary'
2 |
--------------------------------------------------------------------------------
/work.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------