├── .github └── workflows │ └── android.yml ├── .gitignore ├── CHANGELOG.md ├── LICENSE.txt ├── MIGRATION.md ├── README.md ├── app ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── ic_launcher-playstore.png │ ├── java │ └── com │ │ └── akexorcist │ │ └── roundcornerprogressbar │ │ └── example │ │ ├── MainActivity.kt │ │ ├── ViewPagerAdapter.kt │ │ └── fragment │ │ ├── CenteredDemoFragment.kt │ │ ├── IconDemoFragment.kt │ │ ├── IndeterminateDemoFragment.kt │ │ ├── SimpleDemoFragment.kt │ │ └── TextDemoFragment.kt │ └── res │ ├── drawable-hdpi │ ├── ic_android.png │ ├── ic_clock.png │ ├── ic_download.png │ └── ic_television.png │ ├── drawable-mdpi │ ├── ic_android.png │ ├── ic_clock.png │ ├── ic_download.png │ └── ic_television.png │ ├── drawable-night │ └── shape_sample_card_background.xml │ ├── drawable-xhdpi │ ├── ic_android.png │ ├── ic_clock.png │ ├── ic_download.png │ └── ic_television.png │ ├── drawable-xxhdpi │ ├── ic_android.png │ ├── ic_clock.png │ ├── ic_download.png │ └── ic_television.png │ ├── drawable │ └── shape_sample_card_background.xml │ ├── layout │ ├── activity_main.xml │ ├── fragment_centered_demo.xml │ ├── fragment_icon_demo.xml │ ├── fragment_indeterminate_demo.xml │ ├── fragment_simple_demo.xml │ └── fragment_text_demo.xml │ ├── mipmap-anydpi-v26 │ ├── ic_launcher.xml │ └── ic_launcher_round.xml │ ├── mipmap-hdpi │ ├── ic_launcher.png │ ├── ic_launcher_background.png │ ├── ic_launcher_foreground.png │ └── ic_launcher_round.png │ ├── mipmap-mdpi │ ├── ic_launcher.png │ ├── ic_launcher_background.png │ ├── ic_launcher_foreground.png │ └── ic_launcher_round.png │ ├── mipmap-xhdpi │ ├── ic_launcher.png │ ├── ic_launcher_background.png │ ├── ic_launcher_foreground.png │ └── ic_launcher_round.png │ ├── mipmap-xxhdpi │ ├── ic_launcher.png │ ├── ic_launcher_background.png │ ├── ic_launcher_foreground.png │ └── ic_launcher_round.png │ ├── mipmap-xxxhdpi │ ├── ic_launcher.png │ ├── ic_launcher_background.png │ ├── ic_launcher_foreground.png │ └── ic_launcher_round.png │ ├── values-night │ └── colors.xml │ └── values │ ├── colors.xml │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── image ├── animation_comparison.gif ├── google_play.jpg ├── header.jpg ├── overview_centered.jpg ├── overview_icon.jpg ├── overview_indeterminate.gif ├── overview_simple.jpg ├── overview_text.jpg ├── sample_centered.jpg ├── sample_gradient.jpg ├── sample_icon.jpg ├── sample_indeterminate.gif ├── sample_indeterminate_centered.gif ├── sample_simple.jpg └── sample_text.jpg ├── publish └── mavencentral.gradle ├── round-corner-progress-bar ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── akexorcist │ │ └── roundcornerprogressbar │ │ ├── CenteredRoundCornerProgressBar.kt │ │ ├── IconRoundCornerProgressBar.kt │ │ ├── RoundCornerProgressBar.kt │ │ ├── TextRoundCornerProgressBar.kt │ │ ├── common │ │ ├── AnimatedRoundCornerProgressBar.kt │ │ └── BaseRoundCornerProgressBar.kt │ │ └── indeterminate │ │ ├── IndeterminateCenteredRoundCornerProgressBar.kt │ │ └── IndeterminateRoundCornerProgressBar.kt │ └── res │ ├── layout │ ├── layout_icon_round_corner_progress_bar.xml │ ├── layout_round_corner_progress_bar.xml │ └── layout_text_round_corner_progress_bar.xml │ └── values │ ├── attrs.xml │ └── colors.xml └── settings.gradle /.github/workflows/android.yml: -------------------------------------------------------------------------------- 1 | name: Android CI 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | jobs: 10 | test: 11 | name: Unit Test 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: actions/checkout@v3 15 | 16 | - name: set up JDK 1.8 17 | uses: actions/setup-java@v3 18 | with: 19 | distribution: 'adopt' 20 | java-version: '11' 21 | cache: 'gradle' 22 | 23 | - name: Grant execute permission for gradlew 24 | run: chmod +x gradlew 25 | 26 | - name: Run Clean 27 | run: ./gradlew clean 28 | 29 | - name: Run build compatibility test 30 | run: ./gradlew assembleDebug 31 | -------------------------------------------------------------------------------- /.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/assetWizardSettings.xml 41 | .idea/dictionaries 42 | .idea/libraries 43 | .idea/caches 44 | 45 | # Keystore files 46 | # Uncomment the following line if you do not want to check your keystore files in. 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 | 60 | # fastlane 61 | fastlane/report.xml 62 | fastlane/Preview.html 63 | fastlane/screenshots 64 | fastlane/test_output 65 | fastlane/readme.md 66 | .idea 67 | .DS_Store 68 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | Release Notes 2 | ==== 3 | 4 | 2.2.1 5 | -- 6 | * Gradle 8.0 7 | * Android Gradle Plugin 8.1.0 8 | * Using Java 17 for Compile & Kotlin options 9 | 10 | 2.2.0 11 | -- 12 | * Convert all Java classes to Kotlin 13 | * Gradle 7.5 14 | * Android Gradle Plugin 7.4.2 15 | * Kotlin 1.8.20 16 | * Compile & Target SDK version 33 17 | * Minimum SDK version 17 18 | * Update dependencies 19 | * AndroidX Annotation 1.6.0 20 | 21 | 2.1.2 22 | -- 23 | * Fix unspecified module error 24 | 25 | 2.1.1 26 | -- 27 | * Fix bug in ([#57](https://github.com/akexorcist/Android-RoundCornerProgressBar/issues/57)) ([#77](https://github.com/akexorcist/Android-RoundCornerProgressBar/issues/77)) 28 | 29 | 2.1.0 30 | ---- 31 | * `CenteredRoundCornerProgressBar` added ([#42](https://github.com/akexorcist/Android-RoundCornerProgressBar/issues/42)) 32 | * `IndeterminateRoundCornerProgressBar` and `IndeterminateCenteredRoundCornerProgressBar` added 33 | * `IconRoundCornerProgressBar` now support for `Bitmap` and `Drawable` for icon 34 | * Animation for progress update (disable by default) added. This feature applied to all progress bars 35 | * Gradient progress color support (both primary and secondary progress) added. This feature applied to all progress bars (([#39](https://github.com/akexorcist/Android-RoundCornerProgressBar/issues/39))) 36 | * Text gravity when inside/outside and text position priority attribute in `TextRoundCornerProgressBar` added 37 | * Integer value support for progress setter (convert to float inside) added 38 | * Update to Gradle Plugin 3.6.3 and Gradle 5.6.4 39 | * Migrate from Android Support to AndroidX 40 | * Still in Java! (will be Kotlin in next version) 41 | * Fix bug in ([#43](https://github.com/akexorcist/Android-RoundCornerProgressBar/issues/43)) ([#20](https://github.com/akexorcist/Android-RoundCornerProgressBar/issues/20)) ([#74](https://github.com/akexorcist/Android-RoundCornerProgressBar/issues/74)) 42 | * Moved from MavenCentral to JCenter. Please see "Installation" section for new artifact ID 43 | * All new sample code. You should try it! 44 | * Add useful annotations for Kotlin 45 | 46 | 2.0.X 47 | ---- 48 | * New code structure for further development 49 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright 2023 Akexorcist 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. -------------------------------------------------------------------------------- /MIGRATION.md: -------------------------------------------------------------------------------- 1 | # Migration 2 | 3 | ## Migrate from 2.0 to 2.1+ 4 | 5 | ### BaseRoundCornerProgressBar.OnProgressChangedListener 6 | 7 | Change the view ID parameter in `onProgressChanged` to View class 8 | 9 | ```kotlin 10 | // Old 11 | fun onProgressChanged( 12 | viewId: Int, 13 | progress: Float, 14 | isPrimaryProgress: Boolean, 15 | isSecondaryProgress: Boolean 16 | ) 17 | 18 | // New 19 | fun onProgressChanged( 20 | view: View, 21 | progress: Float, 22 | isPrimaryProgress: Boolean, 23 | isSecondaryProgress: Boolean 24 | ) 25 | ``` 26 | 27 | ### Custom your own progress bar by extends BaseRoundCornerProgressBar 28 | 29 | Use AnimatedRoundCornerProgressBar instead of BaseRoundCornerProgressBar for progress change animation support. 30 | 31 | ```Kotlin 32 | class CustomRoundCornerProgressBar: AnimatedRoundCornerProgressBar() { 33 | /* ... */ 34 | } 35 | ``` 36 | 37 | And you do not have to create the `GradientDrawable` by yourself anymore. `drawProgress` will send it as parameter. 38 | 39 | ```kotlin 40 | // Old 41 | fun drawProgress( 42 | layoutProgress: LinearLayout, 43 | max: Float, 44 | progress: Float, 45 | totalWidth: Float, 46 | radius: Int, 47 | padding: Int, 48 | progressColor: Int, 49 | isReverse: Boolean 50 | ) 51 | 52 | // New 53 | fun drawProgress( 54 | layoutProgress: LinearLayout, 55 | progressDrawable: GradientDrawable, 56 | max: Float, 57 | progress: Float, 58 | totalWidth: Float, 59 | radius: Int, 60 | padding: Int, 61 | isReverse: Boolean 62 | ) 63 | ``` -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.android.application' 3 | id 'org.jetbrains.kotlin.android' 4 | id 'kotlin-parcelize' 5 | } 6 | 7 | android { 8 | namespace 'com.akexorcist.roundcornerprogressbar.example' 9 | compileSdk project.compileSdkVersion 10 | 11 | defaultConfig { 12 | applicationId "com.akexorcist.roundcornerprogressbar" 13 | minSdkVersion project.minSdkVersion 14 | targetSdkVersion project.targetSdkVersion 15 | versionCode project.versionCode 16 | versionName project.versionName 17 | } 18 | 19 | buildTypes { 20 | release { 21 | minifyEnabled true 22 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 23 | } 24 | } 25 | 26 | compileOptions { 27 | sourceCompatibility JavaVersion.VERSION_17 28 | targetCompatibility JavaVersion.VERSION_17 29 | } 30 | 31 | kotlinOptions { 32 | jvmTarget = '17' 33 | } 34 | 35 | buildFeatures { 36 | viewBinding = true 37 | } 38 | } 39 | 40 | dependencies { 41 | implementation 'androidx.appcompat:appcompat:1.6.1' 42 | implementation 'com.google.android.material:material:1.10.0' 43 | implementation 'androidx.constraintlayout:constraintlayout:2.1.4' 44 | testImplementation 'junit:junit:4.13.2' 45 | implementation project(':round-corner-progress-bar') 46 | // implementation "com.akexorcist:round-corner-progress-bar:${project.versionName}" 47 | } 48 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Applications/ADT/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /app/src/main/ic_launcher-playstore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akexorcist/RoundCornerProgressBar/1c5823c91fd9572a081b4e625cc73b0e3475955c/app/src/main/ic_launcher-playstore.png -------------------------------------------------------------------------------- /app/src/main/java/com/akexorcist/roundcornerprogressbar/example/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.akexorcist.roundcornerprogressbar.example 2 | 3 | import android.os.Bundle 4 | import androidx.appcompat.app.AppCompatActivity 5 | import com.akexorcist.roundcornerprogressbar.example.databinding.ActivityMainBinding 6 | import com.google.android.material.tabs.TabLayoutMediator 7 | 8 | class MainActivity : AppCompatActivity() { 9 | private val binding: ActivityMainBinding by lazy { ActivityMainBinding.inflate(layoutInflater) } 10 | 11 | override fun onCreate(savedInstanceState: Bundle?) { 12 | super.onCreate(savedInstanceState) 13 | setContentView(binding.root) 14 | 15 | val adapter = ViewPagerAdapter(this) 16 | binding.viewPager.adapter = adapter 17 | TabLayoutMediator(binding.tabLayout, binding.viewPager) { tab, position -> 18 | tab.text = getString( 19 | when (position) { 20 | 0 -> R.string.tab_round_corner_progress_bar 21 | 1 -> R.string.tab_centered_round_corner_progress_bar 22 | 2 -> R.string.tab_icon_round_corner_progress_bar 23 | 3 -> R.string.tab_text_round_corner_progress_bar 24 | 4 -> R.string.tab_indeterminate_round_corner_progress_bar 25 | else -> R.string.blank 26 | } 27 | ) 28 | }.attach() 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /app/src/main/java/com/akexorcist/roundcornerprogressbar/example/ViewPagerAdapter.kt: -------------------------------------------------------------------------------- 1 | package com.akexorcist.roundcornerprogressbar.example 2 | 3 | import androidx.fragment.app.Fragment 4 | import androidx.fragment.app.FragmentActivity 5 | import androidx.viewpager2.adapter.FragmentStateAdapter 6 | import com.akexorcist.roundcornerprogressbar.example.fragment.* 7 | 8 | class ViewPagerAdapter(activity: FragmentActivity) : FragmentStateAdapter(activity) { 9 | override fun getItemCount(): Int = 5 10 | 11 | override fun createFragment(position: Int): Fragment = when (position) { 12 | 0 -> SimpleDemoFragment.newInstance() 13 | 1 -> CenteredDemoFragment.newInstance() 14 | 2 -> IconDemoFragment.newInstance() 15 | 3 -> TextDemoFragment.newInstance() 16 | 4 -> IndeterminateDemoFragment.newInstance() 17 | else -> SimpleDemoFragment.newInstance() 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /app/src/main/java/com/akexorcist/roundcornerprogressbar/example/fragment/CenteredDemoFragment.kt: -------------------------------------------------------------------------------- 1 | package com.akexorcist.roundcornerprogressbar.example.fragment 2 | 3 | import android.os.Bundle 4 | import android.view.LayoutInflater 5 | import android.view.View 6 | import android.view.ViewGroup 7 | import androidx.fragment.app.Fragment 8 | import com.akexorcist.roundcornerprogressbar.example.R 9 | import com.akexorcist.roundcornerprogressbar.example.databinding.FragmentCenteredDemoBinding 10 | 11 | class 12 | CenteredDemoFragment : Fragment() { 13 | private lateinit var binding: FragmentCenteredDemoBinding 14 | 15 | companion object { 16 | fun newInstance(): Fragment = CenteredDemoFragment() 17 | } 18 | 19 | override fun onCreateView( 20 | inflater: LayoutInflater, 21 | container: ViewGroup?, 22 | savedInstanceState: Bundle? 23 | ): View { 24 | binding = FragmentCenteredDemoBinding.inflate(layoutInflater, container, false) 25 | return binding.root 26 | } 27 | 28 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) { 29 | super.onViewCreated(view, savedInstanceState) 30 | with(binding) { 31 | textViewCentered1.text = getCentered1Description() 32 | textViewCentered2.text = getCentered2Description() 33 | textViewCentered3.text = getCentered3Description() 34 | textViewCentered4.text = getCentered4Description() 35 | textViewCentered5.text = getCentered5Description() 36 | buttonCenteredCustomIncrease.setOnClickListener { increaseCustomProgress() } 37 | buttonCenteredCustomExtraIncrease.setOnClickListener { extraIncreaseCustomProgress() } 38 | buttonCenteredCustomDecrease.setOnClickListener { decreaseCustomProgress() } 39 | buttonCenteredCustomExtraDecrease.setOnClickListener { extraDecreaseCustomProgress() } 40 | checkBoxAnimationEnable.setOnCheckedChangeListener { _, isChecked -> 41 | onAnimationEnableCheckedChange( 42 | isChecked 43 | ) 44 | } 45 | checkBoxGradientProgressColor.setOnCheckedChangeListener { _, isChecked -> 46 | onApplyGradientProgressColorCheckedChange( 47 | isChecked 48 | ) 49 | } 50 | progressBarCenteredCustom.setOnProgressChangedListener { _, _, isPrimaryProgress, _ -> 51 | if (isPrimaryProgress) { 52 | updateCustomProgressText() 53 | } 54 | } 55 | } 56 | updateCustomProgressText() 57 | } 58 | 59 | private fun onAnimationEnableCheckedChange(isChecked: Boolean) { 60 | with(binding) { 61 | if (isChecked) { 62 | progressBarCenteredCustom.enableAnimation() 63 | } else { 64 | progressBarCenteredCustom.disableAnimation() 65 | } 66 | } 67 | } 68 | 69 | private fun onApplyGradientProgressColorCheckedChange(isChecked: Boolean) { 70 | with(binding) { 71 | if (isChecked) { 72 | progressBarCenteredCustom.setProgressColors(resources.getIntArray(R.array.sample_progress_gradient)) 73 | } else { 74 | @Suppress("DEPRECATION") 75 | progressBarCenteredCustom.setProgress(resources.getColor(R.color.sample_progress_primary)) 76 | } 77 | } 78 | } 79 | 80 | private fun increaseCustomProgress() { 81 | with(binding) { 82 | progressBarCenteredCustom.setProgress(progressBarCenteredCustom.getProgress() + 2) 83 | } 84 | updateCustomSecondaryProgress() 85 | } 86 | 87 | private fun extraIncreaseCustomProgress() { 88 | with(binding) { 89 | progressBarCenteredCustom.setProgress(progressBarCenteredCustom.getProgress() + 20) 90 | } 91 | updateCustomSecondaryProgress() 92 | } 93 | 94 | private fun decreaseCustomProgress() { 95 | with(binding) { 96 | progressBarCenteredCustom.setProgress(progressBarCenteredCustom.getProgress() - 2) 97 | } 98 | updateCustomSecondaryProgress() 99 | } 100 | 101 | private fun extraDecreaseCustomProgress() { 102 | with(binding) { 103 | progressBarCenteredCustom.setProgress(progressBarCenteredCustom.getProgress() - 20) 104 | } 105 | updateCustomSecondaryProgress() 106 | } 107 | 108 | private fun updateCustomSecondaryProgress() { 109 | with(binding) { 110 | progressBarCenteredCustom.setSecondaryProgress(progressBarCenteredCustom.getProgress() + 10) 111 | } 112 | } 113 | 114 | private fun updateCustomProgressText() { 115 | with(binding) { 116 | textViewCenteredCustom.text = "${progressBarCenteredCustom.getProgress()}" 117 | } 118 | } 119 | 120 | private fun getCentered1Description() = """ 121 | |Max : 100 122 | |Progress : 50 123 | |Radius : 0dp 124 | |Padding : 4dp 125 | |Width : 260dp 126 | |Height : 30dp 127 | """.trimMargin() 128 | 129 | private fun getCentered2Description() = """ 130 | |Max : 100 131 | |Progress : 40 132 | |SecondaryProgress : 60 133 | |Radius : 10dp 134 | |Radius : 10dp 135 | |Padding : 2dp 136 | |Width : 260dp 137 | |Height : 30dp 138 | """.trimMargin() 139 | 140 | private fun getCentered3Description() = """ 141 | |Max : 100 142 | |Progress : 20 143 | |SecondaryProgress : 75 144 | |Radius : 80dp 145 | |Padding : 2dp 146 | |Reverse : True 147 | |Width : 260dp 148 | |Height : 30dp 149 | """.trimMargin() 150 | 151 | private fun getCentered4Description() = """ 152 | |Max : 100 153 | |Progress : 80 154 | |Radius : 20dp 155 | |Padding : 2dp 156 | |Width : 260dp 157 | |Height : 20dp 158 | """.trimMargin() 159 | 160 | private fun getCentered5Description() = """ 161 | |Max : 200 162 | |Progress : 20 163 | |Radius : 20dp 164 | |Padding : 10dp 165 | |Width : 260dp 166 | |Height : 50dp 167 | """.trimMargin() 168 | } 169 | -------------------------------------------------------------------------------- /app/src/main/java/com/akexorcist/roundcornerprogressbar/example/fragment/IconDemoFragment.kt: -------------------------------------------------------------------------------- 1 | package com.akexorcist.roundcornerprogressbar.example.fragment 2 | 3 | import android.os.Bundle 4 | import android.view.LayoutInflater 5 | import android.view.View 6 | import android.view.ViewGroup 7 | import androidx.fragment.app.Fragment 8 | import com.akexorcist.roundcornerprogressbar.example.R 9 | import com.akexorcist.roundcornerprogressbar.example.databinding.FragmentIconDemoBinding 10 | 11 | class IconDemoFragment : Fragment() { 12 | private lateinit var binding: FragmentIconDemoBinding 13 | 14 | companion object { 15 | fun newInstance(): Fragment = IconDemoFragment() 16 | } 17 | 18 | override fun onCreateView( 19 | inflater: LayoutInflater, 20 | container: ViewGroup?, 21 | savedInstanceState: Bundle? 22 | ): View { 23 | binding = FragmentIconDemoBinding.inflate(layoutInflater, container, false) 24 | return binding.root 25 | } 26 | 27 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) { 28 | super.onViewCreated(view, savedInstanceState) 29 | with(binding) { 30 | textViewIcon1.text = getIcon1Description() 31 | textViewIcon2.text = getIcon2Description() 32 | textViewIcon3.text = getIcon3Description() 33 | textViewIcon4.text = getIcon4Description() 34 | textViewIcon5.text = getIcon5Description() 35 | textViewIcon6.text = getIcon6Description() 36 | textViewIcon7.text = getIcon7Description() 37 | buttonIconCustomIncrease.setOnClickListener { increaseCustomProgress() } 38 | buttonIconCustomExtraIncrease.setOnClickListener { extraIncreaseCustomProgress() } 39 | buttonIconCustomDecrease.setOnClickListener { decreaseCustomProgress() } 40 | buttonIconCustomExtraDecrease.setOnClickListener { extraDecreaseCustomProgress() } 41 | checkBoxAnimationEnable.setOnCheckedChangeListener { _, isChecked -> 42 | onAnimationEnableCheckdChange( 43 | isChecked 44 | ) 45 | } 46 | checkBoxGradientProgressColor.setOnCheckedChangeListener { _, isChecked -> 47 | onApplyGradientProgressColorCheckedChange( 48 | isChecked 49 | ) 50 | } 51 | progressBarIconCustom.setOnProgressChangedListener { _, _, isPrimaryProgress, _ -> 52 | if (isPrimaryProgress) { 53 | updateCustomProgressText() 54 | } 55 | } 56 | } 57 | updateCustomProgressText() 58 | } 59 | 60 | private fun onAnimationEnableCheckdChange(isChecked: Boolean) { 61 | with(binding) { 62 | if (isChecked) { 63 | progressBarIconCustom.enableAnimation() 64 | } else { 65 | progressBarIconCustom.disableAnimation() 66 | } 67 | } 68 | } 69 | 70 | private fun onApplyGradientProgressColorCheckedChange(isChecked: Boolean) { 71 | with(binding) { 72 | if (isChecked) { 73 | progressBarIconCustom.setProgressColors(resources.getIntArray(R.array.sample_progress_gradient)) 74 | } else { 75 | @Suppress("DEPRECATION") 76 | progressBarIconCustom.setProgressColor(resources.getColor(R.color.sample_progress_primary)) 77 | } 78 | } 79 | } 80 | 81 | private fun increaseCustomProgress() { 82 | with(binding) { 83 | progressBarIconCustom.setProgress(progressBarIconCustom.getProgress() + 2) 84 | } 85 | updateCustomSecondaryProgress() 86 | } 87 | 88 | private fun extraIncreaseCustomProgress() { 89 | with(binding) { 90 | progressBarIconCustom.setProgress(progressBarIconCustom.getProgress() + 20) 91 | } 92 | updateCustomSecondaryProgress() 93 | } 94 | 95 | private fun decreaseCustomProgress() { 96 | with(binding) { 97 | progressBarIconCustom.setProgress(progressBarIconCustom.getProgress() - 2) 98 | } 99 | updateCustomSecondaryProgress() 100 | } 101 | 102 | private fun extraDecreaseCustomProgress() { 103 | with(binding) { 104 | progressBarIconCustom.setProgress(progressBarIconCustom.getProgress() - 20) 105 | } 106 | updateCustomSecondaryProgress() 107 | } 108 | 109 | private fun updateCustomSecondaryProgress() { 110 | with(binding) { 111 | progressBarIconCustom.setSecondaryProgress(progressBarIconCustom.getProgress() + 30) 112 | } 113 | } 114 | 115 | private fun updateCustomProgressText() { 116 | with(binding) { 117 | textViewIconCustom.text = "${progressBarIconCustom.getProgress()}" 118 | } 119 | } 120 | 121 | private fun getIcon1Description() = """ 122 | |Max : 150 123 | |Progress : 90 124 | |Icon Size : 40dp 125 | |Icon Padding : 5dp 126 | |Radius : 5dp 127 | |Background Padding : 2dp 128 | |Width : 260dp 129 | |Height : Wrap Content 130 | """.trimMargin() 131 | 132 | private fun getIcon2Description() = """ 133 | |Max : 150 134 | |Progress : 90 135 | |Icon Size : 40dp 136 | |Icon Padding : 5dp 137 | |Radius : 5dp 138 | |Background Padding : 2dp 139 | |Reverse : True 140 | |Width : 260dp 141 | |Height : Wrap Content 142 | """.trimMargin() 143 | 144 | private fun getIcon3Description() = """ 145 | |Max : 150 146 | |Progress : 50 147 | |Secondary Progress : 80 148 | |Icon Size : 25dp 149 | |Icon Padding : 5dp 150 | |Radius : 5dp 151 | |Background Padding : 5dp 152 | |Reverse : True 153 | |Width : 260dp 154 | |Height : Wrap Content 155 | """.trimMargin() 156 | 157 | private fun getIcon4Description() = """ 158 | |Max : 150 159 | |Progress : 40 160 | |Icon Size : 70dp 161 | |Icon Padding : 5dp 162 | |Radius : 5dp 163 | |Background Padding : 10dp 164 | |Width : 260dp 165 | |Height : Wrap Content 166 | """.trimMargin() 167 | 168 | private fun getIcon5Description() = """ 169 | |Max : 150 170 | |Progress : 150 171 | |Icon Size : 30dp 172 | |Icon Padding : 3dp 173 | |Radius : 5dp 174 | |Background Padding : 5dp 175 | |Width : 260dp 176 | |Height : Wrap Content 177 | """.trimMargin() 178 | 179 | private fun getIcon6Description() = """ 180 | |Max : 150 181 | |Progress : 5 182 | |Icon Size : 50dp 183 | |Icon Padding : 3dp 184 | |Radius : 20dp 185 | |Background Padding : 10dp 186 | |Width : 260dp 187 | |Height : Wrap Content 188 | """.trimMargin() 189 | 190 | private fun getIcon7Description() = """ 191 | |No Icon Image 192 | |Max : 150 193 | |Progress : 100 194 | |Icon Size : 20dp 195 | |Icon Padding : 10dp 196 | |Radius : 30dp 197 | |Background Padding : 5dp 198 | |Width : 260dp 199 | |Height : Wrap Content 200 | """.trimMargin() 201 | } 202 | -------------------------------------------------------------------------------- /app/src/main/java/com/akexorcist/roundcornerprogressbar/example/fragment/IndeterminateDemoFragment.kt: -------------------------------------------------------------------------------- 1 | package com.akexorcist.roundcornerprogressbar.example.fragment 2 | 3 | import android.os.Bundle 4 | import android.view.LayoutInflater 5 | import android.view.View 6 | import android.view.ViewGroup 7 | import androidx.fragment.app.Fragment 8 | import com.akexorcist.roundcornerprogressbar.example.databinding.FragmentIndeterminateDemoBinding 9 | 10 | class IndeterminateDemoFragment : Fragment() { 11 | private lateinit var binding: FragmentIndeterminateDemoBinding 12 | 13 | companion object { 14 | fun newInstance(): Fragment = IndeterminateDemoFragment() 15 | } 16 | 17 | override fun onCreateView( 18 | inflater: LayoutInflater, 19 | container: ViewGroup?, 20 | savedInstanceState: Bundle? 21 | ): View { 22 | binding = FragmentIndeterminateDemoBinding.inflate(layoutInflater, container, false) 23 | return binding.root 24 | } 25 | 26 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) { 27 | super.onViewCreated(view, savedInstanceState) 28 | with(binding) { 29 | textViewIndeterminate1.text = getIndeterminate1Description() 30 | textViewIndeterminate2.text = getIndeterminate2Description() 31 | textViewIndeterminate3.text = getIndeterminate3Description() 32 | textViewIndeterminate4.text = getIndeterminate4Description() 33 | } 34 | } 35 | 36 | private fun getIndeterminate1Description() = """ 37 | |Animation Speed Scale : x1 38 | """.trimMargin() 39 | 40 | private fun getIndeterminate2Description() = """ 41 | |Animation Speed Scale : x3 42 | """.trimMargin() 43 | 44 | private fun getIndeterminate3Description() = """ 45 | |Animation Speed Scale : x0.5 46 | """.trimMargin() 47 | 48 | private fun getIndeterminate4Description() = """ 49 | |Animation Speed Scale : x1 50 | """.trimMargin() 51 | } 52 | -------------------------------------------------------------------------------- /app/src/main/java/com/akexorcist/roundcornerprogressbar/example/fragment/SimpleDemoFragment.kt: -------------------------------------------------------------------------------- 1 | package com.akexorcist.roundcornerprogressbar.example.fragment 2 | 3 | import android.os.Bundle 4 | import android.view.LayoutInflater 5 | import android.view.View 6 | import android.view.ViewGroup 7 | import androidx.fragment.app.Fragment 8 | import com.akexorcist.roundcornerprogressbar.example.R 9 | import com.akexorcist.roundcornerprogressbar.example.databinding.FragmentSimpleDemoBinding 10 | 11 | class SimpleDemoFragment : Fragment() { 12 | private lateinit var binding: FragmentSimpleDemoBinding 13 | 14 | companion object { 15 | fun newInstance(): Fragment = SimpleDemoFragment() 16 | } 17 | 18 | override fun onCreateView( 19 | inflater: LayoutInflater, 20 | container: ViewGroup?, 21 | savedInstanceState: Bundle? 22 | ): View { 23 | binding = FragmentSimpleDemoBinding.inflate(layoutInflater, container, false) 24 | return binding.root 25 | } 26 | 27 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) { 28 | super.onViewCreated(view, savedInstanceState) 29 | with(binding) { 30 | textViewSimple1.text = getSimple1Description() 31 | textViewSimple2.text = getSimple2Description() 32 | textViewSimple3.text = getSimple3Description() 33 | textViewSimple4.text = getSimple4Description() 34 | textViewSimple5.text = getSimple5Description() 35 | buttonSimpleCustomIncrease.setOnClickListener { increaseCustomProgress() } 36 | buttonSimpleCustomExtraIncrease.setOnClickListener { extraIncreaseCustomProgress() } 37 | buttonSimpleCustomDecrease.setOnClickListener { decreaseCustomProgress() } 38 | buttonSimpleCustomExtraDecrease.setOnClickListener { extraDecreaseCustomProgress() } 39 | checkBoxAnimationEnable.setOnCheckedChangeListener { _, isChecked -> 40 | onAnimationEnableCheckedChange( 41 | isChecked 42 | ) 43 | } 44 | checkBoxGradientProgressColor.setOnCheckedChangeListener { _, isChecked -> 45 | onApplyGradientProgressColorCheckedChange( 46 | isChecked 47 | ) 48 | } 49 | progressBarSimpleCustom.setOnProgressChangedListener { _, _, isPrimaryProgress, _ -> 50 | if (isPrimaryProgress) { 51 | updateCustomProgressText() 52 | } 53 | } 54 | } 55 | updateCustomProgressText() 56 | } 57 | 58 | private fun onAnimationEnableCheckedChange(isChecked: Boolean) { 59 | with(binding) { 60 | if (isChecked) { 61 | progressBarSimpleCustom.enableAnimation() 62 | } else { 63 | progressBarSimpleCustom.disableAnimation() 64 | } 65 | } 66 | } 67 | 68 | private fun onApplyGradientProgressColorCheckedChange(isChecked: Boolean) { 69 | with(binding) { 70 | if (isChecked) { 71 | progressBarSimpleCustom.setProgressColors(resources.getIntArray(R.array.sample_progress_gradient)) 72 | } else { 73 | @Suppress("DEPRECATION") 74 | progressBarSimpleCustom.setProgressColor(resources.getColor(R.color.sample_progress_primary)) 75 | } 76 | } 77 | } 78 | 79 | private fun increaseCustomProgress() { 80 | with(binding) { 81 | progressBarSimpleCustom.setProgress(progressBarSimpleCustom.getProgress() + 2) 82 | } 83 | updateCustomSecondaryProgress() 84 | } 85 | 86 | private fun extraIncreaseCustomProgress() { 87 | with(binding) { 88 | progressBarSimpleCustom.setProgress(progressBarSimpleCustom.getProgress() + 20) 89 | } 90 | updateCustomSecondaryProgress() 91 | } 92 | 93 | private fun decreaseCustomProgress() { 94 | with(binding) { 95 | progressBarSimpleCustom.setProgress(progressBarSimpleCustom.getProgress() - 2) 96 | } 97 | updateCustomSecondaryProgress() 98 | } 99 | 100 | private fun extraDecreaseCustomProgress() { 101 | with(binding) { 102 | progressBarSimpleCustom.setProgress(progressBarSimpleCustom.getProgress() - 20) 103 | } 104 | updateCustomSecondaryProgress() 105 | } 106 | 107 | private fun updateCustomSecondaryProgress() { 108 | with(binding) { 109 | progressBarSimpleCustom.setSecondaryProgress(progressBarSimpleCustom.getProgress() + 10) 110 | } 111 | } 112 | 113 | private fun updateCustomProgressText() { 114 | with(binding) { 115 | textViewSimpleCustom.text = "${progressBarSimpleCustom.getProgress()}" 116 | } 117 | } 118 | 119 | private fun getSimple1Description() = """ 120 | |Max : 100 121 | |Progress : 50 122 | |Radius : 0dp 123 | |Padding : 4dp 124 | |Width : 260dp 125 | |Height : 30dp 126 | """.trimMargin() 127 | 128 | private fun getSimple2Description() = """ 129 | |Max : 100 130 | |Progress : 40 131 | |SecondaryProgress : 60 132 | |Radius : 10dp 133 | |Padding : 2dp 134 | |Width : 260dp 135 | |Height : 30dp 136 | """.trimMargin() 137 | 138 | private fun getSimple3Description() = """ 139 | |Max : 100 140 | |Progress : 20 141 | |SecondaryProgress : 75 142 | |Radius : 80dp 143 | |Padding : 2dp 144 | |Reverse : True 145 | |Width : 260dp 146 | |Height : 30dp 147 | """.trimMargin() 148 | 149 | private fun getSimple4Description() = """ 150 | |Max : 100 151 | |Progress : 80 152 | |Radius : 20dp 153 | |Padding : 2dp 154 | |Width : 260dp 155 | |Height : 20dp 156 | """.trimMargin() 157 | 158 | private fun getSimple5Description() = """ 159 | |Max : 200 160 | |Progress : 20 161 | |Radius : 20dp 162 | |Padding : 10dp 163 | |Width : 260dp 164 | |Height : 50dp 165 | """.trimMargin() 166 | } 167 | -------------------------------------------------------------------------------- /app/src/main/java/com/akexorcist/roundcornerprogressbar/example/fragment/TextDemoFragment.kt: -------------------------------------------------------------------------------- 1 | package com.akexorcist.roundcornerprogressbar.example.fragment 2 | 3 | import android.os.Bundle 4 | import android.view.LayoutInflater 5 | import android.view.View 6 | import android.view.ViewGroup 7 | import androidx.fragment.app.Fragment 8 | import com.akexorcist.roundcornerprogressbar.TextRoundCornerProgressBar 9 | import com.akexorcist.roundcornerprogressbar.example.databinding.FragmentTextDemoBinding 10 | 11 | class TextDemoFragment : Fragment() { 12 | private lateinit var binding: FragmentTextDemoBinding 13 | 14 | companion object { 15 | fun newInstance(): Fragment = TextDemoFragment() 16 | } 17 | 18 | override fun onCreateView( 19 | inflater: LayoutInflater, 20 | container: ViewGroup?, 21 | savedInstanceState: Bundle? 22 | ): View { 23 | binding = FragmentTextDemoBinding.inflate(layoutInflater, container, false) 24 | return binding.root 25 | } 26 | 27 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) { 28 | super.onViewCreated(view, savedInstanceState) 29 | with(binding) { 30 | textViewText1.text = getText1Description() 31 | textViewText2.text = getText2Description() 32 | textViewText3.text = getText3Description() 33 | textViewText4.text = getText4Description() 34 | textViewText5.text = getText5Description() 35 | buttonTextCustomIncrease.setOnClickListener { increaseCustomProgress() } 36 | buttonTextCustomExtraIncrease.setOnClickListener { extraIncreaseCustomProgress() } 37 | buttonTextCustomDecrease.setOnClickListener { decreaseCustomProgress() } 38 | buttonTextCustomExtraDecrease.setOnClickListener { extraDecreaseCustomProgress() } 39 | checkBoxAnimationEnable.setOnCheckedChangeListener { _, isChecked -> 40 | onAnimationEnableCheckdChange( 41 | isChecked 42 | ) 43 | } 44 | progressBarTextCustom.setOnProgressChangedListener { _, _, isPrimaryProgress, _ -> 45 | if (isPrimaryProgress) { 46 | updateCustomProgressText() 47 | } 48 | } 49 | radioButtonInsideGravityStart.setOnCheckedChangeListener { _, isChecked -> 50 | if (isChecked) { 51 | updateInsideTextGravityCustomProgress(TextRoundCornerProgressBar.GRAVITY_START) 52 | } 53 | } 54 | radioButtonInsideGravityEnd.setOnCheckedChangeListener { _, isChecked -> 55 | if (isChecked) { 56 | updateInsideTextGravityCustomProgress(TextRoundCornerProgressBar.GRAVITY_END) 57 | } 58 | } 59 | radioButtonOutsideGravityStart.setOnCheckedChangeListener { _, isChecked -> 60 | if (isChecked) { 61 | updateOutsideTextGravityCustomProgress(TextRoundCornerProgressBar.GRAVITY_START) 62 | } 63 | } 64 | radioButtonOutsideGravityEnd.setOnCheckedChangeListener { _, isChecked -> 65 | if (isChecked) { 66 | updateOutsideTextGravityCustomProgress(TextRoundCornerProgressBar.GRAVITY_END) 67 | } 68 | } 69 | radioButtonTextPositionPriorityInside.setOnCheckedChangeListener { _, isChecked -> 70 | if (isChecked) { 71 | updateTextPositionPriorityCustomProgress(TextRoundCornerProgressBar.PRIORITY_INSIDE) 72 | } 73 | } 74 | radioButtonTextPositionPriorityOutside.setOnCheckedChangeListener { _, isChecked -> 75 | if (isChecked) { 76 | updateTextPositionPriorityCustomProgress(TextRoundCornerProgressBar.PRIORITY_OUTSIDE) 77 | } 78 | } 79 | } 80 | updateCustomProgressText() 81 | } 82 | 83 | private fun onAnimationEnableCheckdChange(isChecked: Boolean) { 84 | with(binding) { 85 | if (isChecked) { 86 | progressBarTextCustom.enableAnimation() 87 | } else { 88 | progressBarTextCustom.disableAnimation() 89 | } 90 | } 91 | } 92 | 93 | private fun increaseCustomProgress() { 94 | with(binding) { 95 | progressBarTextCustom.setProgress(progressBarTextCustom.getProgress() + 2) 96 | } 97 | } 98 | 99 | private fun extraIncreaseCustomProgress() { 100 | with(binding) { 101 | progressBarTextCustom.setProgress(progressBarTextCustom.getProgress() + 20) 102 | } 103 | } 104 | 105 | private fun decreaseCustomProgress() { 106 | with(binding) { 107 | progressBarTextCustom.setProgress(progressBarTextCustom.getProgress() - 2) 108 | } 109 | } 110 | 111 | private fun extraDecreaseCustomProgress() { 112 | with(binding) { 113 | progressBarTextCustom.setProgress(progressBarTextCustom.getProgress() - 20) 114 | } 115 | } 116 | 117 | private fun updateInsideTextGravityCustomProgress(gravity: Int) { 118 | with(binding) { 119 | progressBarTextCustom.setTextInsideGravity(gravity) 120 | } 121 | } 122 | 123 | private fun updateOutsideTextGravityCustomProgress(gravity: Int) { 124 | with(binding) { 125 | progressBarTextCustom.setTextOutsideGravity(gravity) 126 | } 127 | } 128 | 129 | private fun updateTextPositionPriorityCustomProgress(priority: Int) { 130 | with(binding) { 131 | progressBarTextCustom.setTextPositionPriority(priority) 132 | } 133 | } 134 | 135 | private fun updateCustomProgressText() { 136 | with(binding) { 137 | progressBarTextCustom.setProgressText("${progressBarTextCustom.getProgress()}") 138 | } 139 | } 140 | 141 | private fun getText1Description() = """ 142 | |Max : 100 143 | |Progress : 50 144 | |Radius : 0dp 145 | |Padding : 4dp 146 | |Width : 260dp 147 | |Height : 30dp 148 | """.trimMargin() 149 | 150 | private fun getText2Description() = """ 151 | |Max : 100 152 | |Progress : 40 153 | |SecondaryProgress : 60 154 | |Radius : 10dp 155 | |Padding : 2dp 156 | |Text Inside Gravity : End 157 | |Width : 260dp 158 | |Height : 30dp 159 | """.trimMargin() 160 | 161 | private fun getText3Description() = """ 162 | |Max : 100 163 | |Progress : 20 164 | |SecondaryProgress : 75 165 | |Radius : 80dp 166 | |Padding : 2dp 167 | |Reverse : True 168 | |Text Position Priority : Outside 169 | |Width : 260dp 170 | |Height : 30dp 171 | """.trimMargin() 172 | 173 | private fun getText4Description() = """ 174 | |Max : 100 175 | |Progress : 80 176 | |Radius : 20dp 177 | |Padding : 2dp 178 | |Text Size : 12sp 179 | |Width : 260dp 180 | |Height : 20dp 181 | """.trimMargin() 182 | 183 | private fun getText5Description() = """ 184 | |Max : 200 185 | |Progress : 20 186 | |Radius : 20dp 187 | |Padding : 10dp 188 | |Width : 260dp 189 | |Height : 50dp 190 | """.trimMargin() 191 | } 192 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_android.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akexorcist/RoundCornerProgressBar/1c5823c91fd9572a081b4e625cc73b0e3475955c/app/src/main/res/drawable-hdpi/ic_android.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_clock.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akexorcist/RoundCornerProgressBar/1c5823c91fd9572a081b4e625cc73b0e3475955c/app/src/main/res/drawable-hdpi/ic_clock.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_download.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akexorcist/RoundCornerProgressBar/1c5823c91fd9572a081b4e625cc73b0e3475955c/app/src/main/res/drawable-hdpi/ic_download.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_television.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akexorcist/RoundCornerProgressBar/1c5823c91fd9572a081b4e625cc73b0e3475955c/app/src/main/res/drawable-hdpi/ic_television.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_android.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akexorcist/RoundCornerProgressBar/1c5823c91fd9572a081b4e625cc73b0e3475955c/app/src/main/res/drawable-mdpi/ic_android.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_clock.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akexorcist/RoundCornerProgressBar/1c5823c91fd9572a081b4e625cc73b0e3475955c/app/src/main/res/drawable-mdpi/ic_clock.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_download.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akexorcist/RoundCornerProgressBar/1c5823c91fd9572a081b4e625cc73b0e3475955c/app/src/main/res/drawable-mdpi/ic_download.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_television.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akexorcist/RoundCornerProgressBar/1c5823c91fd9572a081b4e625cc73b0e3475955c/app/src/main/res/drawable-mdpi/ic_television.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-night/shape_sample_card_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_android.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akexorcist/RoundCornerProgressBar/1c5823c91fd9572a081b4e625cc73b0e3475955c/app/src/main/res/drawable-xhdpi/ic_android.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_clock.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akexorcist/RoundCornerProgressBar/1c5823c91fd9572a081b4e625cc73b0e3475955c/app/src/main/res/drawable-xhdpi/ic_clock.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_download.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akexorcist/RoundCornerProgressBar/1c5823c91fd9572a081b4e625cc73b0e3475955c/app/src/main/res/drawable-xhdpi/ic_download.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_television.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akexorcist/RoundCornerProgressBar/1c5823c91fd9572a081b4e625cc73b0e3475955c/app/src/main/res/drawable-xhdpi/ic_television.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_android.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akexorcist/RoundCornerProgressBar/1c5823c91fd9572a081b4e625cc73b0e3475955c/app/src/main/res/drawable-xxhdpi/ic_android.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_clock.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akexorcist/RoundCornerProgressBar/1c5823c91fd9572a081b4e625cc73b0e3475955c/app/src/main/res/drawable-xxhdpi/ic_clock.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_download.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akexorcist/RoundCornerProgressBar/1c5823c91fd9572a081b4e625cc73b0e3475955c/app/src/main/res/drawable-xxhdpi/ic_download.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_television.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akexorcist/RoundCornerProgressBar/1c5823c91fd9572a081b4e625cc73b0e3475955c/app/src/main/res/drawable-xxhdpi/ic_television.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/shape_sample_card_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 17 | 18 | 21 | 22 | 25 | 26 | 29 | 30 | 33 | 34 | 37 | 38 | 39 | 40 | 48 | 49 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_centered_demo.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 15 | 16 | 24 | 25 | 30 | 31 | 43 | 44 | 50 | 51 |