├── .gitignore
├── CHANGELOG.md
├── LICENSE
├── README.md
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── library
├── build.gradle
├── gradle.properties
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── filippudak
│ │ └── ProgressPieView
│ │ └── ProgressPieView.java
│ └── res
│ └── values
│ ├── attrs.xml
│ └── colors.xml
├── maven_push.gradle
├── sample
├── build.gradle
├── images
│ ├── en_generic_rgb_wo_60.png
│ ├── googleplus.png
│ ├── linkedin.png
│ └── progresspieview.png
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── assets
│ └── fonts
│ │ └── Roboto
│ │ ├── Roboto-Italic.ttf
│ │ └── RobotoCondensed-Bold.ttf
│ ├── java
│ └── com
│ │ └── filippudak
│ │ └── ProgressPieView
│ │ └── sample
│ │ └── MainActivity.java
│ └── res
│ ├── drawable-hdpi
│ └── ic_launcher.png
│ ├── drawable-mdpi
│ └── ic_launcher.png
│ ├── drawable-xhdpi
│ └── ic_launcher.png
│ ├── drawable-xxhdpi
│ ├── ic_action_accept.png
│ └── ic_launcher.png
│ ├── drawable-xxxhdpi
│ └── ic_launcher.png
│ ├── layout
│ └── main_activity.xml
│ ├── menu
│ └── menu_main.xml
│ └── values
│ ├── colors.xml
│ ├── strings.xml
│ └── styles.xml
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | .metadata/
2 |
3 | # built application files
4 | *.apk
5 | *.ap_
6 |
7 | # files for the dex VM
8 | *.dex
9 |
10 | # Java class files
11 | *.class
12 |
13 | #DStore
14 | .DS_Store
15 |
16 | # generated files
17 | bin
18 | gen
19 | tmp/
20 | junit/
21 |
22 | # Local configuration file (sdk path, etc)
23 | local.properties
24 |
25 | # Local Eclipse settings files
26 | *.settings
27 |
28 | # Android Gradle build folders
29 | build/
30 | .gradle
31 |
32 | #IntelliJ IDEA
33 | .idea
34 | *.ipr
35 | *.iws
36 | *.iml
37 | out
38 |
39 | #Plugins and errata
40 | mirror/
41 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | Changelog
2 | =========
3 |
4 | v1.0.4
5 | ------
6 | * Updated with Lolipop Appcompat compatibility
7 |
8 | v1.0.3
9 | ------
10 | * Animation updated - now possible to animate backwards
11 |
12 | v1.0.2
13 | ------
14 | * Possibility to animate the view added
15 |
16 | v1.0.1
17 | ------
18 | * Added onMeasure behaviour to enable wrap_content and match_parent
19 |
20 | v1.0.0
21 | ------
22 | * Initial version available via Maven Central
23 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright {yyyy} {name of copyright owner}
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ProgressPieView
2 | ===============
3 |
4 | Android library for showing progress in a highly customizable pie.
5 |
6 | 
7 |
8 | Choose from the broad spectre of styleable elements:
9 |
10 | * `ppvStrokeWidth` - The width of stroke around the view.
11 | * `ppvStrokeColor` - The color of stroke around the view.
12 | * `ppvBackgroundColor` - The color of the views background.
13 | * `ppvProgressColor` - The color view of the views progress.
14 | * `ppvInverted` - Inverts the drawing of progress (fill radial only).
15 | * `ppvCounterclockwise` - Draws the progress counterclockwise (fill radial only).
16 | * `ppvProgressFillType` - Type for the progress fill (either fill radial at an angle or fill from center outwards).
17 | * `ppvImage` - image (can be hidden).
18 | * `ppvTypeface` - Font of the text.
19 | * `text` - text (can be hidden).
20 | * `textSize` - Size of the text.
21 | * `textColor` - Color of the text.
22 |
23 | Usage
24 | ======
25 |
26 | To get a feel of how it works you can also try out the sample:
27 |
28 |
29 |
31 |
32 |
33 | Find out the latest version from [Maven Central](http://search.maven.org/) or [Gradle Please](http://gradleplease.appspot.com/).
34 |
35 | build.gradle:
36 | ```
37 | dependencies {
38 | compile 'com.github.filippudak.progresspieview:library:1.0.+'
39 | }
40 | ```
41 |
42 | Example
43 | =======
44 | ```xml
45 |
61 | ```
62 | You can find more examples from code styling or xml styling in the sample that is provided.
63 |
64 | Credits
65 | =======
66 | Author : Filip Puđak (filip.pudak@gmail.com)
67 |
68 |
69 |
71 |
72 |
73 |
75 |
76 |
77 | Thanks to [+Gabriele Mariotti](https://plus.google.com/+GabrieleMariotti/) and [+Chris Banes](https://plus.google.com/+ChrisBanes/) for the maven push gradle code!
78 |
79 | Thanks to [+Prateek Srivastava](https://plus.google.com/u/0/+PrateekSrivastava/) and [+Roman Nurik](https://plus.google.com/+RomanNurik/) for the base idea which was ProgressButton!
80 |
81 | License
82 | =======
83 |
84 | Copyright 2014 Filip Puđak
85 |
86 | Licensed under the Apache License, Version 2.0 (the "License");
87 | you may not use this file except in compliance with the License.
88 | You may obtain a copy of the License at
89 |
90 | http://www.apache.org/licenses/LICENSE-2.0
91 |
92 | Unless required by applicable law or agreed to in writing, software
93 | distributed under the License is distributed on an "AS IS" BASIS,
94 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
95 | See the License for the specific language governing permissions and
96 | limitations under the License.
97 |
--------------------------------------------------------------------------------
/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 | mavenCentral()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:1.0.0-rc1'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | def isReleaseBuild() {
16 | return version.contains("SNAPSHOT") == false
17 | }
18 |
19 | allprojects {
20 | version = VERSION_NAME
21 | group = GROUP
22 |
23 | repositories {
24 | mavenCentral()
25 | }
26 | }
27 |
28 | apply plugin: 'android-reporting'
29 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | VERSION_NAME=1.0.4-SNAPSHOT
2 | VERSION_CODE=5
3 | GROUP=com.github.filippudak.progresspieview
4 |
5 | POM_DESCRIPTION=Android library for showing progress in a highly customizable pie
6 | POM_URL=https://github.com/FilipPudak/ProgressPieView
7 | POM_SCM_URL=https://github.com/FilipPudak/ProgressPieView
8 | POM_SCM_CONNECTION=scm:git@github.com:FilipPudak/ProgressPieView.git
9 | POM_SCM_DEV_CONNECTION=scm:git@github.com:FilipPudak/ProgressPieView.git
10 | POM_LICENCE_NAME=The Apache Software License, Version 2.0
11 | POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt
12 | POM_LICENCE_DIST=repo
13 | POM_DEVELOPER_ID=filippudak
14 | POM_DEVELOPER_NAME=Filip Pudak
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FilipPudak/ProgressPieView/3588947b0c68135f8cff22cf7aa9bceda9fb4c72/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sat Nov 29 14:03:30 CET 2014
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.2.1-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 |
--------------------------------------------------------------------------------
/library/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 21
5 | buildToolsVersion "21.1.1"
6 |
7 | defaultConfig {
8 | minSdkVersion 4
9 | targetSdkVersion 21
10 | versionCode Integer.parseInt(project.VERSION_CODE)
11 | versionName project.VERSION_NAME
12 | }
13 |
14 | }
15 |
16 | dependencies {
17 | compile 'com.android.support:support-v4:21.0.2'
18 | }
19 |
20 | apply from: '../maven_push.gradle'
--------------------------------------------------------------------------------
/library/gradle.properties:
--------------------------------------------------------------------------------
1 | POM_NAME=ProgressPieView Library
2 | POM_ARTIFACT_ID=library
3 | POM_PACKAGING=aar
--------------------------------------------------------------------------------
/library/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/library/src/main/java/com/filippudak/ProgressPieView/ProgressPieView.java:
--------------------------------------------------------------------------------
1 | package com.filippudak.ProgressPieView;
2 |
3 | import android.content.Context;
4 | import android.content.res.AssetManager;
5 | import android.content.res.Resources;
6 | import android.content.res.TypedArray;
7 | import android.graphics.Canvas;
8 | import android.graphics.Paint;
9 | import android.graphics.Rect;
10 | import android.graphics.RectF;
11 | import android.graphics.Typeface;
12 | import android.graphics.drawable.Drawable;
13 | import android.os.Handler;
14 | import android.os.Message;
15 | import android.text.TextUtils;
16 | import android.util.AttributeSet;
17 | import android.util.DisplayMetrics;
18 | import android.support.v4.util.LruCache;
19 | import android.view.View;
20 |
21 | public class ProgressPieView extends View {
22 |
23 | public interface OnProgressListener {
24 | public void onProgressChanged(int progress, int max);
25 | public void onProgressCompleted();
26 | }
27 |
28 | /**
29 | * Fills the progress radially in a clockwise direction.
30 | */
31 | public static final int FILL_TYPE_RADIAL = 0;
32 | /**
33 | * Fills the progress expanding from the center of the view.
34 | */
35 | public static final int FILL_TYPE_CENTER = 1;
36 |
37 | public static final int SLOW_ANIMATION_SPEED = 50;
38 | public static final int MEDIUM_ANIMATION_SPEED = 25;
39 | public static final int FAST_ANIMATION_SPEED = 1;
40 |
41 | private static final int DEFAULT_MAX = 100;
42 | private static final int DEFAULT_PROGRESS = 0;
43 | private static final int DEFAULT_START_ANGLE = -90;
44 | private static final float DEFAULT_STROKE_WIDTH = 3f;
45 | private static final float DEFAULT_TEXT_SIZE = 14f;
46 | private static final int DEFAULT_VIEW_SIZE = 96;
47 |
48 | private static LruCache sTypefaceCache = new LruCache(8);
49 |
50 | private OnProgressListener mListener;
51 | private DisplayMetrics mDisplayMetrics;
52 | private int mMax = DEFAULT_MAX;
53 | private int mProgress = DEFAULT_PROGRESS;
54 | private int mStartAngle = DEFAULT_START_ANGLE;
55 | private boolean mInverted = false;
56 | private boolean mCounterclockwise = false;
57 | private boolean mShowStroke = true;
58 | private float mStrokeWidth = DEFAULT_STROKE_WIDTH;
59 | private boolean mShowText = true;
60 | private float mTextSize = DEFAULT_TEXT_SIZE;
61 | private String mText;
62 | private String mTypeface;
63 | private boolean mShowImage = true;
64 | private Drawable mImage;
65 | private Rect mImageRect;
66 | private Paint mStrokePaint;
67 | private Paint mTextPaint;
68 | private Paint mProgressPaint;
69 | private Paint mBackgroundPaint;
70 | private RectF mInnerRectF;
71 | private int mProgressFillType = FILL_TYPE_RADIAL;
72 |
73 | private int mAnimationSpeed = MEDIUM_ANIMATION_SPEED;
74 | private AnimationHandler mAnimationHandler = new AnimationHandler();
75 |
76 | private int mViewSize;
77 |
78 | public ProgressPieView(Context context) {
79 | this(context, null);
80 | }
81 |
82 | public ProgressPieView(Context context, AttributeSet attrs) {
83 | this(context, attrs, 0);
84 | }
85 |
86 | public ProgressPieView(Context context, AttributeSet attrs, int defStyleAttr) {
87 | super(context, attrs, defStyleAttr);
88 | init(context, attrs);
89 | }
90 |
91 | private void init(Context context, AttributeSet attrs) {
92 | mDisplayMetrics = context.getResources().getDisplayMetrics();
93 |
94 | mStrokeWidth = mStrokeWidth * mDisplayMetrics.density;
95 | mTextSize = mTextSize * mDisplayMetrics.scaledDensity;
96 |
97 | final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ProgressPieView);
98 | final Resources res = getResources();
99 |
100 | mMax = a.getInteger(R.styleable.ProgressPieView_ppvMax, mMax);
101 | mProgress = a.getInteger(R.styleable.ProgressPieView_ppvProgress, mProgress);
102 | mStartAngle = a.getInt(R.styleable.ProgressPieView_ppvStartAngle, mStartAngle);
103 | mInverted = a.getBoolean(R.styleable.ProgressPieView_ppvInverted, mInverted);
104 | mCounterclockwise = a.getBoolean(R.styleable.ProgressPieView_ppvCounterclockwise, mCounterclockwise);
105 | mStrokeWidth = a.getDimension(R.styleable.ProgressPieView_ppvStrokeWidth, mStrokeWidth);
106 | mTypeface = a.getString(R.styleable.ProgressPieView_ppvTypeface);
107 | mTextSize = a.getDimension(R.styleable.ProgressPieView_android_textSize, mTextSize);
108 | mText = a.getString(R.styleable.ProgressPieView_android_text);
109 |
110 | mShowStroke = a.getBoolean(R.styleable.ProgressPieView_ppvShowStroke, mShowStroke);
111 | mShowText = a.getBoolean(R.styleable.ProgressPieView_ppvShowText, mShowText);
112 | mImage = a.getDrawable(R.styleable.ProgressPieView_ppvImage);
113 |
114 | int backgroundColor = res.getColor(R.color.default_background_color);
115 | backgroundColor = a.getColor(R.styleable.ProgressPieView_ppvBackgroundColor, backgroundColor);
116 | int progressColor = res.getColor(R.color.default_progress_color);
117 | progressColor = a.getColor(R.styleable.ProgressPieView_ppvProgressColor, progressColor);
118 | int strokeColor = res.getColor(R.color.default_stroke_color);
119 | strokeColor = a.getColor(R.styleable.ProgressPieView_ppvStrokeColor, strokeColor);
120 | int textColor = res.getColor(R.color.default_text_color);
121 | textColor = a.getColor(R.styleable.ProgressPieView_android_textColor, textColor);
122 |
123 | mProgressFillType = a.getInteger(R.styleable.ProgressPieView_ppvProgressFillType, mProgressFillType);
124 |
125 | a.recycle();
126 |
127 | mBackgroundPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
128 | mBackgroundPaint.setColor(backgroundColor);
129 | mBackgroundPaint.setStyle(Paint.Style.FILL);
130 |
131 | mProgressPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
132 | mProgressPaint.setColor(progressColor);
133 | mProgressPaint.setStyle(Paint.Style.FILL);
134 |
135 | mStrokePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
136 | mStrokePaint.setColor(strokeColor);
137 | mStrokePaint.setStyle(Paint.Style.STROKE);
138 | mStrokePaint.setStrokeWidth(mStrokeWidth);
139 |
140 | mTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
141 | mTextPaint.setColor(textColor);
142 | mTextPaint.setTextSize(mTextSize);
143 | mTextPaint.setTextAlign(Paint.Align.CENTER);
144 |
145 | mInnerRectF = new RectF();
146 | mImageRect = new Rect();
147 | }
148 |
149 | @Override
150 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
151 | super.onMeasure(widthMeasureSpec, heightMeasureSpec);
152 |
153 | int width = resolveSize(DEFAULT_VIEW_SIZE, widthMeasureSpec);
154 | int height = resolveSize(DEFAULT_VIEW_SIZE, heightMeasureSpec);
155 | mViewSize = Math.min(width, height);
156 |
157 | setMeasuredDimension(width, height);
158 | }
159 |
160 | @Override
161 | protected void onDraw(Canvas canvas) {
162 | super.onDraw(canvas);
163 | mInnerRectF.set(0, 0, mViewSize, mViewSize);
164 | mInnerRectF.offset((getWidth() - mViewSize) / 2, (getHeight() - mViewSize) / 2);
165 | if (mShowStroke) {
166 | final int halfBorder = (int) (mStrokePaint.getStrokeWidth() / 2f + 0.5f);
167 | mInnerRectF.inset(halfBorder, halfBorder);
168 | }
169 | float centerX = mInnerRectF.centerX();
170 | float centerY = mInnerRectF.centerY();
171 |
172 | canvas.drawArc(mInnerRectF, 0, 360, true, mBackgroundPaint);
173 |
174 | switch (mProgressFillType) {
175 | case FILL_TYPE_RADIAL:
176 | float sweepAngle = 360 * mProgress / mMax;
177 | if (mInverted) {
178 | sweepAngle = sweepAngle - 360;
179 | }
180 | if (mCounterclockwise) {
181 | sweepAngle = -sweepAngle;
182 | }
183 | canvas.drawArc(mInnerRectF, mStartAngle, sweepAngle, true, mProgressPaint);
184 | break;
185 | case FILL_TYPE_CENTER:
186 | float radius = (mViewSize / 2) * ((float) mProgress / mMax);
187 | if (mShowStroke) {
188 | radius = radius + 0.5f - mStrokePaint.getStrokeWidth();
189 | }
190 | canvas.drawCircle(centerX, centerY, radius, mProgressPaint);
191 | break;
192 | default:
193 | throw new IllegalArgumentException("Invalid Progress Fill = " + mProgressFillType);
194 | }
195 |
196 | if (!TextUtils.isEmpty(mText) && mShowText) {
197 | if (!TextUtils.isEmpty(mTypeface)) {
198 | Typeface typeface = sTypefaceCache.get(mTypeface);
199 | if (null == typeface && null != getResources()) {
200 | AssetManager assets = getResources().getAssets();
201 | if (null != assets) {
202 | typeface = Typeface.createFromAsset(assets, mTypeface);
203 | sTypefaceCache.put(mTypeface, typeface);
204 | }
205 | }
206 | mTextPaint.setTypeface(typeface);
207 | }
208 | int xPos = (int) centerX;
209 | int yPos = (int) (centerY - (mTextPaint.descent() + mTextPaint.ascent()) / 2);
210 | canvas.drawText(mText, xPos, yPos, mTextPaint);
211 | }
212 |
213 | if (null != mImage && mShowImage) {
214 | int drawableSize = mImage.getIntrinsicWidth();
215 | mImageRect.set(0, 0, drawableSize, drawableSize);
216 | mImageRect.offset((getWidth() - drawableSize) / 2, (getHeight() - drawableSize) / 2);
217 | mImage.setBounds(mImageRect);
218 | mImage.draw(canvas);
219 | }
220 |
221 | if (mShowStroke) {
222 | canvas.drawOval(mInnerRectF, mStrokePaint);
223 | }
224 |
225 | }
226 |
227 | /**
228 | * Gets the maximum progress value.
229 | */
230 | public int getMax() {
231 | return mMax;
232 | }
233 |
234 | /**
235 | * Sets the maximum progress value. Defaults to 100.
236 | */
237 | public void setMax(int max) {
238 | if (max <= 0 || max < mProgress) {
239 | throw new IllegalArgumentException(
240 | String.format("Max (%d) must be > 0 and >= %d", max, mProgress));
241 | }
242 | mMax = max;
243 | invalidate();
244 | }
245 |
246 | /**
247 | * Sets the animation speed used in the animateProgressFill method.
248 | */
249 | public void setAnimationSpeed(int animationSpeed){
250 | this.mAnimationSpeed = animationSpeed;
251 | }
252 |
253 | /**
254 | * Returns the current animation speed used in animateProgressFill method.
255 | */
256 | public int getAnimationSpeed(){
257 | return this.mAnimationSpeed;
258 | }
259 |
260 | /**
261 | * Animates a progress fill of the view, using a Handler.
262 | */
263 | public void animateProgressFill() {
264 | mAnimationHandler.removeMessages(0);
265 | mAnimationHandler.setAnimateTo(mMax);
266 | mAnimationHandler.sendEmptyMessage(0);
267 | invalidate();
268 | }
269 |
270 | /**
271 | * Animates a progress fill of the view, using a Handler.
272 | * @param animateTo - the progress value the animation should stop at (0 - MAX)
273 | */
274 | public void animateProgressFill(int animateTo) {
275 | mAnimationHandler.removeMessages(0);
276 | if (animateTo > mMax || animateTo < 0) {
277 | throw new IllegalArgumentException(
278 | String.format("Animation progress (%d) is greater than the max progress (%d) or lower than 0 ", animateTo, mMax));
279 | }
280 | mAnimationHandler.setAnimateTo(animateTo);
281 | mAnimationHandler.sendEmptyMessage(0);
282 | invalidate();
283 | }
284 |
285 | /**
286 | * Stops the views animation.
287 | */
288 | public void stopAnimating() {
289 | mAnimationHandler.removeMessages(0);
290 | mAnimationHandler.setAnimateTo(mProgress);
291 | invalidate();
292 | }
293 |
294 | /**
295 | * Gets the current progress from 0 to max.
296 | */
297 | public int getProgress() {
298 | return mProgress;
299 | }
300 |
301 | /**
302 | * Sets the current progress (must be between 0 and max).
303 | */
304 | public void setProgress(int progress) {
305 | if (progress > mMax || progress < 0) {
306 | throw new IllegalArgumentException(
307 | String.format("Progress (%d) must be between %d and %d", progress, 0, mMax));
308 | }
309 | mProgress = progress;
310 | if (null != mListener) {
311 | if (mProgress == mMax) {
312 | mListener.onProgressCompleted();
313 | } else {
314 | mListener.onProgressChanged(mProgress, mMax);
315 | }
316 | }
317 | invalidate();
318 | }
319 |
320 | /**
321 | * Gets the start angle the {@link #FILL_TYPE_RADIAL} uses.
322 | */
323 | public int getStartAngle() {
324 | return mStartAngle;
325 | }
326 |
327 | /**
328 | * Sets the start angle the {@link #FILL_TYPE_RADIAL} uses.
329 | * @param startAngle start angle in degrees
330 | */
331 | public void setStartAngle(int startAngle) {
332 | mStartAngle = startAngle;
333 | }
334 |
335 | /**
336 | * Gets the inverted state.
337 | */
338 | public boolean isInverted() {
339 | return mInverted;
340 | }
341 |
342 | /**
343 | * Sets the inverted state.
344 | * @param inverted draw the progress inverted or not
345 | */
346 | public void setInverted(boolean inverted) {
347 | mInverted = inverted;
348 | }
349 |
350 | /**
351 | * Gets the counterclockwise state.
352 | */
353 | public boolean isCounterclockwise() {
354 | return mCounterclockwise;
355 | }
356 |
357 | /**
358 | * Sets the counterclockwise state.
359 | * @param counterclockwise draw the progress counterclockwise or not
360 | */
361 | public void setCounterclockwise(boolean counterclockwise) {
362 | mCounterclockwise = counterclockwise;
363 | }
364 |
365 | /**
366 | * Gets the color used to display the progress of the view.
367 | */
368 | public int getProgressColor() {
369 | return mProgressPaint.getColor();
370 | }
371 |
372 | /**
373 | * Sets the color used to display the progress of the view.
374 | * @param color - color of the progress part of the view
375 | */
376 | public void setProgressColor(int color) {
377 | mProgressPaint.setColor(color);
378 | invalidate();
379 | }
380 |
381 | /**
382 | * Gets the color used to display the background of the view.
383 | */
384 | public int getBackgroundColor() {
385 | return mBackgroundPaint.getColor();
386 | }
387 |
388 | /**
389 | * Sets the color used to display the background of the view.
390 | * @param color - color of the background part of the view
391 | */
392 | public void setBackgroundColor(int color) {
393 | mBackgroundPaint.setColor(color);
394 | invalidate();
395 | }
396 |
397 | /**
398 | * Gets the color used to display the text of the view.
399 | */
400 | public int getTextColor() {
401 | return mTextPaint.getColor();
402 | }
403 |
404 | /**
405 | * Sets the color used to display the text of the view.
406 | * @param color - color of the text part of the view
407 | */
408 | public void setTextColor(int color) {
409 | mTextPaint.setColor(color);
410 | invalidate();
411 | }
412 |
413 | /**
414 | * Gets the text size in sp.
415 | */
416 | public float getTextSize() {
417 | return mTextSize;
418 | }
419 |
420 | /**
421 | * Sets the text size.
422 | * @param sizeSp in sp for the text
423 | */
424 | public void setTextSize(int sizeSp) {
425 | mTextSize = sizeSp * mDisplayMetrics.scaledDensity;
426 | mTextPaint.setTextSize(mTextSize);
427 | invalidate();
428 | }
429 |
430 | /**
431 | * Gets the text of the view.
432 | */
433 | public String getText() {
434 | return mText;
435 | }
436 |
437 | /**
438 | * Sets the text of the view.
439 | * @param text to be displayed in the view
440 | */
441 | public void setText(String text) {
442 | mText = text;
443 | invalidate();
444 | }
445 |
446 | /**
447 | * Gets the typeface of the text.
448 | */
449 | public String getTypeface() {
450 | return mTypeface;
451 | }
452 |
453 | /**
454 | * Sets the text typeface.
455 | * - i.e. fonts/Roboto/Roboto-Regular.ttf
456 | * @param typeface that the text is displayed in
457 | */
458 | public void setTypeface(String typeface) {
459 | mTypeface = typeface;
460 | invalidate();
461 | }
462 |
463 | /**
464 | * Gets the show text state.
465 | */
466 | public boolean isTextShowing() {
467 | return mShowText;
468 | }
469 |
470 | /**
471 | * Sets the show text state.
472 | * @param showText show or hide text
473 | */
474 | public void setShowText(boolean showText) {
475 | mShowText = showText;
476 | invalidate();
477 | }
478 |
479 | /**
480 | * Get the color used to display the stroke of the view.
481 | */
482 | public int getStrokeColor() {
483 | return mStrokePaint.getColor();
484 | }
485 |
486 | /**
487 | * Sets the color used to display the stroke of the view.
488 | * @param color - color of the stroke part of the view
489 | */
490 | public void setStrokeColor(int color) {
491 | mStrokePaint.setColor(color);
492 | invalidate();
493 | }
494 |
495 | /**
496 | * Gets the stroke width in dp.
497 | */
498 | public float getStrokeWidth() {
499 | return mStrokeWidth;
500 | }
501 |
502 | /**
503 | * Set the stroke width.
504 | * @param widthDp in dp for the pie border
505 | */
506 | public void setStrokeWidth(int widthDp) {
507 | mStrokeWidth = widthDp * mDisplayMetrics.density;
508 | mStrokePaint.setStrokeWidth(mStrokeWidth);
509 | invalidate();
510 | }
511 |
512 | /**
513 | * Gets the show stroke state.
514 | */
515 | public boolean isStrokeShowing() {
516 | return mShowStroke;
517 | }
518 |
519 | /**
520 | * Sets the show stroke state.
521 | * @param showStroke show or hide stroke
522 | */
523 | public void setShowStroke(boolean showStroke) {
524 | mShowStroke = showStroke;
525 | invalidate();
526 | }
527 |
528 | /**
529 | * Gets the drawable of the view.
530 | */
531 | public Drawable getImageDrawable() {
532 | return mImage;
533 | }
534 |
535 | /**
536 | * Sets the drawable of the view.
537 | * @param image drawable of the view
538 | */
539 | public void setImageDrawable(Drawable image) {
540 | mImage = image;
541 | invalidate();
542 | }
543 |
544 | /**
545 | * Sets the drawable of the view.
546 | * @param resId resource id of the view's drawable
547 | */
548 | public void setImageResource(int resId) {
549 | if (null != getResources()) {
550 | mImage = getResources().getDrawable(resId);
551 | invalidate();
552 | }
553 | }
554 |
555 | /**
556 | * Gets the show image state.
557 | */
558 | public boolean isImageShowing() {
559 | return mShowImage;
560 | }
561 |
562 | /**
563 | * Sets the show image state.
564 | * @param showImage show or hide image
565 | */
566 | public void setShowImage(boolean showImage) {
567 | mShowImage = showImage;
568 | invalidate();
569 | }
570 |
571 | /**
572 | * Gets the progress fill type.
573 | */
574 | public int getProgressFillType() {
575 | return mProgressFillType;
576 | }
577 |
578 | /**
579 | * Sets the progress fill type.
580 | * @param fillType one of {@link #FILL_TYPE_CENTER}, {@link #FILL_TYPE_RADIAL}
581 | */
582 | public void setProgressFillType(int fillType) {
583 | mProgressFillType = fillType;
584 | }
585 |
586 | /**
587 | * Sets the progress listner.
588 | * @param listener progress listener
589 | *
590 | * @see com.filippudak.ProgressPieView.ProgressPieView.OnProgressListener
591 | */
592 | public void setOnProgressListener(OnProgressListener listener) {
593 | mListener = listener;
594 | }
595 |
596 | /**
597 | * Handler used to perform the fill animation.
598 | */
599 | private class AnimationHandler extends Handler {
600 |
601 | private int mAnimateTo;
602 |
603 | public void setAnimateTo(int animateTo) {
604 | mAnimateTo = animateTo;
605 | }
606 |
607 | @Override
608 | public void handleMessage(Message msg) {
609 | if (mProgress > mAnimateTo) {
610 | setProgress(mProgress - 1);
611 | sendEmptyMessageDelayed(0, mAnimationSpeed);
612 | } else if (mProgress < mAnimateTo) {
613 | setProgress(mProgress + 1);
614 | sendEmptyMessageDelayed(0, mAnimationSpeed);
615 | } else {
616 | removeMessages(0);
617 | }
618 | }
619 | }
620 |
621 | }
622 |
--------------------------------------------------------------------------------
/library/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 |
--------------------------------------------------------------------------------
/library/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | @android:color/transparent
4 | #33b5e5
5 | #33b5e5
6 | #333333
7 |
--------------------------------------------------------------------------------
/maven_push.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'maven'
2 | apply plugin: 'signing'
3 |
4 | def sonatypeRepositoryUrl
5 | if (isReleaseBuild()) {
6 | println 'RELEASE BUILD'
7 | sonatypeRepositoryUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
8 | } else {
9 | println 'DEBUG BUILD'
10 | sonatypeRepositoryUrl = "https://oss.sonatype.org/content/repositories/snapshots/"
11 | }
12 |
13 | afterEvaluate { project ->
14 | uploadArchives {
15 | repositories {
16 | mavenDeployer {
17 | beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
18 |
19 | pom.artifactId = POM_ARTIFACT_ID
20 |
21 | repository(url: sonatypeRepositoryUrl) {
22 | authentication(userName: nexusUsername, password: nexusPassword)
23 | }
24 |
25 | pom.project {
26 | name POM_NAME
27 | packaging POM_PACKAGING
28 | description POM_DESCRIPTION
29 | url POM_URL
30 |
31 | scm {
32 | url POM_SCM_URL
33 | connection POM_SCM_CONNECTION
34 | developerConnection POM_SCM_DEV_CONNECTION
35 | }
36 |
37 | licenses {
38 | license {
39 | name POM_LICENCE_NAME
40 | url POM_LICENCE_URL
41 | distribution POM_LICENCE_DIST
42 | }
43 | }
44 |
45 | developers {
46 | developer {
47 | id POM_DEVELOPER_ID
48 | name POM_DEVELOPER_NAME
49 | }
50 | }
51 | }
52 | }
53 | }
54 | }
55 |
56 | signing {
57 | required { isReleaseBuild() && gradle.taskGraph.hasTask("uploadArchives") }
58 | sign configurations.archives
59 | }
60 |
61 | task androidJavadocs(type: Javadoc) {
62 | source = android.sourceSets.main.java
63 | }
64 |
65 | task androidJavadocsJar(type: Jar) {
66 | classifier = 'javadoc'
67 | //basename = artifact_id
68 | from androidJavadocs.destinationDir
69 | }
70 |
71 | task androidSourcesJar(type: Jar) {
72 | classifier = 'sources'
73 | //basename = artifact_id
74 | from android.sourceSets.main.java.sourceFiles
75 | }
76 |
77 | artifacts {
78 | //archives packageReleaseJar
79 | archives androidSourcesJar
80 | archives androidJavadocsJar
81 | }
82 | }
--------------------------------------------------------------------------------
/sample/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 21
5 | buildToolsVersion "21.1.1"
6 |
7 | defaultConfig {
8 | applicationId "com.filippudak.ProgressPieView.sample"
9 | minSdkVersion 8
10 | targetSdkVersion 21
11 | versionCode Integer.parseInt(project.VERSION_CODE)
12 | versionName project.VERSION_NAME
13 | }
14 |
15 | }
16 |
17 | dependencies {
18 | compile 'com.android.support:appcompat-v7:21.0.2'
19 | compile project(':library')
20 | }
21 |
--------------------------------------------------------------------------------
/sample/images/en_generic_rgb_wo_60.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FilipPudak/ProgressPieView/3588947b0c68135f8cff22cf7aa9bceda9fb4c72/sample/images/en_generic_rgb_wo_60.png
--------------------------------------------------------------------------------
/sample/images/googleplus.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FilipPudak/ProgressPieView/3588947b0c68135f8cff22cf7aa9bceda9fb4c72/sample/images/googleplus.png
--------------------------------------------------------------------------------
/sample/images/linkedin.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FilipPudak/ProgressPieView/3588947b0c68135f8cff22cf7aa9bceda9fb4c72/sample/images/linkedin.png
--------------------------------------------------------------------------------
/sample/images/progresspieview.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FilipPudak/ProgressPieView/3588947b0c68135f8cff22cf7aa9bceda9fb4c72/sample/images/progresspieview.png
--------------------------------------------------------------------------------
/sample/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
8 |
9 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/sample/src/main/assets/fonts/Roboto/Roboto-Italic.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FilipPudak/ProgressPieView/3588947b0c68135f8cff22cf7aa9bceda9fb4c72/sample/src/main/assets/fonts/Roboto/Roboto-Italic.ttf
--------------------------------------------------------------------------------
/sample/src/main/assets/fonts/Roboto/RobotoCondensed-Bold.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FilipPudak/ProgressPieView/3588947b0c68135f8cff22cf7aa9bceda9fb4c72/sample/src/main/assets/fonts/Roboto/RobotoCondensed-Bold.ttf
--------------------------------------------------------------------------------
/sample/src/main/java/com/filippudak/ProgressPieView/sample/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.filippudak.ProgressPieView.sample;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.app.ActionBarActivity;
5 | import android.view.Gravity;
6 | import android.view.Menu;
7 | import android.view.MenuItem;
8 | import android.view.ViewGroup;
9 | import android.widget.LinearLayout;
10 | import android.widget.SeekBar;
11 |
12 | import com.filippudak.ProgressPieView.ProgressPieView;
13 |
14 | public class MainActivity extends ActionBarActivity {
15 |
16 | private static final int SIZE = 96;
17 | private static final int MARGIN = 8;
18 |
19 | private SeekBar mSeekBar;
20 | private ProgressPieView mProgressPieView;
21 | private ProgressPieView mProgressPieViewInverted;
22 | private ProgressPieView mProgressPieViewXml;
23 | private ProgressPieView mProgressPieViewCode;
24 |
25 | @Override
26 | protected void onCreate(Bundle savedInstanceState) {
27 | super.onCreate(savedInstanceState);
28 | setContentView(R.layout.main_activity);
29 |
30 | // Code version
31 | float density = getResources().getDisplayMetrics().density;
32 | int size = (int) (density * SIZE);
33 | int margin = (int) (density * MARGIN);
34 | LinearLayout container = (LinearLayout) findViewById(R.id.container);
35 | mProgressPieViewCode = new ProgressPieView(this);
36 | final LinearLayout.LayoutParams layoutParams
37 | = new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.MATCH_PARENT, 1);
38 | layoutParams.gravity = Gravity.CENTER;
39 | layoutParams.setMargins(margin, margin, margin, margin);
40 | mProgressPieViewCode.setLayoutParams(layoutParams);
41 | mProgressPieViewCode.setText("Code");
42 | mProgressPieViewCode.setTextSize(22);
43 | mProgressPieViewCode.setTextColor(getResources().getColor(R.color.holo_orange_light));
44 | mProgressPieViewCode.setBackgroundColor(getResources().getColor(R.color.holo_red_dark));
45 | mProgressPieViewCode.setProgressColor(getResources().getColor(R.color.holo_green_dark));
46 | mProgressPieViewCode.setStrokeColor(getResources().getColor(R.color.holo_blue_dark));
47 | mProgressPieViewCode.setTypeface("fonts/Roboto/Roboto-Italic.ttf");
48 | mProgressPieViewCode.setStartAngle(720);
49 | container.addView(mProgressPieViewCode);
50 |
51 | // Default version
52 | mProgressPieView = (ProgressPieView) findViewById(R.id.progressPieView);
53 | mProgressPieView.setOnProgressListener(new ProgressPieView.OnProgressListener() {
54 | @Override
55 | public void onProgressChanged(int progress, int max) {
56 | if (!mProgressPieView.isTextShowing()) {
57 | mProgressPieView.setShowText(true);
58 | mProgressPieView.setShowImage(false);
59 | }
60 | }
61 |
62 | @Override
63 | public void onProgressCompleted() {
64 | if (!mProgressPieView.isImageShowing()) {
65 | mProgressPieView.setShowImage(true);
66 | }
67 | mProgressPieView.setShowText(false);
68 | mProgressPieView.setImageResource(R.drawable.ic_action_accept);
69 | }
70 | });
71 |
72 | // Inverted default version
73 | mProgressPieViewInverted = (ProgressPieView) findViewById(R.id.progressPieViewInverted);
74 |
75 | // XML version
76 | mProgressPieViewXml = (ProgressPieView) findViewById(R.id.progressPieViewXml);
77 |
78 | // SeekBar
79 | mSeekBar = (SeekBar) findViewById(R.id.seekbar);
80 | mSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
81 | @Override
82 | public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
83 | mProgressPieView.setProgress(i);
84 | mProgressPieView.setText(i + "%");
85 | mProgressPieViewInverted.setProgress(i);
86 | mProgressPieViewXml.setProgress(i);
87 | mProgressPieViewCode.setProgress(i);
88 | }
89 |
90 | @Override
91 | public void onStartTrackingTouch(SeekBar seekBar) {
92 |
93 | }
94 |
95 | @Override
96 | public void onStopTrackingTouch(SeekBar seekBar) {
97 |
98 | }
99 | });
100 | }
101 |
102 | @Override
103 | public boolean onCreateOptionsMenu(Menu menu) {
104 | getMenuInflater().inflate(R.menu.menu_main, menu);
105 | return super.onCreateOptionsMenu(menu);
106 | }
107 |
108 | @Override
109 | public boolean onOptionsItemSelected(MenuItem item) {
110 | if (item.getItemId() == R.id.menu_item_animate) {
111 | mProgressPieView.setProgress(0);
112 | mProgressPieView.animateProgressFill();
113 | mProgressPieViewInverted.setProgress(0);
114 | mProgressPieViewInverted.animateProgressFill();
115 | mProgressPieViewXml.setProgress(0);
116 | mProgressPieViewXml.animateProgressFill();
117 | mProgressPieViewCode.setProgress(0);
118 | mProgressPieViewCode.animateProgressFill();
119 | }
120 | return super.onOptionsItemSelected(item);
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FilipPudak/ProgressPieView/3588947b0c68135f8cff22cf7aa9bceda9fb4c72/sample/src/main/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FilipPudak/ProgressPieView/3588947b0c68135f8cff22cf7aa9bceda9fb4c72/sample/src/main/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FilipPudak/ProgressPieView/3588947b0c68135f8cff22cf7aa9bceda9fb4c72/sample/src/main/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/drawable-xxhdpi/ic_action_accept.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FilipPudak/ProgressPieView/3588947b0c68135f8cff22cf7aa9bceda9fb4c72/sample/src/main/res/drawable-xxhdpi/ic_action_accept.png
--------------------------------------------------------------------------------
/sample/src/main/res/drawable-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FilipPudak/ProgressPieView/3588947b0c68135f8cff22cf7aa9bceda9fb4c72/sample/src/main/res/drawable-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/drawable-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FilipPudak/ProgressPieView/3588947b0c68135f8cff22cf7aa9bceda9fb4c72/sample/src/main/res/drawable-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/layout/main_activity.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 |
17 |
18 |
24 |
25 |
32 |
33 |
43 |
44 |
60 |
61 |
62 |
63 |
--------------------------------------------------------------------------------
/sample/src/main/res/menu/menu_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | #ff33b5e5
5 |
6 | #ff99cc00
7 |
8 | #ffff4444
9 |
10 | #ff0099cc
11 |
12 | #ff669900
13 |
14 | #ffcc0000
15 |
16 | #ffaa66cc
17 |
18 | #ffffbb33
19 |
20 | #ffff8800
21 |
22 | #ff00ddff
23 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | ProgressPieView
3 |
4 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':sample', ':library'
2 |
--------------------------------------------------------------------------------