├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md └── workflows │ ├── buildAndTest.yml │ ├── ktlint.yml │ └── stale.yml ├── .gitignore ├── .idea ├── codeStyles │ ├── Project.xml │ └── codeStyleConfig.xml ├── compiler.xml ├── gradle.xml ├── jarRepositories.xml ├── misc.xml ├── runConfigurations.xml └── vcs.xml ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── assets │ └── KaushanScript-Regular.otf │ ├── java │ └── com │ │ └── mackhartley │ │ └── roundedprogressbarexample │ │ ├── MainActivity.kt │ │ ├── MainActivityViewModel.kt │ │ ├── NumberTextView.kt │ │ └── helpers.kt │ └── res │ ├── drawable │ ├── bg_advanced_bar_1.xml │ ├── bg_advanced_bar_2.xml │ ├── bg_advanced_bar_4.xml │ ├── bg_rpb_settings.xml │ ├── ic_baseline_cloud_upload_24.xml │ └── ic_baseline_corporate_fare_24.xml │ ├── layout │ └── activity_main.xml │ ├── mipmap-hdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-mdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xxhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xxxhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ └── values │ ├── colors.xml │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml ├── art ├── readme │ ├── MiniPic.png │ └── savesStateOnConfigChange.gif └── whoUsesRpb │ ├── Food_Lookup.png │ ├── Macrotracker.gif │ └── Screen Shot 2021-04-12 at 11.21.52 PM.png ├── build.gradle ├── exampleXmlLayouts ├── feature2.xml ├── feature3.xml ├── feature4.xml └── feature5.xml ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── ktlint.gradle ├── roundedprogressbar ├── .gitignore ├── build.gradle ├── consumer-rules.pro ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── mackhartley │ │ └── roundedprogressbar │ │ └── RoundedProgressBarTest.kt │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── mackhartley │ │ │ └── roundedprogressbar │ │ │ ├── CornerRadius.kt │ │ │ ├── DefaultProgressTextFormatter.kt │ │ │ ├── ProgressTextFormatter.kt │ │ │ ├── ProgressTextOverlay.kt │ │ │ ├── RoundedProgressBar.kt │ │ │ ├── ext │ │ │ └── DrawableExt.kt │ │ │ └── utils │ │ │ └── MiscUtils.kt │ └── res │ │ ├── drawable │ │ └── rounded_progress_bar_drawable.xml │ │ ├── layout │ │ └── layout_rounded_progress_bar.xml │ │ └── values │ │ ├── attrs.xml │ │ ├── colors.xml │ │ ├── dimens.xml │ │ └── integers.xml │ └── test │ └── java │ └── com │ └── mackhartley │ └── roundedprogressbar │ └── RoundedProgressBarHelpersTest.kt ├── settings.gradle └── who_uses_rpb.md /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Additional context** 27 | Add any other context about the problem here. 28 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Additional context** 17 | Add any other context or screenshots about the feature request here. 18 | -------------------------------------------------------------------------------- /.github/workflows/buildAndTest.yml: -------------------------------------------------------------------------------- 1 | name: Tests 2 | on: 3 | push: 4 | branches: 5 | - master 6 | pull_request: 7 | branches: 8 | - master 9 | 10 | jobs: 11 | run_tests: 12 | runs-on: macos-latest 13 | 14 | # Sets variables for what android environments I want to test 15 | strategy: 16 | matrix: 17 | api-level: [21, 29] 18 | 19 | # Workflow steps 20 | steps: 21 | 22 | # Cancel any previously started (but currently unfinished) workflows 23 | - name: Cancel Previous Runs 24 | uses: styfle/cancel-workflow-action@0.8.0 25 | with: 26 | access_token: ${{ github.token }} 27 | 28 | # Check out repo (under $GITHUB_WORKSPACE) so the job can access it 29 | - uses: actions/checkout@v2 30 | 31 | # Set up JDK 32 | - name: Set up JDK 1.8 33 | uses: actions/setup-java@v1 34 | with: 35 | java-version: 1.8 36 | 37 | # Cache 38 | - name: Cache Gradle packages 39 | uses: actions/cache@v2 40 | with: 41 | path: | 42 | ~/.gradle/caches 43 | ~/.gradle/wrapper 44 | key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} 45 | restore-keys: | 46 | ${{ runner.os }}-gradle- 47 | 48 | # Verify project can build and basic junit unit tests pass 49 | - name: Build With Gradle and Run Unit Tests 50 | run: ./gradlew build 51 | 52 | # Verify instrumentation tests pass 53 | - name: Run Instrumentation Tests 54 | uses: reactivecircus/android-emulator-runner@v2 55 | with: 56 | api-level: ${{ matrix.api-level }} 57 | arch: x86_64 58 | profile: Nexus 6 59 | script: ./gradlew connectedCheck 60 | 61 | # Clean up cache 62 | - name: Cleanup Gradle Cache 63 | # Remove some files from the Gradle cache, so they aren't cached by GitHub Actions. 64 | # Restoring these files from a GitHub Actions cache might cause problems for future builds. 65 | run: | 66 | rm -f ~/.gradle/caches/modules-2/modules-2.lock 67 | rm -f ~/.gradle/caches/modules-2/gc.properties 68 | -------------------------------------------------------------------------------- /.github/workflows/ktlint.yml: -------------------------------------------------------------------------------- 1 | name: ktlint 2 | 3 | on: 4 | pull_request: 5 | paths: 6 | - "**/*.kt" 7 | - ".github/workflows/ktlint.yml" 8 | 9 | jobs: 10 | ktlint: 11 | runs-on: ubuntu-latest 12 | 13 | steps: 14 | - name: "checkout" 15 | uses: actions/checkout@v2 16 | 17 | - name: "ktlint" 18 | uses: "vroy/gha-kotlin-linter@v1" 19 | -------------------------------------------------------------------------------- /.github/workflows/stale.yml: -------------------------------------------------------------------------------- 1 | name: Mark stale issues and pull requests 2 | 3 | on: 4 | schedule: 5 | - cron: "30 1 * * *" 6 | 7 | jobs: 8 | stale: 9 | 10 | runs-on: ubuntu-latest 11 | 12 | steps: 13 | - uses: actions/stale@v3 14 | with: 15 | repo-token: ${{ secrets.GITHUB_TOKEN }} 16 | stale-issue-message: 'This issue has been inactive and is now considered stale.' 17 | stale-pr-message: 'This PR has been inactive and is now considered stale.' 18 | stale-issue-label: 'no-issue-activity' 19 | stale-pr-label: 'no-pr-activity' 20 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/caches 5 | /.idea/libraries 6 | /.idea/modules.xml 7 | /.idea/workspace.xml 8 | /.idea/navEditor.xml 9 | /.idea/assetWizardSettings.xml 10 | .DS_Store 11 | /build 12 | /captures 13 | .externalNativeBuild 14 | .cxx 15 | -------------------------------------------------------------------------------- /.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 20 | 24 | 25 | 26 | 28 | 29 | 30 |
31 | 32 | 33 | 34 | xmlns:android 35 | 36 | ^$ 37 | 38 | 39 | 40 |
41 |
42 | 43 | 44 | 45 | xmlns:.* 46 | 47 | ^$ 48 | 49 | 50 | BY_NAME 51 | 52 |
53 |
54 | 55 | 56 | 57 | .*:id 58 | 59 | http://schemas.android.com/apk/res/android 60 | 61 | 62 | 63 |
64 |
65 | 66 | 67 | 68 | .*:name 69 | 70 | http://schemas.android.com/apk/res/android 71 | 72 | 73 | 74 |
75 |
76 | 77 | 78 | 79 | name 80 | 81 | ^$ 82 | 83 | 84 | 85 |
86 |
87 | 88 | 89 | 90 | style 91 | 92 | ^$ 93 | 94 | 95 | 96 |
97 |
98 | 99 | 100 | 101 | .* 102 | 103 | ^$ 104 | 105 | 106 | BY_NAME 107 | 108 |
109 |
110 | 111 | 112 | 113 | .* 114 | 115 | http://schemas.android.com/apk/res/android 116 | 117 | 118 | ANDROID_ATTRIBUTE_ORDER 119 | 120 |
121 |
122 | 123 | 124 | 125 | .* 126 | 127 | .* 128 | 129 | 130 | BY_NAME 131 | 132 |
133 |
134 |
135 |
136 | 137 | 139 |
140 |
-------------------------------------------------------------------------------- /.idea/codeStyles/codeStyleConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 22 | 23 | -------------------------------------------------------------------------------- /.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 | 5 | 6 | 7 | 9 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, sex characteristics, gender identity and expression, 9 | level of experience, education, socio-economic status, nationality, personal 10 | appearance, race, religion, or sexual identity and orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project team at mackh777@gmail.com. All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Attribution 69 | 70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 71 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html 72 | 73 | [homepage]: https://www.contributor-covenant.org 74 | 75 | For answers to common questions about this code of conduct, see 76 | https://www.contributor-covenant.org/faq 77 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | If you find a bug or have a feature request you are free to open a Github Issue at any time. These will be addressed promptly after being created. 4 | 5 | If you are interested in contributing to the repo that's great! Before doing so, contact me via direct message or a Github Issue to let me know what you would like to add. That way we can avoid overwritting each other's work in the event I am also working on the library. 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 2021 Mack Hartley 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 |

2 | 3 |

4 |

RoundedProgressBar

5 |

Easy, Beautiful, Customizable

6 | 7 |

8 | 9 | 10 | ktlint 11 | Android Weekly 12 | Medium 13 |

14 | 15 | Using the `RoundedProgressBar` library you can easily create beautiful progress bars with individually rounded corners, animating progress text and more! Below are several examples of progress bars created with this library. 16 |
17 |
18 |

19 | 20 |

21 | 22 | If you’d like to see if this library is right for your project then try downloading the demo app which is available on the [Google Play Store](https://play.google.com/store/apps/details?id=com.mackhartley.roundedprogressbarexample). There you can fully customize a `RoundedProgressBar` to see if you’re able to achieve the desired look and feel for your project. 23 |
24 |

25 | Get it on Google Play 26 |
27 | 28 |

29 | 30 | Do you use `RoundedProgressBar` in your app? Consider adding a picture or GIF of your usage to [`who_uses_rpb.md`](https://github.com/MackHartley/RoundedProgressBar/blob/master/who_uses_rpb.md). This provides examples to developers on how the library is used and gives your app a bit of **free publicity!** 31 | 32 | # Gradle Setup ⚙️ 33 | [![](https://jitpack.io/v/MackHartley/RoundedProgressBar.svg)](https://jitpack.io/#MackHartley/RoundedProgressBar) 34 | 35 | If you don't have this already, add it to your **root** build.gradle file: 36 | ``` 37 | allprojects { 38 | repositories { 39 | ... 40 | maven { url 'https://jitpack.io' } 41 | } 42 | } 43 | ``` 44 | 45 | Then you can add the dependency to your **app** build.gradle file: 46 | ``` 47 | dependencies { 48 | ... 49 | implementation 'com.github.MackHartley:RoundedProgressBar:3.0.0' 50 | } 51 | ``` 52 | 53 | # Notable Features 🌟 54 | 55 | 1) **Full Color Customization** - You can even specify what color the text is depending on which background it draws over. Transparent colors are also supported 56 |

57 | 58 |
59 | Click here to see code 60 |

61 | 62 | 2) **Complete Text Customization** - The text displayed on the progress bar can be customized to say whatever you want. Additionally you can add padding and even supply your own font for use with the progress bar (`.ttf` and `.otf` formats supported) 63 |

64 | 65 |
66 | Click here to see code 67 |

68 | 69 | 3) **Low Value Support** - The progress bar looks nice even at low values (This is a common issue when dealing with rounded progress bars) 70 |

71 | 72 |
73 | Click here to see code 74 |

75 | 76 | 4) **Any Corner Radius Allowed** - Individual corners can even have different radius values 77 |

78 | 79 |
80 | Click here to see code 81 |

82 | 83 | 5) **Modular** - The `RoundedProgressBar` library can be seamlessly included in custom layouts due to the fact that each corner can have a different radius 84 |

85 | 86 |
87 | Click here or here to see code 88 |

89 | 90 | **Additionally**, the `RoundedProgressBar` handles all internal state during configuration changes 91 | 92 | # Public Methods and Xml Attributes 💻 93 | These are the methods which can be called on the `RoundedProgressBar` class: 94 | 95 | ``` 96 | setProgressPercentage(progressPercentage: Double, shouldAnimate: Boolean = true) 97 | getProgressPercentage(): Double 98 | 99 | setProgressDrawableColor(@ColorInt newColor: Int) // Sets the color of the 'progress' part of the progress bar 100 | setBackgroundDrawableColor(@ColorInt newColor: Int) // Sets the color of the 'background' part of the progress bar 101 | setProgressTextColor(@ColorInt newColor: Int) // Sets text color for when it is drawn over the progress part of progress bar 102 | setBackgroundTextColor(@ColorInt newColor: Int) // Sets text color for when it is drawn over the background part of progress bar 103 | 104 | setCornerRadius( 105 | topLeftRadius: Float, 106 | topRightRadius: Float, 107 | bottomRightRadius: Float, 108 | bottomLeftRadius: Float 109 | ) 110 | 111 | setTextSize(newTextSize: Float) 112 | setTextPadding(newTextPadding: Float) // Sets the padding between the progress text and end (or start) of the progress bar 113 | setAnimationLength(newAnimationLength: Long) 114 | 115 | showProgressText(shouldShowProgressText: Boolean) 116 | setRadiusRestricted(isRestricted: Boolean) 117 | ``` 118 | 119 | The `RoundedProgressBar` can also be configured via xml attributes. Below is the full list of attributes along with the methods they map to. 120 | | Xml Attribute | Method | 121 | |---|---| 122 | | `rpbProgress` | `setProgressPercentage(...)` | 123 | | `rpbProgressColor` | `setProgressDrawableColor(...)` | 124 | | `rpbBackgroundColor` | `setBackgroundDrawableColor(...)` | 125 | | `rpbProgressTextColor` | `setProgressTextColor(...)` | 126 | | `rpbBackgroundTextColor` | `setBackgroundTextColor(...)` | 127 | | `rpbCornerRadius` | `setCornerRadius(...)` | 128 | | `rpbCornerRadiusTopLeft` | `setCornerRadius(...)` | 129 | | `rpbCornerRadiusTopRight` | `setCornerRadius(...)` | 130 | | `rpbCornerRadiusBottomRight` | `setCornerRadius(...)` | 131 | | `rpbCornerRadiusBottomLeft` | `setCornerRadius(...)` | 132 | | `rpbTextSize` | `setTextSize(...)` | 133 | | `rpbTextPadding` | `setTextPadding(...)` | 134 | | `rpbAnimationLength` | `setAnimationLength(...)` | 135 | | `rpbShowProgressText` | `showProgressText(...)` | 136 | | `rpbIsRadiusRestricted` | `setRadiusRestricted(...)` | 137 | 138 | # Contributing 🤝 139 | Feel free to open up issues on this repo to report bugs or request features. 140 | 141 | Additionally if you'd like to contribute to the library please feel free to open up a pull request! Just give me a heads up first though (via issues or comments) so we don't overwrite each other in the event I am updating the project. 142 | 143 | **Special thanks to all those who have supported this repo thus far!** 144 | 145 |

146 | 147 |
148 | 149 |
150 |
151 | Featured in Android Weekly, Android Arsenal and Medium. 152 |

153 | 154 | # License 📄 155 | ``` 156 | Copyright 2021 Mack Hartley 157 | 158 | Licensed under the Apache License, Version 2.0 (the "License"); 159 | you may not use this file except in compliance with the License. 160 | You may obtain a copy of the License at 161 | 162 | http://www.apache.org/licenses/LICENSE-2.0 163 | 164 | Unless required by applicable law or agreed to in writing, software 165 | distributed under the License is distributed on an "AS IS" BASIS, 166 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 167 | See the License for the specific language governing permissions and 168 | limitations under the License. 169 | ``` 170 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | apply plugin: 'kotlin-android' 3 | apply plugin: 'kotlin-android-extensions' 4 | 5 | android { 6 | compileSdkVersion 33 7 | buildToolsVersion "29.0.3" 8 | 9 | defaultConfig { 10 | applicationId "com.mackhartley.roundedprogressbarexample" 11 | minSdkVersion 21 12 | targetSdkVersion 33 13 | versionCode 3 14 | versionName "1.0.2" 15 | 16 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 17 | } 18 | 19 | buildTypes { 20 | release { 21 | minifyEnabled false 22 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 23 | } 24 | } 25 | } 26 | 27 | dependencies { 28 | implementation fileTree(dir: "libs", include: ["*.jar"]) 29 | implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" 30 | implementation 'androidx.core:core-ktx:1.3.1' 31 | implementation 'androidx.appcompat:appcompat:1.2.0' 32 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3' 33 | testImplementation 'junit:junit:4.12' 34 | androidTestImplementation 'androidx.test.ext:junit:1.1.1' 35 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' 36 | 37 | implementation project(":roundedprogressbar") 38 | implementation 'com.jaredrummler:colorpicker:1.1.0' 39 | implementation 'com.google.android.material:material:1.3.0' 40 | implementation 'com.github.sephiroth74:NumberSlidingPicker:1.0.3' 41 | implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' 42 | } -------------------------------------------------------------------------------- /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 -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /app/src/main/assets/KaushanScript-Regular.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MackHartley/RoundedProgressBar/06460414f19851118d31cbdeba712d1f71299284/app/src/main/assets/KaushanScript-Regular.otf -------------------------------------------------------------------------------- /app/src/main/java/com/mackhartley/roundedprogressbarexample/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.mackhartley.roundedprogressbarexample 2 | 3 | import android.animation.ObjectAnimator 4 | import android.graphics.Color 5 | import androidx.appcompat.app.AppCompatActivity 6 | import android.os.Bundle 7 | import androidx.core.content.ContextCompat 8 | import androidx.lifecycle.ViewModelProvider 9 | import com.jaredrummler.android.colorpicker.ColorPickerDialog 10 | import com.jaredrummler.android.colorpicker.ColorPickerDialogListener 11 | import com.mackhartley.roundedprogressbar.CornerRadius 12 | import com.mackhartley.roundedprogressbar.ProgressTextFormatter 13 | import com.mackhartley.roundedprogressbar.RoundedProgressBar 14 | import it.sephiroth.android.library.numberpicker.doOnProgressChanged 15 | import kotlinx.android.synthetic.main.activity_main.* 16 | import kotlin.math.roundToInt 17 | 18 | /** 19 | * Disclaimer: This app was quickly built and is intended to demonstrate the functionality of 20 | * the RoundedProgressBar library. It may not follow best design practices in all areas. Please do 21 | * not use it as a judge of good design/architecture. 22 | */ 23 | class MainActivity : AppCompatActivity(), ColorPickerDialogListener { 24 | 25 | private val viewModel by lazy { ViewModelProvider(this).get(MainActivityViewModel::class.java) } 26 | 27 | private lateinit var allProgressBars: List 28 | 29 | private companion object { 30 | private const val ID_PROG_COLOR = 1 31 | private const val ID_PROG_TEXT_COLOR = 2 32 | private const val ID_BACKGROUND_COLOR = 3 33 | private const val ID_BACKGROUND_TEXT_COLOR = 4 34 | private const val ID_ACTIVITY_BG_COLOR = 5 35 | } 36 | 37 | override fun onCreate(savedInstanceState: Bundle?) { 38 | super.onCreate(savedInstanceState) 39 | setContentView(R.layout.activity_main) 40 | 41 | button_decrease.setOnClickListener { decreaseProgress() } 42 | button_increase.setOnClickListener { increaseProgress() } 43 | button_change_amount.setOnClickListener { 44 | viewModel.nextAmount() 45 | updateAmountButtonLabel() 46 | } 47 | 48 | // The state for these isn't held by RPB as they aren't RPB specific 49 | updateAmountButtonLabel() 50 | custom_bar_layout.setBackgroundColor(Color.parseColor(viewModel.behindProgBarColor)) 51 | setNewProgressBarHeight(viewModel.progressBarHeight) 52 | 53 | allProgressBars = listOf( 54 | custom_bar, 55 | simple_bar_1, 56 | simple_bar_2, 57 | simple_bar_4, 58 | advanced_bar_1, 59 | advanced_bar_3_top, 60 | advanced_bar_3_mid, 61 | advanced_bar_3_bot, 62 | advanced_bar_5, 63 | advanced_bar_6, 64 | advanced_bar_7 65 | ) 66 | setProgressBarAttributesProgrammatically(simple_bar_1) 67 | setUpCustomProgressTextExample(advanced_bar_7) 68 | 69 | populateSettings() 70 | initSettingsListeners() 71 | } 72 | 73 | private fun setUpCustomProgressTextExample(advancedBar7: RoundedProgressBar) { 74 | 75 | val exampleCustomFormatter = object : ProgressTextFormatter { 76 | override fun getProgressText(progressValue: Float): String { 77 | return when { 78 | progressValue == 0f -> "0/10, Lets start!" 79 | progressValue <= .1f -> "1/10" 80 | progressValue <= .2f -> "2/10" 81 | progressValue <= .3f -> "3/10" 82 | progressValue <= .4f -> "4/10" 83 | progressValue <= .5f -> "5/10 Almost!" 84 | progressValue <= .6f -> "6/10" 85 | progressValue <= .7f -> "7/10" 86 | progressValue <= .8f -> "8/10" 87 | progressValue <= .9f -> "9/10" 88 | else -> "10/10, Done!" 89 | } 90 | } 91 | } 92 | 93 | advancedBar7.setProgressTextFormatter(exampleCustomFormatter) 94 | } 95 | 96 | private fun updateAmountButtonLabel() { 97 | button_change_amount.text = getNewAmountLabel(viewModel.getCurAmount()) 98 | } 99 | 100 | private fun getNewAmountLabel(intVal: Int): String = "+$intVal" 101 | 102 | private fun populateSettings() { 103 | behind_prog_bar_button.text = viewModel.behindProgBarColor 104 | prog_bar_height_field.setProgress(viewModel.progressBarHeight) 105 | 106 | prog_color.text = viewModel.progressColor 107 | prog_text_color.text = viewModel.progressTextColor 108 | background_color.text = viewModel.backgroundColor 109 | background_text_color.text = viewModel.backgroundTextColor 110 | 111 | tl_radius_field.setProgress(viewModel.tlRadius) 112 | tr_radius_field.setProgress(viewModel.trRadius) 113 | br_radius_field.setProgress(viewModel.brRadius) 114 | bl_radius_field.setProgress(viewModel.blRadius) 115 | 116 | text_size_field.setProgress(viewModel.textSize) 117 | text_padding_field.setProgress(viewModel.textPadding) 118 | animation_length_field.setProgress(viewModel.animLength) 119 | 120 | show_text_switch.isChecked = viewModel.showProgText 121 | restrict_radius_switch.isChecked = viewModel.restrictRadius 122 | } 123 | 124 | private fun initSettingsListeners() { 125 | // Not RPB specific 126 | behind_prog_bar_button.setOnClickListener { 127 | ColorPickerDialog.newBuilder() 128 | .setColor(Color.parseColor(viewModel.behindProgBarColor)) 129 | .setDialogId(ID_ACTIVITY_BG_COLOR).show(this) 130 | } 131 | prog_bar_height_field.doOnProgressChanged { _, progress, _ -> 132 | viewModel.progressBarHeight = progress 133 | setNewProgressBarHeight(progress) 134 | } 135 | 136 | // Colors 137 | prog_color.setOnClickListener { 138 | ColorPickerDialog.newBuilder() 139 | .setColor(Color.parseColor(viewModel.progressColor)) 140 | .setDialogId(ID_PROG_COLOR).show(this) 141 | } 142 | prog_text_color.setOnClickListener { 143 | ColorPickerDialog.newBuilder() 144 | .setColor(Color.parseColor(viewModel.progressTextColor)) 145 | .setDialogId(ID_PROG_TEXT_COLOR).show(this) 146 | } 147 | background_color.setOnClickListener { 148 | ColorPickerDialog.newBuilder() 149 | .setColor(Color.parseColor(viewModel.backgroundColor)) 150 | .setDialogId(ID_BACKGROUND_COLOR).show(this) 151 | } 152 | background_text_color.setOnClickListener { 153 | ColorPickerDialog.newBuilder() 154 | .setColor(Color.parseColor(viewModel.backgroundTextColor)) 155 | .setDialogId(ID_BACKGROUND_TEXT_COLOR).show(this) 156 | } 157 | 158 | // Radius 159 | tl_radius_field.doOnProgressChanged { _, progress, _ -> 160 | viewModel.tlRadius = progress 161 | val radius = convertDpToPix(progress.toFloat(), resources) 162 | custom_bar.setCornerRadius(radius, CornerRadius.TOP_LEFT) 163 | } 164 | tr_radius_field.doOnProgressChanged { _, progress, _ -> 165 | viewModel.trRadius = progress 166 | val radius = convertDpToPix(progress.toFloat(), resources) 167 | custom_bar.setCornerRadius(radius, CornerRadius.TOP_RIGHT) 168 | } 169 | br_radius_field.doOnProgressChanged { _, progress, _ -> 170 | viewModel.brRadius = progress 171 | val radius = convertDpToPix(progress.toFloat(), resources) 172 | custom_bar.setCornerRadius(radius, CornerRadius.BOTTOM_RIGHT) 173 | } 174 | bl_radius_field.doOnProgressChanged { _, progress, _ -> 175 | viewModel.blRadius = progress 176 | val radius = convertDpToPix(progress.toFloat(), resources) 177 | custom_bar.setCornerRadius(radius, CornerRadius.BOTTOM_LEFT) 178 | } 179 | 180 | // Text and Anim 181 | text_size_field.doOnProgressChanged { _, progress, _ -> 182 | viewModel.textSize = progress 183 | val textSize = convertSpToPix(progress.toFloat(), resources) 184 | custom_bar.setTextSize(textSize) 185 | } 186 | text_padding_field.doOnProgressChanged { _, progress, _ -> 187 | viewModel.textPadding = progress 188 | val paddingSize = convertDpToPix(progress.toFloat(), resources) 189 | custom_bar.setTextPadding(paddingSize) 190 | } 191 | animation_length_field.doOnProgressChanged { _, progress, _ -> 192 | viewModel.animLength = progress 193 | custom_bar.setAnimationLength(progress.toLong()) 194 | } 195 | 196 | // Show Text and Restrict Radius 197 | show_text_switch.setOnCheckedChangeListener { _, isChecked -> 198 | viewModel.showProgText = isChecked 199 | custom_bar.showProgressText(isChecked) 200 | } 201 | restrict_radius_switch.setOnCheckedChangeListener { _, isChecked -> 202 | viewModel.restrictRadius = isChecked 203 | custom_bar.setRadiusRestricted(isChecked) 204 | } 205 | } 206 | 207 | private fun setNewProgressBarHeight(heightDp: Int) { 208 | val heightInPix = convertDpToPix(heightDp.toFloat(), resources) 209 | val newLayoutParams = custom_bar.layoutParams 210 | newLayoutParams.height = heightInPix.roundToInt() 211 | custom_bar.layoutParams = newLayoutParams 212 | } 213 | 214 | /** 215 | * Example of how to set progress bar attributes programmatically 216 | */ 217 | private fun setProgressBarAttributesProgrammatically(roundedProgressBar: RoundedProgressBar) { 218 | roundedProgressBar.setProgressDrawableColor(ContextCompat.getColor(this, R.color.progress_color_s1)) 219 | roundedProgressBar.setBackgroundDrawableColor(ContextCompat.getColor(this, R.color.progress_background_color_s1)) 220 | roundedProgressBar.setTextSize(resources.getDimension(R.dimen.small_text_size)) 221 | roundedProgressBar.setProgressTextColor(ContextCompat.getColor(this, R.color.text_color_s1)) 222 | roundedProgressBar.setBackgroundTextColor(ContextCompat.getColor(this, R.color.bg_text_color_s1)) 223 | roundedProgressBar.showProgressText(true) 224 | } 225 | 226 | private fun increaseProgress() { 227 | allProgressBars.forEach { changeProgress(it) } 228 | changeProgressAdvBar2() 229 | changeProgressAdvBar3() 230 | } 231 | 232 | private fun decreaseProgress() { 233 | allProgressBars.forEach { changeProgress(it, false) } 234 | changeProgressAdvBar2(false) 235 | changeProgressAdvBar3(false) 236 | } 237 | 238 | private fun changeProgress(roundedProgressBar: RoundedProgressBar, isAddition: Boolean = true) { 239 | val curValue = roundedProgressBar.getProgressPercentage() 240 | var adjustment = viewModel.getCurAmount() 241 | if (!isAddition) adjustment *= -1 242 | roundedProgressBar.setProgressPercentage(curValue + adjustment) 243 | } 244 | 245 | private fun changeProgressAdvBar2(isAddition: Boolean = true) { 246 | val curValue = advanced_bar_2.getProgressPercentage() 247 | var adjustment = viewModel.getCurAmount() 248 | if (!isAddition) adjustment *= -1 249 | advanced_bar_2.setProgressPercentage(curValue + adjustment) 250 | val newValue = advanced_bar_2.getProgressPercentage() 251 | animateDownloadCount(curValue.roundToInt(), newValue.roundToInt()) 252 | } 253 | 254 | private fun changeProgressAdvBar3(isAddition: Boolean = true) { 255 | val curValue = advanced_bar_4.getProgressPercentage() 256 | var adjustment = viewModel.getCurAmount() 257 | if (!isAddition) adjustment *= -1 258 | advanced_bar_4.setProgressPercentage(curValue + adjustment) 259 | val newValue = advanced_bar_4.getProgressPercentage() 260 | updateShieldLabel(newValue.roundToInt()) 261 | } 262 | 263 | private fun animateDownloadCount(oldValue: Int, newValue: Int) { 264 | val downloadCountMulti = 2.8 // This is just here to make the download number look a bit more realistic in the example 265 | ObjectAnimator.ofInt( 266 | label_advanced_bar_2, 267 | "intVal", 268 | (oldValue * downloadCountMulti).toInt(), 269 | (newValue * downloadCountMulti).toInt() 270 | ).apply { 271 | duration = 200 272 | start() 273 | } 274 | } 275 | 276 | private fun updateShieldLabel(newValue: Int) { 277 | val shieldStatusLabel = when { 278 | newValue >= 75 -> "Shields Full" 279 | newValue >= 50 -> "Shields Worn" 280 | newValue >= 25 -> "Shields Damaged" 281 | newValue > 0 -> "Shields Critical" 282 | else -> "Shields Depleted" 283 | } 284 | label_advanced_bar_4.text = shieldStatusLabel 285 | } 286 | 287 | override fun onColorSelected(dialogId: Int, color: Int) { 288 | when (dialogId) { 289 | ID_PROG_COLOR -> { 290 | val colorStr = colorIntToHexString(color) 291 | prog_color.text = colorStr 292 | viewModel.progressColor = colorStr 293 | custom_bar.setProgressDrawableColor(color) 294 | } 295 | ID_PROG_TEXT_COLOR -> { 296 | val colorStr = colorIntToHexString(color) 297 | prog_text_color.text = colorStr 298 | viewModel.progressTextColor = colorStr 299 | custom_bar.setProgressTextColor(color) 300 | } 301 | ID_BACKGROUND_COLOR -> { 302 | val colorStr = colorIntToHexString(color) 303 | background_color.text = colorStr 304 | viewModel.backgroundColor = colorStr 305 | custom_bar.setBackgroundDrawableColor(color) 306 | } 307 | ID_BACKGROUND_TEXT_COLOR -> { 308 | val colorStr = colorIntToHexString(color) 309 | background_text_color.text = colorStr 310 | viewModel.backgroundTextColor = colorStr 311 | custom_bar.setBackgroundTextColor(color) 312 | } 313 | ID_ACTIVITY_BG_COLOR -> { 314 | val colorStr = colorIntToHexString(color) 315 | behind_prog_bar_button.text = colorStr 316 | custom_bar_layout.setBackgroundColor(color) 317 | viewModel.behindProgBarColor = colorStr 318 | } 319 | } 320 | } 321 | 322 | override fun onDialogDismissed(dialogId: Int) {} 323 | } -------------------------------------------------------------------------------- /app/src/main/java/com/mackhartley/roundedprogressbarexample/MainActivityViewModel.kt: -------------------------------------------------------------------------------- 1 | package com.mackhartley.roundedprogressbarexample 2 | 3 | import androidx.lifecycle.ViewModel 4 | 5 | class MainActivityViewModel : ViewModel() { 6 | 7 | private var changeAmounts = listOf(1, 10, 25, 50, 100) 8 | private var changeAmountInd: Int = 1 9 | 10 | var behindProgBarColor = "#FFFFFF" 11 | var progressBarHeight = 40 12 | 13 | var progressColor = "#FF9B42" 14 | var progressTextColor = "#000000" 15 | var backgroundColor = "#BBBBBB" 16 | var backgroundTextColor = "#000000" 17 | 18 | var tlRadius = 8 19 | var trRadius = 8 20 | var brRadius = 8 21 | var blRadius = 8 22 | 23 | var textSize = 14 24 | var textPadding = 8 25 | var animLength = 500 26 | 27 | var showProgText = true 28 | var restrictRadius = true 29 | 30 | fun nextAmount() { 31 | changeAmountInd = ((changeAmountInd + 1) % (changeAmounts.size)) 32 | } 33 | 34 | fun getCurAmount(): Int = changeAmounts[changeAmountInd] 35 | } -------------------------------------------------------------------------------- /app/src/main/java/com/mackhartley/roundedprogressbarexample/NumberTextView.kt: -------------------------------------------------------------------------------- 1 | package com.mackhartley.roundedprogressbarexample 2 | 3 | import android.content.Context 4 | import android.util.AttributeSet 5 | import androidx.appcompat.widget.AppCompatTextView 6 | 7 | /** 8 | * This class just lets you easily animate a text view that shows numbers. 9 | */ 10 | class NumberTextView @JvmOverloads constructor( 11 | context: Context, 12 | attrs: AttributeSet? = null, 13 | defStyleAttr: Int = 0 14 | ) : AppCompatTextView(context, attrs, defStyleAttr) { 15 | fun setIntVal(value: Int) { 16 | val str = value.toString() 17 | setText(str) 18 | } 19 | } -------------------------------------------------------------------------------- /app/src/main/java/com/mackhartley/roundedprogressbarexample/helpers.kt: -------------------------------------------------------------------------------- 1 | package com.mackhartley.roundedprogressbarexample 2 | 3 | import android.content.res.Resources 4 | import android.util.TypedValue 5 | import androidx.annotation.ColorInt 6 | 7 | fun colorIntToHexString(@ColorInt color: Int): String { 8 | return String.format("#%06X", 0xFFFFFF and color) 9 | } 10 | 11 | fun convertDpToPix(dp: Float, resources: Resources): Float { 12 | return TypedValue.applyDimension( 13 | TypedValue.COMPLEX_UNIT_DIP, 14 | dp, 15 | resources.displayMetrics 16 | ) 17 | } 18 | 19 | fun convertSpToPix(sp: Float, resources: Resources): Float { 20 | return TypedValue.applyDimension( 21 | TypedValue.COMPLEX_UNIT_SP, 22 | sp, 23 | resources.displayMetrics 24 | ) 25 | } -------------------------------------------------------------------------------- /app/src/main/res/drawable/bg_advanced_bar_1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/bg_advanced_bar_2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/bg_advanced_bar_4.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/bg_rpb_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_baseline_cloud_upload_24.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_baseline_corporate_fare_24.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 21 | 22 |