├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── mipmap-hdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── values
│ │ │ │ ├── strings.xml
│ │ │ │ ├── colors.xml
│ │ │ │ ├── dimens.xml
│ │ │ │ ├── styles.xml
│ │ │ │ └── attrs.xml
│ │ │ ├── values-w820dp
│ │ │ │ └── dimens.xml
│ │ │ └── layout
│ │ │ │ └── activity_main.xml
│ │ ├── java
│ │ │ └── id
│ │ │ │ └── co
│ │ │ │ └── blogspot
│ │ │ │ └── wimsonevel
│ │ │ │ └── countdown_animation
│ │ │ │ ├── Utils.java
│ │ │ │ ├── MainActivity.java
│ │ │ │ └── DonutProgress.java
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── id
│ │ │ └── co
│ │ │ └── blogspot
│ │ │ └── wimsonevel
│ │ │ └── countdown_animation
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── id
│ │ └── co
│ │ └── blogspot
│ │ └── wimsonevel
│ │ └── countdown_animation
│ │ └── ExampleInstrumentedTest.java
├── proguard-rules.pro
└── build.gradle
├── settings.gradle
├── .idea
├── copyright
│ └── profiles_settings.xml
├── modules.xml
├── runConfigurations.xml
├── gradle.xml
├── compiler.xml
└── misc.xml
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── README.md
├── gradle.properties
├── gradlew.bat
└── gradlew
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wimsonevel/Countdown-Animation/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wimsonevel/Countdown-Animation/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wimsonevel/Countdown-Animation/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wimsonevel/Countdown-Animation/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wimsonevel/Countdown-Animation/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wimsonevel/Countdown-Animation/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Countdown-Animation
2 | Simple Countdown with Circular Progress Animation
3 |
4 |
5 | 
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Countdown-Animation
3 | Start
4 | Stop
5 | Reset
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Dec 28 10:00:20 PST 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.14.1-all.zip
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/test/java/id/co/blogspot/wimsonevel/countdown_animation/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package id.co.blogspot.wimsonevel.countdown_animation;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/app/src/main/java/id/co/blogspot/wimsonevel/countdown_animation/Utils.java:
--------------------------------------------------------------------------------
1 | package id.co.blogspot.wimsonevel.countdown_animation;
2 |
3 | import android.content.res.Resources;
4 |
5 | /**
6 | * Created by bruce on 14-11-6.
7 | */
8 |
9 | public final class Utils {
10 |
11 | private Utils() {
12 | }
13 |
14 | public static float dp2px(Resources resources, float dp) {
15 | final float scale = resources.getDisplayMetrics().density;
16 | return dp * scale + 0.5f;
17 | }
18 |
19 | public static float sp2px(Resources resources, float sp){
20 | final float scale = resources.getDisplayMetrics().scaledDensity;
21 | return sp * scale;
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/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 /Users/kwikkunusantara/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 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion "25.0.2"
6 | defaultConfig {
7 | applicationId "id.co.blogspot.wimsonevel.countdown_animation"
8 | minSdkVersion 16
9 | targetSdkVersion 25
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 | compile 'com.android.support:appcompat-v7:25.3.1'
24 |
25 | testCompile 'junit:junit:4.12'
26 | }
27 |
--------------------------------------------------------------------------------
/.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 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/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 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/id/co/blogspot/wimsonevel/countdown_animation/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package id.co.blogspot.wimsonevel.countdown_animation;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("id.co.blogspot.wimsonevel.countdown_animation", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/res/values/attrs.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 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
13 |
14 |
23 |
24 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/app/src/main/java/id/co/blogspot/wimsonevel/countdown_animation/MainActivity.java:
--------------------------------------------------------------------------------
1 | package id.co.blogspot.wimsonevel.countdown_animation;
2 |
3 | import android.os.CountDownTimer;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.os.Bundle;
6 | import android.view.View;
7 | import android.widget.Button;
8 |
9 | public class MainActivity extends AppCompatActivity implements View.OnClickListener{
10 |
11 | private CountDownTimer countDownTimer;
12 | private DonutProgress countDownProgress;
13 | private Button btnStart;
14 |
15 | private int status = 0;
16 | private final long startTime = 10 * 1000;
17 | private final long interval = 1 * 1000;
18 |
19 | @Override
20 | protected void onCreate(Bundle savedInstanceState) {
21 | super.onCreate(savedInstanceState);
22 | setContentView(R.layout.activity_main);
23 |
24 | countDownProgress = (DonutProgress) findViewById(R.id.countdown_progress);
25 | btnStart = (Button) findViewById(R.id.btn_start);
26 |
27 | countDownProgress.setProgress(10);
28 |
29 | btnStart.setOnClickListener(this);
30 |
31 | countDownTimer = new CountDownTimer(startTime, interval) {
32 | @Override
33 | public void onTick(long millisUntilFinished) {
34 | countDownProgress.setProgress((int) millisUntilFinished / 1000);
35 | }
36 |
37 | @Override
38 | public void onFinish() {
39 | countDownProgress.setProgress(0);
40 | status = 2;
41 | btnStart.setText(R.string.reset);
42 | }
43 | };
44 | }
45 |
46 | @Override
47 | public void onClick(View view) {
48 | if (status == 0) {
49 | countDownTimer.start();
50 | status = 1;
51 | btnStart.setText(R.string.stop);
52 | } else if(status == 1){
53 | countDownTimer.cancel();
54 | countDownProgress.setProgress(10);
55 | status = 0;
56 | btnStart.setText(R.string.start);
57 | } else {
58 | countDownProgress.setProgress(10);
59 | status = 0;
60 | btnStart.setText(R.string.start);
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/.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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/app/src/main/java/id/co/blogspot/wimsonevel/countdown_animation/DonutProgress.java:
--------------------------------------------------------------------------------
1 | package id.co.blogspot.wimsonevel.countdown_animation;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.graphics.Bitmap;
6 | import android.graphics.BitmapFactory;
7 | import android.graphics.Canvas;
8 | import android.graphics.Color;
9 | import android.graphics.Paint;
10 | import android.graphics.RectF;
11 | import android.os.Bundle;
12 | import android.os.Parcelable;
13 | import android.text.TextPaint;
14 | import android.text.TextUtils;
15 | import android.util.AttributeSet;
16 | import android.view.View;
17 |
18 | /**
19 | * Created by bruce on 11/4/14.
20 | */
21 |
22 | public class DonutProgress extends View {
23 |
24 | private Paint finishedPaint;
25 | private Paint unfinishedPaint;
26 | private Paint innerCirclePaint;
27 |
28 | protected Paint textPaint;
29 | protected Paint innerBottomTextPaint;
30 |
31 | private RectF finishedOuterRect = new RectF();
32 | private RectF unfinishedOuterRect = new RectF();
33 |
34 | private int attributeResourceId = 0;
35 | private boolean showText;
36 | private float textSize;
37 | private int textColor;
38 | private int innerBottomTextColor;
39 | private int progress = 0;
40 | private int max;
41 | private int finishedStrokeColor;
42 | private int unfinishedStrokeColor;
43 | private int startingDegree;
44 | private float finishedStrokeWidth;
45 | private float unfinishedStrokeWidth;
46 | private int innerBackgroundColor;
47 | private String prefixText = "";
48 | private String suffixText = "";
49 | private String text = null;
50 | private float innerBottomTextSize;
51 | private String innerBottomText;
52 | private float innerBottomTextHeight;
53 |
54 | private final float default_stroke_width;
55 | private final int default_finished_color = Color.rgb(66, 145, 241);
56 | private final int default_unfinished_color = Color.rgb(204, 204, 204);
57 | private final int default_text_color = Color.rgb(66, 145, 241);
58 | private final int default_inner_bottom_text_color = Color.rgb(66, 145, 241);
59 | private final int default_inner_background_color = Color.TRANSPARENT;
60 | private final int default_max = 100;
61 | private final int default_startingDegree = 0;
62 | private final float default_text_size;
63 | private final float default_inner_bottom_text_size;
64 | private final int min_size;
65 |
66 |
67 | private static final String INSTANCE_STATE = "saved_instance";
68 | private static final String INSTANCE_TEXT_COLOR = "text_color";
69 | private static final String INSTANCE_TEXT_SIZE = "text_size";
70 | private static final String INSTANCE_TEXT = "text";
71 | private static final String INSTANCE_INNER_BOTTOM_TEXT_SIZE = "inner_bottom_text_size";
72 | private static final String INSTANCE_INNER_BOTTOM_TEXT = "inner_bottom_text";
73 | private static final String INSTANCE_INNER_BOTTOM_TEXT_COLOR = "inner_bottom_text_color";
74 | private static final String INSTANCE_FINISHED_STROKE_COLOR = "finished_stroke_color";
75 | private static final String INSTANCE_UNFINISHED_STROKE_COLOR = "unfinished_stroke_color";
76 | private static final String INSTANCE_MAX = "max";
77 | private static final String INSTANCE_PROGRESS = "progress";
78 | private static final String INSTANCE_SUFFIX = "suffix";
79 | private static final String INSTANCE_PREFIX = "prefix";
80 | private static final String INSTANCE_FINISHED_STROKE_WIDTH = "finished_stroke_width";
81 | private static final String INSTANCE_UNFINISHED_STROKE_WIDTH = "unfinished_stroke_width";
82 | private static final String INSTANCE_BACKGROUND_COLOR = "inner_background_color";
83 | private static final String INSTANCE_STARTING_DEGREE = "starting_degree";
84 | private static final String INSTANCE_INNER_DRAWABLE = "inner_drawable";
85 |
86 | public DonutProgress(Context context) {
87 | this(context, null);
88 | }
89 |
90 | public DonutProgress(Context context, AttributeSet attrs) {
91 | this(context, attrs, 0);
92 | }
93 |
94 | public DonutProgress(Context context, AttributeSet attrs, int defStyleAttr) {
95 | super(context, attrs, defStyleAttr);
96 |
97 | default_text_size = Utils.sp2px(getResources(), 18);
98 | min_size = (int) Utils.dp2px(getResources(), 100);
99 | default_stroke_width = Utils.dp2px(getResources(), 10);
100 | default_inner_bottom_text_size = Utils.sp2px(getResources(), 18);
101 |
102 | final TypedArray attributes = context.getTheme().obtainStyledAttributes(attrs, R.styleable.DonutProgress, defStyleAttr, 0);
103 | initByAttributes(attributes);
104 | attributes.recycle();
105 |
106 | initPainters();
107 | }
108 |
109 | protected void initPainters() {
110 | if (showText) {
111 | textPaint = new TextPaint();
112 | textPaint.setColor(textColor);
113 | textPaint.setTextSize(textSize);
114 | textPaint.setAntiAlias(true);
115 |
116 | innerBottomTextPaint = new TextPaint();
117 | innerBottomTextPaint.setColor(innerBottomTextColor);
118 | innerBottomTextPaint.setTextSize(innerBottomTextSize);
119 | innerBottomTextPaint.setAntiAlias(true);
120 | }
121 |
122 | finishedPaint = new Paint();
123 | finishedPaint.setColor(finishedStrokeColor);
124 | finishedPaint.setStyle(Paint.Style.STROKE);
125 | finishedPaint.setAntiAlias(true);
126 | finishedPaint.setStrokeWidth(finishedStrokeWidth);
127 |
128 | unfinishedPaint = new Paint();
129 | unfinishedPaint.setColor(unfinishedStrokeColor);
130 | unfinishedPaint.setStyle(Paint.Style.STROKE);
131 | unfinishedPaint.setAntiAlias(true);
132 | unfinishedPaint.setStrokeWidth(unfinishedStrokeWidth);
133 |
134 | innerCirclePaint = new Paint();
135 | innerCirclePaint.setColor(innerBackgroundColor);
136 | innerCirclePaint.setAntiAlias(true);
137 | }
138 |
139 | protected void initByAttributes(TypedArray attributes) {
140 | finishedStrokeColor = attributes.getColor(R.styleable.DonutProgress_donut_finished_color, default_finished_color);
141 | unfinishedStrokeColor = attributes.getColor(R.styleable.DonutProgress_donut_unfinished_color, default_unfinished_color);
142 | showText = attributes.getBoolean(R.styleable.DonutProgress_donut_show_text, true);
143 | attributeResourceId = attributes.getResourceId(R.styleable.DonutProgress_donut_inner_drawable, 0);
144 |
145 | setMax(attributes.getInt(R.styleable.DonutProgress_donut_max, default_max));
146 | setProgress(attributes.getInt(R.styleable.DonutProgress_donut_progress, 0));
147 | finishedStrokeWidth = attributes.getDimension(R.styleable.DonutProgress_donut_finished_stroke_width, default_stroke_width);
148 | unfinishedStrokeWidth = attributes.getDimension(R.styleable.DonutProgress_donut_unfinished_stroke_width, default_stroke_width);
149 |
150 | if (showText) {
151 | if (attributes.getString(R.styleable.DonutProgress_donut_prefix_text) != null) {
152 | prefixText = attributes.getString(R.styleable.DonutProgress_donut_prefix_text);
153 | }
154 | if (attributes.getString(R.styleable.DonutProgress_donut_suffix_text) != null) {
155 | suffixText = attributes.getString(R.styleable.DonutProgress_donut_suffix_text);
156 | }
157 | if (attributes.getString(R.styleable.DonutProgress_donut_text) != null) {
158 | text = attributes.getString(R.styleable.DonutProgress_donut_text);
159 | }
160 |
161 | textColor = attributes.getColor(R.styleable.DonutProgress_donut_text_color, default_text_color);
162 | textSize = attributes.getDimension(R.styleable.DonutProgress_donut_text_size, default_text_size);
163 | innerBottomTextSize = attributes.getDimension(R.styleable.DonutProgress_donut_inner_bottom_text_size, default_inner_bottom_text_size);
164 | innerBottomTextColor = attributes.getColor(R.styleable.DonutProgress_donut_inner_bottom_text_color, default_inner_bottom_text_color);
165 | innerBottomText = attributes.getString(R.styleable.DonutProgress_donut_inner_bottom_text);
166 | }
167 |
168 | innerBottomTextSize = attributes.getDimension(R.styleable.DonutProgress_donut_inner_bottom_text_size, default_inner_bottom_text_size);
169 | innerBottomTextColor = attributes.getColor(R.styleable.DonutProgress_donut_inner_bottom_text_color, default_inner_bottom_text_color);
170 | innerBottomText = attributes.getString(R.styleable.DonutProgress_donut_inner_bottom_text);
171 |
172 | startingDegree = attributes.getInt(R.styleable.DonutProgress_donut_circle_starting_degree, default_startingDegree);
173 | innerBackgroundColor = attributes.getColor(R.styleable.DonutProgress_donut_background_color, default_inner_background_color);
174 | }
175 |
176 | @Override
177 | public void invalidate() {
178 | initPainters();
179 | super.invalidate();
180 | }
181 |
182 | public boolean isShowText() {
183 | return showText;
184 | }
185 |
186 | public void setShowText(boolean showText) {
187 | this.showText = showText;
188 | }
189 |
190 | public float getFinishedStrokeWidth() {
191 | return finishedStrokeWidth;
192 | }
193 |
194 | public void setFinishedStrokeWidth(float finishedStrokeWidth) {
195 | this.finishedStrokeWidth = finishedStrokeWidth;
196 | this.invalidate();
197 | }
198 |
199 | public float getUnfinishedStrokeWidth() {
200 | return unfinishedStrokeWidth;
201 | }
202 |
203 | public void setUnfinishedStrokeWidth(float unfinishedStrokeWidth) {
204 | this.unfinishedStrokeWidth = unfinishedStrokeWidth;
205 | this.invalidate();
206 | }
207 |
208 | private float getProgressAngle() {
209 | return getProgress() / (float) max * 360f;
210 | }
211 |
212 | public float getProgress() {
213 | return progress;
214 | }
215 |
216 | public void setProgress(int progress) {
217 | this.progress = progress;
218 | if (this.progress > getMax()) {
219 | this.progress %= getMax();
220 | }
221 | invalidate();
222 | }
223 |
224 | public int getMax() {
225 | return max;
226 | }
227 |
228 | public void setMax(int max) {
229 | if (max > 0) {
230 | this.max = max;
231 | invalidate();
232 | }
233 | }
234 |
235 | public float getTextSize() {
236 | return textSize;
237 | }
238 |
239 | public void setTextSize(float textSize) {
240 | this.textSize = textSize;
241 | this.invalidate();
242 | }
243 |
244 | public int getTextColor() {
245 | return textColor;
246 | }
247 |
248 | public void setTextColor(int textColor) {
249 | this.textColor = textColor;
250 | this.invalidate();
251 | }
252 |
253 | public int getFinishedStrokeColor() {
254 | return finishedStrokeColor;
255 | }
256 |
257 | public void setFinishedStrokeColor(int finishedStrokeColor) {
258 | this.finishedStrokeColor = finishedStrokeColor;
259 | this.invalidate();
260 | }
261 |
262 | public int getUnfinishedStrokeColor() {
263 | return unfinishedStrokeColor;
264 | }
265 |
266 | public void setUnfinishedStrokeColor(int unfinishedStrokeColor) {
267 | this.unfinishedStrokeColor = unfinishedStrokeColor;
268 | this.invalidate();
269 | }
270 |
271 | public String getText() {
272 | return text;
273 | }
274 |
275 | public void setText(String text) {
276 | this.text = text;
277 | this.invalidate();
278 | }
279 |
280 | public String getSuffixText() {
281 | return suffixText;
282 | }
283 |
284 | public void setSuffixText(String suffixText) {
285 | this.suffixText = suffixText;
286 | this.invalidate();
287 | }
288 |
289 | public String getPrefixText() {
290 | return prefixText;
291 | }
292 |
293 | public void setPrefixText(String prefixText) {
294 | this.prefixText = prefixText;
295 | this.invalidate();
296 | }
297 |
298 | public int getInnerBackgroundColor() {
299 | return innerBackgroundColor;
300 | }
301 |
302 | public void setInnerBackgroundColor(int innerBackgroundColor) {
303 | this.innerBackgroundColor = innerBackgroundColor;
304 | this.invalidate();
305 | }
306 |
307 |
308 | public String getInnerBottomText() {
309 | return innerBottomText;
310 | }
311 |
312 | public void setInnerBottomText(String innerBottomText) {
313 | this.innerBottomText = innerBottomText;
314 | this.invalidate();
315 | }
316 |
317 |
318 | public float getInnerBottomTextSize() {
319 | return innerBottomTextSize;
320 | }
321 |
322 | public void setInnerBottomTextSize(float innerBottomTextSize) {
323 | this.innerBottomTextSize = innerBottomTextSize;
324 | this.invalidate();
325 | }
326 |
327 | public int getInnerBottomTextColor() {
328 | return innerBottomTextColor;
329 | }
330 |
331 | public void setInnerBottomTextColor(int innerBottomTextColor) {
332 | this.innerBottomTextColor = innerBottomTextColor;
333 | this.invalidate();
334 | }
335 |
336 | public int getStartingDegree() {
337 | return startingDegree;
338 | }
339 |
340 | public void setStartingDegree(int startingDegree) {
341 | this.startingDegree = startingDegree;
342 | this.invalidate();
343 | }
344 |
345 | public int getAttributeResourceId() {
346 | return attributeResourceId;
347 | }
348 |
349 | public void setAttributeResourceId(int attributeResourceId) {
350 | this.attributeResourceId = attributeResourceId;
351 | }
352 |
353 | @Override
354 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
355 | setMeasuredDimension(measure(widthMeasureSpec), measure(heightMeasureSpec));
356 |
357 | //TODO calculate inner circle height and then position bottom text at the bottom (3/4)
358 | innerBottomTextHeight = getHeight() - (getHeight() * 3) / 4;
359 | }
360 |
361 | private int measure(int measureSpec) {
362 | int result;
363 | int mode = MeasureSpec.getMode(measureSpec);
364 | int size = MeasureSpec.getSize(measureSpec);
365 | if (mode == MeasureSpec.EXACTLY) {
366 | result = size;
367 | } else {
368 | result = min_size;
369 | if (mode == MeasureSpec.AT_MOST) {
370 | result = Math.min(result, size);
371 | }
372 | }
373 | return result;
374 | }
375 |
376 | @Override
377 | protected void onDraw(Canvas canvas) {
378 | super.onDraw(canvas);
379 |
380 | float delta = Math.max(finishedStrokeWidth, unfinishedStrokeWidth);
381 | finishedOuterRect.set(delta,
382 | delta,
383 | getWidth() - delta,
384 | getHeight() - delta);
385 | unfinishedOuterRect.set(delta,
386 | delta,
387 | getWidth() - delta,
388 | getHeight() - delta);
389 |
390 | float innerCircleRadius = (getWidth() - Math.min(finishedStrokeWidth, unfinishedStrokeWidth) + Math.abs(finishedStrokeWidth - unfinishedStrokeWidth)) / 2f;
391 | canvas.drawCircle(getWidth() / 2.0f, getHeight() / 2.0f, innerCircleRadius, innerCirclePaint);
392 | canvas.drawArc(finishedOuterRect, getStartingDegree(), getProgressAngle(), false, finishedPaint);
393 | canvas.drawArc(unfinishedOuterRect, getStartingDegree() + getProgressAngle(), 360 - getProgressAngle(), false, unfinishedPaint);
394 |
395 | if (showText) {
396 | String text = this.text != null ? this.text : prefixText + progress + suffixText;
397 | if (!TextUtils.isEmpty(text)) {
398 | float textHeight = textPaint.descent() + textPaint.ascent();
399 | canvas.drawText(text, (getWidth() - textPaint.measureText(text)) / 2.0f, (getWidth() - textHeight) / 2.0f, textPaint);
400 | }
401 |
402 | if (!TextUtils.isEmpty(getInnerBottomText())) {
403 | innerBottomTextPaint.setTextSize(innerBottomTextSize);
404 | float bottomTextBaseline = getHeight() - innerBottomTextHeight - (textPaint.descent() + textPaint.ascent()) / 2;
405 | canvas.drawText(getInnerBottomText(), (getWidth() - innerBottomTextPaint.measureText(getInnerBottomText())) / 2.0f, bottomTextBaseline, innerBottomTextPaint);
406 | }
407 | }
408 |
409 | if (attributeResourceId != 0) {
410 | Bitmap bitmap = BitmapFactory.decodeResource(getResources(), attributeResourceId);
411 | canvas.drawBitmap(bitmap, (getWidth() - bitmap.getWidth()) / 2.0f, (getHeight() - bitmap.getHeight()) / 2.0f, null);
412 | }
413 | }
414 |
415 | @Override
416 | protected Parcelable onSaveInstanceState() {
417 | final Bundle bundle = new Bundle();
418 | bundle.putParcelable(INSTANCE_STATE, super.onSaveInstanceState());
419 | bundle.putInt(INSTANCE_TEXT_COLOR, getTextColor());
420 | bundle.putFloat(INSTANCE_TEXT_SIZE, getTextSize());
421 | bundle.putFloat(INSTANCE_INNER_BOTTOM_TEXT_SIZE, getInnerBottomTextSize());
422 | bundle.putFloat(INSTANCE_INNER_BOTTOM_TEXT_COLOR, getInnerBottomTextColor());
423 | bundle.putString(INSTANCE_INNER_BOTTOM_TEXT, getInnerBottomText());
424 | bundle.putInt(INSTANCE_INNER_BOTTOM_TEXT_COLOR, getInnerBottomTextColor());
425 | bundle.putInt(INSTANCE_FINISHED_STROKE_COLOR, getFinishedStrokeColor());
426 | bundle.putInt(INSTANCE_UNFINISHED_STROKE_COLOR, getUnfinishedStrokeColor());
427 | bundle.putInt(INSTANCE_MAX, getMax());
428 | bundle.putInt(INSTANCE_STARTING_DEGREE, getStartingDegree());
429 | bundle.putFloat(INSTANCE_PROGRESS, getProgress());
430 | bundle.putString(INSTANCE_SUFFIX, getSuffixText());
431 | bundle.putString(INSTANCE_PREFIX, getPrefixText());
432 | bundle.putString(INSTANCE_TEXT, getText());
433 | bundle.putFloat(INSTANCE_FINISHED_STROKE_WIDTH, getFinishedStrokeWidth());
434 | bundle.putFloat(INSTANCE_UNFINISHED_STROKE_WIDTH, getUnfinishedStrokeWidth());
435 | bundle.putInt(INSTANCE_BACKGROUND_COLOR, getInnerBackgroundColor());
436 | bundle.putInt(INSTANCE_INNER_DRAWABLE, getAttributeResourceId());
437 | return bundle;
438 | }
439 |
440 | @Override
441 | protected void onRestoreInstanceState(Parcelable state) {
442 | if (state instanceof Bundle) {
443 | final Bundle bundle = (Bundle) state;
444 | textColor = bundle.getInt(INSTANCE_TEXT_COLOR);
445 | textSize = bundle.getFloat(INSTANCE_TEXT_SIZE);
446 | innerBottomTextSize = bundle.getFloat(INSTANCE_INNER_BOTTOM_TEXT_SIZE);
447 | innerBottomText = bundle.getString(INSTANCE_INNER_BOTTOM_TEXT);
448 | innerBottomTextColor = bundle.getInt(INSTANCE_INNER_BOTTOM_TEXT_COLOR);
449 | finishedStrokeColor = bundle.getInt(INSTANCE_FINISHED_STROKE_COLOR);
450 | unfinishedStrokeColor = bundle.getInt(INSTANCE_UNFINISHED_STROKE_COLOR);
451 | finishedStrokeWidth = bundle.getFloat(INSTANCE_FINISHED_STROKE_WIDTH);
452 | unfinishedStrokeWidth = bundle.getFloat(INSTANCE_UNFINISHED_STROKE_WIDTH);
453 | innerBackgroundColor = bundle.getInt(INSTANCE_BACKGROUND_COLOR);
454 | attributeResourceId = bundle.getInt(INSTANCE_INNER_DRAWABLE);
455 | initPainters();
456 | setMax(bundle.getInt(INSTANCE_MAX));
457 | setStartingDegree(bundle.getInt(INSTANCE_STARTING_DEGREE));
458 | setProgress(bundle.getInt(INSTANCE_PROGRESS));
459 | suffixText = bundle.getString(INSTANCE_SUFFIX);
460 | prefixText = bundle.getString(INSTANCE_PREFIX);
461 | text = bundle.getString(INSTANCE_TEXT);
462 | super.onRestoreInstanceState(bundle.getParcelable(INSTANCE_STATE));
463 | return;
464 | }
465 | super.onRestoreInstanceState(state);
466 | }
467 | public void setDonut_progress(String percent){
468 | if(!TextUtils.isEmpty(percent)){
469 | setProgress(Integer.parseInt(percent));
470 | }
471 | }
472 |
473 | }
474 |
--------------------------------------------------------------------------------