├── .github ├── FUNDING.yml └── workflows │ └── publish_to_maven.yml ├── .gitignore ├── .idea ├── codeStyles │ └── Project.xml ├── compiler.xml ├── jarRepositories.xml ├── misc.xml └── vcs.xml ├── LICENSE ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── wajahatkarim3 │ │ └── mediumclap_android │ │ └── ExampleInstrumentedTest.kt │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── wajahatkarim3 │ │ │ └── mediumclap_android │ │ │ ├── DemoActivity.kt │ │ │ ├── ExampleActivity.kt │ │ │ ├── MainActivity.kt │ │ │ ├── MyAnimatorListener.kt │ │ │ └── MyApp.java │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ ├── circle_shape_background.xml │ │ ├── ic_apps_black_24dp.xml │ │ ├── ic_clap_hands_filled.xml │ │ ├── ic_clap_hands_outline.xml │ │ ├── ic_favorite_black_24dp.xml │ │ ├── ic_favorite_border_black_24dp.xml │ │ ├── ic_launcher_background.xml │ │ ├── ic_star_black_24dp.xml │ │ └── ic_star_border_black_24dp.xml │ │ ├── layout │ │ ├── activity_demo.xml │ │ ├── activity_example.xml │ │ ├── activity_main.xml │ │ └── cicle_text_view_layout.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── wajahatkarim3 │ └── mediumclap_android │ └── ExampleUnitTest.kt ├── art ├── demo.gif └── demo_2.gif ├── build.gradle ├── clapfab ├── .gitignore ├── build.gradle ├── gradle.properties ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── wajahatkarim3 │ │ └── clapfab │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── wajahatkarim3 │ │ │ └── clapfab │ │ │ ├── ClapFAB.kt │ │ │ ├── DotsView.kt │ │ │ └── NumberUtil.kt │ └── res │ │ ├── drawable │ │ ├── circle_shape_background.xml │ │ ├── ic_clap_hands_filled.xml │ │ └── ic_clap_hands_outline.xml │ │ ├── layout │ │ └── clap_fab_layout.xml │ │ ├── values-v21 │ │ └── styles.xml │ │ └── values │ │ ├── attrs.xml │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── wajahatkarim3 │ └── clapfab │ └── ExampleUnitTest.java ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | custom: ['https://www.paypal.me/WajahatKarim/5', 'https://www.paypal.me/WajahatKarim/20', 'https://www.paypal.me/WajahatKarim/50', 'https://www.paypal.me/WajahatKarim/100'] 2 | -------------------------------------------------------------------------------- /.github/workflows/publish_to_maven.yml: -------------------------------------------------------------------------------- 1 | name: Publish 2 | on: 3 | release: 4 | # We'll run this workflow when a new GitHub release is created 5 | types: [released] 6 | 7 | jobs: 8 | publish: 9 | name: Release build and publish 10 | runs-on: ubuntu-latest 11 | steps: 12 | - name: Check out code 13 | uses: actions/checkout@v2 14 | 15 | - name: Set up JDK 11 16 | uses: actions/setup-java@v2 17 | with: 18 | distribution: adopt 19 | java-version: 11 20 | 21 | - name: Grant Permission to Execute Gradle 22 | run: chmod +x gradlew 23 | 24 | - name: Build with Gradle 25 | uses: gradle/gradle-build-action@v2 26 | with: 27 | arguments: build 28 | 29 | - name: Publish Library 30 | run: | 31 | echo "Publishing library🚀" 32 | ./gradlew publish --no-daemon --no-parallel 33 | echo "Published✅" 34 | echo "Releasing repository...🚀" 35 | ./gradlew closeAndReleaseRepository 36 | echo "Released✅" 37 | env: 38 | ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_KEY }} 39 | ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.GPG_PASSWORD }} 40 | ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }} 41 | ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }} -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the ART/Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | out/ 15 | 16 | # Gradle files 17 | .gradle/ 18 | build/ 19 | 20 | # Local configuration file (sdk path, etc) 21 | local.properties 22 | 23 | # Proguard folder generated by Eclipse 24 | proguard/ 25 | 26 | # Log Files 27 | *.log 28 | 29 | # Android Studio Navigation editor temp files 30 | .navigation/ 31 | 32 | # Android Studio captures folder 33 | captures/ 34 | 35 | # Intellij 36 | *.iml 37 | .idea/workspace.xml 38 | .idea/tasks.xml 39 | .idea/gradle.xml 40 | .idea/dictionaries 41 | .idea/libraries 42 | .idea/modules.xml 43 | .idea/misc.xml 44 | .idea/assetWizardSettings.xml 45 | 46 | # Keystore files 47 | *.jks 48 | 49 | # External native build folder generated in Android Studio 2.2 and later 50 | .externalNativeBuild 51 | 52 | # Google Services (e.g. APIs or Firebase) 53 | google-services.json 54 | 55 | # Freeline 56 | freeline.py 57 | freeline/ 58 | freeline_project_description.json 59 | .idea/caches/build_file_checksums.ser 60 | -------------------------------------------------------------------------------- /.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 15 | 16 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/jarRepositories.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 10 | 14 | 15 | 19 | 20 | 24 | 25 | 29 | 30 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 | 12 | 32 | 49 | 50 | 51 | 52 | 53 | 54 | 56 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 👏 MediumClap-Android 2 | [![Build status](https://build.appcenter.ms/v0.1/apps/c7b7ac7b-34b7-4a0d-89b3-8c325cc047a7/branches/master/badge)](https://appcenter.ms) [![](https://img.shields.io/badge/Android%20Weekly-%23317-blue.svg)](https://androidweekly.net/issues/issue-317) [![](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)]() [![](https://img.shields.io/badge/MaterialUp-MediumClap-yellowgreen.svg)](https://www.uplabs.com/posts/medium-clap-android) [![Android Arsenal]( https://img.shields.io/badge/Android%20Arsenal-Medium%20Clap%20Button-green.svg?style=flat )]( https://android-arsenal.com/details/1/7031 ) 3 | [![](https://img.shields.io/badge/Available%20On-ProductHunt-orange.svg)](https://www.producthunt.com/posts/medium-clap-button-in-android) [![Say Thanks!](https://img.shields.io/badge/Say%20Thanks-!-1EAEDB.svg)](https://saythanks.io/to/wajahatkarim3) [![Twitter](https://img.shields.io/twitter/url/https/github.com/wajahatkarim3/MediumClap-Android.svg?style=social)](https://twitter.com/intent/tweet?text=Wow:&url=https%3A%2F%2Fgithub.com%2Fwajahatkarim3%2FMediumClap-Android) 4 | 5 |
6 | Built with ❤︎ by 7 | Wajahat Karim and 8 | 9 | contributors 10 | 11 |
12 |
13 | 14 | A Custom Floating Action Button (FAB) library like clapping effect on Medium 15 | 16 | ![](https://raw.githubusercontent.com/wajahatkarim3/MediumClap-Android/master/art/demo_2.gif) 17 | 18 | ### 📄 How-To Article 19 | * [Publishing your Android, Kotlin or Java library to jCenter from Android Studio](https://android.jlelse.eu/publishing-your-android-kotlin-or-java-library-to-jcenter-from-android-studio-1b24977fe450) 20 | 21 | ## ✔️ Changelog 22 | Changes exist in the [releases](https://github.com/wajahatkarim3/MediumClap-Android/releases) tab. 23 | 24 | ## 💻 Installation 25 | Add this in your app's build.gradle file: 26 | ```groovy 27 | dependencies { 28 | implementation 'com.wajahatkarim:clapfab:2.0.0' 29 | } 30 | ``` 31 | 32 | Or add ClapFab as a new dependency inside your pom.xml 33 | 34 | ```xml 35 | 36 | com.wajahatkarim3 37 | clapfab 38 | 2.0.0 39 | pom 40 | 41 | ``` 42 | 43 | ## ❔ Usage 44 | 45 | ```xml 46 | 65 | ``` 66 | 67 | ## 🎨 Customization and Attributes 68 | 69 | All customizable attributes for ClapFab 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 |
Attribute NameDefault ValueDescription
app:cf_default_icon@drawable/ic_clap_hands_outlineThe default icon of the ClapFab button
app:cf_filled_icon@drawable/ic_clap_hands_filledThe filled icon after clapping of the ClapFab button
app:cf_default_icon_color@color/colorClapIconThe color of default icon of the ClapFab button
app:cf_filled_icon_color@color/colorClapIconThe filled color of icon after clapping of the ClapFab button
app:cf_max_clap_count50The maximum count of clapping of the ClapFab button
app:cf_count_circle_color@color/colorClapIconThe color of count's circle background
app:cf_count_text_color@android:color/whiteThe color of count's circle text
app:cf_dots_1_color@color/dotsColor1The color of particle's dots 1
app:cf_dots_2_color@color/dotsColor2The color of particle's dots 2
app:cf_clap_count0The default clap count
app:cf_format_clap_counttrueTrue, if the formatter for clap count is enabled. Formatter will convert 1000 to 1.0K etc.
app:cf_long_press_enabledtrueThe flag to turn on/off the long press auto-clap ability. Default is true.
app:cf_long_press_clap_interval300The interval to automatically clap on long press in milliseconds. Default is 300ms
140 | 141 | ## Clap Listener 142 | ```java 143 | ClapFAB clapFAB = (ClapFAB) findViewById(R.id.clapFAB); 144 | clapFAB.setClapListener(new ClapFAB.OnClapListener() { 145 | @Override 146 | public void onFabClapped(@NotNull ClapFAB clapFab, int count, boolean isMaxReached) { 147 | // count is the current count of the clapping 148 | // isMaxReached is true when button has already reached the maximum count 149 | // and is not being clapped anymore. Otherwise its false 150 | } 151 | }); 152 | ``` 153 | 154 | ## 📃 Libraries Used 155 | * ViewAnimator [https://github.com/florent37/ViewAnimator](https://github.com/florent37/ViewAnimator) 156 | * DotsView from Like Animation [https://github.com/jd-alexander/LikeButton](https://github.com/jd-alexander/LikeButton) 157 | 158 | ## 💥 Achievements 159 | * #1 on [Github Trending in Kotlin](https://github.com/trending/kotlin?since=daily) language from 22nd June, 2018 to 24th June, 2018 160 | * Featured in [Caster IO's](http://www.caster.io/) weekly [#AndroidDev Digest](https://www.androiddevdigest.com/) in the [Issue #193](https://www.androiddevdigest.com/digest-193/) 161 | * Featured in [Infinum's](https://infinum.co/) weekly #AndroidSweets newsletter issue #4 162 | * Featured in Mindork's [Kotlin Weekly Update 44](https://medium.com/mindorks/kotlin-weekly-update-44-70b7969027f9) 163 | * Featured in [Android Weekly China's](https://androidweekly.cn/) Issue [#185](https://androidweekly.cn/android-dev-weekly-issue-185/) 164 | * Mentioned in an [article about publishing libraries on jCenter](https://android.jlelse.eu/publishing-your-android-kotlin-or-java-library-to-jcenter-from-android-studio-1b24977fe450) on [AndroidPub](https://android.jlelse.eu/) 165 | 166 | ## 💰 Donations 167 | 168 | This project needs you! If you would like to support this project's further development, the creator of this project or the continuous maintenance of this project, feel free to donate. Your donation is highly appreciated (and I love food, coffee and beer). Thank you! 169 | 170 | **PayPal** 171 | 172 | * **[Donate $5](https://www.paypal.me/WajahatKarim/5)**: Thank's for creating this project, here's a tea (or some juice) for you! 173 | * **[Donate $10](https://www.paypal.me/WajahatKarim/10)**: Wow, I am stunned. Let me take you to the movies! 174 | * **[Donate $15](https://www.paypal.me/WajahatKarim/15)**: I really appreciate your work, let's grab some lunch! 175 | * **[Donate $25](https://www.paypal.me/WajahatKarim/25)**: That's some awesome stuff you did right there, dinner is on me! 176 | * **[Donate $50](https://www.paypal.me/WajahatKarim/50)**: I really really want to support this project, great job! 177 | * **[Donate $100](https://www.paypal.me/WajahatKarim/100)**: You are the man! This project saved me hours (if not days) of struggle and hard work, simply awesome! 178 | * **[Donate $2799](https://www.paypal.me/WajahatKarim/2799)**: Go buddy, buy Macbook Pro for yourself! 179 | 180 | Of course, you can also choose what you want to donate, all donations are awesome! 181 | 182 | ## 👨 Developed By 183 | 184 | ``` 185 | Wajahat Karim 186 | ``` 187 | - Website (http://wajahatkarim.com) 188 | - Twitter (http://twitter.com/wajahatkarim) 189 | - Medium (http://www.medium.com/@wajahatkarim3) 190 | - LinkedIn (http://www.linkedin.com/in/wajahatkarim) 191 | 192 | # 👍 How to Contribute 193 | 1. Fork it 194 | 2. Create your feature branch (git checkout -b my-new-feature) 195 | 3. Commit your changes (git commit -am 'Add some feature') 196 | 4. Push to the branch (git push origin my-new-feature) 197 | 5. Create new Pull Request 198 | 199 | # 📃 License 200 | 201 | Copyright 2022 Wajahat Karim 202 | 203 | Licensed under the Apache License, Version 2.0 (the "License"); 204 | you may not use this file except in compliance with the License. 205 | You may obtain a copy of the License at 206 | 207 | http://www.apache.org/licenses/LICENSE-2.0 208 | 209 | Unless required by applicable law or agreed to in writing, software 210 | distributed under the License is distributed on an "AS IS" BASIS, 211 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 212 | See the License for the specific language governing permissions and 213 | limitations under the License. 214 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | apply plugin: 'kotlin-android' 4 | apply plugin: 'kotlin-kapt' 5 | apply plugin: 'kotlin-android-extensions' 6 | 7 | android { 8 | compileSdkVersion 31 9 | defaultConfig { 10 | applicationId "com.wajahatkarim3.mediumclap_android" 11 | minSdkVersion 19 12 | targetSdkVersion 31 13 | versionCode 1 14 | versionName "1.0" 15 | vectorDrawables.useSupportLibrary true 16 | testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' 17 | } 18 | buildTypes { 19 | release { 20 | minifyEnabled false 21 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 22 | } 23 | } 24 | 25 | buildFeatures { 26 | dataBinding true 27 | } 28 | } 29 | 30 | dependencies { 31 | implementation fileTree(dir: 'libs', include: ['*.jar']) 32 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion" 33 | implementation "androidx.appcompat:appcompat:$appcompat_version" 34 | implementation 'com.facebook.stetho:stetho:1.5.0' 35 | //kapt 'com.android.databinding:compiler:3.0.1' 36 | implementation 'com.google.android.material:material:1.6.0-alpha02' 37 | implementation 'androidx.constraintlayout:constraintlayout:2.1.3' 38 | implementation 'com.github.florent37:viewanimator:1.1.2' 39 | testImplementation 'junit:junit:4.12' 40 | androidTestImplementation 'androidx.test.ext:junit:1.1.1' 41 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0' 42 | implementation project(":clapfab") 43 | } 44 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/wajahatkarim3/mediumclap_android/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.wajahatkarim3.mediumclap_android 2 | 3 | import android.support.test.InstrumentationRegistry 4 | import android.support.test.runner.AndroidJUnit4 5 | 6 | import org.junit.Test 7 | import org.junit.runner.RunWith 8 | 9 | import org.junit.Assert.* 10 | 11 | /** 12 | * Instrumented test, which will execute on an Android device. 13 | * 14 | * See [testing documentation](http://d.android.com/tools/testing). 15 | */ 16 | @RunWith(AndroidJUnit4::class) 17 | class ExampleInstrumentedTest { 18 | @Test 19 | fun useAppContext() { 20 | // Context of the app under test. 21 | val appContext = InstrumentationRegistry.getTargetContext() 22 | assertEquals("com.wajahatkarim3.mediumclap_android", appContext.packageName) 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /app/src/main/java/com/wajahatkarim3/mediumclap_android/DemoActivity.kt: -------------------------------------------------------------------------------- 1 | package com.wajahatkarim3.mediumclap_android 2 | 3 | import android.os.Bundle 4 | import android.widget.Toast 5 | import androidx.appcompat.app.AppCompatActivity 6 | import com.wajahatkarim3.clapfab.ClapFAB 7 | import kotlinx.android.synthetic.main.activity_demo.* 8 | 9 | class DemoActivity : AppCompatActivity() { 10 | 11 | override fun onCreate(savedInstanceState: Bundle?) { 12 | super.onCreate(savedInstanceState) 13 | setContentView(R.layout.activity_demo) 14 | 15 | clapFAB.clapListener = listener 16 | clapFAB2.clapListener = listener 17 | clapFAB3.clapListener = listener 18 | clapFAB4.clapListener = listener 19 | 20 | //Set max clap count 21 | clapFAB4.maxCount = 20000 22 | 23 | //Set Default clap count 24 | clapFAB4.setClapCount(9999) 25 | } 26 | 27 | private val listener = object : ClapFAB.OnClapListener{ 28 | override fun onFabClapped(clapFab: ClapFAB, count: Int, isMaxReached: Boolean) { 29 | if(isMaxReached) { 30 | Toast.makeText(this@DemoActivity, "Clapped: $count of ${clapFab.maxCount}", Toast.LENGTH_LONG).show() 31 | } 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /app/src/main/java/com/wajahatkarim3/mediumclap_android/ExampleActivity.kt: -------------------------------------------------------------------------------- 1 | package com.wajahatkarim3.mediumclap_android 2 | 3 | import android.animation.ObjectAnimator 4 | import android.os.Bundle 5 | import android.os.CountDownTimer 6 | import android.view.View 7 | import android.view.animation.AccelerateDecelerateInterpolator 8 | import android.view.animation.DecelerateInterpolator 9 | import androidx.appcompat.app.AppCompatActivity 10 | import com.github.florent37.viewanimator.ViewAnimator 11 | import com.wajahatkarim3.clapfab.DotsView 12 | import kotlinx.android.synthetic.main.activity_example.* 13 | 14 | class ExampleActivity : AppCompatActivity() { 15 | 16 | var clapCount = 0 17 | var isCirlceAvailable = false 18 | 19 | var hideAnimator: ViewAnimator? = null 20 | var textMoveUpAnimator: ViewAnimator? = null 21 | 22 | // Animations 23 | var fabScaleAnimation_1: ViewAnimator? = null 24 | var circleShowMoveUpAnimation_2: ViewAnimator? = null 25 | var circleScaleAnimation_3: ViewAnimator? = null 26 | var circleHideMoveAnimation_4: ViewAnimator? = null 27 | 28 | lateinit var dotsView: DotsView 29 | 30 | override fun onCreate(savedInstanceState: Bundle?) { 31 | super.onCreate(savedInstanceState) 32 | setContentView(R.layout.activity_example) 33 | 34 | initDots() 35 | 36 | fabDemoClap.setOnClickListener { 37 | 38 | clapCount++ 39 | txtCountCircle.text = "+$clapCount" 40 | if (clapCount > 0) 41 | { 42 | fabDemoClap.setImageResource(R.drawable.ic_clap_hands_filled) 43 | } 44 | 45 | playActualFabAnim() 46 | } 47 | } 48 | 49 | fun initDots() 50 | { 51 | dotsView = findViewById(R.id.dotsView) 52 | dotsView.setColors(resources.getColor(R.color.colorPrimaryLight), resources.getColor(R.color.colorAccent)) 53 | dotsView.currentProgress = 0f 54 | dotsView.setSize(400, 400) 55 | } 56 | 57 | fun playActualFabAnim() 58 | { 59 | isHideAnimStopped = true 60 | 61 | playDotsAnimation() 62 | 63 | // 1. Scale Up FAB Button On Each Click 64 | fabScaleUpAnimation() 65 | 66 | // 2. Show and move count text circle from button 67 | // If circle is not shown on top, then move up and show circle 68 | if (!isCirlceAvailable) 69 | { 70 | circleShowMoveUpAnimation() 71 | } 72 | // Else, scale up the counter text 73 | else 74 | { 75 | circleScaleAnimation() 76 | } 77 | 78 | } 79 | 80 | fun playDotsAnimation() 81 | { 82 | dotsView.currentProgress = 0f 83 | 84 | var dotsAnimator = ObjectAnimator.ofFloat(dotsView, DotsView.DOTS_PROGRESS, 0f, 1f) 85 | dotsAnimator.duration = 500 86 | dotsAnimator.interpolator = AccelerateDecelerateInterpolator() 87 | dotsAnimator.start() 88 | } 89 | 90 | 91 | fun fabScaleUpAnimation() 92 | { 93 | fabScaleAnimation_1 = ViewAnimator 94 | .animate(fabDemoClap) 95 | .scale(1f, 1.2f) 96 | .duration(70) 97 | .thenAnimate(fabDemoClap) 98 | .scale(1.2f, 1.0f) 99 | .duration(70) 100 | .start() 101 | .onStop { 102 | fabScaleAnimation_1 = null 103 | } 104 | } 105 | 106 | fun circleShowMoveUpAnimation() 107 | { 108 | txtCountCircle.visibility = View.VISIBLE 109 | txtCountCircle.y = fabDemoClap.y + fabDemoClap.height/2 110 | txtCountCircle.alpha = 0f 111 | circleShowMoveUpAnimation_2 = ViewAnimator 112 | .animate(txtCountCircle) 113 | .dp().translationY(0f, -70f) 114 | .interpolator(DecelerateInterpolator()) 115 | .alpha(0f, 1f) 116 | .duration(500) 117 | .onStop { 118 | isCirlceAvailable = true 119 | //circleShowMoveUpAnimation_2 = null 120 | //circleHideMoveAnimation() 121 | isHideAnimStopped = false 122 | hideAnimTimer.start() 123 | } 124 | .start() 125 | } 126 | 127 | fun circleScaleAnimation() 128 | { 129 | circleScaleAnimation_3 = ViewAnimator 130 | .animate(txtCountCircle) 131 | .scale(1f, 1.2f) 132 | .duration(70) 133 | .thenAnimate(txtCountCircle) 134 | .scale(1.2f, 1.0f) 135 | .duration(70) 136 | .onStop { 137 | // Hide Circle Anim 138 | //circleScaleAnimation_3 = null 139 | //circleHideMoveAnimation() 140 | isHideAnimStopped = false 141 | hideAnimTimer.start() 142 | } 143 | .start() 144 | } 145 | 146 | var hideAnimRunnable = Runnable { 147 | runOnUiThread { 148 | circleHideMoveAnimation() 149 | } 150 | } 151 | 152 | var isHideAnimStopped = false 153 | var hideAnimTimer = object : CountDownTimer(800, 50){ 154 | override fun onTick(millisUntilFinished: Long) { 155 | if (isHideAnimStopped) 156 | cancel() 157 | } 158 | 159 | override fun onFinish() { 160 | runOnUiThread { 161 | circleHideMoveAnimation() 162 | } 163 | } 164 | } 165 | 166 | fun circleHideMoveAnimation() 167 | { 168 | circleHideMoveAnimation_4?.cancel() 169 | circleHideMoveAnimation_4 = ViewAnimator 170 | .animate(txtCountCircle) 171 | .alpha(1f, 0f) 172 | .dp().translationY( -70f, -140f) 173 | .duration(400) 174 | //.startDelay(1500) 175 | .onStop { 176 | isCirlceAvailable = false 177 | //circleShowMoveUpAnimation_2 = null 178 | //circleHideMoveAnimation_4 = null 179 | } 180 | .start() 181 | } 182 | 183 | /* 184 | fun animateClapFab() 185 | { 186 | if (hideAnimator != null) 187 | { 188 | hideAnimator?.cancel() 189 | isCirlceAvailable = true 190 | } 191 | else 192 | { 193 | isCirlceAvailable = false 194 | hideAnimator?.cancel() 195 | } 196 | 197 | if (textMoveUpAnimator != null) 198 | return 199 | 200 | // Update clap icon depending on clap count 201 | txtCountCircle.text = "+$clapCount" 202 | if (clapCount > 0) 203 | { 204 | fabDemoClap.setImageResource(R.drawable.ic_clap_hands_filled) 205 | } 206 | 207 | // 1. Scale Up FAB Button On Each Click 208 | ViewAnimator 209 | .animate(fabDemoClap) 210 | .scale(1f, 1.2f) 211 | .duration(70) 212 | //.interpolator(AccelerateDecelerateInterpolator()) 213 | .thenAnimate(fabDemoClap) 214 | .scale(1.2f, 1.0f) 215 | .duration(70) 216 | //.interpolator(AccelerateDecelerateInterpolator()) 217 | .start() 218 | 219 | // 2. Show and move count text circle from button 220 | 221 | // Reset Circle Text State 222 | txtCountCircle.visibility = View.VISIBLE 223 | txtCountCircle.y = fabDemoClap.y + fabDemoClap.height/2 224 | txtCountCircle.alpha = 0f 225 | 226 | if (!isCirlceAvailable) 227 | { 228 | // Animate Text up 229 | textMoveUpAnimator = ViewAnimator 230 | .animate(txtCountCircle) 231 | .dp().translationY(0f, -70f) 232 | .interpolator(DecelerateInterpolator()) 233 | .alpha(0f, 1f) 234 | .duration(500) 235 | .onStop { 236 | Log.w("ANIM", "Circle stopped!") 237 | isCirlceAvailable = true 238 | textMoveUpAnimator = null 239 | } 240 | .start() 241 | 242 | // Hide Circle Anim 243 | hideAnimator = ViewAnimator.animate(txtCountCircle) 244 | .alpha(1f, 0f) 245 | .dp().translationY( -70f, -140f) 246 | .duration(500) 247 | .startDelay(500) 248 | .onStop { 249 | Log.e("ANIM", "Circle hidden") 250 | //isCirlceAvailable = false 251 | } 252 | .start() 253 | } 254 | else 255 | { 256 | // Scale up Circle Text 257 | txtCountCircle.alpha = 1f 258 | ViewAnimator 259 | .animate(txtCountCircle) 260 | .scale(1f, 1.2f) 261 | .duration(70) 262 | .thenAnimate(txtCountCircle) 263 | .scale(1.2f, 1.0f) 264 | .duration(70) 265 | .onStop { 266 | 267 | // Hide Circle Anim 268 | hideAnimator = ViewAnimator.animate(txtCountCircle) 269 | .alpha(1f, 0f) 270 | .dp().translationY( -70f, -140f) 271 | .duration(500) 272 | .startDelay(500) 273 | .onStop { 274 | Log.e("ANIM", "Circle hidden") 275 | //isCirlceAvailable = false 276 | } 277 | .start() 278 | } 279 | .start() 280 | 281 | 282 | } 283 | 284 | 285 | 286 | } 287 | */ 288 | 289 | } 290 | -------------------------------------------------------------------------------- /app/src/main/java/com/wajahatkarim3/mediumclap_android/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.wajahatkarim3.mediumclap_android 2 | 3 | import android.animation.AnimatorSet 4 | import android.animation.ObjectAnimator 5 | import android.os.Bundle 6 | import android.view.View 7 | import android.widget.Toast 8 | import androidx.appcompat.app.AppCompatActivity 9 | import com.wajahatkarim3.clapfab.ClapFAB 10 | import kotlinx.android.synthetic.main.activity_main.* 11 | import kotlinx.android.synthetic.main.activity_main.txtCountCircle 12 | 13 | class MainActivity : AppCompatActivity() { 14 | 15 | private var clapCount = 0 16 | private var isTranslateAnimActive = false 17 | private var isAlphaAnimActive = false 18 | 19 | override fun onCreate(savedInstanceState: Bundle?) { 20 | super.onCreate(savedInstanceState) 21 | setContentView(R.layout.activity_main) 22 | 23 | clapFab.clapListener = object : ClapFAB.OnClapListener{ 24 | override fun onFabClapped(clapFab: ClapFAB, count: Int, isMaxReached: Boolean) { 25 | Toast.makeText(this@MainActivity, "Clapped: $count with $isMaxReached" , Toast.LENGTH_LONG).show() 26 | } 27 | } 28 | } 29 | 30 | private fun onClapButtonClick() 31 | { 32 | clapCount++ 33 | 34 | // Update clap icon depending on clap count 35 | if (clapCount > 0) 36 | { 37 | fabDemoClap.setImageResource(R.drawable.ic_clap_hands_filled) 38 | } 39 | 40 | showCircleCount() 41 | } 42 | 43 | private fun showCircleCount() 44 | { 45 | txtCountCircle.text = "+$clapCount" 46 | txtCountCircle.visibility = View.VISIBLE 47 | txtCountCircle.y = fabDemoClap.y 48 | txtCountCircle.alpha = 1f 49 | 50 | 51 | if (isTranslateAnimActive) return 52 | 53 | val showAnim = ObjectAnimator.ofFloat(txtCountCircle, "translationY", -200f) 54 | showAnim.duration = 200 55 | showAnim.addListener(MyAnimatorListener{ 56 | setOnAnimationEnd { 57 | isTranslateAnimActive = false 58 | } 59 | }) 60 | 61 | val hideAnim = ObjectAnimator.ofFloat(txtCountCircle, "alpha", 0f) 62 | hideAnim.duration = 150 63 | hideAnim.startDelay = 200 64 | hideAnim.addListener(MyAnimatorListener{ 65 | setOnAnimationEnd { 66 | isAlphaAnimActive = false 67 | } 68 | }) 69 | 70 | /* 71 | var hideAnim = bi.txtCountCircle.animate() 72 | .alpha(0f) 73 | .setInterpolator(DecelerateInterpolator()) 74 | .setDuration(150) 75 | */ 76 | 77 | isTranslateAnimActive = true 78 | isAlphaAnimActive = true 79 | 80 | val animSet = AnimatorSet() 81 | animSet.playSequentially(showAnim, hideAnim) 82 | animSet.addListener(MyAnimatorListener{ 83 | setOnAnimationEnd { 84 | resetCircleCountTextView() 85 | } 86 | }) 87 | animSet.start() 88 | } 89 | 90 | private fun resetCircleCountTextView() 91 | { 92 | txtCountCircle.y = fabDemoClap.y 93 | txtCountCircle.visibility = View.GONE 94 | txtCountCircle.alpha = 1f 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /app/src/main/java/com/wajahatkarim3/mediumclap_android/MyAnimatorListener.kt: -------------------------------------------------------------------------------- 1 | package com.wajahatkarim3.mediumclap_android 2 | 3 | import android.animation.Animator 4 | 5 | class MyAnimatorListener(initMethod: MyAnimatorListener.() -> Unit) : Animator.AnimatorListener { 6 | 7 | private var _endListener: (animation: Animator?) -> Unit = { _ -> } 8 | private var _cancelListener: (animation: Animator?) -> Unit = { _ -> } 9 | private var _repeatListener: (animation: Animator?) -> Unit = { _ -> } 10 | private var _startListener: (animation: Animator?) -> Unit = { _ -> } 11 | 12 | override fun onAnimationEnd(animation: Animator?) { 13 | _endListener?.invoke(animation) 14 | } 15 | 16 | override fun onAnimationCancel(animation: Animator?) { 17 | 18 | } 19 | 20 | override fun onAnimationRepeat(animation: Animator?) { 21 | 22 | } 23 | 24 | override fun onAnimationStart(animation: Animator?) { 25 | 26 | } 27 | 28 | fun setOnAnimationEnd(method: (animation: Animator?) -> Unit) 29 | { 30 | _endListener = method 31 | } 32 | 33 | init { 34 | initMethod() 35 | } 36 | } -------------------------------------------------------------------------------- /app/src/main/java/com/wajahatkarim3/mediumclap_android/MyApp.java: -------------------------------------------------------------------------------- 1 | package com.wajahatkarim3.mediumclap_android; 2 | 3 | import android.app.Application; 4 | 5 | import com.facebook.stetho.Stetho; 6 | 7 | public class MyApp extends Application { 8 | @Override 9 | public void onCreate() { 10 | super.onCreate(); 11 | Stetho.initializeWithDefaults(this); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/circle_shape_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_apps_black_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_clap_hands_filled.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_clap_hands_outline.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_favorite_black_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_favorite_border_black_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_star_black_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_star_border_black_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_demo.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 20 | 21 | 22 | 43 | 44 | 45 | 64 | 65 | 66 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_example.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 25 | 26 | 42 | 43 | 51 | 52 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 19 | 20 | 32 | 33 | 53 | 54 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /app/src/main/res/layout/cicle_text_view_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wajahatkarim3/MediumClap-Android/dfbb3ee346fc950f71db788aafb40df09710ff52/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wajahatkarim3/MediumClap-Android/dfbb3ee346fc950f71db788aafb40df09710ff52/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wajahatkarim3/MediumClap-Android/dfbb3ee346fc950f71db788aafb40df09710ff52/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wajahatkarim3/MediumClap-Android/dfbb3ee346fc950f71db788aafb40df09710ff52/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wajahatkarim3/MediumClap-Android/dfbb3ee346fc950f71db788aafb40df09710ff52/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wajahatkarim3/MediumClap-Android/dfbb3ee346fc950f71db788aafb40df09710ff52/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wajahatkarim3/MediumClap-Android/dfbb3ee346fc950f71db788aafb40df09710ff52/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wajahatkarim3/MediumClap-Android/dfbb3ee346fc950f71db788aafb40df09710ff52/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wajahatkarim3/MediumClap-Android/dfbb3ee346fc950f71db788aafb40df09710ff52/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wajahatkarim3/MediumClap-Android/dfbb3ee346fc950f71db788aafb40df09710ff52/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #6677d3 5 | #303F9F 6 | #FF4081 7 | 8 | 9 | #028875 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | MediumClap-Android 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/test/java/com/wajahatkarim3/mediumclap_android/ExampleUnitTest.kt: -------------------------------------------------------------------------------- 1 | package com.wajahatkarim3.mediumclap_android 2 | 3 | import org.junit.Test 4 | 5 | import org.junit.Assert.* 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * See [testing documentation](http://d.android.com/tools/testing). 11 | */ 12 | class ExampleUnitTest { 13 | @Test 14 | fun addition_isCorrect() { 15 | assertEquals(4, 2 + 2) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /art/demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wajahatkarim3/MediumClap-Android/dfbb3ee346fc950f71db788aafb40df09710ff52/art/demo.gif -------------------------------------------------------------------------------- /art/demo_2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wajahatkarim3/MediumClap-Android/dfbb3ee346fc950f71db788aafb40df09710ff52/art/demo_2.gif -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | ext { 5 | agpVersion = '7.0.4' 6 | kotlinVersion = '1.5.30' 7 | appcompat_version = '1.0.2' 8 | mavenPublishVersion = '0.18.0' 9 | } 10 | repositories { 11 | google() 12 | mavenCentral() 13 | maven { url = "https://jitpack.io/" } 14 | } 15 | dependencies { 16 | classpath "com.android.tools.build:gradle:$agpVersion" 17 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" 18 | classpath "com.vanniktech:gradle-maven-publish-plugin:$mavenPublishVersion" 19 | } 20 | } 21 | 22 | allprojects { 23 | repositories { 24 | google() 25 | mavenCentral() 26 | maven { url = "https://jitpack.io/" } 27 | } 28 | } 29 | 30 | task clean(type: Delete) { 31 | delete rootProject.buildDir 32 | } 33 | 34 | subprojects { 35 | tasks.withType(Javadoc).all { enabled = false } 36 | } -------------------------------------------------------------------------------- /clapfab/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /clapfab/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | apply plugin: 'kotlin-android' 3 | 4 | ext { 5 | 6 | bintrayRepo = "ClapFab" 7 | bintrayName = "com.wajahatkarim3.clapfab" 8 | 9 | publishedGroupId = 'com.wajahatkarim3.clapfab' 10 | libraryName = 'clapfab' 11 | artifact = 'clapfab' 12 | 13 | libraryDescription = 'A Custom Floating Action Button (FAB) library like clapping effect on Medium' 14 | 15 | siteUrl = 'https://github.com/wajahatkarim3/MediumClap-Android' 16 | gitUrl = 'https://github.com/wajahatkarim3/MediumClap-Android.git' 17 | 18 | libraryVersion = '1.0.6' 19 | 20 | developerId = 'wajahatkarim3' 21 | developerName = 'Wajahat Karim' 22 | developerEmail = 'wajahatkarim3@gmail.com' 23 | 24 | licenseName = 'The Apache Software License, Version 2.0' 25 | licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt' 26 | allLicenses = ["Apache-2.0"] 27 | } 28 | 29 | android { 30 | compileSdkVersion 29 31 | buildToolsVersion "29.0.2" 32 | 33 | 34 | defaultConfig { 35 | minSdkVersion 16 36 | targetSdkVersion 29 37 | vectorDrawables.useSupportLibrary true 38 | testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' 39 | 40 | } 41 | 42 | buildTypes { 43 | release { 44 | minifyEnabled false 45 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 46 | } 47 | } 48 | 49 | compileOptions { 50 | sourceCompatibility JavaVersion.VERSION_1_8 51 | targetCompatibility JavaVersion.VERSION_1_8 52 | } 53 | 54 | kotlinOptions { 55 | jvmTarget = '1.8' 56 | useIR = true 57 | } 58 | 59 | lintOptions { 60 | abortOnError false 61 | } 62 | 63 | } 64 | 65 | dependencies { 66 | implementation fileTree(dir: 'libs', include: ['*.jar']) 67 | 68 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion" 69 | implementation "androidx.appcompat:appcompat:$appcompat_version" 70 | implementation 'com.github.florent37:ViewAnimator:1.1.2' 71 | implementation 'com.google.android.material:material:1.5.0' 72 | testImplementation 'junit:junit:4.12' 73 | androidTestImplementation 'androidx.test.ext:junit:1.1.1' 74 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0' 75 | } 76 | apply plugin: 'com.vanniktech.maven.publish' -------------------------------------------------------------------------------- /clapfab/gradle.properties: -------------------------------------------------------------------------------- 1 | # Maven 2 | POM_ARTIFACT_ID=clapfab 3 | POM_NAME=clapfab 4 | POM_DESCRIPTION=A Custom Floating Action Button (FAB) library like clapping effect on Medium 5 | POM_PACKAGING=aar 6 | POM_INCEPTION_YEAR=2022 7 | 8 | GROUP=com.wajahatkarim 9 | VERSION_NAME=2.0.0 10 | VERSION_CODE=4 11 | 12 | POM_URL=https://github.com/wajahatkarim3/MediumClap-Android/ 13 | 14 | POM_LICENSE_NAME=The Apache Software License, Version 2.0 15 | POM_LICENSE_URL=https://github.com/wajahatkarim3/MediumClap-Android/blob/master/LICENSE 16 | POM_LICENSE_DIST=repo 17 | 18 | POM_SCM_URL=https://github.com/wajahatkarim3/MediumClap-Android/ 19 | POM_SCM_CONNECTION=scm:git:git://github.com/wajahatkarim3/MediumClap-Android.git 20 | POM_SCM_DEV_CONNECTION=scm:git:ssh://git@github.com/wajahatkarim3/MediumClap-Android.git 21 | 22 | POM_DEVELOPER_ID=wajahatkarim 23 | POM_DEVELOPER_NAME=Wajahat Karim 24 | POM_DEVELOPER_URL=https://github.com/wajahatkarim3/ -------------------------------------------------------------------------------- /clapfab/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /clapfab/src/androidTest/java/com/wajahatkarim3/clapfab/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.wajahatkarim3.clapfab; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumented test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.wajahatkarim3.clapfab.test", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /clapfab/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | -------------------------------------------------------------------------------- /clapfab/src/main/java/com/wajahatkarim3/clapfab/ClapFAB.kt: -------------------------------------------------------------------------------- 1 | package com.wajahatkarim3.clapfab 2 | 3 | import android.animation.ObjectAnimator 4 | import android.content.Context 5 | import android.content.res.ColorStateList 6 | import android.graphics.PorterDuff 7 | import android.graphics.drawable.Drawable 8 | import android.os.CountDownTimer 9 | import android.os.Handler 10 | import android.util.AttributeSet 11 | import android.util.Log 12 | import android.view.MotionEvent 13 | import android.view.View 14 | import android.view.animation.AccelerateDecelerateInterpolator 15 | import android.view.animation.DecelerateInterpolator 16 | import android.widget.RelativeLayout 17 | import android.widget.TextView 18 | import androidx.appcompat.content.res.AppCompatResources 19 | import androidx.core.content.ContextCompat 20 | import androidx.core.widget.ImageViewCompat 21 | import com.github.florent37.viewanimator.ViewAnimator 22 | import com.google.android.material.floatingactionbutton.FloatingActionButton 23 | 24 | /** 25 | * Created by Wajahat Karim on 2/7/2018. 26 | * @author Wajahat Karim 27 | */ 28 | class ClapFAB 29 | @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0) 30 | : RelativeLayout(context, attrs, defStyleAttr) 31 | { 32 | private val TAG = ClapFAB::class.java.simpleName 33 | 34 | // Data Values 35 | private var clapCount = 0 36 | private var isCirlceAvailable = false 37 | private var isHideAnimStopped = false 38 | private var hidingStarted = false 39 | private var formatClapCount = true; 40 | 41 | // Animations 42 | private var fabScaleAnimation_1: ViewAnimator? = null 43 | private var circleShowMoveUpAnimation_2: ViewAnimator? = null 44 | private var circleScaleAnimation_3: ViewAnimator? = null 45 | private var circleHideMoveAnimation_4: ViewAnimator? = null 46 | 47 | // Views 48 | private lateinit var txtCountCircle: TextView 49 | private lateinit var dotsView: DotsView 50 | private lateinit var fabDemoClap: FloatingActionButton 51 | 52 | // Long tap down 53 | private var tapDownRunnable: Runnable? = null 54 | /** 55 | * The interval to automatically clap on long press in milliseconds. 56 | */ 57 | var longPressClapInterval: Long = 300 58 | 59 | /** 60 | * The flag to turn on/off the long press ability 61 | */ 62 | var longPressClapEnabled = true 63 | 64 | /** 65 | * Maximum Claps Count. Can't be less than 1 66 | */ 67 | var maxCount: Int = 50 68 | set(value) { 69 | if (value < 1) 70 | field = 1 71 | field = value 72 | } 73 | 74 | /** 75 | * Default Icon Resource ID 76 | */ 77 | var defaultIconResId: Int = R.drawable.ic_clap_hands_outline 78 | 79 | /** 80 | * Filled Icon Resource ID 81 | */ 82 | var filledIconResId: Int = R.drawable.ic_clap_hands_filled 83 | 84 | /** 85 | * Default Icon Color Resource 86 | */ 87 | var defaultIconColorRes = R.color.colorClapIcon 88 | 89 | /** 90 | * Filled Icon Color Resource 91 | */ 92 | var filledIconColorRes = R.color.colorClapIcon 93 | 94 | /** 95 | * Count Circle Background Color Resource 96 | */ 97 | var countCircleColorRes = R.color.colorClapIcon 98 | 99 | /** 100 | * Count Circle Text Color Resource 101 | */ 102 | var countTextColorRes = R.color.white_color 103 | 104 | /** 105 | * Dots One Color Resource 106 | */ 107 | var dots1ColorRes = R.color.dotsColor1 108 | 109 | /** 110 | * Dots Two Color Resource 111 | */ 112 | var dots2ColorRes = R.color.dotsColor2 113 | 114 | /** 115 | * The Clap Listener 116 | */ 117 | var clapListener: OnClapListener? = null 118 | 119 | init { 120 | init(context, attrs) 121 | } 122 | 123 | private fun init(context: Context, attributes: AttributeSet?) 124 | { 125 | attributes?.let { attrs -> 126 | // Getting the views 127 | inflate(context, R.layout.clap_fab_layout, this) 128 | txtCountCircle = findViewById(R.id.txtCountCircle) 129 | fabDemoClap = findViewById(R.id.fabDemoClap) 130 | dotsView = findViewById(R.id.dotsView) 131 | 132 | // Setting Listener 133 | fabDemoClap.setOnClickListener { 134 | clapCount++ 135 | if (clapCount > 0) 136 | { 137 | fabDemoClap.setImageDrawable(getDrawable(filledIconResId)) 138 | ImageViewCompat.setImageTintList(fabDemoClap, ColorStateList.valueOf( 139 | ContextCompat.getColor(context, filledIconColorRes))) 140 | } 141 | 142 | if (clapCount > maxCount) 143 | { 144 | clapCount = maxCount 145 | clapListener?.onFabClapped(this, clapCount, true) 146 | return@setOnClickListener 147 | } 148 | 149 | clapListener?.onFabClapped(this, clapCount, false) 150 | if(formatClapCount){ 151 | txtCountCircle.text = NumberUtil.format(clapCount) 152 | }else{ 153 | txtCountCircle.text = "$clapCount" 154 | } 155 | 156 | playActualFabAnim() 157 | } 158 | 159 | 160 | // Setting long click listener 161 | if (longPressClapEnabled) 162 | { 163 | fabDemoClap.setOnTouchListener { v, event -> 164 | super.onTouchEvent(event) 165 | Log.e("MC", "OnTouch") 166 | if (!longPressClapEnabled) 167 | { 168 | handler.removeCallbacks(tapDownRunnable) 169 | return@setOnTouchListener false 170 | } 171 | 172 | when(event.action) 173 | { 174 | MotionEvent.ACTION_DOWN -> { 175 | 176 | tapDownRunnable = Runnable { 177 | // Clap effect goes here 178 | clapCount++ 179 | if (clapCount > 0) 180 | { 181 | fabDemoClap.setImageDrawable(getDrawable(filledIconResId)) 182 | ImageViewCompat.setImageTintList(fabDemoClap, ColorStateList.valueOf(ContextCompat.getColor(context, filledIconColorRes))) 183 | } 184 | 185 | if (clapCount > maxCount) 186 | { 187 | clapCount = maxCount 188 | clapListener?.onFabClapped(this, clapCount, true) 189 | 190 | // Stop the runnable 191 | handler.removeCallbacks(tapDownRunnable) 192 | } 193 | else { 194 | // Repeat the timer 195 | handler.postDelayed(tapDownRunnable, longPressClapInterval) 196 | } 197 | 198 | clapListener?.onFabClapped(this, clapCount, false) 199 | if(formatClapCount){ 200 | txtCountCircle.text = NumberUtil.format(clapCount) 201 | }else{ 202 | txtCountCircle.text = "$clapCount" 203 | } 204 | 205 | playActualFabAnim() 206 | 207 | 208 | } 209 | // Start the timer handler 210 | handler.postDelayed(tapDownRunnable, longPressClapInterval) 211 | 212 | Log.e("MC", "OnTouch - ACTION_DOWN") 213 | return@setOnTouchListener false 214 | } 215 | MotionEvent.ACTION_UP -> { 216 | // Stop the runnable 217 | handler.removeCallbacks(tapDownRunnable) 218 | return@setOnTouchListener false 219 | } 220 | } 221 | 222 | return@setOnTouchListener false 223 | } 224 | } 225 | 226 | 227 | 228 | 229 | // Set Default Values Here 230 | maxCount = 50 231 | defaultIconResId = R.drawable.ic_clap_hands_outline 232 | filledIconResId = R.drawable.ic_clap_hands_filled 233 | defaultIconColorRes = R.color.colorClapIcon 234 | filledIconColorRes = R.color.colorClapIcon 235 | countCircleColorRes = R.color.colorClapIcon 236 | countTextColorRes = R.color.white_color 237 | longPressClapInterval = 300 238 | longPressClapEnabled = true 239 | 240 | // Check for attributes 241 | val typedArray = context.obtainStyledAttributes(attributes, R.styleable.clap_fab, 0, 0) 242 | typedArray.apply { 243 | maxCount = getInt(R.styleable.clap_fab_cf_max_clap_count, 50) 244 | clapCount = getInt(R.styleable.clap_fab_cf_clap_count, 0) 245 | formatClapCount = getBoolean(R.styleable.clap_fab_cf_format_clap_count, true) 246 | defaultIconResId = getResourceId(R.styleable.clap_fab_cf_default_icon, R.drawable.ic_clap_hands_outline) 247 | filledIconResId = getResourceId(R.styleable.clap_fab_cf_filled_icon, R.drawable.ic_clap_hands_filled) 248 | defaultIconColorRes = getResourceId(R.styleable.clap_fab_cf_default_icon_color, R.color.colorClapIcon) 249 | filledIconColorRes = getResourceId(R.styleable.clap_fab_cf_filled_icon_color, R.color.colorClapIcon) 250 | countCircleColorRes = getResourceId(R.styleable.clap_fab_cf_count_circle_color, R.color.colorClapIcon) 251 | countTextColorRes = getResourceId(R.styleable.clap_fab_cf_count_text_color, R.color.white_color) 252 | dots1ColorRes = getResourceId(R.styleable.clap_fab_cf_dots_1_color, R.color.dotsColor1) 253 | dots2ColorRes = getResourceId(R.styleable.clap_fab_cf_dots_2_color, R.color.dotsColor2) 254 | longPressClapEnabled = getBoolean(R.styleable.clap_fab_cf_long_press_enabled, true) 255 | longPressClapInterval = getInteger(R.styleable.clap_fab_cf_long_press_clap_interval, 300).toLong() 256 | } 257 | 258 | // Apply Attributes 259 | applyAttributes() 260 | 261 | // Init Animations 262 | initAnimation() 263 | 264 | typedArray?.recycle() 265 | } 266 | } 267 | 268 | private fun applyAttributes() 269 | { 270 | fabDemoClap.setImageDrawable(getDrawable(defaultIconResId)) 271 | ImageViewCompat.setImageTintList(fabDemoClap, ColorStateList.valueOf(ContextCompat.getColor(context, defaultIconColorRes))) 272 | txtCountCircle.setTextColor(ContextCompat.getColor(context, countTextColorRes)) 273 | //txtCountCircle.setBackgroundColor(context.resources.getColor(countCircleColorRes)) 274 | 275 | // Circle Count 276 | var shapeDrawable = getDrawable(R.drawable.circle_shape_background) 277 | var ovalShape = shapeDrawable 278 | ovalShape.setColorFilter(ContextCompat.getColor(context, countCircleColorRes), PorterDuff.Mode.SRC_ATOP) 279 | txtCountCircle.background = shapeDrawable 280 | txtCountCircle.setTextColor(ContextCompat.getColor(context, countTextColorRes)) 281 | txtCountCircle.setTextColor(ColorStateList.valueOf(ContextCompat.getColor(context, countTextColorRes))) 282 | 283 | } 284 | 285 | private fun runClickBehaviour() 286 | { 287 | 288 | } 289 | 290 | private fun initAnimation() 291 | { 292 | initDotsAnim() 293 | } 294 | 295 | private fun initDotsAnim() 296 | { 297 | dotsView.setColors(ContextCompat.getColor(context, dots1ColorRes), ContextCompat.getColor(context, dots2ColorRes)) 298 | dotsView.currentProgress = 0f 299 | dotsView.setSize(400, 400) 300 | } 301 | 302 | private fun playActualFabAnim() 303 | { 304 | isHideAnimStopped = true 305 | 306 | playDotsAnimation() 307 | 308 | // 1. Scale Up FAB Button On Each Click 309 | fabScaleUpAnimation() 310 | 311 | // 2. Show and move count text circle from button 312 | // If circle is not shown on top, then move up and show circle 313 | if (!isCirlceAvailable) 314 | { 315 | circleShowMoveUpAnimation() 316 | } 317 | // Else, scale up the counter text 318 | else 319 | { 320 | circleScaleAnimation() 321 | } 322 | } 323 | 324 | private fun playDotsAnimation() 325 | { 326 | dotsView.currentProgress = 0f 327 | 328 | var dotsAnimator = ObjectAnimator.ofFloat(dotsView, DotsView.DOTS_PROGRESS, 0f, 1f) 329 | dotsAnimator.duration = 500 330 | dotsAnimator.interpolator = AccelerateDecelerateInterpolator() 331 | dotsAnimator.start() 332 | } 333 | 334 | 335 | private fun fabScaleUpAnimation() 336 | { 337 | fabScaleAnimation_1 = ViewAnimator 338 | .animate(fabDemoClap) 339 | .scale(1f, 1.2f) 340 | .duration(70) 341 | .thenAnimate(fabDemoClap) 342 | .scale(1.2f, 1.0f) 343 | .duration(70) 344 | .start() 345 | .onStop { 346 | fabScaleAnimation_1 = null 347 | } 348 | } 349 | 350 | private fun circleShowMoveUpAnimation() 351 | { 352 | if (circleShowMoveUpAnimation_2 != null) return 353 | 354 | txtCountCircle.visibility = View.VISIBLE 355 | txtCountCircle.y = fabDemoClap.y + fabDemoClap.height/2 356 | txtCountCircle.alpha = 0f 357 | circleShowMoveUpAnimation_2 = ViewAnimator 358 | .animate(txtCountCircle) 359 | .dp().translationY(0f, -70f) 360 | .interpolator(DecelerateInterpolator()) 361 | .alpha(0f, 1f) 362 | .duration(500) 363 | .onStop { 364 | isCirlceAvailable = true 365 | circleShowMoveUpAnimation_2 = null 366 | //circleHideMoveAnimation() 367 | isHideAnimStopped = false 368 | hideAnimTimer.start() 369 | } 370 | .start() 371 | } 372 | 373 | private fun circleScaleAnimation() 374 | { 375 | circleScaleAnimation_3 = ViewAnimator 376 | .animate(txtCountCircle) 377 | .scale(1f, 1.2f) 378 | .duration(70) 379 | .thenAnimate(txtCountCircle) 380 | .scale(1.2f, 1.0f) 381 | .duration(70) 382 | .onStop { 383 | // Hide Circle Anim 384 | //circleScaleAnimation_3 = null 385 | //circleHideMoveAnimation() 386 | isHideAnimStopped = false 387 | hideAnimTimer.start() 388 | } 389 | .start() 390 | } 391 | 392 | private var hideAnimTimer = object : CountDownTimer(800, 50){ 393 | override fun onTick(millisUntilFinished: Long) { 394 | if (isHideAnimStopped) 395 | cancel() 396 | } 397 | 398 | override fun onFinish() { 399 | post { 400 | circleHideMoveAnimation() 401 | } 402 | } 403 | } 404 | 405 | private fun circleHideMoveAnimation() 406 | { 407 | if (hidingStarted) return 408 | circleHideMoveAnimation_4?.cancel() 409 | circleHideMoveAnimation_4 = ViewAnimator 410 | .animate(txtCountCircle) 411 | .alpha(1f, 0f) 412 | .dp().translationY( -70f, -140f) 413 | .duration(400) 414 | //.startDelay(1500) 415 | .onStart { 416 | hidingStarted = true 417 | } 418 | .onStop { 419 | hidingStarted = false 420 | isCirlceAvailable = false 421 | //circleShowMoveUpAnimation_2 = null 422 | //circleHideMoveAnimation_4 = null 423 | } 424 | .start() 425 | } 426 | 427 | /** 428 | * Set Default clap count 429 | * 430 | * @param count Default clap count. It can be greater than {@link maxCount} 431 | */ 432 | fun setClapCount(count:Int){ 433 | if(clapCount<=maxCount){ 434 | clapCount = count 435 | } 436 | } 437 | 438 | interface OnClapListener { 439 | fun onFabClapped(clapFab: ClapFAB, count: Int, isMaxReached: Boolean) 440 | } 441 | 442 | /** 443 | * Get Drawable object from resource Id, irrespective of vector or image resource. 444 | * 445 | * @param resId Drawable resource Id 446 | * @return Drawable object from resource Id 447 | */ 448 | private fun getDrawable(resId: Int): Drawable { 449 | return AppCompatResources.getDrawable(context, resId)!! 450 | } 451 | 452 | } -------------------------------------------------------------------------------- /clapfab/src/main/java/com/wajahatkarim3/clapfab/DotsView.kt: -------------------------------------------------------------------------------- 1 | package com.wajahatkarim3.clapfab 2 | 3 | import android.animation.ArgbEvaluator 4 | import android.content.Context 5 | import android.graphics.Canvas 6 | import android.graphics.Paint 7 | import android.util.AttributeSet 8 | import android.util.Property 9 | import android.view.View 10 | 11 | /** 12 | * Created by Miroslaw Stanek on 21.12.2015. 13 | * Modified by Joel Dean 14 | */ 15 | class DotsView : View { 16 | 17 | private var COLOR_1 = -0x3ef9 18 | private var COLOR_2 = -0x6800 19 | private var COLOR_3 = -0xa8de 20 | private var COLOR_4 = -0xbbcca 21 | 22 | private var widthInternal = 0 23 | private var heightInternal = 0 24 | 25 | private val circlePaints = arrayOfNulls(4) 26 | 27 | private var centerX: Int = 0 28 | private var centerY: Int = 0 29 | 30 | private var maxOuterDotsRadius: Float = 0.toFloat() 31 | private var maxInnerDotsRadius: Float = 0.toFloat() 32 | private var maxDotSize: Float = 0.toFloat() 33 | 34 | var currentProgress = 0f 35 | set(currentProgress) { 36 | field = currentProgress 37 | 38 | updateInnerDotsPosition() 39 | updateOuterDotsPosition() 40 | updateDotsPaints() 41 | updateDotsAlpha() 42 | 43 | postInvalidate() 44 | } 45 | 46 | private var currentRadius1 = 0f 47 | private var currentDotSize1 = 0f 48 | 49 | private var currentDotSize2 = 0f 50 | private var currentRadius2 = 0f 51 | 52 | private val argbEvaluator = ArgbEvaluator() 53 | 54 | constructor(context: Context) : super(context) { 55 | init() 56 | } 57 | 58 | constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { 59 | init() 60 | } 61 | 62 | constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { 63 | init() 64 | } 65 | 66 | 67 | private fun init() { 68 | for (i in circlePaints.indices) { 69 | circlePaints[i] = Paint() 70 | circlePaints[i]?.style = Paint.Style.FILL 71 | circlePaints[i]?.isAntiAlias = true 72 | } 73 | } 74 | 75 | override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) { 76 | super.onSizeChanged(w, h, oldw, oldh) 77 | centerX = w / 2 78 | centerY = h / 2 79 | maxDotSize = 5f 80 | maxOuterDotsRadius = w / 2 - maxDotSize * 2 81 | maxInnerDotsRadius = 0.8f * maxOuterDotsRadius 82 | } 83 | 84 | override fun onDraw(canvas: Canvas) { 85 | drawOuterDotsFrame(canvas) 86 | drawInnerDotsFrame(canvas) 87 | } 88 | 89 | private fun drawOuterDotsFrame(canvas: Canvas) { 90 | for (i in 0 until DOTS_COUNT) { 91 | val cX = (centerX + currentRadius1 * Math.cos(i.toDouble() * OUTER_DOTS_POSITION_ANGLE.toDouble() * Math.PI / 180)).toInt() 92 | val cY = (centerY + currentRadius1 * Math.sin(i.toDouble() * OUTER_DOTS_POSITION_ANGLE.toDouble() * Math.PI / 180)).toInt() 93 | canvas.drawCircle(cX.toFloat(), cY.toFloat(), currentDotSize1, circlePaints[i % circlePaints.size]!!) 94 | } 95 | } 96 | 97 | private fun drawInnerDotsFrame(canvas: Canvas) { 98 | for (i in 0 until DOTS_COUNT) { 99 | val cX = (centerX + currentRadius2 * Math.cos((i * OUTER_DOTS_POSITION_ANGLE - 10) * Math.PI / 180)).toInt() 100 | val cY = (centerY + currentRadius2 * Math.sin((i * OUTER_DOTS_POSITION_ANGLE - 10) * Math.PI / 180)).toInt() 101 | canvas.drawCircle(cX.toFloat(), cY.toFloat(), currentDotSize2, circlePaints[(i + 1) % circlePaints.size]!!) 102 | } 103 | } 104 | 105 | private fun updateInnerDotsPosition() { 106 | if (this.currentProgress < 0.3f) { 107 | this.currentRadius2 = mapValueFromRangeToRange(this.currentProgress.toDouble(), 0.0, 0.3, 0.0, maxInnerDotsRadius.toDouble()).toFloat() 108 | } else { 109 | this.currentRadius2 = maxInnerDotsRadius 110 | } 111 | if (this.currentProgress == 0f) { 112 | this.currentDotSize2 = 0f 113 | } else if (this.currentProgress < 0.2) { 114 | this.currentDotSize2 = maxDotSize 115 | } else if (this.currentProgress < 0.5) { 116 | this.currentDotSize2 = mapValueFromRangeToRange(this.currentProgress.toDouble(), 0.2, 0.5, maxDotSize.toDouble(), 0.3 * maxDotSize).toFloat() 117 | } else { 118 | this.currentDotSize2 = mapValueFromRangeToRange(this.currentProgress.toDouble(), 0.5, 1.0, (maxDotSize * 0.3f).toDouble(), 0.0).toFloat() 119 | } 120 | 121 | } 122 | 123 | private fun updateOuterDotsPosition() { 124 | if (this.currentProgress < 0.3f) { 125 | this.currentRadius1 = mapValueFromRangeToRange(this.currentProgress.toDouble(), 0.0, 0.3, 0.0, (maxOuterDotsRadius * 0.8f).toDouble()).toFloat() 126 | } else { 127 | this.currentRadius1 = mapValueFromRangeToRange(this.currentProgress.toDouble(), 0.3, 1.0, (0.8f * maxOuterDotsRadius).toDouble(), maxOuterDotsRadius.toDouble()).toFloat() 128 | } 129 | if (this.currentProgress == 0f) { 130 | this.currentDotSize1 = 0f 131 | } else if (this.currentProgress < 0.7) { 132 | this.currentDotSize1 = maxDotSize 133 | } else { 134 | this.currentDotSize1 = mapValueFromRangeToRange(this.currentProgress.toDouble(), 0.7, 1.0, maxDotSize.toDouble(), 0.0).toFloat() 135 | } 136 | } 137 | 138 | private fun updateDotsPaints() { 139 | if (this.currentProgress < 0.5f) { 140 | val progress = mapValueFromRangeToRange(this.currentProgress.toDouble(), 0.0, 0.5, 0.0, 1.0).toFloat() 141 | circlePaints[0]?.color = argbEvaluator.evaluate(progress, COLOR_1, COLOR_2) as Int 142 | circlePaints[1]?.color = argbEvaluator.evaluate(progress, COLOR_2, COLOR_3) as Int 143 | circlePaints[2]?.color = argbEvaluator.evaluate(progress, COLOR_3, COLOR_4) as Int 144 | circlePaints[3]?.color = argbEvaluator.evaluate(progress, COLOR_4, COLOR_1) as Int 145 | } else { 146 | val progress = mapValueFromRangeToRange(this.currentProgress.toDouble(), 0.5, 1.0, 0.0, 1.0).toFloat() 147 | circlePaints[0]?.color = argbEvaluator.evaluate(progress, COLOR_2, COLOR_3) as Int 148 | circlePaints[1]?.color = argbEvaluator.evaluate(progress, COLOR_3, COLOR_4) as Int 149 | circlePaints[2]?.color = argbEvaluator.evaluate(progress, COLOR_4, COLOR_1) as Int 150 | circlePaints[3]?.color = argbEvaluator.evaluate(progress, COLOR_1, COLOR_2) as Int 151 | } 152 | } 153 | 154 | fun setColors(primaryColor: Int, secondaryColor: Int) { 155 | COLOR_1 = primaryColor 156 | COLOR_2 = secondaryColor 157 | COLOR_3 = primaryColor 158 | COLOR_4 = secondaryColor 159 | invalidate() 160 | } 161 | 162 | private fun updateDotsAlpha() { 163 | val progress = clamp(this.currentProgress.toDouble(), 0.6, 1.0).toFloat() 164 | val alpha = mapValueFromRangeToRange(progress.toDouble(), 0.6, 1.0, 255.0, 0.0).toInt() 165 | circlePaints[0]?.alpha = alpha 166 | circlePaints[1]?.alpha = alpha 167 | circlePaints[2]?.alpha = alpha 168 | circlePaints[3]?.alpha = alpha 169 | } 170 | 171 | fun setSize(width: Int, height: Int) { 172 | this.widthInternal = width 173 | this.heightInternal = height 174 | invalidate() 175 | } 176 | 177 | override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) { 178 | super.onMeasure(widthMeasureSpec, heightMeasureSpec) 179 | 180 | if (widthInternal != 0 && heightInternal != 0) 181 | setMeasuredDimension(widthInternal, heightInternal) 182 | } 183 | 184 | fun mapValueFromRangeToRange(value: Double, fromLow: Double, fromHigh: Double, toLow: Double, toHigh: Double): Double { 185 | return toLow + (value - fromLow) / (fromHigh - fromLow) * (toHigh - toLow) 186 | } 187 | 188 | fun clamp(value: Double, low: Double, high: Double): Double { 189 | return Math.min(Math.max(value, low), high) 190 | } 191 | 192 | companion object { 193 | private val DOTS_COUNT = 7 194 | private val OUTER_DOTS_POSITION_ANGLE = 51 195 | 196 | 197 | val DOTS_PROGRESS: Property = object : Property(Float::class.java, "dotsProgress") { 198 | override fun get(`object`: DotsView): Float { 199 | return `object`.currentProgress 200 | } 201 | 202 | override fun set(`object`: DotsView, value: Float) { 203 | `object`.currentProgress = value 204 | } 205 | } 206 | } 207 | 208 | 209 | } -------------------------------------------------------------------------------- /clapfab/src/main/java/com/wajahatkarim3/clapfab/NumberUtil.kt: -------------------------------------------------------------------------------- 1 | package com.wajahatkarim3.clapfab 2 | 3 | import java.util.* 4 | 5 | 6 | /** 7 | * Taken From 8 | * https://stackoverflow.com/questions/4753251/how-to-go-about-formatting-1200-to-1-2k-in-java#answer-30661479 9 | * 10 | * @author assylias 11 | * @version 1.0 12 | */ 13 | object NumberUtil { 14 | 15 | private val suffixes = TreeMap() 16 | 17 | init { 18 | suffixes[1_000L] = "K"; 19 | suffixes[1_000_000L] = "M"; 20 | suffixes[1_000_000_000L] = "G"; 21 | suffixes[1_000_000_000_000L] = "T"; 22 | suffixes[1_000_000_000_000_000L] = "P"; 23 | suffixes[1_000_000_000_000_000_000L] = "E"; 24 | } 25 | 26 | fun format(value: Int): String { 27 | if (value == Int.MIN_VALUE) return format(Int.MIN_VALUE + 1) 28 | if (value < 0) return "-" + format(-value) 29 | if (value < 1000) return value.toString() //deal with easy case 30 | 31 | val e = suffixes.floorEntry(value.toLong()) 32 | val divideBy = e.key 33 | val suffix = e.value 34 | 35 | val truncated = (value / (divideBy!! / 10)).toFloat() //the number part of the output times 10 36 | val hasDecimal = truncated < 100 && truncated / 10.0 != (truncated / 10).toDouble() 37 | return if (hasDecimal) (truncated / 10.0).toString() + suffix else (truncated / 10).toString() + suffix 38 | } 39 | 40 | } -------------------------------------------------------------------------------- /clapfab/src/main/res/drawable/circle_shape_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /clapfab/src/main/res/drawable/ic_clap_hands_filled.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 14 | 15 | -------------------------------------------------------------------------------- /clapfab/src/main/res/drawable/ic_clap_hands_outline.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /clapfab/src/main/res/layout/clap_fab_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 24 | 25 | 38 | 39 | 44 | 45 | -------------------------------------------------------------------------------- /clapfab/src/main/res/values-v21/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | -------------------------------------------------------------------------------- /clapfab/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /clapfab/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #028875 4 | #6677d3 5 | #028875 6 | #FFFFFF 7 | -------------------------------------------------------------------------------- /clapfab/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8dp 4 | -------------------------------------------------------------------------------- /clapfab/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | ClapFAB 3 | 4 | -------------------------------------------------------------------------------- /clapfab/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /clapfab/src/test/java/com/wajahatkarim3/clapfab/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.wajahatkarim3.clapfab; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | org.gradle.jvmargs=-Xmx1536m 13 | 14 | # When configured, Gradle will run in incubating parallel mode. 15 | # This option should only be used with decoupled projects. More details, visit 16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 17 | # org.gradle.parallel=true 18 | 19 | # AndroidX package structure to make it clearer which packages are bundled with the 20 | # Android operating system, and which are packaged with your app's APK 21 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 22 | android.useAndroidX=true 23 | # Automatically convert third-party libraries to use AndroidX 24 | android.enableJetifier=true -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wajahatkarim3/MediumClap-Android/dfbb3ee346fc950f71db788aafb40df09710ff52/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sun Feb 04 20:10:51 PKT 2018 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-7.3.3-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':clapfab' 2 | --------------------------------------------------------------------------------