├── .gitignore
├── .idea
├── codeStyles
│ └── Project.xml
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── encodings.xml
├── gradle.xml
├── misc.xml
├── modules.xml
├── runConfigurations.xml
└── vcs.xml
├── README.md
├── build.gradle
├── example
├── .gitignore
├── build.gradle
├── example-release.apk
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── wldev
│ │ └── example
│ │ └── MainActivity.java
│ └── res
│ ├── layout
│ └── activity_main.xml
│ ├── mipmap-hdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-mdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xxhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xxxhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ └── values
│ ├── colors.xml
│ ├── strings.xml
│ └── styles.xml
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── library
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── ekalips
│ │ └── fancybuttonproj
│ │ ├── FancyButton.java
│ │ └── Utils.java
│ └── res
│ └── values
│ └── attrs.xml
├── settings.gradle
└── showcase
└── demo.gif
/.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 |
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.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 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
21 |
22 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 | 1.8
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [  ](https://bintray.com/ekalips/FancyProgressButton/FancyProgressButton/_latestVersion)
2 |
3 |
4 | # FancyButtonProj
5 |
6 | Juste a funcy button with progress bar
7 |
8 |
9 |
10 | # List of attributes:
11 |
12 | 1) ```app:f_btnStyle with values "stroke" , "fill", "stroke_fill". [default - stroke]```
13 |
14 | Use this for defining style of your button
15 |
16 | 2) ```app:f_text [default - ""]```
17 |
18 | 3) ```app:f_textColor [default - black]```
19 |
20 | 4) ```app:f_fillColor [default - transperent]```
21 |
22 | Use this for changing fill color of button (for "fill" and "stroke_fill" styles)
23 |
24 | 5) ```app:f_strokeColor [default - black]```
25 |
26 | Use this for changing stroke color of button (for "fill" and "stroke_fill" styles)
27 |
28 | 6) ```app:f_progressColor [default - black]```
29 |
30 | Use this for changing color of progress bar (for "fill" and "stroke_fill" styles)
31 |
32 | 7) ```app:f_hideFillAfterCollapse [default - false]```
33 |
34 | Use this for determing if button will stay on screen after collapsing (for "fill" and "stroke_fill", looks like little circle inside of progress bar)
35 |
36 | 8) ```app:f_strokeWidth [default - 4]```
37 |
38 | Determins stroke width (for "stroke" and "stroke_fill")
39 |
40 | 9) ```app:f_capsText [default - true]```
41 |
42 | If true will make all text uppercase
43 |
44 |
45 |
46 | # Example of usage:
47 |
48 | xmlns:app="http://schemas.android.com/apk/res-auto"
49 |
50 |
62 |
63 |
64 | FancyButton button1 = (FancyButton) findViewById(R.id.btn1);
65 |
66 | View.OnClickListener listener = new View.OnClickListener() {
67 | @Override
68 | public void onClick(View view) {
69 | if (view instanceof FancyButton)
70 | {
71 | if (((FancyButton)view).isExpanded())
72 | ((FancyButton)view).collapse();
73 | else
74 | ((FancyButton)view).expand();
75 | }
76 |
77 | }
78 | };
79 | button1.setOnClickListener(listener);
80 |
81 |
82 |
83 | # Adding to project:
84 |
85 | ## Maven
86 |
87 |
88 | com.ekalips.android
89 | fancyprogressbutton
90 | 1.2.1
91 | pom
92 |
93 |
94 | ## Gradle
95 |
96 | implementation 'com.ekalips.android:fancyprogressbutton:1.2.1'
97 |
98 | ## Ivy
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 | ```
108 | Copyright 2017 Ekalips
109 |
110 | Licensed under the Apache License, Version 2.0 (the "License");
111 | you may not use this file except in compliance with the License.
112 | You may obtain a copy of the License at
113 |
114 | http://www.apache.org/licenses/LICENSE-2.0
115 |
116 | Unless required by applicable law or agreed to in writing, software
117 | distributed under the License is distributed on an "AS IS" BASIS,
118 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
119 | See the License for the specific language governing permissions and
120 | limitations under the License.
121 | ```
122 |
--------------------------------------------------------------------------------
/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 | google()
6 | jcenter()
7 | }
8 | dependencies {
9 | classpath 'com.android.tools.build:gradle:3.3.0'
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 |
14 | }
15 |
16 |
17 | allprojects {
18 | repositories {
19 | google()
20 | jcenter()
21 | }
22 | }
23 |
24 | task clean(type: Delete) {
25 | delete rootProject.buildDir
26 | }
27 |
28 |
29 |
--------------------------------------------------------------------------------
/example/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/example/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 28
5 |
6 | defaultConfig {
7 | applicationId "com.wldev.example"
8 | minSdkVersion 19
9 | targetSdkVersion 28
10 | versionCode 1
11 | versionName "1.0"
12 |
13 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
14 |
15 | }
16 | buildTypes {
17 | release {
18 | minifyEnabled false
19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
20 | }
21 | }
22 | lintOptions {
23 | abortOnError false
24 | }
25 |
26 | }
27 |
28 | dependencies {
29 | implementation fileTree(dir: 'libs', include: ['*.jar'])
30 | implementation 'com.android.support:appcompat-v7:28.0.0'
31 | implementation 'com.android.support.constraint:constraint-layout:1.1.3'
32 | implementation project(path: ':library')
33 | }
34 |
--------------------------------------------------------------------------------
/example/example-release.apk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ekalips/FancyButtonProj/2046e375f3f19579c80540f0bb9523c012dc325b/example/example-release.apk
--------------------------------------------------------------------------------
/example/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 /home/wldev/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 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/example/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/example/src/main/java/com/wldev/example/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.wldev.example;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.view.View;
6 |
7 | import com.ekalips.fancybuttonproj.FancyButton;
8 |
9 |
10 | public class MainActivity extends AppCompatActivity {
11 |
12 | public static final String TAG = MainActivity.class.getSimpleName();
13 |
14 | @Override
15 | protected void onCreate(Bundle savedInstanceState) {
16 | super.onCreate(savedInstanceState);
17 | setContentView(R.layout.activity_main);
18 |
19 | FancyButton button1 = (FancyButton) findViewById(R.id.btn1);
20 | FancyButton button2 = (FancyButton) findViewById(R.id.btn2);
21 | FancyButton button3 = (FancyButton) findViewById(R.id.btn3);
22 |
23 | View.OnClickListener listener = new View.OnClickListener() {
24 | @Override
25 | public void onClick(View view) {
26 | if (view instanceof FancyButton)
27 | {
28 | if (((FancyButton)view).isExpanded())
29 | ((FancyButton)view).collapse();
30 | else
31 | ((FancyButton)view).expand();
32 | }
33 |
34 | }
35 | };
36 | button1.setOnClickListener(listener);
37 | button2.setOnClickListener(listener);
38 | button3.setOnClickListener(listener);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/example/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
22 |
23 |
24 |
36 |
37 |
38 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/example/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ekalips/FancyButtonProj/2046e375f3f19579c80540f0bb9523c012dc325b/example/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ekalips/FancyButtonProj/2046e375f3f19579c80540f0bb9523c012dc325b/example/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/example/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ekalips/FancyButtonProj/2046e375f3f19579c80540f0bb9523c012dc325b/example/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ekalips/FancyButtonProj/2046e375f3f19579c80540f0bb9523c012dc325b/example/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/example/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ekalips/FancyButtonProj/2046e375f3f19579c80540f0bb9523c012dc325b/example/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ekalips/FancyButtonProj/2046e375f3f19579c80540f0bb9523c012dc325b/example/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/example/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ekalips/FancyButtonProj/2046e375f3f19579c80540f0bb9523c012dc325b/example/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ekalips/FancyButtonProj/2046e375f3f19579c80540f0bb9523c012dc325b/example/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/example/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ekalips/FancyButtonProj/2046e375f3f19579c80540f0bb9523c012dc325b/example/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ekalips/FancyButtonProj/2046e375f3f19579c80540f0bb9523c012dc325b/example/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/example/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/example/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Example
3 |
4 |
--------------------------------------------------------------------------------
/example/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/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 | bintray.user=ekalips
14 | bintray.apikey=d58221b9d5d2810d294559b76055a395f8ec8881
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
19 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ekalips/FancyButtonProj/2046e375f3f19579c80540f0bb9523c012dc325b/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Jan 30 00:24:59 EET 2019
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-4.10.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 | # 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 |
--------------------------------------------------------------------------------
/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/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/library/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 |
4 | ext{
5 | PUBLISH_GROUP_ID = 'com.ekalips.android'
6 | PUBLISH_ARTIFACT_ID = 'fancyprogressbutton'
7 | PUBLISH_VERSION = '1.2.1'
8 | }
9 |
10 | android {
11 | compileSdkVersion 28
12 | defaultConfig {
13 | minSdkVersion 16
14 | targetSdkVersion 28
15 | versionCode 1
16 | versionName "1.0"
17 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
18 | }
19 | buildTypes {
20 | release {
21 | minifyEnabled false
22 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
23 | }
24 | }
25 | lintOptions {
26 | abortOnError false
27 | }
28 | }
29 |
30 | dependencies {
31 | implementation fileTree(dir: 'libs', include: ['*.jar'])
32 | implementation 'me.zhanghai.android.materialprogressbar:library:1.4.2'
33 | }
34 |
35 | apply from: 'https://raw.githubusercontent.com/' +
36 | 'blundell/release-android-library/master/' +
37 | 'android-release-aar.gradle'
--------------------------------------------------------------------------------
/library/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 /home/ekalips/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 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/library/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
8 |
9 |
--------------------------------------------------------------------------------
/library/src/main/java/com/ekalips/fancybuttonproj/FancyButton.java:
--------------------------------------------------------------------------------
1 | package com.ekalips.fancybuttonproj;
2 |
3 | import android.animation.Animator;
4 | import android.animation.AnimatorListenerAdapter;
5 | import android.animation.ObjectAnimator;
6 | import android.animation.ValueAnimator;
7 | import android.content.Context;
8 | import android.content.res.TypedArray;
9 | import android.graphics.Canvas;
10 | import android.graphics.Color;
11 | import android.graphics.Paint;
12 | import android.os.Build;
13 | import android.support.annotation.Nullable;
14 | import android.support.annotation.RequiresApi;
15 | import android.util.AttributeSet;
16 | import android.util.Log;
17 | import android.util.TypedValue;
18 | import android.view.Gravity;
19 | import android.view.ViewGroup;
20 | import android.widget.FrameLayout;
21 | import android.widget.RelativeLayout;
22 | import android.widget.TextView;
23 |
24 | import me.zhanghai.android.materialprogressbar.IndeterminateCircularProgressDrawable;
25 | import me.zhanghai.android.materialprogressbar.MaterialProgressBar;
26 |
27 | /**
28 | * Created by Ekalips on 1/18/17.
29 | */
30 | public class FancyButton extends FrameLayout {
31 |
32 | interface AnimationEndListener {
33 | void animationEnded();
34 | }
35 |
36 | private static final String TAG = FancyButton.class.getSimpleName();
37 |
38 |
39 | public FancyButton(Context context, AttributeSet attrs) {
40 | super(context, attrs);
41 | init(context, attrs);
42 | }
43 |
44 | public FancyButton(Context context, AttributeSet attrs, int defStyleAttr) {
45 | super(context, attrs, defStyleAttr);
46 | init(context, attrs);
47 | }
48 |
49 | @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
50 | public FancyButton(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
51 | super(context, attrs, defStyleAttr, defStyleRes);
52 | init(context, attrs);
53 | }
54 |
55 | private Paint strokePaint, fillPaint;
56 | private MaterialProgressBar bar;
57 | private TextView view;
58 |
59 | /*
60 | 0 - stroke
61 | 1 - fill
62 | 2 - stroke and fill
63 | */
64 | private int style;
65 | private boolean hideAfterCollapse = true;
66 | private boolean isExpanded = true;
67 | private AnimationEndListener listener;
68 |
69 | public boolean isExpanded() {
70 | return isExpanded;
71 | }
72 |
73 | public void setListener(AnimationEndListener listener) {
74 | this.listener = listener;
75 | }
76 |
77 | private AnimatorListenerAdapter hideProgressBarListener = new AnimatorListenerAdapter() {
78 | @Override
79 | public void onAnimationEnd(Animator animation) {
80 | super.onAnimationEnd(animation);
81 | bar.setVisibility(INVISIBLE);
82 | }
83 | };
84 |
85 | @Override
86 | public void setOnClickListener(@Nullable OnClickListener l) {
87 | super.setOnClickListener(l);
88 | }
89 |
90 | private int initPadd = 16;
91 | private int trueSixtee = 60;
92 |
93 |
94 | public void init(Context context, AttributeSet attrs) {
95 |
96 | this.setClickable(true);
97 | this.setWillNotDraw(false);
98 |
99 | TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.FancyButton);
100 | String text = ta.getString(R.styleable.FancyButton_f_text);
101 | int strokeColor = ta.getColor(R.styleable.FancyButton_f_strokeColor, Color.BLACK);
102 | int fillColor = ta.getColor(R.styleable.FancyButton_f_fillColor, Color.TRANSPARENT);
103 | int textColor = ta.getColor(R.styleable.FancyButton_f_textColor, Color.BLACK);
104 | int progressColor = ta.getColor(R.styleable.FancyButton_f_progressColor, Color.BLACK);
105 | int strokeWidth = ta.getInt(R.styleable.FancyButton_f_strokeWidth, -1);
106 | if (strokeWidth == -1)
107 | strokeWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4, context.getResources().getDisplayMetrics());
108 |
109 | boolean capsText = ta.getBoolean(R.styleable.FancyButton_f_capsText, true);
110 | float textSize = ta.getDimensionPixelSize(R.styleable.FancyButton_f_textSize, -1);
111 | if (textSize == -1)
112 | textSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 16, context.getResources().getDisplayMetrics());
113 | if (capsText && text != null)
114 | text = text.toUpperCase();
115 | String temp = ta.getString(R.styleable.FancyButton_f_btnStyle);
116 | if (temp != null)
117 | style = Integer.parseInt(temp);
118 | hideAfterCollapse = ta.getBoolean(R.styleable.FancyButton_f_hideFillAfterCollapse, true);
119 | ta.recycle();
120 |
121 | view = new TextView(context, attrs, android.R.attr.borderlessButtonStyle);
122 | view.setClickable(false);
123 | view.setFocusable(false);
124 | view.setTextColor(textColor);
125 | view.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
126 | RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
127 | view.setLayoutParams(params);
128 | view.setText(text);
129 | this.addView(view);
130 |
131 | bar = new MaterialProgressBar(context);
132 | FrameLayout.LayoutParams barParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
133 | barParams.gravity = Gravity.CENTER;
134 | bar.setLayoutParams(barParams);
135 | bar.setIndeterminate(true);
136 |
137 | // fixes pre-Lollipop progressBar indeterminateDrawable tinting
138 | IndeterminateCircularProgressDrawable drawable = new IndeterminateCircularProgressDrawable(context);
139 | drawable.setTint(progressColor);
140 | bar.setIndeterminateDrawable(drawable);
141 |
142 | bar.setVisibility(INVISIBLE);
143 | this.addView(bar);
144 |
145 | strokePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
146 | strokePaint.setColor(strokeColor);
147 | strokePaint.setStyle(Paint.Style.STROKE);
148 | strokePaint.setStrokeJoin(Paint.Join.ROUND);
149 | strokePaint.setStrokeWidth(strokeWidth);
150 |
151 | fillPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
152 | fillPaint.setColor(fillColor);
153 | fillPaint.setStyle(Paint.Style.FILL);
154 |
155 | initPadd = Utils.dp2px(context.getResources(), 5);
156 | trueSixtee = Utils.dp2px(context.getResources(), 20);
157 |
158 |
159 | }
160 |
161 |
162 | @Override
163 | protected void onDraw(Canvas canvas) {
164 | super.onDraw(canvas);
165 |
166 | if (state == State.normal) {
167 | if (style == 0)
168 | canvas.drawPath(Utils.composeRoundedRectPath(initPadd, initPadd, canvas.getWidth() - initPadd, canvas.getHeight() - initPadd, initPadd), strokePaint);
169 | else if (style == 1)
170 | canvas.drawPath(Utils.composeRoundedRectPath(initPadd, initPadd, canvas.getWidth() - initPadd, canvas.getHeight() - initPadd, initPadd), fillPaint);
171 | else if (style == 2) {
172 | canvas.drawPath(Utils.composeRoundedRectPath(initPadd, initPadd, canvas.getWidth() - initPadd, canvas.getHeight() - initPadd, initPadd), fillPaint);
173 | canvas.drawPath(Utils.composeRoundedRectPath(initPadd, initPadd, canvas.getWidth() - initPadd, canvas.getHeight() - initPadd, initPadd), strokePaint);
174 | }
175 | destLeft = (this.getRight() - this.getLeft()) / 2 - trueSixtee;
176 | destRight = (this.getRight() - this.getLeft()) / 2 + trueSixtee;
177 | destTop = (this.getBottom() - this.getTop()) / 2 - trueSixtee;
178 | destBot = (this.getBottom() - this.getTop()) / 2 + trueSixtee;
179 | circleR = Math.abs(destLeft - destRight);
180 | ObjectAnimator animator = ObjectAnimator.ofFloat(bar, "alpha", 1, 0);
181 | animator.addListener(hideProgressBarListener);
182 | animator.setDuration(0);
183 | animator.start();
184 | } else if (state == State.shrieked) {
185 | if (!hideAfterCollapse) {
186 | if (style == 1 || style == 2)
187 | canvas.drawCircle(destRight - ((destRight - destLeft) / 2), destBot - ((destBot - destTop) / 2), circleR / 2, fillPaint);
188 |
189 | }
190 | ObjectAnimator animator = ObjectAnimator.ofFloat(bar, "alpha", 0, 1);
191 | animator.setDuration(0);
192 | animator.start();
193 | bar.setVisibility(VISIBLE);
194 | } else {
195 | if (state == State.shrink)
196 | if (style == 0)
197 | canvas.drawPath(Utils.composeRoundedRectPath((float) (0 + nowPadW), (float) (0 + nowPadH), (float) (canvas.getWidth() - nowPadW), (float) (canvas.getHeight() - nowPadH), (float) nowRad), strokePaint);
198 | else if (style == 1)
199 | canvas.drawPath(Utils.composeRoundedRectPath((float) (0 + nowPadW), (float) (0 + nowPadH), (float) (canvas.getWidth() - nowPadW), (float) (canvas.getHeight() - nowPadH), (float) nowRad), fillPaint);
200 | else if (style == 2) {
201 | canvas.drawPath(Utils.composeRoundedRectPath((float) (0 + nowPadW), (float) (0 + nowPadH), (float) (canvas.getWidth() - nowPadW), (float) (canvas.getHeight() - nowPadH), (float) nowRad), fillPaint);
202 | canvas.drawPath(Utils.composeRoundedRectPath((float) (0 + nowPadW), (float) (0 + nowPadH), (float) (canvas.getWidth() - nowPadW), (float) (canvas.getHeight() - nowPadH), (float) nowRad), strokePaint);
203 | }
204 | if (state == State.back) {
205 | if (style == 0)
206 | canvas.drawPath(Utils.composeRoundedRectPath((float) (0 + nowPadW), (float) (0 + nowPadH), (float) (canvas.getWidth() - nowPadW), (float) (canvas.getHeight() - nowPadH), (float) nowRad), strokePaint);
207 | else if (style == 1)
208 | canvas.drawPath(Utils.composeRoundedRectPath((float) (0 + nowPadW), (float) (0 + nowPadH), (float) (canvas.getWidth() - nowPadW), (float) (canvas.getHeight() - nowPadH), (float) nowRad), fillPaint);
209 | else if (style == 2) {
210 | canvas.drawPath(Utils.composeRoundedRectPath((float) (0 + nowPadW), (float) (0 + nowPadH), (float) (canvas.getWidth() - nowPadW), (float) (canvas.getHeight() - nowPadH), (float) nowRad), fillPaint);
211 | canvas.drawPath(Utils.composeRoundedRectPath((float) (0 + nowPadW), (float) (0 + nowPadH), (float) (canvas.getWidth() - nowPadW), (float) (canvas.getHeight() - nowPadH), (float) nowRad), strokePaint);
212 | }
213 | if (bar.getVisibility() != INVISIBLE)
214 | bar.setVisibility(INVISIBLE);
215 | }
216 | }
217 | }
218 |
219 |
220 | private double nowPadW = initPadd;
221 | private double nowPadH = initPadd;
222 | private double nowRad = initPadd;
223 | private float destLeft, destTop, destRight, destBot, circleR;
224 | private State state = FancyButton.State.normal;
225 |
226 |
227 | ValueAnimator animator;
228 |
229 | public void expand() {
230 | // if (state == State.shrieked){
231 | if (state == State.normal)
232 | return;
233 | if (animator != null) {
234 | animator.removeAllUpdateListeners();
235 | animator.cancel();
236 | }
237 | state = State.back;
238 | animator = ValueAnimator.ofInt(0, 255);
239 | animator.setDuration(200);
240 |
241 | final float addWVal = (float) Math.abs(0 - nowPadW + initPadd) / 15f;
242 | final float addHVal = (float) Math.abs(0 - nowPadH + initPadd) / 15f;
243 |
244 | nowRad = circleR;
245 | final float addRad = Math.abs(circleR - 10f) / 15f;
246 | animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
247 | @Override
248 | public void onAnimationUpdate(ValueAnimator valueAnimator) {
249 | FancyButton.this.invalidate();
250 | nowPadH -= addHVal;
251 | nowPadW -= addWVal;
252 | nowRad -= addRad;
253 | if (hideAfterCollapse) {
254 | if (strokePaint.getColor() != Color.TRANSPARENT)
255 | strokePaint.setAlpha((Integer) valueAnimator.getAnimatedValue());
256 | if (fillPaint.getColor() != Color.TRANSPARENT)
257 | fillPaint.setAlpha((Integer) valueAnimator.getAnimatedValue());
258 | }
259 | view.setAlpha((int) valueAnimator.getAnimatedValue() / 255f);
260 | }
261 | });
262 | animator.addListener(new AnimatorListenerAdapter() {
263 | @Override
264 | public void onAnimationEnd(Animator animation) {
265 | super.onAnimationEnd(animation);
266 | state = State.normal;
267 | if (listener != null)
268 | listener.animationEnded();
269 | isExpanded = true;
270 | }
271 | });
272 | animator.start();
273 | // }
274 | }
275 |
276 | public void collapse() {
277 | // if (state == State.normal){
278 | if (state == State.shrieked)
279 | return;
280 | if (animator != null) {
281 | animator.removeAllUpdateListeners();
282 | animator.cancel();
283 | }
284 | state = State.shrink;
285 | nowPadW = initPadd;
286 | nowPadH = initPadd;
287 | nowRad = initPadd;
288 | animator = ValueAnimator.ofInt(255, 0);
289 | animator.setDuration(200);
290 |
291 | final float addWVal = Math.abs(initPadd - destLeft) / 15f;
292 | final float addHVal = Math.abs(initPadd - destTop) / 15f;
293 | final float addRad = circleR / 15f;
294 |
295 | isExpanded = false;
296 |
297 | animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
298 | @Override
299 | public void onAnimationUpdate(ValueAnimator valueAnimator) {
300 | FancyButton.this.invalidate();
301 | nowPadH += addHVal;
302 | nowPadW += addWVal;
303 | nowRad += addRad;
304 | if (hideAfterCollapse) {
305 | if (strokePaint.getColor() != Color.TRANSPARENT)
306 | strokePaint.setAlpha((Integer) valueAnimator.getAnimatedValue());
307 | if (fillPaint.getColor() != Color.TRANSPARENT)
308 | fillPaint.setAlpha((Integer) valueAnimator.getAnimatedValue());
309 | }
310 | view.setAlpha((int) valueAnimator.getAnimatedValue() / 255f);
311 | }
312 | });
313 | animator.addListener(new AnimatorListenerAdapter() {
314 | @Override
315 | public void onAnimationEnd(Animator animation) {
316 | super.onAnimationEnd(animation);
317 | state = State.shrieked;
318 | if (listener != null)
319 | listener.animationEnded();
320 | }
321 | });
322 | animator.start();
323 | // }
324 | }
325 |
326 | public void setText(String text) {
327 | view.setText(text);
328 | }
329 |
330 | private enum State {normal, shrink, back, shrieked}
331 | }
332 |
--------------------------------------------------------------------------------
/library/src/main/java/com/ekalips/fancybuttonproj/Utils.java:
--------------------------------------------------------------------------------
1 | package com.ekalips.fancybuttonproj;
2 |
3 | import android.content.res.Resources;
4 | import android.graphics.Path;
5 | import android.graphics.RectF;
6 | import android.util.TypedValue;
7 |
8 | /**
9 | * Created by Ekalips on 1/18/17.
10 | */
11 |
12 | public class Utils {
13 | public static Path composeRoundedRectPath(float left, float top, float right, float bottom, float diameter){
14 | Path path = new Path();
15 | path.moveTo(left + diameter/2 ,top);
16 | path.lineTo(right - diameter/2,top);
17 | path.quadTo(right, top, right, top + diameter/2);
18 | path.lineTo(right ,bottom - diameter/2);
19 | path.quadTo(right ,bottom, right - diameter/2, bottom);
20 | path.lineTo(left + diameter/2,bottom);
21 | path.quadTo(left,bottom,left, bottom - diameter/2);
22 | path.lineTo(left,top + diameter/2);
23 | path.quadTo(left,top, left + diameter/2, top);
24 | path.close();
25 | return path;
26 | }
27 |
28 | public static Path composeRoundedRectPath(RectF rectF, float diameter){
29 | return composeRoundedRectPath(rectF,diameter,diameter,diameter,diameter);
30 | }
31 |
32 | public static Path composeRoundedRectPath(RectF rect, float topLeftDiameter, float topRightDiameter, float bottomRightDiameter, float bottomLeftDiameter){
33 | Path path = new Path();
34 | topLeftDiameter = topLeftDiameter < 0 ? 0 : topLeftDiameter;
35 | topRightDiameter = topRightDiameter < 0 ? 0 : topRightDiameter;
36 | bottomLeftDiameter = bottomLeftDiameter < 0 ? 0 : bottomLeftDiameter;
37 | bottomRightDiameter = bottomRightDiameter < 0 ? 0 : bottomRightDiameter;
38 |
39 | path.moveTo(rect.left + topLeftDiameter/2 ,rect.top);
40 | path.lineTo(rect.right - topRightDiameter/2,rect.top);
41 | path.quadTo(rect.right, rect.top, rect.right, rect.top + topRightDiameter/2);
42 | path.lineTo(rect.right ,rect.bottom - bottomRightDiameter/2);
43 | path.quadTo(rect.right ,rect.bottom, rect.right - bottomRightDiameter/2, rect.bottom);
44 | path.lineTo(rect.left + bottomLeftDiameter/2,rect.bottom);
45 | path.quadTo(rect.left,rect.bottom,rect.left, rect.bottom - bottomLeftDiameter/2);
46 | path.lineTo(rect.left,rect.top + topLeftDiameter/2);
47 | path.quadTo(rect.left,rect.top, rect.left + topLeftDiameter/2, rect.top);
48 | path.close();
49 |
50 | return path;
51 | }
52 |
53 |
54 | public static float px2dp(Resources resource, float px) {
55 | return (float) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_PX, px,resource.getDisplayMetrics());
56 | }
57 |
58 | public static int dp2px(Resources resource, int dp) {
59 | return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp,resource.getDisplayMetrics());
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':library', ':example'
2 |
--------------------------------------------------------------------------------
/showcase/demo.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ekalips/FancyButtonProj/2046e375f3f19579c80540f0bb9523c012dc325b/showcase/demo.gif
--------------------------------------------------------------------------------