├── .classpath ├── .project ├── AndroidManifest.xml ├── LICENSE.txt ├── README.md ├── ScreenCaps ├── device-2013-11-24-022111.png └── device-2013-11-24-022153.png ├── bin ├── AndroidManifest.xml ├── ProgressButton.apk ├── classes.dex ├── classes │ └── com │ │ ├── example │ │ └── progressbutton │ │ │ ├── BuildConfig.class │ │ │ ├── R$attr.class │ │ │ ├── R$color.class │ │ │ ├── R$dimen.class │ │ │ ├── R$drawable.class │ │ │ ├── R$id.class │ │ │ ├── R$layout.class │ │ │ ├── R$menu.class │ │ │ ├── R$string.class │ │ │ ├── R$style.class │ │ │ ├── R$styleable.class │ │ │ └── R.class │ │ └── sun │ │ └── progressbutton │ │ ├── ProgressButton.class │ │ └── sample │ │ ├── MainActivity$1.class │ │ └── MainActivity.class ├── dexedLibs │ └── android-support-v4-8b753d560e67a92671ac8dd0eb0a5c2b.jar ├── res │ └── crunch │ │ ├── drawable-hdpi │ │ ├── ic_launcher.png │ │ └── loading_circle.png │ │ ├── drawable-mdpi │ │ └── ic_launcher.png │ │ ├── drawable-xhdpi │ │ └── ic_launcher.png │ │ └── drawable-xxhdpi │ │ └── ic_launcher.png └── resources.ap_ ├── gen └── com │ └── example │ └── progressbutton │ ├── BuildConfig.java │ └── R.java ├── ic_launcher-web.png ├── libs └── android-support-v4.jar ├── proguard-project.txt ├── project.properties ├── res ├── drawable-hdpi │ ├── ic_launcher.png │ ├── loading_circle.png │ └── progress_view.xml ├── drawable-mdpi │ └── ic_launcher.png ├── drawable-xhdpi │ └── ic_launcher.png ├── drawable-xxhdpi │ └── ic_launcher.png ├── layout │ └── activity_main.xml ├── menu │ └── main.xml ├── values-sw600dp │ └── dimens.xml ├── values-sw720dp-land │ └── dimens.xml ├── values-v11 │ └── styles.xml ├── values-v14 │ └── styles.xml └── values │ ├── attrs.xml │ ├── colors.xml │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml └── src └── com └── sun └── progressbutton ├── ProgressButton.java └── sample └── MainActivity.java /.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | ProgressButton 4 | 5 | 6 | 7 | 8 | 9 | com.android.ide.eclipse.adt.ResourceManagerBuilder 10 | 11 | 12 | 13 | 14 | com.android.ide.eclipse.adt.PreCompilerBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.jdt.core.javabuilder 20 | 21 | 22 | 23 | 24 | com.android.ide.eclipse.adt.ApkBuilder 25 | 26 | 27 | 28 | 29 | 30 | com.android.ide.eclipse.adt.AndroidNature 31 | org.eclipse.jdt.core.javanature 32 | 33 | 34 | -------------------------------------------------------------------------------- /AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 10 | 11 | 16 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) [2014] [SundeepK] 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ProgressButton 2 | ============== 3 | 4 | Simple Android widget that display's a loading animation when a user clicks the button 5 | 6 | ![ScreenShot](https://raw.github.com/SundeepK/ProgressButton/master/ScreenCaps/device-2013-11-24-022111.png) 7 | 8 | After user has clicked button: 9 | 10 | ![ScreenShot](https://raw.github.com/SundeepK/ProgressButton/master/ScreenCaps/device-2013-11-24-022153.png) 11 | 12 | 13 | **Layout code** 14 | 15 | Simply define a ProgressButton: 16 | 17 | ``` xml 18 | 19 | 28 | 29 | 37 | 38 | 39 | 40 | ``` 41 | -------------------------------------------------------------------------------- /ScreenCaps/device-2013-11-24-022111.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SundeepK/ProgressButton/24f66dd2dbaa18b8f5074cd6602c953856b2e067/ScreenCaps/device-2013-11-24-022111.png -------------------------------------------------------------------------------- /ScreenCaps/device-2013-11-24-022153.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SundeepK/ProgressButton/24f66dd2dbaa18b8f5074cd6602c953856b2e067/ScreenCaps/device-2013-11-24-022153.png -------------------------------------------------------------------------------- /bin/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 10 | 11 | 16 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /bin/ProgressButton.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SundeepK/ProgressButton/24f66dd2dbaa18b8f5074cd6602c953856b2e067/bin/ProgressButton.apk -------------------------------------------------------------------------------- /bin/classes.dex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SundeepK/ProgressButton/24f66dd2dbaa18b8f5074cd6602c953856b2e067/bin/classes.dex -------------------------------------------------------------------------------- /bin/classes/com/example/progressbutton/BuildConfig.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SundeepK/ProgressButton/24f66dd2dbaa18b8f5074cd6602c953856b2e067/bin/classes/com/example/progressbutton/BuildConfig.class -------------------------------------------------------------------------------- /bin/classes/com/example/progressbutton/R$attr.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SundeepK/ProgressButton/24f66dd2dbaa18b8f5074cd6602c953856b2e067/bin/classes/com/example/progressbutton/R$attr.class -------------------------------------------------------------------------------- /bin/classes/com/example/progressbutton/R$color.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SundeepK/ProgressButton/24f66dd2dbaa18b8f5074cd6602c953856b2e067/bin/classes/com/example/progressbutton/R$color.class -------------------------------------------------------------------------------- /bin/classes/com/example/progressbutton/R$dimen.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SundeepK/ProgressButton/24f66dd2dbaa18b8f5074cd6602c953856b2e067/bin/classes/com/example/progressbutton/R$dimen.class -------------------------------------------------------------------------------- /bin/classes/com/example/progressbutton/R$drawable.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SundeepK/ProgressButton/24f66dd2dbaa18b8f5074cd6602c953856b2e067/bin/classes/com/example/progressbutton/R$drawable.class -------------------------------------------------------------------------------- /bin/classes/com/example/progressbutton/R$id.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SundeepK/ProgressButton/24f66dd2dbaa18b8f5074cd6602c953856b2e067/bin/classes/com/example/progressbutton/R$id.class -------------------------------------------------------------------------------- /bin/classes/com/example/progressbutton/R$layout.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SundeepK/ProgressButton/24f66dd2dbaa18b8f5074cd6602c953856b2e067/bin/classes/com/example/progressbutton/R$layout.class -------------------------------------------------------------------------------- /bin/classes/com/example/progressbutton/R$menu.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SundeepK/ProgressButton/24f66dd2dbaa18b8f5074cd6602c953856b2e067/bin/classes/com/example/progressbutton/R$menu.class -------------------------------------------------------------------------------- /bin/classes/com/example/progressbutton/R$string.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SundeepK/ProgressButton/24f66dd2dbaa18b8f5074cd6602c953856b2e067/bin/classes/com/example/progressbutton/R$string.class -------------------------------------------------------------------------------- /bin/classes/com/example/progressbutton/R$style.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SundeepK/ProgressButton/24f66dd2dbaa18b8f5074cd6602c953856b2e067/bin/classes/com/example/progressbutton/R$style.class -------------------------------------------------------------------------------- /bin/classes/com/example/progressbutton/R$styleable.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SundeepK/ProgressButton/24f66dd2dbaa18b8f5074cd6602c953856b2e067/bin/classes/com/example/progressbutton/R$styleable.class -------------------------------------------------------------------------------- /bin/classes/com/example/progressbutton/R.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SundeepK/ProgressButton/24f66dd2dbaa18b8f5074cd6602c953856b2e067/bin/classes/com/example/progressbutton/R.class -------------------------------------------------------------------------------- /bin/classes/com/sun/progressbutton/ProgressButton.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SundeepK/ProgressButton/24f66dd2dbaa18b8f5074cd6602c953856b2e067/bin/classes/com/sun/progressbutton/ProgressButton.class -------------------------------------------------------------------------------- /bin/classes/com/sun/progressbutton/sample/MainActivity$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SundeepK/ProgressButton/24f66dd2dbaa18b8f5074cd6602c953856b2e067/bin/classes/com/sun/progressbutton/sample/MainActivity$1.class -------------------------------------------------------------------------------- /bin/classes/com/sun/progressbutton/sample/MainActivity.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SundeepK/ProgressButton/24f66dd2dbaa18b8f5074cd6602c953856b2e067/bin/classes/com/sun/progressbutton/sample/MainActivity.class -------------------------------------------------------------------------------- /bin/dexedLibs/android-support-v4-8b753d560e67a92671ac8dd0eb0a5c2b.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SundeepK/ProgressButton/24f66dd2dbaa18b8f5074cd6602c953856b2e067/bin/dexedLibs/android-support-v4-8b753d560e67a92671ac8dd0eb0a5c2b.jar -------------------------------------------------------------------------------- /bin/res/crunch/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SundeepK/ProgressButton/24f66dd2dbaa18b8f5074cd6602c953856b2e067/bin/res/crunch/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /bin/res/crunch/drawable-hdpi/loading_circle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SundeepK/ProgressButton/24f66dd2dbaa18b8f5074cd6602c953856b2e067/bin/res/crunch/drawable-hdpi/loading_circle.png -------------------------------------------------------------------------------- /bin/res/crunch/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SundeepK/ProgressButton/24f66dd2dbaa18b8f5074cd6602c953856b2e067/bin/res/crunch/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /bin/res/crunch/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SundeepK/ProgressButton/24f66dd2dbaa18b8f5074cd6602c953856b2e067/bin/res/crunch/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /bin/res/crunch/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SundeepK/ProgressButton/24f66dd2dbaa18b8f5074cd6602c953856b2e067/bin/res/crunch/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /bin/resources.ap_: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SundeepK/ProgressButton/24f66dd2dbaa18b8f5074cd6602c953856b2e067/bin/resources.ap_ -------------------------------------------------------------------------------- /gen/com/example/progressbutton/BuildConfig.java: -------------------------------------------------------------------------------- 1 | /** Automatically generated file. DO NOT MODIFY */ 2 | package com.example.progressbutton; 3 | 4 | public final class BuildConfig { 5 | public final static boolean DEBUG = true; 6 | } -------------------------------------------------------------------------------- /gen/com/example/progressbutton/R.java: -------------------------------------------------------------------------------- 1 | /* AUTO-GENERATED FILE. DO NOT MODIFY. 2 | * 3 | * This class was automatically generated by the 4 | * aapt tool from the resource data it found. It 5 | * should not be modified by hand. 6 | */ 7 | 8 | package com.example.progressbutton; 9 | 10 | public final class R { 11 | public static final class attr { 12 | /**

Must be a color value, in the form of "#rgb", "#argb", 13 | "#rrggbb", or "#aarrggbb". 14 |

This may also be a reference to a resource (in the form 15 | "@[package:]type:name") or 16 | theme attribute (in the form 17 | "?[package:][type:]name") 18 | containing a value of this type. 19 | */ 20 | public static final int defaultBackgroundColor=0x7f010001; 21 | /**

Must be a color value, in the form of "#rgb", "#argb", 22 | "#rrggbb", or "#aarrggbb". 23 |

This may also be a reference to a resource (in the form 24 | "@[package:]type:name") or 25 | theme attribute (in the form 26 | "?[package:][type:]name") 27 | containing a value of this type. 28 | */ 29 | public static final int defaultFontColor=0x7f010003; 30 | /**

Must be an integer value, such as "100". 31 |

This may also be a reference to a resource (in the form 32 | "@[package:]type:name") or 33 | theme attribute (in the form 34 | "?[package:][type:]name") 35 | containing a value of this type. 36 | */ 37 | public static final int defaultFontSize=0x7f010002; 38 | /**

Must be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character. 39 |

This may also be a reference to a resource (in the form 40 | "@[package:]type:name") or 41 | theme attribute (in the form 42 | "?[package:][type:]name") 43 | containing a value of this type. 44 | */ 45 | public static final int defaultText=0x7f010004; 46 | /**

Must be a reference to another resource, in the form "@[+][package:]type:name" 47 | or to a theme attribute in the form "?[package:][type:]name". 48 | */ 49 | public static final int progressButtonStyle=0x7f010000; 50 | } 51 | public static final class color { 52 | public static final int black_color=0x7f040000; 53 | public static final int white_color=0x7f040001; 54 | } 55 | public static final class dimen { 56 | /** Default screen margins, per the Android Design guidelines. 57 | 58 | Customize dimensions originally defined in res/values/dimens.xml (such as 59 | screen margins) for sw720dp devices (e.g. 10" tablets) in landscape here. 60 | 61 | */ 62 | public static final int activity_horizontal_margin=0x7f050000; 63 | public static final int activity_vertical_margin=0x7f050001; 64 | } 65 | public static final class drawable { 66 | public static final int ic_launcher=0x7f020000; 67 | public static final int loading_circle=0x7f020001; 68 | public static final int progress_view=0x7f020002; 69 | } 70 | public static final class id { 71 | public static final int action_settings=0x7f090001; 72 | public static final int progressView=0x7f090000; 73 | } 74 | public static final class layout { 75 | public static final int activity_main=0x7f030000; 76 | } 77 | public static final class menu { 78 | public static final int main=0x7f080000; 79 | } 80 | public static final class string { 81 | public static final int action_settings=0x7f060001; 82 | public static final int app_name=0x7f060000; 83 | public static final int hello_world=0x7f060002; 84 | } 85 | public static final class style { 86 | /** 87 | Base application theme, dependent on API level. This theme is replaced 88 | by AppBaseTheme from res/values-vXX/styles.xml on newer devices. 89 | 90 | 91 | 92 | 93 | 94 | Theme customizations available in newer API levels can go in 95 | res/values-vXX/styles.xml, while customizations related to 96 | backward-compatibility can go here. 97 | 98 | 99 | 100 | 101 | 102 | Base application theme for API 11+. This theme completely replaces 103 | AppBaseTheme from res/values/styles.xml on API 11+ devices. 104 | 105 | API 11 theme customizations can go here. 106 | 107 | Base application theme for API 14+. This theme completely replaces 108 | AppBaseTheme from BOTH res/values/styles.xml and 109 | res/values-v11/styles.xml on API 14+ devices. 110 | 111 | API 14 theme customizations can go here. 112 | */ 113 | public static final int AppBaseTheme=0x7f070002; 114 | /** Application theme. 115 | All customizations that are NOT specific to a particular API-level can go here. 116 | */ 117 | public static final int AppTheme=0x7f070003; 118 | public static final int ProgressButton=0x7f070000; 119 | /** Base theme for the Progress button. 120 | */ 121 | public static final int ProgressButton_attrs=0x7f070001; 122 | } 123 | public static final class styleable { 124 | /** Attributes that can be used with a ProgressButton. 125 |

Includes the following attributes:

126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 |
AttributeDescription
{@link #ProgressButton_android_clickable android:clickable}
{@link #ProgressButton_android_focusable android:focusable}
{@link #ProgressButton_defaultBackgroundColor com.example.progressbutton:defaultBackgroundColor}
{@link #ProgressButton_defaultFontColor com.example.progressbutton:defaultFontColor}
{@link #ProgressButton_defaultFontSize com.example.progressbutton:defaultFontSize}
{@link #ProgressButton_defaultText com.example.progressbutton:defaultText}
137 | @see #ProgressButton_android_clickable 138 | @see #ProgressButton_android_focusable 139 | @see #ProgressButton_defaultBackgroundColor 140 | @see #ProgressButton_defaultFontColor 141 | @see #ProgressButton_defaultFontSize 142 | @see #ProgressButton_defaultText 143 | */ 144 | public static final int[] ProgressButton = { 145 | 0x010100da, 0x010100e5, 0x7f010001, 0x7f010002, 146 | 0x7f010003, 0x7f010004 147 | }; 148 | /** 149 |

This symbol is the offset where the {@link android.R.attr#clickable} 150 | attribute's value can be found in the {@link #ProgressButton} array. 151 | @attr name android:clickable 152 | */ 153 | public static final int ProgressButton_android_clickable = 1; 154 | /** 155 |

This symbol is the offset where the {@link android.R.attr#focusable} 156 | attribute's value can be found in the {@link #ProgressButton} array. 157 | @attr name android:focusable 158 | */ 159 | public static final int ProgressButton_android_focusable = 0; 160 | /** 161 |

This symbol is the offset where the {@link com.example.progressbutton.R.attr#defaultBackgroundColor} 162 | attribute's value can be found in the {@link #ProgressButton} array. 163 | 164 | 165 |

Must be a color value, in the form of "#rgb", "#argb", 166 | "#rrggbb", or "#aarrggbb". 167 |

This may also be a reference to a resource (in the form 168 | "@[package:]type:name") or 169 | theme attribute (in the form 170 | "?[package:][type:]name") 171 | containing a value of this type. 172 | @attr name com.example.progressbutton:defaultBackgroundColor 173 | */ 174 | public static final int ProgressButton_defaultBackgroundColor = 2; 175 | /** 176 |

This symbol is the offset where the {@link com.example.progressbutton.R.attr#defaultFontColor} 177 | attribute's value can be found in the {@link #ProgressButton} array. 178 | 179 | 180 |

Must be a color value, in the form of "#rgb", "#argb", 181 | "#rrggbb", or "#aarrggbb". 182 |

This may also be a reference to a resource (in the form 183 | "@[package:]type:name") or 184 | theme attribute (in the form 185 | "?[package:][type:]name") 186 | containing a value of this type. 187 | @attr name com.example.progressbutton:defaultFontColor 188 | */ 189 | public static final int ProgressButton_defaultFontColor = 4; 190 | /** 191 |

This symbol is the offset where the {@link com.example.progressbutton.R.attr#defaultFontSize} 192 | attribute's value can be found in the {@link #ProgressButton} array. 193 | 194 | 195 |

Must be an integer value, such as "100". 196 |

This may also be a reference to a resource (in the form 197 | "@[package:]type:name") or 198 | theme attribute (in the form 199 | "?[package:][type:]name") 200 | containing a value of this type. 201 | @attr name com.example.progressbutton:defaultFontSize 202 | */ 203 | public static final int ProgressButton_defaultFontSize = 3; 204 | /** 205 |

This symbol is the offset where the {@link com.example.progressbutton.R.attr#defaultText} 206 | attribute's value can be found in the {@link #ProgressButton} array. 207 | 208 | 209 |

Must be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character. 210 |

This may also be a reference to a resource (in the form 211 | "@[package:]type:name") or 212 | theme attribute (in the form 213 | "?[package:][type:]name") 214 | containing a value of this type. 215 | @attr name com.example.progressbutton:defaultText 216 | */ 217 | public static final int ProgressButton_defaultText = 5; 218 | }; 219 | } 220 | -------------------------------------------------------------------------------- /ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SundeepK/ProgressButton/24f66dd2dbaa18b8f5074cd6602c953856b2e067/ic_launcher-web.png -------------------------------------------------------------------------------- /libs/android-support-v4.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SundeepK/ProgressButton/24f66dd2dbaa18b8f5074cd6602c953856b2e067/libs/android-support-v4.jar -------------------------------------------------------------------------------- /proguard-project.txt: -------------------------------------------------------------------------------- 1 | # To enable ProGuard in your project, edit project.properties 2 | # to define the proguard.config property as described in that file. 3 | # 4 | # Add project specific ProGuard rules here. 5 | # By default, the flags in this file are appended to flags specified 6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt 7 | # You can edit the include path and order by changing the ProGuard 8 | # include property in project.properties. 9 | # 10 | # For more details, see 11 | # http://developer.android.com/guide/developing/tools/proguard.html 12 | 13 | # Add any project specific keep options here: 14 | 15 | # If your project uses WebView with JS, uncomment the following 16 | # and specify the fully qualified class name to the JavaScript interface 17 | # class: 18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 19 | # public *; 20 | #} 21 | -------------------------------------------------------------------------------- /project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system edit 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | # 10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): 11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt 12 | 13 | # Project target. 14 | target=android-19 15 | -------------------------------------------------------------------------------- /res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SundeepK/ProgressButton/24f66dd2dbaa18b8f5074cd6602c953856b2e067/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /res/drawable-hdpi/loading_circle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SundeepK/ProgressButton/24f66dd2dbaa18b8f5074cd6602c953856b2e067/res/drawable-hdpi/loading_circle.png -------------------------------------------------------------------------------- /res/drawable-hdpi/progress_view.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 16 | -------------------------------------------------------------------------------- /res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SundeepK/ProgressButton/24f66dd2dbaa18b8f5074cd6602c953856b2e067/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SundeepK/ProgressButton/24f66dd2dbaa18b8f5074cd6602c953856b2e067/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SundeepK/ProgressButton/24f66dd2dbaa18b8f5074cd6602c953856b2e067/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 10 | 11 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /res/menu/main.xml: -------------------------------------------------------------------------------- 1 |

2 | 3 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /res/values-sw600dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /res/values-sw720dp-land/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 128dp 8 | 9 | 10 | -------------------------------------------------------------------------------- /res/values-v11/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /res/values-v14/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | #000000 21 | #ffffff 22 | 23 | -------------------------------------------------------------------------------- /res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 16dp 5 | 16dp 6 | 7 | 8 | -------------------------------------------------------------------------------- /res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ProgressButton 5 | Settings 6 | Hello world! 7 | 8 | 9 | -------------------------------------------------------------------------------- /res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 14 | 15 | 19 | 26 | 27 | 28 | 31 | 32 | -------------------------------------------------------------------------------- /src/com/sun/progressbutton/ProgressButton.java: -------------------------------------------------------------------------------- 1 | package com.sun.progressbutton; 2 | 3 | import com.example.progressbutton.R; 4 | 5 | import android.content.Context; 6 | import android.content.res.TypedArray; 7 | import android.graphics.Canvas; 8 | import android.graphics.Color; 9 | import android.graphics.Paint; 10 | import android.graphics.Paint.Align; 11 | import android.graphics.Rect; 12 | import android.graphics.drawable.Animatable; 13 | import android.graphics.drawable.Drawable; 14 | import android.text.TextPaint; 15 | import android.util.AttributeSet; 16 | import android.widget.ImageButton; 17 | 18 | public class ProgressButton extends ImageButton { 19 | 20 | private boolean _shouldDisplayLoadingAnimation = false; 21 | private Drawable _loadingAnimation; 22 | private TextPaint _textPaint; 23 | private Rect _textBounds; 24 | private String _defaultText; 25 | 26 | /** 27 | * {@link ProgressButton} can be used to display a simple rotating {@link Drawable} to give the user 28 | * the effect of a loading button. The {@link Drawable} will be displayed once the user clicks the button and will have to be 29 | * manually dismissed using the {@link #stopLoadingAnimation()} method. 30 | * 31 | * @param context_ 32 | * the current {@link Context} 33 | * @param attrs_ 34 | * the {@link AttributeSet} to retrieve data from compiled xml files 35 | * @param defStyle_ 36 | * the default style to apply 37 | */ 38 | public ProgressButton(Context context_, AttributeSet attrs_, int defStyle_) { 39 | super(context_, attrs_, defStyle_); 40 | 41 | final TypedArray a = context_.obtainStyledAttributes(attrs_, R.styleable.ProgressButton, 42 | R.attr.progressButtonStyle, R.style.ProgressButton_attrs); 43 | 44 | this.setBackgroundColor(a.getInteger(R.styleable.ProgressButton_defaultBackgroundColor, Color.WHITE)); 45 | 46 | _loadingAnimation = getDrawable(); 47 | _loadingAnimation.setAlpha(0); 48 | _defaultText = a.getString(R.styleable.ProgressButton_defaultText); 49 | _textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG); 50 | _textPaint.density = getResources().getDisplayMetrics().density; 51 | 52 | _textPaint.setColor(a.getInteger(R.styleable.ProgressButton_defaultFontColor, Color.BLACK)); 53 | _textPaint.setTextAlign(Align.CENTER); 54 | _textPaint.setTextSize(a.getInteger(R.styleable.ProgressButton_defaultFontSize, 40)); 55 | _textPaint.setFakeBoldText(true); 56 | _textBounds = new Rect(); 57 | 58 | a.recycle(); 59 | } 60 | 61 | public ProgressButton(Context context_, AttributeSet attrs_) { 62 | this(context_, attrs_, 0); 63 | } 64 | 65 | public ProgressButton(Context context_) { 66 | this(context_, null); 67 | } 68 | 69 | /** 70 | * Ensures that the loading animation will be displayed when the user clicks the button 71 | */ 72 | @Override 73 | public boolean performClick() { 74 | boolean isClicked = super.performClick(); 75 | if (isClicked) { 76 | _shouldDisplayLoadingAnimation = true; 77 | this.invalidate(); 78 | } 79 | 80 | return isClicked; 81 | }; 82 | 83 | 84 | public void startLoadingAnimation() { 85 | _shouldDisplayLoadingAnimation = true; 86 | this.invalidate(); 87 | } 88 | 89 | public void stopLoadingAnimation() { 90 | _shouldDisplayLoadingAnimation = false; 91 | this.invalidate(); 92 | } 93 | 94 | /** 95 | * Display a loading animation if the user has clicked the button or hide it if {@link #stopLoadingAnimation()} 96 | * has been called. 97 | * 98 | */ 99 | @Override 100 | protected void onDraw(Canvas canvas_) { 101 | if (_shouldDisplayLoadingAnimation) { 102 | shouldShowAnimation(true); 103 | } else { 104 | _textPaint.getTextBounds(_defaultText, 0, _defaultText.length(), _textBounds); 105 | canvas_.drawText( _defaultText , getWidth()/2, (getHeight()/2)+((_textBounds.bottom-_textBounds.top)/2) , _textPaint); 106 | shouldShowAnimation(false); 107 | _loadingAnimation.setVisible(false, false); 108 | } 109 | super.onDraw(canvas_); 110 | 111 | } 112 | 113 | /** 114 | * Start or stop the current {@link Animatable} instance 115 | * 116 | * @param shouldShow_ 117 | * to indicate whether {@link android.graphics.drawable.Animatable#stop()} or 118 | * {@link android.graphics.drawable.Animatable#start()} should be invoked on the current {@link Animatable} instance 119 | */ 120 | private void shouldShowAnimation(boolean shouldShow_) { 121 | if (_loadingAnimation instanceof Animatable) { 122 | if (shouldShow_) { 123 | _loadingAnimation.setAlpha(255); 124 | ((Animatable) _loadingAnimation).start(); 125 | } else { 126 | _loadingAnimation.setAlpha(0); 127 | ((Animatable) _loadingAnimation).stop(); 128 | } 129 | } 130 | } 131 | 132 | } 133 | -------------------------------------------------------------------------------- /src/com/sun/progressbutton/sample/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.sun.progressbutton.sample; 2 | 3 | import android.app.Activity; 4 | import android.os.Bundle; 5 | import android.view.Menu; 6 | import android.view.View; 7 | import android.view.View.OnClickListener; 8 | 9 | import com.example.progressbutton.R; 10 | import com.sun.progressbutton.ProgressButton; 11 | 12 | public class MainActivity extends Activity { 13 | 14 | @Override 15 | protected void onCreate(Bundle savedInstanceState) { 16 | super.onCreate(savedInstanceState); 17 | setContentView(R.layout.activity_main); 18 | 19 | ProgressButton button = (ProgressButton) findViewById(R.id.progressView); 20 | button.setOnClickListener(new OnClickListener() { 21 | @Override 22 | public void onClick(View v) { 23 | } 24 | }); 25 | } 26 | 27 | @Override 28 | public boolean onCreateOptionsMenu(Menu menu) { 29 | // Inflate the menu; this adds items to the action bar if it is present. 30 | getMenuInflater().inflate(R.menu.main, menu); 31 | return true; 32 | } 33 | 34 | } 35 | --------------------------------------------------------------------------------