├── .gitignore ├── Changelog.md ├── License.txt ├── README.md ├── apk └── sample-app.apk ├── art ├── cat.png ├── cat_hi_res_icon.png ├── cat_icon_original.png ├── cat_original.jpg └── en-play-badge.png ├── build.gradle ├── circularimageview ├── .gitignore ├── build.gradle ├── gradle.properties ├── pom.xml ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── subinkrishna │ │ └── widget │ │ └── ApplicationTest.java │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── subinkrishna │ │ └── widget │ │ └── CircularImageView.java │ └── res │ └── values │ └── attrs.xml ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── quick_samples └── AvatarView.java ├── sample ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── subinkrishna │ │ └── circularimageview │ │ └── demo │ │ └── ApplicationTest.java │ └── main │ ├── AndroidManifest.xml │ ├── assets │ └── fonts │ │ └── roboto │ │ ├── Mono-Light.ttf │ │ └── Mono-Regular.ttf │ ├── java │ └── com │ │ └── subinkrishna │ │ └── circularimageview │ │ └── demo │ │ ├── App.java │ │ ├── MainActivity.java │ │ └── view │ │ ├── AvatarView.java │ │ └── CompoundImageView.java │ └── res │ ├── drawable-hdpi │ ├── ic_check_circle_white_36dp.png │ ├── ic_close_black_24dp.png │ ├── ic_cloud_download_white_36dp.png │ ├── ic_code_black_24dp.png │ ├── ic_tune_black_24dp.png │ └── ic_tune_black_36dp.png │ ├── drawable-mdpi │ ├── ic_check_circle_white_36dp.png │ ├── ic_close_black_24dp.png │ ├── ic_cloud_download_white_36dp.png │ ├── ic_code_black_24dp.png │ ├── ic_tune_black_24dp.png │ └── ic_tune_black_36dp.png │ ├── drawable-nodpi │ ├── c1.jpg │ ├── c2.jpg │ ├── c3.jpg │ ├── grid.png │ └── placeholder.png │ ├── drawable-xhdpi │ ├── ic_check_circle_white_36dp.png │ ├── ic_close_black_24dp.png │ ├── ic_cloud_download_white_36dp.png │ ├── ic_code_black_24dp.png │ ├── ic_tune_black_24dp.png │ └── ic_tune_black_36dp.png │ ├── drawable-xxhdpi │ ├── ic_check_circle_white_36dp.png │ ├── ic_close_black_24dp.png │ ├── ic_cloud_download_white_36dp.png │ ├── ic_code_black_24dp.png │ ├── ic_tune_black_24dp.png │ └── ic_tune_black_36dp.png │ ├── drawable-xxxhdpi │ ├── ic_check_circle_white_36dp.png │ ├── ic_close_black_24dp.png │ ├── ic_cloud_download_white_36dp.png │ ├── ic_code_black_24dp.png │ ├── ic_tune_black_24dp.png │ └── ic_tune_black_36dp.png │ ├── drawable │ ├── bg_launcher.xml │ ├── shadow_gradient_bottom.xml │ └── shape.xml │ ├── layout │ ├── activity_main.xml │ └── item_compound_image_view.xml │ ├── menu │ └── menu_main.xml │ ├── mipmap-hdpi │ └── ic_launcher.png │ ├── mipmap-mdpi │ └── ic_launcher.png │ ├── mipmap-xhdpi │ └── ic_launcher.png │ ├── mipmap-xxhdpi │ └── ic_launcher.png │ ├── mipmap-xxxhdpi │ └── ic_launcher.png │ ├── values-land │ └── dimens.xml │ ├── values-v21 │ └── dimens.xml │ ├── values-w820dp │ └── dimens.xml │ └── values │ ├── colors.xml │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml ├── screenshots ├── ScreenShot_Phone1.png ├── Screenshot_Phone2.png ├── Screenshot_Phone_N5_1.png ├── Screenshot_Phone_N5_2.png └── samples.png └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | # Files for the Dalvik VM 2 | *.dex 3 | 4 | # Java class files 5 | *.class 6 | 7 | # Generated files 8 | bin/ 9 | gen/ 10 | 11 | # Gradle files 12 | .gradle/ 13 | build/ 14 | 15 | # Local configuration file (sdk path, etc) 16 | local.properties 17 | 18 | # Proguard folder generated by Eclipse 19 | proguard/ 20 | 21 | #Android Studio 22 | .idea/ 23 | *.iml 24 | 25 | # Misc 26 | .DS_Store 27 | -------------------------------------------------------------------------------- /Changelog.md: -------------------------------------------------------------------------------- 1 | ## Changelog 2 | 3 | #### 1.2.2 4 | 5 | * Fixed a major bug when using `android:src` 6 | 7 | #### 1.2.1 8 | 9 | * Added support for shadows 10 | 11 | #### 1.1.0 12 | 13 | * Added support for alpha (`setImageAlpha(int alpha)` & `getImageAlpha()`) 14 | * Added support to enable/disable check state change animation 15 | * Added support to override check mark style, runtime border visibility 16 | * Bug fixes 17 | 18 | #### 1.0.2 19 | 20 | * `CircularImageView` implements `android.widget.Checkable` 21 | 22 | #### 1.0.1 23 | 24 | * Renamed all custom attributes to suffix `ci_` to avoid conflicts 25 | -------------------------------------------------------------------------------- /License.txt: -------------------------------------------------------------------------------- 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. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | CircularImageView 2 | ==== 3 | A checkable Android ImageView implementation that draws circular images with support for optional placeholder text. CircularTextView works with [Picasso][picasso] (tested with picasso:2.5.2) & [Glide][glide] (tested with glide:3.6.1). 4 | 5 | ![Cat](art/cat.png) 6 | 7 | [**Download sample application from Google Play**][app] 8 | 9 | ## Download 10 | 11 | Download the latest version from [releases][1]. 12 | 13 | Or get it using **Gradle:** 14 | 15 | ````groovy 16 | dependencies { 17 | compile 'com.subinkrishna:circularimageview:1.2.2' 18 | } 19 | ```` 20 | 21 | Or **Maven:** 22 | 23 | ````xml 24 | 25 | com.subinkrishna 26 | circularimageview 27 | 1.2.2 28 | 29 | ```` 30 | 31 | ## Usage 32 | 33 | **XML:** 34 | 35 | ````xml 36 | 49 | ```` 50 | 51 | **Java:** 52 | 53 | ````java 54 | CircularImageView imageView = findViewById(R.id.image); 55 | imageView.setBorderColor(Color.WHITE); 56 | imageView.setBorderWidth(TypedValue.COMPLEX_UNIT_DIP, 2); 57 | imageView.setPlaceholder("CV", Color.BLACK, Color.WHITE); 58 | imageView.setPlaceholderTextSize(TypedValue.COMPLEX_UNIT_SP, 22); 59 | imageView.setShadowRadius(5.0f); 60 | imageView.setShadowColor(0xFF999999); 61 | ```` 62 | 63 | **Custom Attributes** 64 | 65 | * `ci_borderWidth` (default: `0`) 66 | * `ci_borderColor` (default: `#FFFFFFFF`) 67 | * `ci_placeholderText` 68 | * `ci_placeholderTextSize` (default: `0`) 69 | * `ci_placeholderTextColor` (default: `#FF000000`) 70 | * `ci_placeholderBackgroundColor` (default: `#FFDDDDDD`) 71 | * `ci_checked` (default: `false`) 72 | * `ci_checkedStateBackgroundColor` (default: `#FFBBBBBB`) 73 | * `ci_shadowRadius` (default: `0`) 74 | * `ci_shadowColor` (default: `#FF666666`) 75 | 76 | **Java Methods** 77 | 78 | * `setBorderWidth(int unit, int size)` 79 | * `setBorderColor(@ColorInt int color)` 80 | * `setPlaceholder(String text)` 81 | * `setPlaceholder(String text, @ColorInt int backgroundColor, @ColorInt int textColor)` 82 | * `setPlaceholderTextSize(int unit, int size)` 83 | * `setCheckedStateBackgroundColor(@ColorInt int backgroundColor)` 84 | * `setImageAlpha(int alpha)` 85 | * `allowCheckStateAnimation(boolean allowAnimation)` 86 | * `setShadowRadius(float radius)` 87 | * `setShadowColor(@ColorInt int shadowColor)` 88 | * `allowCheckStateShadow(boolean allowShadow)` 89 | 90 | Methods implemented from `android.widget.Checkable` 91 | 92 | * `isChecked()` 93 | * `setChecked(boolean checked)` 94 | * `toggle()` 95 | 96 | ## Samples 97 | 98 | ![Sample](screenshots/samples.png) 99 | 100 | **#1 Using Picasso** 101 | 102 | XML: 103 | 104 | ```` xml 105 | 109 | ```` 110 | 111 | Java: 112 | 113 | ````java 114 | CircularImageView i1 = (CircularImageView) findViewById(R.id.image1); 115 | Picasso.with(this) 116 | .load("https://raw.githubusercontent.com/subinkrishna/CircularImageView/master/art/cat_original.jpg") 117 | .placeholder(R.drawable.placeholder) 118 | .centerCrop() 119 | .resize(200, 200) 120 | .into(i1); 121 | ```` 122 | 123 | **#2 Using Glide - Error handling** 124 | 125 | Placeholder image is shown in the sample since Glide tried to load an image from an invalid URL. 126 | 127 | XML: 128 | 129 | ````xml 130 | 138 | 139 | ```` 140 | 141 | Java: 142 | 143 | ````java 144 | CircularImageView i2 = (CircularImageView) findViewById(R.id.image2); 145 | Glide.with(this) 146 | .load("http://invalid.url") 147 | .asBitmap() 148 | .error(R.drawable.placeholder) 149 | .into(i2); 150 | ```` 151 | 152 | **#3 Local asset** 153 | 154 | ````xml 155 | 162 | ```` 163 | 164 | **#4 Placeholder text with custom border & background** 165 | 166 | Placeholder text is shown along with custom border & background when no bitmap is loaded. 167 | 168 | ````xml 169 | 177 | ```` 178 | 179 | ## Changelog 180 | 181 | You can find the changelog [here][Changelog]. 182 | 183 | ## Limitations & known issues 184 | 185 | * CircularImageView doesn't resize bitmaps to match the view size. 186 | * No support for animations. Please use `DrawableTypeRequest.asBitmap()` to make CircularImageView to work with [Glide][glide]. 187 | 188 | ## Using vectors/XML drawable resources 189 | 190 | As of now, XML drawable resources need to be set using `setImageBitmap()`. 191 | 192 | ```java 193 | final Bitmap bitmap = getBitmap(context, resId, width, height); 194 | image.setImageBitmap(bitmap); 195 | 196 | // Converts the drawable resource to Bitmap 197 | public static Bitmap getBitmap(Context context, 198 | int resId, 199 | int w, 200 | int h) { 201 | Drawable drawable = AppCompatDrawableManager.get().getDrawable(context, resId); 202 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { 203 | drawable = (DrawableCompat.wrap(drawable)).mutate(); 204 | } 205 | 206 | Bitmap bitmap = (w > 0) && (h > 0) 207 | ? Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888) 208 | : null; 209 | if (null != bitmap) { 210 | final Canvas canvas = new Canvas(bitmap); 211 | drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); 212 | drawable.draw(canvas); 213 | } 214 | 215 | return bitmap; 216 | } 217 | ``` 218 | 219 | ## License 220 | 221 | Copyright (C) 2016 Subinkrishna Gopi 222 | 223 | Licensed under the Apache License, Version 2.0 (the "License"); 224 | you may not use this file except in compliance with the License. 225 | You may obtain a copy of the License at 226 | 227 | http://www.apache.org/licenses/LICENSE-2.0 228 | 229 | Unless required by applicable law or agreed to in writing, software 230 | distributed under the License is distributed on an "AS IS" BASIS, 231 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 232 | See the License for the specific language governing permissions and 233 | limitations under the License. 234 | 235 | [1]: ../../releases 236 | [app]:https://play.google.com/store/apps/details?id=com.subinkrishna.circularimageview.demo 237 | [picasso]: http://square.github.io/picasso/ 238 | [glide]: https://github.com/bumptech/glide 239 | [changelog]: Changelog.md -------------------------------------------------------------------------------- /apk/sample-app.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subinkrishna/CircularImageView/b3033a79f4f831c0a7c2567cc52f63b8410198a2/apk/sample-app.apk -------------------------------------------------------------------------------- /art/cat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subinkrishna/CircularImageView/b3033a79f4f831c0a7c2567cc52f63b8410198a2/art/cat.png -------------------------------------------------------------------------------- /art/cat_hi_res_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subinkrishna/CircularImageView/b3033a79f4f831c0a7c2567cc52f63b8410198a2/art/cat_hi_res_icon.png -------------------------------------------------------------------------------- /art/cat_icon_original.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subinkrishna/CircularImageView/b3033a79f4f831c0a7c2567cc52f63b8410198a2/art/cat_icon_original.png -------------------------------------------------------------------------------- /art/cat_original.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subinkrishna/CircularImageView/b3033a79f4f831c0a7c2567cc52f63b8410198a2/art/cat_original.jpg -------------------------------------------------------------------------------- /art/en-play-badge.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subinkrishna/CircularImageView/b3033a79f4f831c0a7c2567cc52f63b8410198a2/art/en-play-badge.png -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:2.2.3' 9 | 10 | // NOTE: Do not place your application dependencies here; they belong 11 | // in the individual module build.gradle files 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | jcenter() 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /circularimageview/.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | 15 | # Gradle files 16 | .gradle/ 17 | build/ 18 | 19 | # Local configuration file (sdk path, etc) 20 | local.properties 21 | 22 | # Proguard folder generated by Eclipse 23 | proguard/ 24 | 25 | #Android Studio 26 | .idea/ 27 | *.iml 28 | 29 | # Misc 30 | .DS_Store -------------------------------------------------------------------------------- /circularimageview/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion "23.0.2" 6 | 7 | defaultConfig { 8 | minSdkVersion 14 9 | targetSdkVersion 23 10 | versionCode 7 11 | versionName "1.2.2" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | } 20 | 21 | dependencies { 22 | compile 'com.android.support:support-annotations:23.2.1' 23 | } 24 | 25 | apply from: 'https://raw.github.com/chrisbanes/gradle-mvn-push/master/gradle-mvn-push.gradle' -------------------------------------------------------------------------------- /circularimageview/gradle.properties: -------------------------------------------------------------------------------- 1 | POM_NAME=CircularImageView 2 | POM_ARTIFACT_ID=circularimageview 3 | POM_PACKAGING=aar -------------------------------------------------------------------------------- /circularimageview/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.subinkrishna 8 | circularimageview 9 | 1.0.0 10 | aar 11 | CircularImageView 12 | Android ImageView implementation that draws circular images with support for optional placeholder text. CircularImageView supports Picasso and Glide. 13 | https://github.com/subinkrishna/CircularImageView 14 | 15 | 16 | 17 | The Apache License, Version 2.0 18 | http://www.apache.org/licenses/LICENSE-2.0.txt 19 | 20 | 21 | 22 | 23 | 24 | Subinkrishna Gopi 25 | subinkrishna.gopi@gmail.com 26 | Subinkrishna Gopi 27 | https://github.com/subinkrishna 28 | 29 | 30 | 31 | 32 | scm:git:git@github.com:subinkrishna/CircularImageView.git 33 | scm:git:git@github.com:subinkrishna/CircularImageView.git 34 | git@github.com:subinkrishna/CircularImageView.git 35 | 36 | 37 | 38 | 39 | com.android.support 40 | support-annotations 41 | 23.0.0 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /circularimageview/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/subin/Dev/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 | -------------------------------------------------------------------------------- /circularimageview/src/androidTest/java/com/subinkrishna/widget/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.subinkrishna.widget; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /circularimageview/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /circularimageview/src/main/java/com/subinkrishna/widget/CircularImageView.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Subinkrishna Gopi 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.subinkrishna.widget; 18 | 19 | import android.animation.Animator; 20 | import android.animation.AnimatorListenerAdapter; 21 | import android.animation.ObjectAnimator; 22 | import android.content.Context; 23 | import android.content.res.TypedArray; 24 | import android.graphics.Bitmap; 25 | import android.graphics.BitmapShader; 26 | import android.graphics.Canvas; 27 | import android.graphics.ColorFilter; 28 | import android.graphics.Matrix; 29 | import android.graphics.Paint; 30 | import android.graphics.Path; 31 | import android.graphics.Shader; 32 | import android.graphics.Typeface; 33 | import android.graphics.drawable.BitmapDrawable; 34 | import android.graphics.drawable.Drawable; 35 | import android.os.Build; 36 | import android.support.annotation.CallSuper; 37 | import android.support.annotation.ColorInt; 38 | import android.text.TextUtils; 39 | import android.util.AttributeSet; 40 | import android.util.TypedValue; 41 | import android.view.animation.DecelerateInterpolator; 42 | import android.view.animation.Interpolator; 43 | import android.widget.Checkable; 44 | import android.widget.ImageView; 45 | 46 | import java.util.Locale; 47 | 48 | /** 49 | * Circular Image View. 50 | * 51 | * @author Subinkrishna Gopi 52 | */ 53 | public class CircularImageView 54 | extends ImageView 55 | implements Checkable { 56 | 57 | /** Log tag */ 58 | private static final String TAG = CircularImageView.class.getSimpleName(); 59 | 60 | /** Default colors */ 61 | private static final int DEFAULT_BORDER_COLOR = 0xFFFFFFFF; 62 | private static final int DEFAULT_BACKGROUND_COLOR = 0xFFDDDDDD; 63 | private static final int DEFAULT_TEXT_COLOR = 0xFF000000; 64 | private static final int DEFAULT_CHECKED_BACKGROUND_COLOR = 0xFFBBBBBB; 65 | private static final int DEFAULT_CHECK_STROKE_COLOR = 0xFFFFFFFF; 66 | private static final int DEFAULT_SHADOW_COLOR = 0xFF666666; 67 | 68 | /** Default dimensions */ 69 | private static final float DEFAULT_CHECK_STROKE_WIDTH_IN_DP = 3f; 70 | private static final float DEFAULT_SHADOW_RADIUS = 0; 71 | 72 | private Paint mBitmapPaint; 73 | private Paint mBorderPaint; 74 | private Paint mBackgroundPaint; 75 | private Paint mCheckMarkPaint; 76 | private Paint mCheckedBackgroundPaint; 77 | private Paint mTextPaint; 78 | private int mWidth, mHeight, mRadius; 79 | private float mShadowRadius; 80 | private int mLongStrokeHeight; 81 | private Path mPath = new Path(); 82 | 83 | // Configurations 84 | private int mBorderWidth; 85 | private int mBorderColor; 86 | private int mBackgroundColor; 87 | private int mCheckedBackgroundColor; 88 | private int mShadowColor; 89 | private int mTextColor; 90 | private int mAlpha = 0xFF; 91 | private String mText; 92 | private int mTextSize; 93 | private boolean mChecked; 94 | private boolean mAllowCheckStateAnimation = true, 95 | mAllowCheckStateShadow = false; 96 | 97 | public CircularImageView(Context context) { 98 | this(context, null, 0); 99 | } 100 | 101 | public CircularImageView(Context context, AttributeSet attrs) { 102 | this(context, attrs, 0); 103 | } 104 | 105 | public CircularImageView(Context context, AttributeSet attrs, int defStyleAttr) { 106 | super(context, attrs, defStyleAttr); 107 | init(context, attrs); 108 | } 109 | 110 | private void init(Context context, AttributeSet attrs) { 111 | TypedArray t = null; 112 | if (null != attrs) { 113 | t = context.getTheme().obtainStyledAttributes(attrs, 114 | R.styleable.CircularImageView, 0, 0); 115 | } 116 | 117 | // Extract configurations 118 | mBorderColor = DEFAULT_BORDER_COLOR; 119 | mBackgroundColor = DEFAULT_BACKGROUND_COLOR; 120 | mCheckedBackgroundColor = DEFAULT_CHECKED_BACKGROUND_COLOR; 121 | mShadowRadius = DEFAULT_SHADOW_RADIUS; 122 | mShadowColor = DEFAULT_SHADOW_COLOR; 123 | 124 | if (null != t) { 125 | // Border and background 126 | mBorderWidth = t.getDimensionPixelSize(R.styleable.CircularImageView_ci_borderWidth, 0); 127 | mBorderColor = t.getColor(R.styleable.CircularImageView_ci_borderColor, 128 | DEFAULT_BORDER_COLOR); 129 | mBackgroundColor = t.getColor(R.styleable.CircularImageView_ci_placeholderBackgroundColor, 130 | DEFAULT_BACKGROUND_COLOR); 131 | 132 | // Placeholder text 133 | mText = t.getString(R.styleable.CircularImageView_ci_placeholderText); 134 | mTextColor = t.getColor(R.styleable.CircularImageView_ci_placeholderTextColor, 135 | DEFAULT_TEXT_COLOR); 136 | mTextSize = t.getDimensionPixelSize(R.styleable.CircularImageView_ci_placeholderTextSize, 0); 137 | 138 | // Check state 139 | mChecked = t.getBoolean(R.styleable.CircularImageView_ci_checked, false); 140 | mCheckedBackgroundColor = t.getColor(R.styleable.CircularImageView_ci_checkedStateBackgroundColor, 141 | DEFAULT_CHECKED_BACKGROUND_COLOR); 142 | 143 | // Shadow 144 | mShadowRadius = Math.max(t.getFloat(R.styleable.CircularImageView_ci_shadowRadius, 145 | DEFAULT_SHADOW_RADIUS), 0); 146 | mShadowColor = t.getColor(R.styleable.CircularImageView_ci_shadowColor, 147 | DEFAULT_SHADOW_COLOR); 148 | 149 | t.recycle(); 150 | } 151 | 152 | mBitmapPaint = new Paint(Paint.ANTI_ALIAS_FLAG); 153 | 154 | setBorderInternal(mBorderWidth, mBorderColor, false); 155 | setPlaceholderTextInternal(mText, 156 | mTextColor, mTextSize, false); 157 | 158 | mBackgroundPaint = new Paint(); 159 | mBackgroundPaint.setAntiAlias(true); 160 | mBackgroundPaint.setColor(mBackgroundColor); 161 | mBackgroundPaint.setStyle(Paint.Style.FILL); 162 | 163 | mCheckedBackgroundPaint = new Paint(Paint.ANTI_ALIAS_FLAG); 164 | mCheckedBackgroundPaint.setColor(mCheckedBackgroundColor); 165 | mCheckedBackgroundPaint.setStyle(Paint.Style.FILL); 166 | 167 | mCheckMarkPaint = getCheckMarkPaint(); 168 | 169 | setShadowInternal(mShadowRadius, mShadowColor, false); 170 | } 171 | 172 | /** 173 | * Sets the border paint (and configs). 174 | * 175 | * @param rawSize 176 | * @param color 177 | * @param invalidate 178 | */ 179 | private void setBorderInternal(int rawSize, 180 | @ColorInt int color, 181 | boolean invalidate) { 182 | mBorderWidth = rawSize; 183 | mBorderColor = color; 184 | 185 | if (null == mBorderPaint) { 186 | mBorderPaint = new Paint(); 187 | mBorderPaint.setAntiAlias(true); 188 | mBorderPaint.setStyle(Paint.Style.FILL); 189 | } 190 | 191 | if (null != mBorderPaint) { 192 | mBorderPaint.setColor(mBorderColor); 193 | mBorderPaint.setStrokeWidth(Math.max(0, mBorderWidth)); // in pixels 194 | } 195 | 196 | // Invalidate the view if asked 197 | if (invalidate) { 198 | invalidate(); 199 | } 200 | } 201 | 202 | /** 203 | * Set shadow layers 204 | * 205 | * @param radius 206 | * @param color 207 | * @param invalidate 208 | */ 209 | private void setShadowInternal(float radius, 210 | @ColorInt int color, 211 | boolean invalidate) { 212 | mShadowRadius = radius; 213 | mShadowColor = color; 214 | 215 | // Reset previous shadow layer 216 | mBorderPaint.clearShadowLayer(); 217 | mCheckedBackgroundPaint.clearShadowLayer(); 218 | 219 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { 220 | setLayerType(LAYER_TYPE_SOFTWARE, mBorderPaint); 221 | setLayerType(LAYER_TYPE_SOFTWARE, mCheckedBackgroundPaint); 222 | } 223 | 224 | mBorderPaint.setShadowLayer( 225 | mShadowRadius, 226 | 0.0f, 227 | mShadowRadius / 2, 228 | mShadowColor); 229 | 230 | if (mAllowCheckStateShadow) { 231 | mCheckedBackgroundPaint.setShadowLayer( 232 | mShadowRadius, 233 | 0.0f, 234 | mShadowRadius / 2, 235 | mShadowColor); 236 | } 237 | 238 | // Invalidate the view if asked 239 | if (invalidate) { 240 | invalidate(); 241 | } 242 | } 243 | 244 | /** 245 | * Sets placeholder text paint and configs. 246 | * 247 | * @param text 248 | * @param color 249 | * @param textSize 250 | * @param invalidate 251 | */ 252 | private void setPlaceholderTextInternal(String text, 253 | @ColorInt int color, 254 | int textSize, 255 | boolean invalidate) { 256 | // Takes only the first character as the place holder 257 | mText = formatPlaceholderText(text); 258 | mTextColor = color; 259 | mTextSize = textSize; 260 | 261 | if ((null == mTextPaint) && 262 | (textSize > 0) && 263 | !TextUtils.isEmpty(mText)) { 264 | mTextPaint = getTextPaint(); 265 | } 266 | 267 | if (null != mTextPaint) { 268 | mTextPaint.setColor(color); 269 | mTextPaint.setTextSize(textSize); 270 | } 271 | 272 | // Invalidate the view if asked 273 | if (invalidate) { 274 | invalidate(); 275 | } 276 | } 277 | 278 | @Override 279 | @CallSuper 280 | protected void onSizeChanged(int w, int h, int oldw, int oldh) { 281 | super.onSizeChanged(w, h, oldw, oldh); 282 | mWidth = w; 283 | mHeight = h; 284 | mRadius = Math.min(w, h) / 2; 285 | 286 | // Check stroke 287 | mLongStrokeHeight = mRadius; 288 | 289 | if (null != mBitmapPaint) { 290 | updateBitmapShader(); 291 | } 292 | } 293 | 294 | @CallSuper 295 | @Override 296 | public void invalidate() { 297 | super.invalidate(); 298 | 299 | if (null != mBitmapPaint) { 300 | updateBitmapShader(); 301 | } 302 | } 303 | 304 | @Override 305 | public void setColorFilter(ColorFilter cf) { 306 | // NOTE: All other variations of ImageView#setColorFilter will 307 | // end up calling ImageView#setColorFilter(ColorFilter). 308 | if (null != mBitmapPaint) { 309 | mBitmapPaint.setColorFilter(cf); 310 | } 311 | } 312 | 313 | public void setImageAlpha(int alpha) { 314 | alpha &= 0xFF; 315 | if (mAlpha != alpha) { 316 | mAlpha = alpha; 317 | if (null != mBitmapPaint) mBitmapPaint.setAlpha(alpha); 318 | if (null != mBorderPaint) mBorderPaint.setAlpha(alpha); 319 | if (null != mBackgroundPaint) mBackgroundPaint.setAlpha(alpha); 320 | if (null != mCheckMarkPaint) mCheckMarkPaint.setAlpha(alpha); 321 | if (null != mCheckedBackgroundPaint) mCheckedBackgroundPaint.setAlpha(alpha); 322 | if (null != mTextPaint) mTextPaint.setAlpha(alpha); 323 | invalidate(); 324 | } 325 | } 326 | 327 | public int getImageAlpha() { 328 | return mAlpha; 329 | } 330 | 331 | /** 332 | * Sets the border width. 333 | * 334 | * @param unit The desired dimension unit. 335 | * @param size 336 | */ 337 | public final void setBorderWidth(int unit, 338 | int size) { 339 | if (size < 0) { 340 | throw new IllegalArgumentException("Border width cannot be less than zero."); 341 | } 342 | 343 | int scaledSize = (int) TypedValue.applyDimension(unit, size, getResources().getDisplayMetrics()); 344 | setBorderInternal(scaledSize, mBorderColor, true); 345 | } 346 | 347 | /** 348 | * Sets the border color. 349 | * 350 | * @param color 351 | */ 352 | public final void setBorderColor(@ColorInt int color) { 353 | if (color != mBorderColor) { 354 | setBorderInternal(mBorderWidth, color, true); 355 | } 356 | } 357 | 358 | /** 359 | * Sets the check state background color. 360 | * 361 | * @param backgroundColor 362 | */ 363 | public final void setCheckedStateBackgroundColor(@ColorInt int backgroundColor) { 364 | if ((backgroundColor != mCheckedBackgroundColor) && 365 | (null != mCheckedBackgroundPaint)) { 366 | mCheckedBackgroundPaint.setColor(backgroundColor); 367 | if (isChecked()) { 368 | invalidate(); 369 | } 370 | } 371 | 372 | mCheckedBackgroundColor = backgroundColor; 373 | } 374 | 375 | /** 376 | * Sets the placeholder text. 377 | * 378 | * @param text 379 | */ 380 | public final void setPlaceholder(String text) { 381 | if (!text.equalsIgnoreCase(mText)) { 382 | setPlaceholderTextInternal(text, mTextColor, mTextSize, true); 383 | } 384 | } 385 | 386 | /** 387 | * Sets the placeholder text size. 388 | * 389 | * @param unit The desired dimension unit. 390 | * @param size 391 | */ 392 | public final void setPlaceholderTextSize(int unit, 393 | int size) { 394 | if (size < 0) { 395 | throw new IllegalArgumentException("Text size cannot be less than zero."); 396 | } 397 | 398 | int scaledSize = (int) TypedValue.applyDimension(unit, size, getResources().getDisplayMetrics()); 399 | setPlaceholderTextInternal(mText, mTextColor, scaledSize, true); 400 | } 401 | 402 | /** 403 | * Set the placeholder text and colors. 404 | * 405 | * @param text 406 | * @param backgroundColor 407 | * @param textColor 408 | */ 409 | public final void setPlaceholder(String text, 410 | @ColorInt int backgroundColor, 411 | @ColorInt int textColor) { 412 | boolean invalidate = false; 413 | // Set the placeholder background color 414 | if (backgroundColor != mBackgroundColor) { 415 | mBackgroundColor = backgroundColor; 416 | if (null != mBackgroundPaint) { 417 | mBackgroundPaint.setColor(backgroundColor); 418 | invalidate = true; 419 | } 420 | } 421 | // Set the placeholder text color 422 | if (!text.equalsIgnoreCase(mText) || 423 | (backgroundColor != mBackgroundColor) || 424 | (textColor != mTextColor)) { 425 | setPlaceholderTextInternal(text, textColor, mTextSize, false); 426 | invalidate = true; 427 | } 428 | 429 | if (invalidate) { 430 | invalidate(); 431 | } 432 | } 433 | 434 | /** 435 | * Allows check state animation if set to true. 436 | * 437 | * @param allowAnimation 438 | */ 439 | public final void allowCheckStateAnimation(boolean allowAnimation) { 440 | mAllowCheckStateAnimation = allowAnimation; 441 | } 442 | 443 | /** 444 | * Sets shadow radius 445 | * 446 | * @param radius 447 | */ 448 | public void setShadowRadius(float radius) { 449 | if (radius < 0) { 450 | throw new IllegalArgumentException("Shadow radius cannot be less than zero."); 451 | } 452 | 453 | if (radius != mShadowRadius) { 454 | setShadowInternal(radius, mShadowColor, true); 455 | } 456 | } 457 | 458 | /** 459 | * Sets shadow color 460 | * 461 | * @param color 462 | */ 463 | public void setShadowColor(@ColorInt int color) { 464 | if (color != mShadowColor) { 465 | setShadowInternal(mShadowRadius, color, true); 466 | } 467 | } 468 | 469 | /** 470 | * Allow shadow when in checked state. 471 | * 472 | * @param allow 473 | */ 474 | public void allowCheckStateShadow(boolean allow) { 475 | if (allow != mAllowCheckStateShadow) { 476 | mAllowCheckStateShadow = allow; 477 | setShadowInternal(mShadowRadius, mShadowColor, true); 478 | } 479 | } 480 | 481 | /** 482 | * Default implementation of the placeholder text formatting. 483 | * 484 | * @param text 485 | * @return 486 | */ 487 | protected String formatPlaceholderText(String text) { 488 | String formattedText = (null != text) ? text.trim() : null; 489 | int length = (null != formattedText) ? formattedText.length() : 0; 490 | if (length > 0) { 491 | return formattedText.substring(0, Math.min(2, length)).toUpperCase(Locale.getDefault()); 492 | } 493 | return null; 494 | } 495 | 496 | /** 497 | * Tells the widget whether it should draw the border. This method will be called 498 | * every time from {@linkplain #onDraw(Canvas)} ONLY when border width > 0 and 499 | * the view is in non-checked state. 500 | * 501 | * @return 502 | */ 503 | protected boolean shouldDrawBorder() { 504 | return true; 505 | } 506 | 507 | /** 508 | * Default implementation of text {@code Paint} creation. 509 | * 510 | * @return 511 | */ 512 | protected Paint getTextPaint() { 513 | Paint textPaint = new Paint(Paint.ANTI_ALIAS_FLAG); 514 | textPaint.setStyle(Paint.Style.FILL); 515 | textPaint.setTypeface(Typeface.DEFAULT); 516 | textPaint.setTextAlign(Paint.Align.CENTER); 517 | return textPaint; 518 | } 519 | 520 | /** 521 | * Default implementation of check mark {@code Paint} creation. 522 | * 523 | * @return 524 | */ 525 | protected Paint getCheckMarkPaint() { 526 | Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); 527 | paint.setColor(DEFAULT_CHECK_STROKE_COLOR); 528 | paint.setStyle(Paint.Style.STROKE); 529 | paint.setStrokeWidth(getCheckMarkStrokeWidthInPixels()); 530 | return paint; 531 | } 532 | 533 | /** 534 | * Returns the default check mark stroke width in pixels. 535 | * 536 | * @return 537 | */ 538 | protected int getCheckMarkStrokeWidthInPixels() { 539 | return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 540 | DEFAULT_CHECK_STROKE_WIDTH_IN_DP, 541 | getResources().getDisplayMetrics()); 542 | } 543 | 544 | @Override 545 | protected void onDraw(Canvas canvas) { 546 | int x = mWidth / 2; 547 | int y = mHeight / 2; 548 | 549 | // Is checked? 550 | if (mChecked) { 551 | drawCheckedState(canvas, mWidth, mHeight); 552 | } 553 | else { 554 | // Checks whether to draw border 555 | boolean drawBorder = shouldDrawBorder(); 556 | int borderWidth = drawBorder ? mBorderWidth : 0; 557 | // Draw the border 558 | if (null != mBorderPaint) { 559 | canvas.drawCircle(x, y, 560 | mRadius - (mShadowRadius * 1.5f + 1), 561 | mBorderPaint); 562 | } 563 | 564 | // Offset makes sure that there is no visible gap between 565 | // border and drawable 566 | int offset = (borderWidth > 0) ? borderWidth : 0; 567 | // Consider shadow 568 | offset += mShadowRadius * 1.5f; 569 | 570 | if (null != getDrawable()) { 571 | // Draws the bitmap if available 572 | canvas.drawCircle(x, y, mRadius - offset, mBitmapPaint); 573 | } else { 574 | // Placeholder background 575 | canvas.drawCircle(x, y, mRadius - offset, mBackgroundPaint); 576 | // Placeholder character 577 | if ((null != mTextPaint) && !TextUtils.isEmpty(mText)) { 578 | int ty = (int) ((mHeight - (mTextPaint.ascent() + mTextPaint.descent())) * 0.5f); 579 | canvas.drawText(mText, x, ty, mTextPaint); 580 | } 581 | } 582 | } 583 | } 584 | 585 | /** 586 | * Draws the checked state. 587 | * 588 | * @param canvas 589 | * @param w 590 | * @param h 591 | */ 592 | protected void drawCheckedState(Canvas canvas, int w, int h) { 593 | int x = w / 2; 594 | int y = h / 2; 595 | 596 | canvas.drawCircle(x, y, 597 | mRadius - (mShadowRadius * 1.5f), 598 | mCheckedBackgroundPaint); 599 | canvas.save(); 600 | 601 | int shortStrokeHeight = (int) (mLongStrokeHeight * .4f); 602 | int halfH = (int) (mLongStrokeHeight * .5f); 603 | int offset = (int)(shortStrokeHeight * .3f); 604 | int sx = x + offset; 605 | int sy = y - offset; 606 | mPath.reset(); 607 | mPath.moveTo(sx, sy - halfH); 608 | mPath.lineTo(sx, sy + halfH); // draw long stroke 609 | mPath.moveTo(sx + (getCheckMarkStrokeWidthInPixels() * .5f), sy + halfH); 610 | mPath.lineTo(sx - shortStrokeHeight, sy + halfH); // draw short stroke 611 | 612 | // Rotates the canvas to draw an angled check mark 613 | canvas.rotate(45f, x, y); 614 | canvas.drawPath(mPath, mCheckMarkPaint); 615 | // Restore the canvas to previously saved state 616 | canvas.restore(); 617 | } 618 | 619 | /** 620 | * Updates BitmapShader to draw the bitmap in CENTER_CROP mode. 621 | */ 622 | private void updateBitmapShader() { 623 | Drawable drawable = getDrawable(); 624 | Bitmap bitmap = null; 625 | if ((null != drawable) && (drawable instanceof BitmapDrawable)) { 626 | bitmap = ((BitmapDrawable) drawable).getBitmap(); 627 | } 628 | 629 | // Clear the shader & abort is the new bitmap is null 630 | if (null == bitmap) { 631 | mBitmapPaint.setShader(null); 632 | return; 633 | } 634 | 635 | int bitmapWidth = bitmap.getWidth(); 636 | int bitmapHeight = bitmap.getHeight(); 637 | float x = 0, y = 0; 638 | int diameter = mRadius * 2; 639 | // Offset takes the border width in to account when calculating the the scale 640 | int borderWidth = shouldDrawBorder() ? mBorderWidth : 0; 641 | int offset = (borderWidth > 0) ? (borderWidth * 2) : 0; 642 | // Consider shadow too 643 | offset += mShadowRadius * 1.5f; 644 | float scale = (float) (diameter - offset) / (float) Math.min(bitmapHeight, bitmapWidth); 645 | 646 | x = (mWidth - bitmapWidth * scale) * 0.5f; 647 | y = (mHeight - bitmapHeight * scale) * 0.5f; 648 | 649 | // Apply scale and translation to matrix 650 | Matrix matrix = new Matrix(); 651 | matrix.setScale(scale, scale); 652 | matrix.postTranslate(Math.round(x), Math.round(y)); 653 | 654 | // Create the BitmapShader and apply the Matrix 655 | BitmapShader shader = new BitmapShader(bitmap, 656 | Shader.TileMode.CLAMP, 657 | Shader.TileMode.CLAMP); 658 | shader.setLocalMatrix(matrix); 659 | mBitmapPaint.setShader(shader); 660 | } 661 | 662 | // Checkable 663 | 664 | @Override 665 | public void setChecked(final boolean checked) { 666 | if (mChecked == checked) 667 | return; 668 | 669 | if (mAllowCheckStateAnimation) { 670 | final int duration = 150; 671 | final Interpolator interpolator = new DecelerateInterpolator(); 672 | ObjectAnimator animation = ObjectAnimator.ofFloat(this, "scaleX", 1f, 0f); 673 | animation.setDuration(duration); 674 | animation.setInterpolator(interpolator); 675 | animation.addListener(new AnimatorListenerAdapter() { 676 | @Override 677 | public void onAnimationEnd(Animator animation) { 678 | mChecked = checked; 679 | invalidate(); 680 | ObjectAnimator reverse = ObjectAnimator.ofFloat(CircularImageView.this, "scaleX", 0f, 1f); 681 | reverse.setDuration(duration); 682 | reverse.setInterpolator(interpolator); 683 | reverse.start(); 684 | } 685 | }); 686 | animation.start(); 687 | } else { 688 | mChecked = checked; 689 | invalidate(); 690 | } 691 | } 692 | 693 | @Override 694 | public boolean isChecked() { 695 | return mChecked; 696 | } 697 | 698 | @Override 699 | public void toggle() { 700 | setChecked(!mChecked); 701 | } 702 | } 703 | -------------------------------------------------------------------------------- /circularimageview/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | VERSION_NAME=1.2.2 2 | VERSION_CODE=7 3 | GROUP=com.subinkrishna 4 | 5 | POM_DESCRIPTION=CircularImageView is a checkable Android ImageView implementation that draws circular images with support for optional placeholder text. CircularImageView supports Picasso & Glide. 6 | POM_URL=https://github.com/subinkrishna/CircularImageView 7 | POM_SCM_URL=https://github.com/subinkrishna/CircularImageView 8 | POM_SCM_CONNECTION=scm:git@github.com:subinkrishna/CircularImageView.git 9 | POM_SCM_DEV_CONNECTION=scm:git@github.com:subinkrishna/CircularImageView.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=subinkrishna 14 | POM_DEVELOPER_NAME=Subinkrishna Gopi -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subinkrishna/CircularImageView/b3033a79f4f831c0a7c2567cc52f63b8410198a2/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Oct 19 09:38:05 MDT 2016 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip 7 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /quick_samples/AvatarView.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Subinkrishna Gopi 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.subinkrishna.customviews.widget; 18 | 19 | import android.content.Context; 20 | import android.graphics.Color; 21 | import android.graphics.Paint; 22 | import android.util.AttributeSet; 23 | import android.util.TypedValue; 24 | 25 | import com.subinkrishna.widget.CircularImageView; 26 | 27 | /** 28 | * Extension of CircularImageView that overrides checkmark color, width 29 | * and animation. 30 | * 31 | * @author Subinkrishna Gopi 32 | */ 33 | public class AvatarView extends CircularImageView { 34 | 35 | public AvatarView(Context context) { 36 | this(context, null, 0); 37 | } 38 | 39 | public AvatarView(Context context, AttributeSet attrs) { 40 | this(context, attrs, 0); 41 | } 42 | 43 | public AvatarView(Context context, AttributeSet attrs, int defStyleAttr) { 44 | super(context, attrs, defStyleAttr); 45 | // Disabling check state animations all together 46 | allowCheckStateAnimation(false); 47 | } 48 | 49 | @Override 50 | protected boolean shouldDrawBorder() { 51 | // Draw border only when no drawable is set 52 | return null != getDrawable(); 53 | } 54 | 55 | @Override 56 | protected Paint getCheckMarkPaint() { 57 | Paint paint = super.getCheckMarkPaint(); 58 | // Overriding stroke color 59 | paint.setColor(Color.YELLOW); 60 | return paint; 61 | } 62 | 63 | @Override 64 | protected int getCheckMarkStrokeWidthInPixels() { 65 | // Overriding stroke width to 5dp (default is 3dp) 66 | return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 67 | 5, // DIPs 68 | getResources().getDisplayMetrics()); 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /sample/.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | 15 | # Gradle files 16 | .gradle/ 17 | build/ 18 | 19 | # Local configuration file (sdk path, etc) 20 | local.properties 21 | 22 | # Proguard folder generated by Eclipse 23 | proguard/ 24 | 25 | #Android Studio 26 | .idea/ 27 | *.iml 28 | 29 | # Misc 30 | .DS_Store 31 | -------------------------------------------------------------------------------- /sample/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion "23.0.2" 6 | 7 | defaultConfig { 8 | applicationId "com.subinkrishna.circularimageview.demo" 9 | minSdkVersion 14 10 | targetSdkVersion 23 11 | versionCode 7 12 | versionName "1.2.2" 13 | } 14 | 15 | signingConfigs { 16 | release { 17 | storeFile file(DEMO_KEYSTORE) 18 | storePassword DEMO_KEYSTORE_PASSWORD 19 | keyAlias DEMO_KEY_ALIAS 20 | keyPassword DEMO_KEY_PASSWORD 21 | } 22 | } 23 | 24 | buildTypes { 25 | release { 26 | minifyEnabled false 27 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 28 | signingConfig signingConfigs.release 29 | } 30 | } 31 | } 32 | 33 | dependencies { 34 | compile project(':circularimageview') 35 | // compile fileTree(dir: 'libs', include: ['*.jar']) 36 | compile 'com.android.support:appcompat-v7:23.2.1' 37 | compile 'com.github.bumptech.glide:glide:3.6.1' 38 | compile 'com.squareup.picasso:picasso:2.5.2' 39 | compile 'com.jakewharton:butterknife:7.0.1' 40 | compile 'com.android.support:design:23.2.1' 41 | } 42 | -------------------------------------------------------------------------------- /sample/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/subin/Dev/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 | -------------------------------------------------------------------------------- /sample/src/androidTest/java/com/subinkrishna/circularimageview/demo/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.subinkrishna.circularimageview.demo; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /sample/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 13 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /sample/src/main/assets/fonts/roboto/Mono-Light.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subinkrishna/CircularImageView/b3033a79f4f831c0a7c2567cc52f63b8410198a2/sample/src/main/assets/fonts/roboto/Mono-Light.ttf -------------------------------------------------------------------------------- /sample/src/main/assets/fonts/roboto/Mono-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subinkrishna/CircularImageView/b3033a79f4f831c0a7c2567cc52f63b8410198a2/sample/src/main/assets/fonts/roboto/Mono-Regular.ttf -------------------------------------------------------------------------------- /sample/src/main/java/com/subinkrishna/circularimageview/demo/App.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Subinkrishna Gopi 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.subinkrishna.circularimageview.demo; 18 | 19 | import android.app.Application; 20 | 21 | /** 22 | * @author Subinkrishna Gopi 23 | */ 24 | public class App extends Application { 25 | 26 | /** Log tag */ 27 | private static final String TAG = App.class.getSimpleName(); 28 | 29 | @Override 30 | public void onCreate() { 31 | super.onCreate(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /sample/src/main/java/com/subinkrishna/circularimageview/demo/MainActivity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Subinkrishna Gopi 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.subinkrishna.circularimageview.demo; 18 | 19 | import android.animation.Animator; 20 | import android.animation.AnimatorListenerAdapter; 21 | import android.animation.ObjectAnimator; 22 | import android.annotation.SuppressLint; 23 | import android.content.res.Resources; 24 | import android.graphics.Bitmap; 25 | import android.graphics.BitmapFactory; 26 | import android.graphics.Shader; 27 | import android.graphics.Typeface; 28 | import android.graphics.drawable.BitmapDrawable; 29 | import android.os.Build; 30 | import android.os.Bundle; 31 | import android.support.design.widget.FloatingActionButton; 32 | import android.support.v7.app.AppCompatActivity; 33 | import android.support.v7.widget.Toolbar; 34 | import android.util.Log; 35 | import android.util.TypedValue; 36 | import android.view.View; 37 | import android.view.ViewAnimationUtils; 38 | import android.view.ViewGroup; 39 | import android.view.animation.DecelerateInterpolator; 40 | import android.widget.CheckBox; 41 | import android.widget.CompoundButton; 42 | import android.widget.ScrollView; 43 | import android.widget.TextView; 44 | import android.widget.Toast; 45 | 46 | import com.squareup.picasso.MemoryPolicy; 47 | import com.squareup.picasso.Picasso; 48 | import com.subinkrishna.circularimageview.demo.view.CompoundImageView; 49 | import com.subinkrishna.widget.CircularImageView; 50 | 51 | import butterknife.Bind; 52 | import butterknife.BindDimen; 53 | import butterknife.ButterKnife; 54 | 55 | public class MainActivity 56 | extends AppCompatActivity 57 | implements View.OnClickListener { 58 | 59 | /** Log tag */ 60 | private static final String TAG = MainActivity.class.getSimpleName(); 61 | 62 | @Bind(R.id.toolbar) Toolbar mToolbar; 63 | @Bind(R.id.toolbar_title) TextView mTitleTextView; 64 | @Bind(R.id.code_container) ScrollView mCodeContainer; 65 | @Bind(R.id.code_xml) TextView mXmlCodeTextView; 66 | @Bind(R.id.code_java) TextView mJavaCodeTextView; 67 | @Bind(R.id.image_container) ViewGroup mImageContainer; 68 | @Bind(R.id.civ) CircularImageView mImage; 69 | @Bind(R.id.fab) FloatingActionButton mFab; 70 | @Bind(R.id.enable_shadow) CheckBox mEnableShadowCheckBox; 71 | @Bind(R.id.enable_border) CheckBox mEnableBorderCheckBox; 72 | 73 | @BindDimen(R.dimen.civ_size) int mCivSize; 74 | @BindDimen(R.dimen.reveal_offset) int mRevealOffset; 75 | 76 | // Thumbnails 77 | @Bind(R.id.thumbnail_1) CompoundImageView mThumbnail1; 78 | @Bind(R.id.thumbnail_2) CompoundImageView mThumbnail2; 79 | @Bind(R.id.thumbnail_from_cloud) CompoundImageView mThumbnail3; 80 | @Bind(R.id.thumbnail_no_image) CompoundImageView mThumbnail4; 81 | 82 | private boolean mIsAnimating = false; 83 | private CompoundImageView mSelectedThumbnail; 84 | 85 | @Override 86 | protected void onCreate(Bundle savedInstanceState) { 87 | // Reset to default theme once the Activity is "cold started" 88 | setTheme(R.style.AppTheme); 89 | 90 | super.onCreate(savedInstanceState); 91 | setContentView(R.layout.activity_main); 92 | ButterKnife.bind(this); 93 | 94 | Log.d(TAG, "Offset: " + mRevealOffset); 95 | 96 | Typeface mono = Typeface.createFromAsset(getAssets(), "fonts/roboto/Mono-Regular.ttf"); 97 | //mTitleTextView.setTypeface(mono); 98 | //mJavaCodeTextView.setTypeface(mono); 99 | //mXmlCodeTextView.setTypeface(mono); 100 | 101 | // Init Picasso 102 | Picasso.with(this).setLoggingEnabled(true); 103 | 104 | mImage.allowCheckStateShadow(true); 105 | mEnableShadowCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { 106 | @Override 107 | public void onCheckedChanged(CompoundButton buttonView, 108 | boolean isChecked) { 109 | mImage.setShadowRadius(isChecked ? 5.0f : 0.0f); 110 | } 111 | }); 112 | 113 | mEnableBorderCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { 114 | @Override 115 | public void onCheckedChanged(CompoundButton buttonView, 116 | boolean isChecked) { 117 | mImage.setBorderWidth(TypedValue.COMPLEX_UNIT_DIP, isChecked ? 5 : 0); 118 | } 119 | }); 120 | 121 | setupThumbnails(); 122 | setToolbar(); 123 | setupImageContainer(); 124 | updateImage(mThumbnail1); 125 | 126 | // Toggle CircularImageView 127 | mImage.setOnClickListener(new View.OnClickListener() { 128 | @Override 129 | public void onClick(View v) { 130 | ((CircularImageView) v).toggle(); 131 | } 132 | }); 133 | 134 | mFab.setOnClickListener(new View.OnClickListener() { 135 | @Override 136 | public void onClick(View v) { 137 | Log.d(TAG, "Animate!"); 138 | if (!mIsAnimating) toggleCode(); 139 | } 140 | }); 141 | } 142 | 143 | @Override 144 | public void onBackPressed() { 145 | if (!mIsAnimating) { 146 | if (mCodeContainer.getVisibility() == View.VISIBLE) { 147 | toggleCode(); 148 | } else { 149 | super.onBackPressed(); 150 | } 151 | } 152 | } 153 | 154 | @SuppressLint("NewApi") 155 | private void toggleCode() { 156 | final boolean isCodeVisible = mCodeContainer.getVisibility() == View.VISIBLE; 157 | int w = mImageContainer.getWidth(), 158 | h = mImageContainer.getHeight(); 159 | 160 | mIsAnimating = true; 161 | 162 | // Reveal only for SDK version 21 or above 163 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { 164 | float startRadius = isCodeVisible ? (float) w * 1.5f : 0; 165 | float endRadius = isCodeVisible ? 0 : (float) w * 1.5f; 166 | Animator anim = ViewAnimationUtils.createCircularReveal(mCodeContainer, 167 | w - mRevealOffset, 168 | h - mRevealOffset, 169 | startRadius, 170 | endRadius); 171 | anim.setDuration(getResources().getInteger(android.R.integer.config_mediumAnimTime)); 172 | 173 | anim.addListener(new AnimatorListenerAdapter() { 174 | @Override 175 | public void onAnimationEnd(Animator animation) { 176 | super.onAnimationEnd(animation); 177 | onCodeContainerAnimationEnd(isCodeVisible); 178 | } 179 | }); 180 | 181 | if (!isCodeVisible) { 182 | mCodeContainer.setVisibility(View.VISIBLE); 183 | } 184 | 185 | anim.start(); 186 | } 187 | 188 | // Else slide 189 | else { 190 | if (!isCodeVisible) { 191 | mCodeContainer.setTranslationY(h); 192 | mCodeContainer.setVisibility(View.VISIBLE); 193 | } 194 | 195 | int startY = isCodeVisible ? 0 : h; 196 | int endY = isCodeVisible ? h : 0; 197 | ObjectAnimator anim = ObjectAnimator.ofFloat(mCodeContainer, "translationY", startY, endY); 198 | anim.setInterpolator(new DecelerateInterpolator()); 199 | anim.setDuration(getResources().getInteger(android.R.integer.config_mediumAnimTime)); 200 | 201 | anim.addListener(new AnimatorListenerAdapter() { 202 | @Override 203 | public void onAnimationEnd(Animator animation) { 204 | onCodeContainerAnimationEnd(isCodeVisible); 205 | } 206 | }); 207 | 208 | anim.start(); 209 | } 210 | } 211 | 212 | /** 213 | * Updates the view on animation end. 214 | * 215 | * @param isCodeVisible 216 | */ 217 | private void onCodeContainerAnimationEnd(boolean isCodeVisible) { 218 | if (isCodeVisible) { 219 | mCodeContainer.setVisibility(View.GONE); 220 | mFab.setImageResource(R.drawable.ic_code_black_24dp); 221 | mCodeContainer.scrollTo(0, 0); 222 | } else { 223 | mFab.setImageResource(R.drawable.ic_close_black_24dp); 224 | } 225 | 226 | mIsAnimating = false; 227 | } 228 | 229 | /** 230 | * Setup thumbnails 231 | */ 232 | private void setupThumbnails() { 233 | int defaultTextBgColor = 0xFFAAAAAA; 234 | int textBgColorForNoImage = 0xFF87170B; 235 | 236 | mThumbnail1.recycle(R.drawable.c1, R.string.image1, defaultTextBgColor, true, false); 237 | mThumbnail2.recycle(R.drawable.c2, R.string.image2, defaultTextBgColor, false, false); 238 | mThumbnail3.recycle(R.drawable.c3, R.string.image_from_cloud, defaultTextBgColor, false, true); 239 | mThumbnail4.recycle(-1, R.string.no_image, textBgColorForNoImage, false, false); 240 | 241 | mThumbnail1.setOnClickListener(this); 242 | mThumbnail2.setOnClickListener(this); 243 | mThumbnail3.setOnClickListener(this); 244 | mThumbnail4.setOnClickListener(this); 245 | } 246 | 247 | private void setToolbar() { 248 | if (null != mToolbar) { 249 | setSupportActionBar(mToolbar); 250 | getSupportActionBar().setTitle(""); 251 | } 252 | } 253 | 254 | /** 255 | * Setup image container 256 | */ 257 | private void setupImageContainer() { 258 | Resources res = getResources(); 259 | Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.grid); 260 | int cellH = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 22, res.getDisplayMetrics()); 261 | bitmap = Bitmap.createScaledBitmap(bitmap, cellH, cellH, true); 262 | 263 | BitmapDrawable bitmapDrawable = new BitmapDrawable(res, bitmap); 264 | bitmapDrawable.setTileModeX(Shader.TileMode.REPEAT); 265 | bitmapDrawable.setTileModeY(Shader.TileMode.REPEAT); 266 | mImageContainer.setBackgroundDrawable(bitmapDrawable); 267 | } 268 | 269 | /** 270 | * Updates image (CircularImageView) on selecting a thumbnail 271 | * 272 | * @param v 273 | */ 274 | private void updateImage(CompoundImageView v) { 275 | if (v == mSelectedThumbnail) 276 | return; 277 | 278 | if (null != mSelectedThumbnail) { 279 | mSelectedThumbnail.setChecked(false); 280 | } 281 | 282 | mImage.setChecked(false); 283 | mSelectedThumbnail = v; 284 | mSelectedThumbnail.setChecked(true); 285 | 286 | switch (mSelectedThumbnail.getId()) { 287 | case R.id.thumbnail_1: 288 | mImage.setImageResource(R.drawable.c1); 289 | updateCode(getString(R.string.java_code_template, "R.drawable.c1")); 290 | break; 291 | case R.id.thumbnail_2: 292 | mImage.setImageResource(R.drawable.c2); 293 | updateCode(getString(R.string.java_code_template, "R.drawable.c2")); 294 | break; 295 | case R.id.thumbnail_no_image: 296 | mImage.setImageDrawable(null); 297 | updateCode(getString(R.string.java_code_template, "null")); 298 | break; 299 | case R.id.thumbnail_from_cloud: 300 | Toast.makeText(this, R.string.loading_remote_image, Toast.LENGTH_SHORT).show(); 301 | Picasso.with(this) 302 | .load("https://raw.githubusercontent.com/subinkrishna/CircularImageView/master/art/cat_original.jpg") 303 | .noFade() 304 | .placeholder(R.drawable.placeholder) 305 | .resize(mCivSize, mCivSize) 306 | .memoryPolicy(MemoryPolicy.NO_CACHE) 307 | .centerCrop() 308 | .into(mImage); 309 | updateCode(getString(R.string.picasso_code_template)); 310 | break; 311 | } 312 | } 313 | 314 | /** 315 | * Updates code 316 | * 317 | * @param java 318 | */ 319 | private void updateCode(String java) { 320 | mJavaCodeTextView.setText(java); 321 | } 322 | 323 | @Override 324 | public void onClick(View v) { 325 | switch (v.getId()) { 326 | case R.id.thumbnail_1: 327 | case R.id.thumbnail_2: 328 | case R.id.thumbnail_no_image: 329 | case R.id.thumbnail_from_cloud: 330 | updateImage((CompoundImageView) v); 331 | break; 332 | 333 | } 334 | } 335 | } 336 | -------------------------------------------------------------------------------- /sample/src/main/java/com/subinkrishna/circularimageview/demo/view/AvatarView.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Subinkrishna Gopi 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.subinkrishna.circularimageview.demo.view; 18 | 19 | import android.content.Context; 20 | import android.graphics.Color; 21 | import android.graphics.Paint; 22 | import android.util.AttributeSet; 23 | import android.util.TypedValue; 24 | 25 | import com.subinkrishna.widget.CircularImageView; 26 | 27 | /** 28 | * Extension of CircularImageView that overrides the check mark color and width. 29 | * 30 | * @author Subinkrishna Gopi 31 | */ 32 | public class AvatarView extends CircularImageView { 33 | 34 | public AvatarView(Context context) { 35 | this(context, null, 0); 36 | } 37 | 38 | public AvatarView(Context context, AttributeSet attrs) { 39 | this(context, attrs, 0); 40 | } 41 | 42 | public AvatarView(Context context, AttributeSet attrs, int defStyleAttr) { 43 | super(context, attrs, defStyleAttr); 44 | allowCheckStateAnimation(true); 45 | } 46 | 47 | @Override 48 | protected Paint getCheckMarkPaint() { 49 | Paint paint = super.getCheckMarkPaint(); 50 | // Overriding stroke color 51 | paint.setColor(Color.WHITE); 52 | return paint; 53 | } 54 | 55 | @Override 56 | protected int getCheckMarkStrokeWidthInPixels() { 57 | // Overriding stroke width to 5dp (default is 3dp) 58 | return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 59 | 8, // DIPs 60 | getResources().getDisplayMetrics()); 61 | } 62 | 63 | @Override 64 | protected boolean shouldDrawBorder() { 65 | return true; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /sample/src/main/java/com/subinkrishna/circularimageview/demo/view/CompoundImageView.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Subinkrishna Gopi 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.subinkrishna.circularimageview.demo.view; 18 | 19 | import android.content.Context; 20 | import android.support.annotation.ColorInt; 21 | import android.support.annotation.StringRes; 22 | import android.util.AttributeSet; 23 | import android.view.LayoutInflater; 24 | import android.widget.Checkable; 25 | import android.widget.FrameLayout; 26 | import android.widget.ImageView; 27 | import android.widget.TextView; 28 | 29 | import com.subinkrishna.circularimageview.demo.R; 30 | 31 | import butterknife.Bind; 32 | import butterknife.ButterKnife; 33 | 34 | /** 35 | * @author Subinkrishna Gopi 36 | */ 37 | public class CompoundImageView 38 | extends FrameLayout 39 | implements Checkable { 40 | 41 | @Bind(R.id.text) TextView mText; 42 | @Bind(R.id.image) ImageView mImage; 43 | @Bind(R.id.check) ImageView mCheckIcon; 44 | @Bind(R.id.cloud) ImageView mCloudIcon; 45 | 46 | private boolean mIsChecked = false; 47 | 48 | public CompoundImageView(Context context) { 49 | super(context); 50 | configure(context); 51 | } 52 | 53 | public CompoundImageView(Context context, AttributeSet attrs) { 54 | super(context, attrs); 55 | configure(context); 56 | } 57 | 58 | public CompoundImageView(Context context, AttributeSet attrs, int defStyleAttr) { 59 | super(context, attrs, defStyleAttr); 60 | configure(context); 61 | } 62 | 63 | private void configure(Context context) { 64 | LayoutInflater.from(context).inflate(R.layout.item_compound_image_view, this, true); 65 | ButterKnife.bind(this, this); 66 | } 67 | 68 | public void recycle(int imageRes, 69 | @StringRes int textRes, 70 | @ColorInt int textBackgroundColor, 71 | boolean isSelected, 72 | boolean isFromCloud) { 73 | if (imageRes != -1) { 74 | mImage.setImageResource(imageRes); 75 | mText.setVisibility(GONE); 76 | } else { 77 | mImage.setImageDrawable(null); 78 | mText.setText(textRes); 79 | mText.setBackgroundColor(textBackgroundColor); 80 | mText.setVisibility(VISIBLE); 81 | } 82 | 83 | mCloudIcon.setVisibility(isFromCloud ? VISIBLE : GONE); 84 | setChecked(isSelected); 85 | } 86 | 87 | @Override 88 | public void setChecked(boolean checked) { 89 | if (mIsChecked != checked) { 90 | mIsChecked = checked; 91 | mCheckIcon.setVisibility(mIsChecked ? VISIBLE : GONE); 92 | } 93 | } 94 | 95 | @Override 96 | public boolean isChecked() { 97 | return mIsChecked; 98 | } 99 | 100 | @Override 101 | public void toggle() { 102 | setChecked(!mIsChecked); 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /sample/src/main/res/drawable-hdpi/ic_check_circle_white_36dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subinkrishna/CircularImageView/b3033a79f4f831c0a7c2567cc52f63b8410198a2/sample/src/main/res/drawable-hdpi/ic_check_circle_white_36dp.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-hdpi/ic_close_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subinkrishna/CircularImageView/b3033a79f4f831c0a7c2567cc52f63b8410198a2/sample/src/main/res/drawable-hdpi/ic_close_black_24dp.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-hdpi/ic_cloud_download_white_36dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subinkrishna/CircularImageView/b3033a79f4f831c0a7c2567cc52f63b8410198a2/sample/src/main/res/drawable-hdpi/ic_cloud_download_white_36dp.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-hdpi/ic_code_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subinkrishna/CircularImageView/b3033a79f4f831c0a7c2567cc52f63b8410198a2/sample/src/main/res/drawable-hdpi/ic_code_black_24dp.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-hdpi/ic_tune_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subinkrishna/CircularImageView/b3033a79f4f831c0a7c2567cc52f63b8410198a2/sample/src/main/res/drawable-hdpi/ic_tune_black_24dp.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-hdpi/ic_tune_black_36dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subinkrishna/CircularImageView/b3033a79f4f831c0a7c2567cc52f63b8410198a2/sample/src/main/res/drawable-hdpi/ic_tune_black_36dp.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-mdpi/ic_check_circle_white_36dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subinkrishna/CircularImageView/b3033a79f4f831c0a7c2567cc52f63b8410198a2/sample/src/main/res/drawable-mdpi/ic_check_circle_white_36dp.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-mdpi/ic_close_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subinkrishna/CircularImageView/b3033a79f4f831c0a7c2567cc52f63b8410198a2/sample/src/main/res/drawable-mdpi/ic_close_black_24dp.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-mdpi/ic_cloud_download_white_36dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subinkrishna/CircularImageView/b3033a79f4f831c0a7c2567cc52f63b8410198a2/sample/src/main/res/drawable-mdpi/ic_cloud_download_white_36dp.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-mdpi/ic_code_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subinkrishna/CircularImageView/b3033a79f4f831c0a7c2567cc52f63b8410198a2/sample/src/main/res/drawable-mdpi/ic_code_black_24dp.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-mdpi/ic_tune_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subinkrishna/CircularImageView/b3033a79f4f831c0a7c2567cc52f63b8410198a2/sample/src/main/res/drawable-mdpi/ic_tune_black_24dp.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-mdpi/ic_tune_black_36dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subinkrishna/CircularImageView/b3033a79f4f831c0a7c2567cc52f63b8410198a2/sample/src/main/res/drawable-mdpi/ic_tune_black_36dp.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-nodpi/c1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subinkrishna/CircularImageView/b3033a79f4f831c0a7c2567cc52f63b8410198a2/sample/src/main/res/drawable-nodpi/c1.jpg -------------------------------------------------------------------------------- /sample/src/main/res/drawable-nodpi/c2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subinkrishna/CircularImageView/b3033a79f4f831c0a7c2567cc52f63b8410198a2/sample/src/main/res/drawable-nodpi/c2.jpg -------------------------------------------------------------------------------- /sample/src/main/res/drawable-nodpi/c3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subinkrishna/CircularImageView/b3033a79f4f831c0a7c2567cc52f63b8410198a2/sample/src/main/res/drawable-nodpi/c3.jpg -------------------------------------------------------------------------------- /sample/src/main/res/drawable-nodpi/grid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subinkrishna/CircularImageView/b3033a79f4f831c0a7c2567cc52f63b8410198a2/sample/src/main/res/drawable-nodpi/grid.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-nodpi/placeholder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subinkrishna/CircularImageView/b3033a79f4f831c0a7c2567cc52f63b8410198a2/sample/src/main/res/drawable-nodpi/placeholder.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xhdpi/ic_check_circle_white_36dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subinkrishna/CircularImageView/b3033a79f4f831c0a7c2567cc52f63b8410198a2/sample/src/main/res/drawable-xhdpi/ic_check_circle_white_36dp.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xhdpi/ic_close_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subinkrishna/CircularImageView/b3033a79f4f831c0a7c2567cc52f63b8410198a2/sample/src/main/res/drawable-xhdpi/ic_close_black_24dp.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xhdpi/ic_cloud_download_white_36dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subinkrishna/CircularImageView/b3033a79f4f831c0a7c2567cc52f63b8410198a2/sample/src/main/res/drawable-xhdpi/ic_cloud_download_white_36dp.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xhdpi/ic_code_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subinkrishna/CircularImageView/b3033a79f4f831c0a7c2567cc52f63b8410198a2/sample/src/main/res/drawable-xhdpi/ic_code_black_24dp.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xhdpi/ic_tune_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subinkrishna/CircularImageView/b3033a79f4f831c0a7c2567cc52f63b8410198a2/sample/src/main/res/drawable-xhdpi/ic_tune_black_24dp.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xhdpi/ic_tune_black_36dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subinkrishna/CircularImageView/b3033a79f4f831c0a7c2567cc52f63b8410198a2/sample/src/main/res/drawable-xhdpi/ic_tune_black_36dp.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xxhdpi/ic_check_circle_white_36dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subinkrishna/CircularImageView/b3033a79f4f831c0a7c2567cc52f63b8410198a2/sample/src/main/res/drawable-xxhdpi/ic_check_circle_white_36dp.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xxhdpi/ic_close_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subinkrishna/CircularImageView/b3033a79f4f831c0a7c2567cc52f63b8410198a2/sample/src/main/res/drawable-xxhdpi/ic_close_black_24dp.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xxhdpi/ic_cloud_download_white_36dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subinkrishna/CircularImageView/b3033a79f4f831c0a7c2567cc52f63b8410198a2/sample/src/main/res/drawable-xxhdpi/ic_cloud_download_white_36dp.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xxhdpi/ic_code_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subinkrishna/CircularImageView/b3033a79f4f831c0a7c2567cc52f63b8410198a2/sample/src/main/res/drawable-xxhdpi/ic_code_black_24dp.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xxhdpi/ic_tune_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subinkrishna/CircularImageView/b3033a79f4f831c0a7c2567cc52f63b8410198a2/sample/src/main/res/drawable-xxhdpi/ic_tune_black_24dp.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xxhdpi/ic_tune_black_36dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subinkrishna/CircularImageView/b3033a79f4f831c0a7c2567cc52f63b8410198a2/sample/src/main/res/drawable-xxhdpi/ic_tune_black_36dp.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xxxhdpi/ic_check_circle_white_36dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subinkrishna/CircularImageView/b3033a79f4f831c0a7c2567cc52f63b8410198a2/sample/src/main/res/drawable-xxxhdpi/ic_check_circle_white_36dp.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xxxhdpi/ic_close_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subinkrishna/CircularImageView/b3033a79f4f831c0a7c2567cc52f63b8410198a2/sample/src/main/res/drawable-xxxhdpi/ic_close_black_24dp.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xxxhdpi/ic_cloud_download_white_36dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subinkrishna/CircularImageView/b3033a79f4f831c0a7c2567cc52f63b8410198a2/sample/src/main/res/drawable-xxxhdpi/ic_cloud_download_white_36dp.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xxxhdpi/ic_code_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subinkrishna/CircularImageView/b3033a79f4f831c0a7c2567cc52f63b8410198a2/sample/src/main/res/drawable-xxxhdpi/ic_code_black_24dp.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xxxhdpi/ic_tune_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subinkrishna/CircularImageView/b3033a79f4f831c0a7c2567cc52f63b8410198a2/sample/src/main/res/drawable-xxxhdpi/ic_tune_black_24dp.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xxxhdpi/ic_tune_black_36dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subinkrishna/CircularImageView/b3033a79f4f831c0a7c2567cc52f63b8410198a2/sample/src/main/res/drawable-xxxhdpi/ic_tune_black_36dp.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable/bg_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /sample/src/main/res/drawable/shadow_gradient_bottom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /sample/src/main/res/drawable/shape.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /sample/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 15 | 16 | 26 | 27 | 28 | 29 | 30 | 36 | 37 | 42 | 43 | 47 | 48 | 52 | 53 | 57 | 58 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 74 | 79 | 80 | 86 | 87 | 99 | 100 | 101 | 102 | 111 | 112 | 117 | 118 | 126 | 127 | 135 | 136 | 145 | 146 | 154 | 155 | 156 | 157 | 158 | 159 | 164 | 165 | 178 | 179 | -------------------------------------------------------------------------------- /sample/src/main/res/layout/item_compound_image_view.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 21 | 22 | 28 | 29 | 39 | 40 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /sample/src/main/res/menu/menu_main.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 12 | 13 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subinkrishna/CircularImageView/b3033a79f4f831c0a7c2567cc52f63b8410198a2/sample/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subinkrishna/CircularImageView/b3033a79f4f831c0a7c2567cc52f63b8410198a2/sample/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subinkrishna/CircularImageView/b3033a79f4f831c0a7c2567cc52f63b8410198a2/sample/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subinkrishna/CircularImageView/b3033a79f4f831c0a7c2567cc52f63b8410198a2/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subinkrishna/CircularImageView/b3033a79f4f831c0a7c2567cc52f63b8410198a2/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/values-land/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 80dp 4 | -------------------------------------------------------------------------------- /sample/src/main/res/values-v21/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 20dp 4 | -------------------------------------------------------------------------------- /sample/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /sample/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | @android:color/white 4 | -------------------------------------------------------------------------------- /sample/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | 130dp 7 | 45dp 8 | 5dp 9 | 120dp 10 | 11 | -------------------------------------------------------------------------------- /sample/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | CircularImageView Sample 3 | Settings 4 | Show Code 5 | Shadow 6 | Border 7 | 8 | Image 1 9 | Image 2 10 | From cloud 11 | No Image 12 | Loading remote image using Picasso [NO CACHE, WITH PLACEHOLDER] 13 | 14 | XML 15 | ]]> 28 | 29 | Java 30 | 34 | 35 | \") 39 | \n\t.noFade() 40 | \n\t.placeholder(R.drawable.placeholder) 41 | \n\t.resize(mCivSize, mCivSize) 42 | \n\t.centerCrop() 43 | \n\t.into(mImage); 44 | ]]> 45 | 46 | 47 | -------------------------------------------------------------------------------- /sample/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /screenshots/ScreenShot_Phone1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subinkrishna/CircularImageView/b3033a79f4f831c0a7c2567cc52f63b8410198a2/screenshots/ScreenShot_Phone1.png -------------------------------------------------------------------------------- /screenshots/Screenshot_Phone2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subinkrishna/CircularImageView/b3033a79f4f831c0a7c2567cc52f63b8410198a2/screenshots/Screenshot_Phone2.png -------------------------------------------------------------------------------- /screenshots/Screenshot_Phone_N5_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subinkrishna/CircularImageView/b3033a79f4f831c0a7c2567cc52f63b8410198a2/screenshots/Screenshot_Phone_N5_1.png -------------------------------------------------------------------------------- /screenshots/Screenshot_Phone_N5_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subinkrishna/CircularImageView/b3033a79f4f831c0a7c2567cc52f63b8410198a2/screenshots/Screenshot_Phone_N5_2.png -------------------------------------------------------------------------------- /screenshots/samples.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subinkrishna/CircularImageView/b3033a79f4f831c0a7c2567cc52f63b8410198a2/screenshots/samples.png -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':sample', ':circularimageview' 2 | --------------------------------------------------------------------------------