├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── ir │ │ └── alirezaiyan │ │ └── levelprogressbar │ │ └── ExampleInstrumentedTest.kt │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── ir │ │ │ └── alirezaiyan │ │ │ └── levelprogressbar │ │ │ └── MainActivity.kt │ └── res │ │ ├── drawable │ │ ├── ic_launcher_background.xml │ │ └── ic_level.jpg │ │ ├── layout │ │ └── activity_main.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ ├── ic_launcher_foreground.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ ├── ic_launcher_foreground.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ ├── ic_launcher_foreground.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ ├── ic_launcher_foreground.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ ├── ic_launcher_foreground.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── ir │ └── alirezaiyan │ └── levelprogressbar │ └── ExampleUnitTest.kt ├── art └── preview.png ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── progressbar ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── ic_launcher-web.png │ ├── java │ └── ir │ │ └── alirezaiyan │ │ └── progressbar │ │ ├── LevelProgressBar.kt │ │ └── utils │ │ └── Ex.kt │ └── res │ ├── mipmap-anydpi-v26 │ ├── ic_launcher.xml │ └── ic_launcher_round.xml │ ├── mipmap-hdpi │ ├── ic_launcher.png │ ├── ic_launcher_foreground.png │ └── ic_launcher_round.png │ ├── mipmap-mdpi │ ├── ic_launcher.png │ ├── ic_launcher_foreground.png │ └── ic_launcher_round.png │ ├── mipmap-xhdpi │ ├── ic_launcher.png │ ├── ic_launcher_foreground.png │ └── ic_launcher_round.png │ ├── mipmap-xxhdpi │ ├── ic_launcher.png │ ├── ic_launcher_foreground.png │ └── ic_launcher_round.png │ ├── mipmap-xxxhdpi │ ├── ic_launcher.png │ ├── ic_launcher_foreground.png │ └── ic_launcher_round.png │ └── values │ ├── attrs.xml │ ├── ic_launcher_background.xml │ └── strings.xml └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | /local.properties 2 | .DS_Store 3 | /build 4 | /captures 5 | .externalNativeBuild 6 | .cxx 7 | 8 | # Built application files 9 | *.apk 10 | *.ap_ 11 | 12 | # Files for the ART/Dalvik VM 13 | *.dex 14 | 15 | # Java class files 16 | *.class 17 | 18 | # Generated files 19 | bin/ 20 | gen/ 21 | out/ 22 | 23 | # Gradle files 24 | .gradle/ 25 | build/ 26 | 27 | # Local configuration file (sdk path, etc) 28 | local.properties 29 | 30 | # Proguard folder generated by Eclipse 31 | proguard/ 32 | 33 | # Log Files 34 | *.log 35 | 36 | # Android Studio Navigation editor temp files 37 | .navigation/ 38 | 39 | # Android Studio captures folder 40 | captures/ 41 | 42 | # IntelliJ 43 | .idea/ 44 | *.iml 45 | .idea/workspace.xml 46 | .idea/tasks.xml 47 | .idea/gradle.xml 48 | .idea/assetWizardSettings.xml 49 | .idea/dictionaries 50 | .idea/libraries 51 | .idea/caches 52 | 53 | # Keystore files 54 | # Uncomment the following line if you do not want to check your keystore files in. 55 | #*.jks 56 | 57 | # External native build folder generated in Android Studio 2.2 and later 58 | .externalNativeBuild 59 | 60 | # Google Services (e.g. APIs or Firebase) 61 | google-services.json 62 | 63 | # Freeline 64 | freeline.py 65 | freeline/ 66 | freeline_project_description.json 67 | 68 | # fastlane 69 | fastlane/report.xml 70 | fastlane/Preview.html 71 | fastlane/screenshots 72 | fastlane/test_output 73 | fastlane/readme.md 74 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: android 2 | jdk: oraclejdk8 3 | sudo: false 4 | 5 | android: 6 | components: 7 | - tools 8 | - platform-tools 9 | - build-tools-28.0.3 10 | - android-23 11 | - android-28 12 | - extra-google-google_play_services 13 | - extra-google-m2repository 14 | - extra-android-m2repository 15 | - extra-android-support 16 | 17 | before_install: 18 | - chmod +x gradlew 19 | 20 | script: 21 | - ./gradlew build check 22 | 23 | before_cache: 24 | - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock 25 | - rm -fr $HOME/.gradle/caches/*/plugin-resolution/ 26 | cache: 27 | directories: 28 | - $HOME/.gradle/caches/ 29 | - $HOME/.gradle/wrapper/ 30 | - $HOME/.android/build-cache 31 | deploy: 32 | skip_cleanup: true 33 | provider: script 34 | script: ./gradlew generateMetadataFileForReleasePublication; ./gradlew generatePomFileForReleasePublication; ./gradlew bintrayUpload -DMP_TARGET=$MP_TARGET -Pbintray_user=$BINTRAY_USER -Pbintray_key=$BINTRAY_KEY 35 | on: 36 | tags: true -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # LevelProgressBar 2 | A Custom View With Circular Progress | **Segmented** & **Continuous** | 3 | 4 | [![Download](https://api.bintray.com/packages/rezaiyan/Android/levelprogressbar/images/download.svg)](https://bintray.com/rezaiyan/Android/levelprogressbar/_latestVersion) 5 | [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-LevelProgressBar-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/7831) 6 | [![Build Status](https://travis-ci.org/rezaiyan/LevelProgressBar.svg?branch=master)](https://travis-ci.org/rezaiyan/LevelProgressBar) 7 | [![License](https://img.shields.io/badge/License-Apache/2.0-blue.svg)](https://github.com/badoo/Reaktive/blob/master/LICENSE) 8 | 9 | 10 |

11 | 12 |

13 | 14 | ## Installation 15 | 16 | Add the dependency to your app build.gradle file: 17 | 18 | ``` 19 | implementation "io.github.rezaiyan:levelprogressbar:1.0.3" 20 | ``` 21 | 22 | ## Usage 23 | 24 | Add `LevelProgressBar`: 25 | 26 | ```xml 27 | 28 | 43 | 44 | 45 | 46 | ``` 47 | 48 | License 49 | -------- 50 | 51 | Copyright 2020 alirezaiyann@gmail.com 52 | 53 | Licensed under the Apache License, Version 2.0 (the "License"); 54 | you may not use this file except in compliance with the License. 55 | You may obtain a copy of the License at 56 | 57 | http://www.apache.org/licenses/LICENSE-2.0 58 | 59 | Unless required by applicable law or agreed to in writing, software 60 | distributed under the License is distributed on an "AS IS" BASIS, 61 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 62 | See the License for the specific language governing permissions and 63 | limitations under the License. 64 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | /.idea 3 | *.iml -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 alirezaiyann@gmail.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | apply plugin: 'com.android.application' 18 | apply plugin: 'kotlin-android' 19 | apply plugin: 'kotlin-android-extensions' 20 | 21 | android { 22 | compileSdkVersion 29 23 | buildToolsVersion "29.0.0" 24 | defaultConfig { 25 | applicationId "ir.alirezaiyan.levelprogressbar" 26 | minSdkVersion 14 27 | targetSdkVersion 29 28 | versionCode 1 29 | versionName "1.0" 30 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 31 | } 32 | buildTypes { 33 | release { 34 | minifyEnabled false 35 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 36 | } 37 | } 38 | } 39 | 40 | dependencies { 41 | implementation fileTree(dir: 'libs', include: ['*.jar']) 42 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 43 | implementation 'androidx.appcompat:appcompat:1.0.2' 44 | implementation 'androidx.core:core-ktx:1.0.2' 45 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3' 46 | testImplementation 'junit:junit:4.12' 47 | androidTestImplementation 'androidx.test.ext:junit:1.1.1' 48 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' 49 | implementation project(path: ':progressbar') 50 | } 51 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app/src/androidTest/java/ir/alirezaiyan/levelprogressbar/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 alirezaiyann@gmail.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package ir.alirezaiyan.levelprogressbar 18 | 19 | import androidx.test.platform.app.InstrumentationRegistry 20 | import androidx.test.ext.junit.runners.AndroidJUnit4 21 | 22 | import org.junit.Test 23 | import org.junit.runner.RunWith 24 | 25 | import org.junit.Assert.* 26 | 27 | /** 28 | * Instrumented test, which will execute on an Android device. 29 | * 30 | * See [testing documentation](http://d.android.com/tools/testing). 31 | */ 32 | @RunWith(AndroidJUnit4::class) 33 | class ExampleInstrumentedTest { 34 | @Test 35 | fun useAppContext() { 36 | // Context of the app under test. 37 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext 38 | assertEquals("ir.alirezaiyan.levelprogressbar", appContext.packageName) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 20 | 21 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /app/src/main/java/ir/alirezaiyan/levelprogressbar/MainActivity.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 alirezaiyann@gmail.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package ir.alirezaiyan.levelprogressbar 18 | 19 | import androidx.appcompat.app.AppCompatActivity 20 | import android.os.Bundle 21 | import kotlinx.android.synthetic.main.activity_main.* 22 | import android.widget.SeekBar 23 | 24 | 25 | class MainActivity : AppCompatActivity() { 26 | 27 | override fun onCreate(savedInstanceState: Bundle?) { 28 | super.onCreate(savedInstanceState) 29 | setContentView(R.layout.activity_main) 30 | 31 | 32 | p1IsEnable.setOnCheckedChangeListener { _, b -> p1.setEnable(b) } 33 | p1IsStepBar.setOnCheckedChangeListener { _, b -> p1.setIsStep(b) } 34 | 35 | p1LevelSeek.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener { 36 | override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) { 37 | 38 | if (fromUser) { 39 | p1.setProgressWithAnimation(progress.toFloat()) 40 | } else 41 | p1.setSpeed(progress.toFloat()) 42 | } 43 | 44 | override fun onStartTrackingTouch(seekBar: SeekBar) { 45 | //write custom code to on start progress 46 | } 47 | 48 | override fun onStopTrackingTouch(seekBar: SeekBar) { 49 | } 50 | }) 51 | 52 | p1LevelSeekStroke.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener { 53 | override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) { 54 | p1.strokeWidth = progress.toFloat() 55 | } 56 | 57 | override fun onStartTrackingTouch(seekBar: SeekBar) { 58 | //write custom code to on start progress 59 | } 60 | 61 | override fun onStopTrackingTouch(seekBar: SeekBar) { 62 | } 63 | }) 64 | 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 24 | 26 | 28 | 30 | 32 | 34 | 36 | 38 | 40 | 42 | 44 | 46 | 48 | 50 | 52 | 54 | 56 | 58 | 60 | 62 | 64 | 66 | 68 | 70 | 72 | 74 | 76 | 78 | 80 | 82 | 84 | 86 | 88 | 90 | 91 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_level.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rezaiyan/LevelProgressBar/b251868aa7d3fc5c1caa6b04fd763820ac374052/app/src/main/res/drawable/ic_level.jpg -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 24 | 25 | 29 | 30 | 31 | 46 | 47 | 48 | 55 | 56 | 64 | 65 | 73 | 74 | 83 | 84 | 91 | 92 | 93 | 102 | 103 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rezaiyan/LevelProgressBar/b251868aa7d3fc5c1caa6b04fd763820ac374052/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rezaiyan/LevelProgressBar/b251868aa7d3fc5c1caa6b04fd763820ac374052/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rezaiyan/LevelProgressBar/b251868aa7d3fc5c1caa6b04fd763820ac374052/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rezaiyan/LevelProgressBar/b251868aa7d3fc5c1caa6b04fd763820ac374052/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rezaiyan/LevelProgressBar/b251868aa7d3fc5c1caa6b04fd763820ac374052/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rezaiyan/LevelProgressBar/b251868aa7d3fc5c1caa6b04fd763820ac374052/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rezaiyan/LevelProgressBar/b251868aa7d3fc5c1caa6b04fd763820ac374052/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rezaiyan/LevelProgressBar/b251868aa7d3fc5c1caa6b04fd763820ac374052/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rezaiyan/LevelProgressBar/b251868aa7d3fc5c1caa6b04fd763820ac374052/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rezaiyan/LevelProgressBar/b251868aa7d3fc5c1caa6b04fd763820ac374052/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rezaiyan/LevelProgressBar/b251868aa7d3fc5c1caa6b04fd763820ac374052/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rezaiyan/LevelProgressBar/b251868aa7d3fc5c1caa6b04fd763820ac374052/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rezaiyan/LevelProgressBar/b251868aa7d3fc5c1caa6b04fd763820ac374052/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rezaiyan/LevelProgressBar/b251868aa7d3fc5c1caa6b04fd763820ac374052/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rezaiyan/LevelProgressBar/b251868aa7d3fc5c1caa6b04fd763820ac374052/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | #008577 20 | #00574B 21 | #D81B60 22 | #FAFAFA 23 | 24 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | LevelProgressBar 19 | 20 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 19 | 20 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /app/src/test/java/ir/alirezaiyan/levelprogressbar/ExampleUnitTest.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 alirezaiyann@gmail.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package ir.alirezaiyan.levelprogressbar 18 | 19 | import org.junit.Test 20 | 21 | import org.junit.Assert.* 22 | 23 | /** 24 | * Example local unit test, which will execute on the development machine (host). 25 | * 26 | * See [testing documentation](http://d.android.com/tools/testing). 27 | */ 28 | class ExampleUnitTest { 29 | @Test 30 | fun addition_isCorrect() { 31 | assertEquals(4, 2 + 2) 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /art/preview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rezaiyan/LevelProgressBar/b251868aa7d3fc5c1caa6b04fd763820ac374052/art/preview.png -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 alirezaiyann@gmail.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 18 | 19 | buildscript { 20 | ext.kotlin_version = '1.3.41' 21 | repositories { 22 | google() 23 | jcenter() 24 | } 25 | dependencies { 26 | classpath 'com.android.tools.build:gradle:3.5.0' 27 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 28 | classpath 'com.novoda:bintray-release:0.9.1' 29 | // NOTE: Do not place your application dependencies here; they belong 30 | // in the individual module build.gradle files 31 | } 32 | } 33 | 34 | allprojects { 35 | repositories { 36 | google() 37 | jcenter() 38 | } 39 | } 40 | 41 | task clean(type: Delete) { 42 | delete rootProject.buildDir 43 | } -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2016 alirezaiyann@gmail.com 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | # Project-wide Gradle settings. 18 | # IDE (e.g. Android Studio) users: 19 | # Gradle settings configured through the IDE *will override* 20 | # any settings specified in this file. 21 | # For more details on how to configure your build environment visit 22 | # http://www.gradle.org/docs/current/userguide/build_environment.html 23 | # Specifies the JVM arguments used for the daemon process. 24 | # The setting is particularly useful for tweaking memory settings. 25 | org.gradle.jvmargs=-Xmx1536m 26 | # When configured, Gradle will run in incubating parallel mode. 27 | # This option should only be used with decoupled projects. More details, visit 28 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 29 | # org.gradle.parallel=true 30 | # AndroidX package structure to make it clearer which packages are bundled with the 31 | # Android operating system, and which are packaged with your app's APK 32 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 33 | android.useAndroidX=true 34 | # Automatically convert third-party libraries to use AndroidX 35 | android.enableJetifier=true 36 | # Kotlin code style for this project: "official" or "obsolete": 37 | kotlin.code.style=official 38 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rezaiyan/LevelProgressBar/b251868aa7d3fc5c1caa6b04fd763820ac374052/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2016 alirezaiyann@gmail.com 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | #Mon Aug 26 09:47:49 IRDT 2019 18 | distributionBase=GRADLE_USER_HOME 19 | distributionPath=wrapper/dists 20 | zipStoreBase=GRADLE_USER_HOME 21 | zipStorePath=wrapper/dists 22 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip 23 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | yes | $ANDROID_HOME/tools/bin/sdkmanager "build-tools;29.0.0" 3 | 4 | ############################################################################## 5 | ## 6 | ## Gradle start up script for UN*X 7 | ## 8 | ############################################################################## 9 | 10 | # Attempt to set APP_HOME 11 | # Resolve links: $0 may be a link 12 | PRG="$0" 13 | # Need this for relative symlinks. 14 | while [ -h "$PRG" ] ; do 15 | ls=`ls -ld "$PRG"` 16 | link=`expr "$ls" : '.*-> \(.*\)$'` 17 | if expr "$link" : '/.*' > /dev/null; then 18 | PRG="$link" 19 | else 20 | PRG=`dirname "$PRG"`"/$link" 21 | fi 22 | done 23 | SAVED="`pwd`" 24 | cd "`dirname \"$PRG\"`/" >/dev/null 25 | APP_HOME="`pwd -P`" 26 | cd "$SAVED" >/dev/null 27 | 28 | APP_NAME="Gradle" 29 | APP_BASE_NAME=`basename "$0"` 30 | 31 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 32 | DEFAULT_JVM_OPTS="" 33 | 34 | # Use the maximum available, or set MAX_FD != -1 to use that value. 35 | MAX_FD="maximum" 36 | 37 | warn () { 38 | echo "$*" 39 | } 40 | 41 | die () { 42 | echo 43 | echo "$*" 44 | echo 45 | exit 1 46 | } 47 | 48 | # OS specific support (must be 'true' or 'false'). 49 | cygwin=false 50 | msys=false 51 | darwin=false 52 | nonstop=false 53 | case "`uname`" in 54 | CYGWIN* ) 55 | cygwin=true 56 | ;; 57 | Darwin* ) 58 | darwin=true 59 | ;; 60 | MINGW* ) 61 | msys=true 62 | ;; 63 | NONSTOP* ) 64 | nonstop=true 65 | ;; 66 | esac 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | JAVACMD=`cygpath --unix "$JAVACMD"` 118 | 119 | # We build the pattern for arguments to be converted via cygpath 120 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 121 | SEP="" 122 | for dir in $ROOTDIRSRAW ; do 123 | ROOTDIRS="$ROOTDIRS$SEP$dir" 124 | SEP="|" 125 | done 126 | OURCYGPATTERN="(^($ROOTDIRS))" 127 | # Add a user-defined pattern to the cygpath arguments 128 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 129 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 130 | fi 131 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 132 | i=0 133 | for arg in "$@" ; do 134 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 135 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 136 | 137 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 138 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 139 | else 140 | eval `echo args$i`="\"$arg\"" 141 | fi 142 | i=$((i+1)) 143 | done 144 | case $i in 145 | (0) set -- ;; 146 | (1) set -- "$args0" ;; 147 | (2) set -- "$args0" "$args1" ;; 148 | (3) set -- "$args0" "$args1" "$args2" ;; 149 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 150 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 151 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 152 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 153 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 154 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 155 | esac 156 | fi 157 | 158 | # Escape application args 159 | save () { 160 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 161 | echo " " 162 | } 163 | APP_ARGS=$(save "$@") 164 | 165 | # Collect all arguments for the java command, following the shell quoting and substitution rules 166 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 167 | 168 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 169 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 170 | cd "$(dirname "$0")" 171 | fi 172 | 173 | exec "$JAVACMD" "$@" 174 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /progressbar/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | /.idea 3 | *.iml -------------------------------------------------------------------------------- /progressbar/build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 alirezaiyann@gmail.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | apply plugin: 'com.android.library' 18 | apply plugin: 'kotlin-android' 19 | apply plugin: 'com.novoda.bintray-release' 20 | 21 | android { 22 | compileSdkVersion 29 23 | 24 | defaultConfig { 25 | minSdkVersion 14 26 | targetSdkVersion 29 27 | versionCode 3 28 | versionName "1.0.2" 29 | 30 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 31 | } 32 | 33 | buildTypes { 34 | release { 35 | minifyEnabled false 36 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 37 | } 38 | } 39 | lintOptions { 40 | checkReleaseBuilds false 41 | //If you want to continue even if errors found use following line 42 | abortOnError false 43 | } 44 | } 45 | 46 | dependencies { 47 | implementation fileTree(dir: 'libs', include: ['*.jar']) 48 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 49 | implementation 'androidx.appcompat:appcompat:1.0.2' 50 | } 51 | 52 | tasks.withType(Javadoc).all { 53 | enabled = false 54 | } 55 | 56 | publish { 57 | userOrg = "" 58 | repoName = "Android" 59 | groupId = 'ir.alirezaiyan' 60 | uploadName = 'levelprogressbar' 61 | artifactId = 'levelprogressbar' 62 | publishVersion = '1.0.2' 63 | desc = 'A Level ProgressBar view for Android' 64 | website = 'https://github.com/rezaiyan/LevelProgressBar' 65 | dryRun = false 66 | 67 | bintrayUser = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER') 68 | bintrayKey = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY') 69 | } 70 | -------------------------------------------------------------------------------- /progressbar/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /progressbar/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 19 | -------------------------------------------------------------------------------- /progressbar/src/main/ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rezaiyan/LevelProgressBar/b251868aa7d3fc5c1caa6b04fd763820ac374052/progressbar/src/main/ic_launcher-web.png -------------------------------------------------------------------------------- /progressbar/src/main/java/ir/alirezaiyan/progressbar/LevelProgressBar.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 alirezaiyann@gmail.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package ir.alirezaiyan.progressbar 18 | 19 | import android.animation.ObjectAnimator 20 | import android.content.Context 21 | import android.graphics.* 22 | import android.graphics.drawable.BitmapDrawable 23 | import android.graphics.drawable.Drawable 24 | import android.util.AttributeSet 25 | import android.view.View 26 | import android.view.animation.DecelerateInterpolator 27 | import androidx.core.content.ContextCompat 28 | import androidx.core.graphics.ColorUtils 29 | import ir.alirezaiyan.progressbar.utils.getBoundRectF 30 | import ir.alirezaiyan.progressbar.utils.getColor 31 | import kotlin.math.min 32 | 33 | 34 | /** 35 | * @author ali (alirezaiyann@gmail.com) 36 | * @since 8/25/19 10:29 PM. 37 | */ 38 | 39 | class LevelProgressBar @JvmOverloads constructor( 40 | context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0 41 | ) : View(context, attrs, defStyleAttr) { 42 | 43 | companion object { 44 | 45 | const val DEFAULT_SPEED = 1F 46 | const val DEFAULT_TEXT_TITLE = "Level" 47 | const val DEFAULT_START_ANGLE = 120 48 | const val DEFAULT_TOTAL_ANGLE = 300 49 | const val DEFAULT_STROKE_WiDTH = 10 50 | const val OPACITY = 100 51 | const val DEFAULT_MAX_PROGRESS = 100 52 | const val DEFAULT_TEXT_LEVEL_COLOR = Color.WHITE 53 | const val DEFAULT_TEXT_TITLE_COLOR = Color.BLACK 54 | const val DEFAULT_BACKGROUND_COLOR = Color.GREEN 55 | const val DEFAULT_UNPROGRESS_COLOR = Color.GRAY 56 | const val DEFAULT_IS_ENABLE = true 57 | const val DEFAULT_IS_STEP_PROGRESS = false 58 | 59 | } 60 | 61 | private var continuousSwipeAngle = 0f 62 | private var continuousStartAngle = 0f 63 | private var speed = DEFAULT_SPEED 64 | private var progress = 0 65 | private var angle = 0F 66 | private var textOffset = 0F 67 | 68 | private var textTitle: String? = DEFAULT_TEXT_TITLE 69 | 70 | private var textLevelColor = DEFAULT_TEXT_LEVEL_COLOR 71 | private var textTitleColor = DEFAULT_TEXT_TITLE_COLOR 72 | private var progressColor = DEFAULT_BACKGROUND_COLOR 73 | private var unprogressColor = DEFAULT_UNPROGRESS_COLOR 74 | 75 | private var isEnable = DEFAULT_IS_ENABLE 76 | private var isStepProgress = DEFAULT_IS_STEP_PROGRESS 77 | 78 | private var mReady: Boolean = false 79 | private var mSetupPending: Boolean = false 80 | 81 | private lateinit var bitmapShader: BitmapShader 82 | private var bitmap: Bitmap? = null 83 | private val mShaderMatrix = Matrix() 84 | private var bitmapWidth: Int = 0 85 | private var bitmapHeight: Int = 0 86 | private val drawableRect = RectF() 87 | 88 | private var radius = 50 89 | var strokeWidth = DEFAULT_STROKE_WiDTH.toFloat() 90 | set(value) { 91 | if (value < radius / 3) 92 | field = value 93 | 94 | setup() 95 | invalidate() 96 | } 97 | 98 | private val borderRect = RectF() 99 | 100 | private var progressPaint = Paint() 101 | private var unProgressPaint = Paint() 102 | private var textLevelPaint = Paint() 103 | private var textTitlePaint = Paint() 104 | private val backgroundPaint = Paint() 105 | 106 | 107 | init { 108 | context.theme.obtainStyledAttributes( 109 | attrs, 110 | R.styleable.SpeedProgressBar, 111 | 0, 0 112 | ).apply { 113 | try { 114 | speed = getFloat( 115 | R.styleable.SpeedProgressBar_spb_level, 116 | DEFAULT_SPEED 117 | ) 118 | 119 | textTitle = getString(R.styleable.SpeedProgressBar_spb_text_title) 120 | 121 | isEnable = getBoolean( 122 | R.styleable.SpeedProgressBar_spb_is_enable, 123 | DEFAULT_IS_ENABLE 124 | ) 125 | 126 | isStepProgress = getBoolean( 127 | R.styleable.SpeedProgressBar_spb_is_step_progress, 128 | DEFAULT_IS_ENABLE 129 | ) 130 | 131 | textLevelColor = getColor( 132 | R.styleable.SpeedProgressBar_spb_text_level_color, 133 | DEFAULT_TEXT_LEVEL_COLOR 134 | ) 135 | 136 | textTitleColor = getColor( 137 | R.styleable.SpeedProgressBar_spb_text_title_color, 138 | DEFAULT_TEXT_TITLE_COLOR 139 | ) 140 | 141 | progressColor = getColor( 142 | R.styleable.SpeedProgressBar_spb_background_color, 143 | DEFAULT_TEXT_TITLE_COLOR 144 | ) 145 | 146 | unprogressColor = getColor( 147 | R.styleable.SpeedProgressBar_spb_unprogress_color, 148 | DEFAULT_UNPROGRESS_COLOR 149 | ) 150 | 151 | strokeWidth = getInteger( 152 | R.styleable.SpeedProgressBar_spb_stroke_with, 153 | DEFAULT_STROKE_WiDTH 154 | ).toFloat() 155 | 156 | getDrawable(R.styleable.SpeedProgressBar_spb_src)?.let { 157 | bitmap = (it as BitmapDrawable).bitmap 158 | progressColor = bitmap.getColor() 159 | } 160 | 161 | } finally { 162 | recycle() 163 | } 164 | } 165 | 166 | mReady = true 167 | 168 | if (mSetupPending) { 169 | setup() 170 | mSetupPending = false 171 | } 172 | 173 | } 174 | 175 | private fun setup() { 176 | 177 | if (!mReady) { 178 | mSetupPending = true 179 | return 180 | } 181 | 182 | if (width == 0 && height == 0) { 183 | return 184 | } 185 | 186 | borderRect.set(getBoundRectF(strokeWidth)) 187 | 188 | textLevelPaint.apply { 189 | isAntiAlias = true 190 | textAlign = Paint.Align.CENTER 191 | textSize = radius.toFloat() 192 | color = textLevelColor 193 | } 194 | 195 | textTitlePaint.apply { 196 | isAntiAlias = true 197 | textAlign = Paint.Align.CENTER 198 | textSize = radius.toFloat() 199 | color = textTitleColor 200 | } 201 | 202 | progressPaint.apply { 203 | isAntiAlias = true 204 | color = ColorUtils.blendARGB(progressColor, Color.BLACK, 0.2f) 205 | style = Paint.Style.STROKE 206 | strokeWidth = this@LevelProgressBar.strokeWidth 207 | strokeCap = if (isStepProgress) Paint.Cap.ROUND else Paint.Cap.BUTT 208 | } 209 | 210 | unProgressPaint.apply { 211 | isAntiAlias = true 212 | color = unprogressColor 213 | style = Paint.Style.STROKE 214 | strokeWidth = this@LevelProgressBar.strokeWidth 215 | strokeCap = if (isStepProgress) Paint.Cap.ROUND else Paint.Cap.BUTT 216 | 217 | } 218 | 219 | backgroundPaint.apply { 220 | isAntiAlias = true 221 | color = progressColor 222 | } 223 | 224 | if (!isEnable) { 225 | textLevelPaint.alpha = OPACITY 226 | textTitlePaint.alpha = OPACITY 227 | progressPaint.alpha = OPACITY 228 | backgroundPaint.alpha = OPACITY 229 | unProgressPaint.alpha = OPACITY 230 | } 231 | 232 | progress = (speed * 10).toInt() 233 | angle = (DEFAULT_TOTAL_ANGLE * progress / DEFAULT_MAX_PROGRESS).toFloat() 234 | 235 | val textHeight = textLevelPaint.descent() - textLevelPaint.ascent() 236 | textOffset = textHeight / 2 - textLevelPaint.descent() 237 | continuousSwipeAngle = DEFAULT_START_ANGLE + angle 238 | continuousStartAngle = DEFAULT_TOTAL_ANGLE - angle 239 | 240 | bitmap?.let { 241 | 242 | bitmapHeight = it.height 243 | bitmapWidth = it.width 244 | 245 | bitmapShader = BitmapShader(it, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP) 246 | 247 | backgroundPaint.shader = bitmapShader 248 | 249 | drawableRect.set(borderRect) 250 | 251 | updateShaderMatrix() 252 | 253 | } 254 | 255 | } 256 | 257 | override fun onDraw(canvas: Canvas) { 258 | super.onDraw(canvas) 259 | 260 | canvas.drawCircle( 261 | borderRect.centerX(), 262 | borderRect.centerY(), 263 | radius - strokeWidth, 264 | backgroundPaint 265 | ) 266 | 267 | 268 | // step progress 269 | if (isStepProgress) { 270 | var step = 10 271 | while (step <= DEFAULT_TOTAL_ANGLE) { 272 | if (step <= angle) { 273 | canvas.drawArc( 274 | borderRect, 275 | (DEFAULT_START_ANGLE + step).toFloat(), 276 | 10f, 277 | false, 278 | progressPaint 279 | ) 280 | } else { 281 | canvas.drawArc( 282 | borderRect, 283 | (DEFAULT_START_ANGLE + step).toFloat(), 284 | 10f, 285 | false, 286 | unProgressPaint 287 | ) 288 | } 289 | step += 30 290 | } 291 | } else { 292 | 293 | 294 | canvas.drawArc(borderRect, DEFAULT_START_ANGLE.toFloat(), angle, false, progressPaint) 295 | 296 | if (angle < DEFAULT_TOTAL_ANGLE) { 297 | 298 | canvas.drawArc( 299 | borderRect, 300 | continuousSwipeAngle, 301 | continuousStartAngle, 302 | false, 303 | unProgressPaint 304 | ) 305 | } 306 | } 307 | 308 | 309 | //levelTitle 310 | if (bitmap == null) { 311 | canvas 312 | .drawText( 313 | speed.toInt().toString(), 314 | borderRect.centerX(), 315 | borderRect.centerY() + textOffset, 316 | textLevelPaint 317 | ) 318 | } 319 | 320 | 321 | } 322 | 323 | 324 | /*Don't set background*/ 325 | override fun setBackground(background: Drawable) { 326 | // super.setBackground(background); 327 | } 328 | 329 | override fun setBackgroundColor(color: Int) { 330 | // super.setBackgroundColor(color); 331 | } 332 | 333 | override fun setOnClickListener(l: OnClickListener?) { 334 | if (isEnable) { 335 | super.setOnClickListener(l) 336 | } 337 | } 338 | 339 | override fun setOnTouchListener(l: OnTouchListener) { 340 | if (isEnable) { 341 | super.setOnTouchListener(l) 342 | } 343 | } 344 | 345 | 346 | override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) { 347 | super.onMeasure(widthMeasureSpec, heightMeasureSpec) 348 | 349 | val widthMode = MeasureSpec.getMode(widthMeasureSpec) 350 | val widthSize = MeasureSpec.getSize(widthMeasureSpec) 351 | val heightMode = MeasureSpec.getMode(heightMeasureSpec) 352 | val heightSize = MeasureSpec.getSize(heightMeasureSpec) 353 | 354 | val desiredWidth = (width + strokeWidth + paddingRight + paddingLeft).toInt() 355 | val desiredHeight = (height + strokeWidth + paddingTop + paddingBottom).toInt() 356 | 357 | val width: Int 358 | val height: Int 359 | 360 | //Measure Width 361 | width = when (widthMode) { 362 | MeasureSpec.EXACTLY -> //Must be this size 363 | widthSize 364 | MeasureSpec.AT_MOST -> //Can't be bigger than... 365 | min(desiredWidth, widthSize) 366 | else -> //Be whatever you want 367 | desiredWidth 368 | } 369 | 370 | //Measure Height 371 | height = when (heightMode) { 372 | MeasureSpec.EXACTLY -> //Must be this size 373 | heightSize 374 | MeasureSpec.AT_MOST -> //Can't be bigger than... 375 | min(desiredHeight, heightSize) 376 | else -> //Be whatever you want 377 | desiredHeight 378 | } 379 | val min = min(width, height) 380 | radius = (min / 2.5).toInt() 381 | 382 | setMeasuredDimension(width, height) 383 | 384 | } 385 | 386 | 387 | override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) { 388 | super.onSizeChanged(w, h, oldw, oldh) 389 | setup() 390 | } 391 | 392 | override fun setPadding(left: Int, top: Int, right: Int, bottom: Int) { 393 | super.setPadding(left, top, right, bottom) 394 | setup() 395 | } 396 | 397 | override fun setPaddingRelative(start: Int, top: Int, end: Int, bottom: Int) { 398 | super.setPaddingRelative(start, top, end, bottom) 399 | setup() 400 | } 401 | 402 | 403 | private fun updateShaderMatrix() { 404 | val scale: Float 405 | var dx = 0f 406 | var dy = 0f 407 | 408 | mShaderMatrix.set(null) 409 | 410 | if (bitmapWidth * drawableRect.height() > drawableRect.width() * bitmapHeight) { 411 | scale = drawableRect.height() / bitmapHeight.toFloat() 412 | dx = (drawableRect.width() - bitmapWidth * scale) * 0.5f 413 | } else { 414 | scale = drawableRect.width() / bitmapWidth.toFloat() 415 | dy = (drawableRect.height() - bitmapHeight * scale) * 0.5f 416 | } 417 | 418 | mShaderMatrix.setScale(scale, scale) 419 | mShaderMatrix.postTranslate( 420 | (dx + 0.5f).toInt() + drawableRect.left, 421 | (dy + 0.5f).toInt() + drawableRect.top 422 | ) 423 | 424 | bitmapShader.setLocalMatrix(mShaderMatrix) 425 | } 426 | 427 | 428 | fun setProgressWithAnimation(progress: Float) { 429 | 430 | val objectAnimator = ObjectAnimator.ofFloat(this, "speed", progress) 431 | objectAnimator.duration = 1500 432 | objectAnimator.interpolator = DecelerateInterpolator() 433 | objectAnimator.start() 434 | } 435 | 436 | // 437 | 438 | fun setTypeface(typeface: Typeface) { 439 | textTitlePaint.typeface = typeface 440 | textLevelPaint.typeface = typeface 441 | } 442 | 443 | fun getSpeed(): Float { 444 | return speed 445 | } 446 | 447 | fun setSpeed(speed: Float) { 448 | 449 | if (this.speed == speed) { 450 | return 451 | } 452 | 453 | this.speed = speed 454 | setup() 455 | invalidate() 456 | } 457 | 458 | 459 | fun getTextTitle(): String? { 460 | return textTitle 461 | } 462 | 463 | fun setTextTitle(textTitle: String) { 464 | 465 | if (this.textTitle == textTitle) { 466 | return 467 | } 468 | 469 | this.textTitle = textTitle 470 | setup() 471 | } 472 | 473 | fun getTextLevelColor(): Int { 474 | return textLevelColor 475 | } 476 | 477 | fun setTextLevelColor(textLevelColor: Int) { 478 | 479 | if (this.textLevelColor == textLevelColor) { 480 | return 481 | } 482 | 483 | this.textLevelColor = textLevelColor 484 | setup() 485 | } 486 | 487 | fun getTextTitleColor(): Int { 488 | return textTitleColor 489 | } 490 | 491 | fun setTextTitleColor(textTitleColor: Int) { 492 | 493 | if (this.textTitleColor == textTitleColor) { 494 | return 495 | } 496 | 497 | this.textTitleColor = textTitleColor 498 | setup() 499 | 500 | } 501 | 502 | fun getBackgroundProgressColor(): Int { 503 | return progressColor 504 | } 505 | 506 | fun setBackgroundProgressColor(backgroundProgressColor: Int) { 507 | 508 | this.bitmap = null 509 | this.progressColor = backgroundProgressColor 510 | setup() 511 | invalidate() 512 | } 513 | 514 | fun getUnprogressColor(): Int { 515 | return unprogressColor 516 | } 517 | 518 | fun setUnprogressColor(unprogressColor: Int) { 519 | 520 | if (this.unprogressColor == unprogressColor) { 521 | return 522 | } 523 | 524 | this.unprogressColor = unprogressColor 525 | setup() 526 | 527 | } 528 | 529 | fun isEnable(): Boolean { 530 | return isEnable 531 | } 532 | 533 | fun setEnable(enable: Boolean) { 534 | if (this.isEnable == enable) { 535 | return 536 | } 537 | 538 | this.isEnable = enable 539 | setup() 540 | requestLayout() 541 | } 542 | 543 | 544 | fun setIsStep(isStepProgress: Boolean) { 545 | if (this.isStepProgress == isStepProgress) { 546 | return 547 | } 548 | 549 | this.isStepProgress = isStepProgress 550 | setup() 551 | invalidate() 552 | } 553 | 554 | 555 | fun setImage(drawable: Int) { 556 | this.bitmap = (ContextCompat.getDrawable(context!!, drawable) as BitmapDrawable).bitmap 557 | setup() 558 | requestLayout() 559 | } 560 | 561 | // 562 | 563 | } -------------------------------------------------------------------------------- /progressbar/src/main/java/ir/alirezaiyan/progressbar/utils/Ex.kt: -------------------------------------------------------------------------------- 1 | package ir.alirezaiyan.progressbar.utils 2 | 3 | import android.graphics.Bitmap 4 | import android.graphics.Color 5 | import android.graphics.RectF 6 | import android.view.View 7 | import kotlin.math.min 8 | 9 | /** 10 | * @author ali (alirezaiyann@gmail.com) 11 | * @since 9/13/19 1:24 PM. 12 | */ 13 | 14 | 15 | fun Bitmap?.getColor(): Int { 16 | 17 | if (null == this) return Color.TRANSPARENT 18 | 19 | var redBucket = 0 20 | var greenBucket = 0 21 | var blueBucket = 0 22 | var alphaBucket = 0 23 | 24 | val hasAlpha = hasAlpha() 25 | val pixelCount = width * height 26 | val pixels = IntArray(pixelCount) 27 | getPixels(pixels, 0, width, 0, 0, width, height) 28 | 29 | var y = 0 30 | val h = height 31 | while (y < h) { 32 | var x = 0 33 | val w = width 34 | while (x < w) { 35 | val color = pixels[x + y * w] // x + y * width 36 | redBucket += color shr 16 and 0xFF // Color.red 37 | greenBucket += color shr 8 and 0xFF // Color.greed 38 | blueBucket += color and 0xFF // Color.blue 39 | if (hasAlpha) alphaBucket += color.ushr(24) // Color.alpha 40 | x++ 41 | } 42 | y++ 43 | } 44 | 45 | return Color.argb( 46 | if (hasAlpha) alphaBucket / pixelCount else 255, 47 | redBucket / pixelCount, 48 | greenBucket / pixelCount, 49 | blueBucket / pixelCount 50 | ) 51 | 52 | } 53 | 54 | fun View.getBoundRectF(strokeWidth: Float): RectF { 55 | 56 | val availableWidth = width - paddingLeft - paddingRight 57 | val availableHeight = height - paddingTop - paddingBottom 58 | 59 | val sideLength = min(availableWidth, availableHeight) 60 | 61 | val left = (paddingLeft + (availableWidth - sideLength)) 62 | val top = (paddingTop + (availableHeight - sideLength)) 63 | 64 | return RectF( 65 | left + strokeWidth, 66 | top + strokeWidth, 67 | left + sideLength - strokeWidth, 68 | top + sideLength - strokeWidth 69 | ) 70 | 71 | } -------------------------------------------------------------------------------- /progressbar/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /progressbar/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /progressbar/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rezaiyan/LevelProgressBar/b251868aa7d3fc5c1caa6b04fd763820ac374052/progressbar/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /progressbar/src/main/res/mipmap-hdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rezaiyan/LevelProgressBar/b251868aa7d3fc5c1caa6b04fd763820ac374052/progressbar/src/main/res/mipmap-hdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /progressbar/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rezaiyan/LevelProgressBar/b251868aa7d3fc5c1caa6b04fd763820ac374052/progressbar/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /progressbar/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rezaiyan/LevelProgressBar/b251868aa7d3fc5c1caa6b04fd763820ac374052/progressbar/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /progressbar/src/main/res/mipmap-mdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rezaiyan/LevelProgressBar/b251868aa7d3fc5c1caa6b04fd763820ac374052/progressbar/src/main/res/mipmap-mdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /progressbar/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rezaiyan/LevelProgressBar/b251868aa7d3fc5c1caa6b04fd763820ac374052/progressbar/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /progressbar/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rezaiyan/LevelProgressBar/b251868aa7d3fc5c1caa6b04fd763820ac374052/progressbar/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /progressbar/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rezaiyan/LevelProgressBar/b251868aa7d3fc5c1caa6b04fd763820ac374052/progressbar/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /progressbar/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rezaiyan/LevelProgressBar/b251868aa7d3fc5c1caa6b04fd763820ac374052/progressbar/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /progressbar/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rezaiyan/LevelProgressBar/b251868aa7d3fc5c1caa6b04fd763820ac374052/progressbar/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /progressbar/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rezaiyan/LevelProgressBar/b251868aa7d3fc5c1caa6b04fd763820ac374052/progressbar/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /progressbar/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rezaiyan/LevelProgressBar/b251868aa7d3fc5c1caa6b04fd763820ac374052/progressbar/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /progressbar/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rezaiyan/LevelProgressBar/b251868aa7d3fc5c1caa6b04fd763820ac374052/progressbar/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /progressbar/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rezaiyan/LevelProgressBar/b251868aa7d3fc5c1caa6b04fd763820ac374052/progressbar/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /progressbar/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rezaiyan/LevelProgressBar/b251868aa7d3fc5c1caa6b04fd763820ac374052/progressbar/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /progressbar/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /progressbar/src/main/res/values/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FAFAFA 4 | -------------------------------------------------------------------------------- /progressbar/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | LevelProgressBar 19 | 20 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 alirezaiyann@gmail.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | include ':app', ':progressbar' 18 | rootProject.name='LevelProgressBar' 19 | --------------------------------------------------------------------------------