├── .gitignore ├── LICENCE ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── ir │ │ └── neo │ │ └── stepbarviewdemo │ │ └── ExampleInstrumentedTest.kt │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── ir │ │ │ └── neo │ │ │ └── stepbarviewdemo │ │ │ └── MainActivity.kt │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ └── ic_launcher_background.xml │ │ ├── layout │ │ └── activity_main.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── ir │ └── neo │ └── stepbarviewdemo │ └── ExampleUnitTest.kt ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── repo_files ├── SbvDemo1-1-0.apk ├── images │ ├── demoo.gif │ └── scrollable_sample.gif └── keystore.jks ├── settings.gradle └── stepbarview ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src ├── androidTest └── java │ └── ir │ └── neo │ └── stepbarview │ └── ExampleInstrumentedTest.java ├── main ├── AndroidManifest.xml ├── java │ └── ir │ │ └── neo │ │ └── stepbarview │ │ ├── DpHandler.kt │ │ └── StepBarView.kt └── res │ └── values │ ├── attrs.xml │ ├── colors.xml │ └── strings.xml └── test └── java └── ir └── neo └── stepbarview └── ExampleUnitTest.java /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .externalNativeBuild 10 | 11 | app/release/* 12 | 13 | # Built application files 14 | #*.apk 15 | #*.ap_ 16 | 17 | # Files for the ART/Dalvik VM 18 | *.dex 19 | 20 | # Java class files 21 | *.class 22 | 23 | # Generated files 24 | bin/ 25 | gen/ 26 | out/ 27 | 28 | # Gradle files 29 | .gradle/ 30 | build/ 31 | 32 | # Local configuration file (sdk path, etc) 33 | local.properties 34 | 35 | # Proguard folder generated by Eclipse 36 | proguard/ 37 | 38 | # Log Files 39 | *.log 40 | 41 | # Android Studio Navigation editor temp files 42 | .navigation/ 43 | 44 | # Android Studio captures folder 45 | captures/ 46 | 47 | # Intellij 48 | *.iml 49 | .idea/workspace.xml 50 | .idea/tasks.xml 51 | .idea/gradle.xml 52 | .idea/dictionaries 53 | .idea/libraries 54 | .idea 55 | 56 | 57 | # External native build folder generated in Android Studio 2.2 and later 58 | .externalNativeBuild 59 | 60 | 61 | # Freeline 62 | freeline.py 63 | freeline/ 64 | freeline_project_description.json 65 | -------------------------------------------------------------------------------- /LICENCE: -------------------------------------------------------------------------------- 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 | [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) 2 | [![APK](https://img.shields.io/badge/APK-Demo-brightgreen.svg)](https://github.com/imaNNeoFighT/StepBarView/raw/master/repo_files/SbvDemo1-1-0.apk) 3 | [![](https://jitpack.io/v/imaNNeoFighT/StepBarView.svg)](https://jitpack.io/#imaNNeoFighT/StepBarView) 4 | [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-StepBarView-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/6931) 5 | 6 | # Step Bar View 7 | 8 | You can use this library to have a step bar. 9 | 10 | It can be used in pages that you have some steps to reach. 11 | 12 | You can download the [Demo apk file](https://github.com/imaNNeoFighT/StepBarView/raw/master/repo_files/SbvDemo1-1-0.apk) (you can first adjust your StepBar in the demoApp and then implement it in code). 13 | 14 | 15 | 16 | 17 | 18 | ## 1 - Getting Started 19 | 20 | By these instructions you can add this library and I will explain how to use it. 21 | 22 | 23 | 24 | ### Add Maven to your root build.gradle 25 | 26 | First of all add it in your root build.gradle at the end of the repositories: 27 | 28 | ``` 29 | allprojects { 30 | repositories { 31 | ... 32 | maven { url 'https://jitpack.io' } 33 | } 34 | } 35 | ``` 36 | 37 | ### Add Dependency 38 | 39 | Add the dependency to your app build.gradle file. 40 | 41 | ``` 42 | dependencies 43 | { 44 | implementation 'com.github.imaNNeoFighT:StepBarView:1.1.0' 45 | // Or in older versions : 46 | // compile'com.github.imaNNeoFighT:StepBarView:1.1.0' 47 | } 48 | ``` 49 | 50 | And then sync your gradle and have a cup of tea. 51 | 52 | 53 | ## 2 - About The View 54 | You can simply use this View like other Views in android, 55 | just add ``StepBarView`` in your java code or xml. 56 | 57 | ## View Properties 58 | 59 | You can customize StepBarView. All of this attributes can be changed via xml or code (runtime). 60 | 61 | 62 | |Attribute|Type|Kotlin|Description| 63 | |:---:|:---:|:---:|:---:| 64 | |sbv_max_count|Integer|`maxCount`|your steps count (max to reach), default value is `8`| 65 | |sbv_steps_reached_colors|Color|`stepsReachedColor`|steps reached color (steps circle reached color)| 66 | |sbv_steps_unreached_colors|Color|`stepsUnreachedColor`|steps unReached color (steps circle default color)| 67 | |sbv_steps_line_reached_colors|Color|`stepsLineReachedColor`|steps line reached color| 68 | |sbv_steps_line_unreached_colors|Color|`stepsLineUnreachedColor`|steps line uReached color| 69 | |sbv_steps_line_height|Dimensions|`stepsLineHeight`|steps line height, default value is `4dp`| 70 | |sbv_steps_size|Dimensions|`stepsSize`|steps circle size, default value is `16dp`| 71 | |sbv_steps_text_color|Color|`stepsTextColor`|steps text color (number that drawn on steps circle)| 72 | |sbv_steps_text_size|Dimensions|`stepsTextSize`|steps text size, default is `14sp`| 73 | |sbv_steps_line_margin_left|Dimensions|`stepsLineMarginLeft`|steps line margin left (gap in left of lines), default value is `2dp`| 74 | |sbv_steps_line_margin_right|Dimensions|`stepsLineMarginRight`|steps line margin right (gap in right of lines), default value is `2dp`| 75 | |sbv_allow_touch_step_to|Integer|`allowTouchStepTo`|allow touch to reach step (for example if you set 3 you can touch to reach step to 3 and not more), default value is `8`| 76 | |sbv_show_step_index|Boolean|`showStepIndex`|you can set this property false to prevent showing indexes (then just a solid circle will be drawn), default value is `true`| 77 | |sbv_steps_stroke_size|Dimensions|`stepsStrokeSize`| Stroke Size of steps , default value is `2dp`| 78 | |sbv_steps_stroke_reached_color|Color|`stepsStrokeReachedColor`| Stroke color of reached steps| 79 | |sbv_steps_stroke_unreached_color|Color|`stepsStrokeUnReachedColor`| Stroke color of unReached steps| 80 | |sbv_steps_stroke_current_color|Color|`stepsStrokeCurrentColor`| Stroke color of current steps| 81 | |sbv_show_step_stroke|Boolean|`showStepStroke`| flag to showing the Stroke or not!, default is false| 82 | |sbv_is_rtl|Boolean|`isRtl`| flag to showing steps in RTL (Right to left), default is false| 83 | |sbv_show_step_name|Boolean|`showStepName`| flag to show title below the steps, default is false| 84 | |sbv_is_fixed_steps_line_width|Boolean|`isFixedStepsLineWidth`| flag to specify that the line widths is fixed or it should calculate depends on View width (use it when you want to achieve scrollable view)| 85 | |sbv_steps_line_width|Dimensions|`stepsLineWidth`|steps line width, default value is `24dp`, it will ignored when isFixedStepsLineWidth is false| 86 | 87 | 88 | ## 3 - Some Samples 89 | 90 | ### Scrollable Sample 91 | To achieve scrollable View just set `isFixedStepsLineWidth : true`, and put this view inside a `HorizontalScrollView`, 92 | 93 | just like this: 94 | 95 | 96 | 97 | ``` 98 | 108 | 109 | 128 | 129 | 130 | ``` 131 | 132 | 133 | # License 134 | ``` 135 | Copyright 2018 Iman Khoshabi 136 | 137 | Licensed under the Apache License, Version 2.0 (the "License"); 138 | you may not use this file except in compliance with the License. 139 | You may obtain a copy of the License at 140 | 141 | http://www.apache.org/licenses/LICENSE-2.0 142 | 143 | Unless required by applicable law or agreed to in writing, software 144 | distributed under the License is distributed on an "AS IS" BASIS, 145 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 146 | See the License for the specific language governing permissions and 147 | limitations under the License. 148 | ``` 149 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | apply plugin: 'kotlin-android' 4 | 5 | apply plugin: 'kotlin-android-extensions' 6 | 7 | android { 8 | compileSdkVersion 26 9 | defaultConfig { 10 | applicationId "ir.neo.stepbarviewdemo" 11 | minSdkVersion 16 12 | targetSdkVersion 26 13 | versionCode 1 14 | versionName "1.0" 15 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 16 | } 17 | buildTypes { 18 | release { 19 | minifyEnabled false 20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 21 | } 22 | } 23 | } 24 | 25 | dependencies { 26 | implementation fileTree(include: ['*.jar'], dir: 'libs') 27 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" 28 | implementation 'com.android.support:appcompat-v7:26.1.0' 29 | implementation 'com.android.support.constraint:constraint-layout:1.0.2' 30 | testImplementation 'junit:junit:4.12' 31 | androidTestImplementation 'com.android.support.test:runner:1.0.1' 32 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' 33 | implementation project(':stepbarview') 34 | } 35 | -------------------------------------------------------------------------------- /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/neo/stepbarviewdemo/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package ir.neo.stepbarviewdemo 2 | 3 | import android.support.test.InstrumentationRegistry 4 | import android.support.test.runner.AndroidJUnit4 5 | 6 | import org.junit.Test 7 | import org.junit.runner.RunWith 8 | 9 | import org.junit.Assert.* 10 | 11 | /** 12 | * Instrumented test, which will execute on an Android device. 13 | * 14 | * See [testing documentation](http://d.android.com/tools/testing). 15 | */ 16 | @RunWith(AndroidJUnit4::class) 17 | class ExampleInstrumentedTest { 18 | @Test 19 | fun useAppContext() { 20 | // Context of the app under test. 21 | val appContext = InstrumentationRegistry.getTargetContext() 22 | assertEquals("ir.neo.stepbarviewdemo", appContext.packageName) 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/java/ir/neo/stepbarviewdemo/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package ir.neo.stepbarviewdemo 2 | 3 | import android.os.Bundle 4 | import android.support.v7.app.AppCompatActivity 5 | import android.view.View 6 | import android.widget.* 7 | import ir.neo.stepbarview.DpHandler 8 | import ir.neo.stepbarview.StepBarView 9 | import ir.neo.stepbarview.StepBarView.StepsTitleSetter 10 | import kotlinx.android.synthetic.main.activity_main.* 11 | 12 | class MainActivity : AppCompatActivity() ,SeekBar.OnSeekBarChangeListener{ 13 | lateinit var sbAttrsValue: SeekBar 14 | lateinit var spActions : Spinner 15 | lateinit var tvValue : TextView 16 | 17 | var actionsList : MutableList = mutableListOf() 18 | 19 | override fun onCreate(savedInstanceState: Bundle?) { 20 | super.onCreate(savedInstanceState) 21 | setContentView(R.layout.activity_main) 22 | 23 | 24 | my_stepBarView4.allowSelectStep = object : StepBarView.AllowSelectStep{ 25 | override fun allowSelectStep(step: Int) = step != 2 26 | } 27 | 28 | sbAttrsValue = findViewById(R.id.sb_attrsValue) 29 | spActions = findViewById(R.id.sp_actions) 30 | tvValue = findViewById(R.id.tv_value) 31 | 32 | 33 | initSpinner() 34 | initStepNames() 35 | } 36 | 37 | private fun initStepNames() { 38 | my_stepBarView2.stepsTitleSetter = object : StepsTitleSetter { 39 | override fun getStepTitle(step: Int): String { 40 | return when (step) { 41 | 1 -> "Fist" 42 | 2 -> "2nd" 43 | 3 -> "Third" 44 | 4 -> "4th" 45 | 5 -> "Fifth" 46 | 6 -> "6th" 47 | 7 -> "Seventh" 48 | 8 -> "8th" 49 | 9 -> "Ninth" 50 | 10 -> "10th" 51 | else -> "Non" 52 | } 53 | } 54 | } 55 | } 56 | 57 | private fun initSpinner() { 58 | actionsList.add("sbv_max_count") 59 | actionsList.add("sbv_steps_line_height") 60 | actionsList.add("sbv_steps_size") 61 | actionsList.add("sbv_steps_text_size") 62 | actionsList.add("sbv_steps_line_margin_left") 63 | actionsList.add("sbv_steps_line_margin_right") 64 | actionsList.add("sbv_allow_touch_step_to") 65 | 66 | val spinnerArrayAdapter = ArrayAdapter(this, android.R.layout.simple_spinner_item, 67 | actionsList) 68 | spinnerArrayAdapter.setDropDownViewResource(android.R.layout 69 | .simple_spinner_dropdown_item) 70 | spActions.adapter = spinnerArrayAdapter 71 | 72 | 73 | spActions.onItemSelectedListener = object : AdapterView.OnItemSelectedListener{ 74 | override fun onNothingSelected(parent: AdapterView<*>?) {} 75 | 76 | override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) { 77 | refreshSelected(position) 78 | } 79 | 80 | } 81 | 82 | spActions.setSelection(0) 83 | refreshValueText(my_stepBarView4.maxCount) 84 | } 85 | 86 | 87 | private fun refreshSelected(position : Int) { 88 | sbAttrsValue.setOnSeekBarChangeListener(null) 89 | when(actionsList[position]){ 90 | "sbv_max_count" -> { 91 | sbAttrsValue.max = 20 92 | sbAttrsValue.progress = my_stepBarView4.maxCount-2 93 | refreshValueText(sbAttrsValue.progress) 94 | } 95 | "sbv_steps_line_height" -> { 96 | sbAttrsValue.max = 20 97 | sbAttrsValue.progress = DpHandler.pxToDp(this@MainActivity, my_stepBarView4.stepsLineHeight.toInt()) 98 | refreshValueText(sbAttrsValue.progress) 99 | } 100 | "sbv_steps_size" -> { 101 | sbAttrsValue.max = 80 102 | sbAttrsValue.progress = DpHandler.pxToDp(this@MainActivity, my_stepBarView4.stepsSize.toInt()) 103 | refreshValueText(sbAttrsValue.progress) 104 | } 105 | "sbv_steps_text_size" -> { 106 | sbAttrsValue.max = 25 107 | sbAttrsValue.progress = DpHandler.pxToSp(this@MainActivity, my_stepBarView4.stepsSize.toInt()).toInt() 108 | refreshValueText(sbAttrsValue.progress) 109 | } 110 | "sbv_steps_line_margin_left" -> { 111 | sbAttrsValue.max = 40 112 | sbAttrsValue.progress = DpHandler.pxToDp(this@MainActivity, my_stepBarView4.stepsLineMarginLeft.toInt()) 113 | refreshValueText(sbAttrsValue.progress) 114 | } 115 | "sbv_steps_line_margin_right" -> { 116 | sbAttrsValue.max = 100 117 | sbAttrsValue.progress = DpHandler.pxToDp(this@MainActivity, my_stepBarView4.stepsLineMarginRight.toInt()) 118 | refreshValueText(sbAttrsValue.progress) 119 | } 120 | "sbv_allow_touch_step_to" -> { 121 | sbAttrsValue.max = my_stepBarView4.maxCount 122 | sbAttrsValue.progress = my_stepBarView4.allowTouchStepTo 123 | refreshValueText(sbAttrsValue.progress) 124 | } 125 | } 126 | sbAttrsValue.setOnSeekBarChangeListener(this) 127 | } 128 | 129 | 130 | private fun refreshValueText(progress: Int) { 131 | when(actionsList[spActions.selectedItemPosition]){ 132 | "sbv_max_count" -> { 133 | tvValue.text = "${progress+2}" 134 | } 135 | "sbv_steps_line_height" -> { 136 | tvValue.text = "$progress dp" 137 | } 138 | "sbv_steps_size" -> { 139 | tvValue.text = "$progress sp" 140 | } 141 | "sbv_steps_text_size" -> { 142 | tvValue.text = "$progress sp" 143 | } 144 | "sbv_steps_line_margin_left" -> { 145 | tvValue.text = "$progress dp" 146 | } 147 | "sbv_steps_line_margin_right" -> { 148 | tvValue.text = "$progress dp" 149 | } 150 | "sbv_allow_touch_step_to" -> { 151 | tvValue.text = "$progress" 152 | } 153 | } 154 | } 155 | 156 | private fun refreshProgress(progress: Int) { 157 | when(actionsList[spActions.selectedItemPosition]){ 158 | "sbv_max_count" -> { 159 | my_stepBarView4.maxCount= progress+2 160 | } 161 | "sbv_steps_line_height" -> { 162 | my_stepBarView4.stepsLineHeight = DpHandler.dpToPx(this@MainActivity,progress).toFloat() 163 | } 164 | "sbv_steps_size" -> { 165 | my_stepBarView4.stepsSize = DpHandler.dpToPx(this@MainActivity,progress).toFloat() 166 | } 167 | "sbv_steps_text_size" -> { 168 | my_stepBarView4.stepsTextSize = DpHandler.spToPx(this,progress.toFloat()) 169 | } 170 | "sbv_steps_line_margin_left" -> { 171 | my_stepBarView4.stepsLineMarginLeft = DpHandler.dpToPx(this@MainActivity,progress).toFloat() 172 | } 173 | "sbv_steps_line_margin_right" -> { 174 | my_stepBarView4.stepsLineMarginRight = DpHandler.dpToPx(this@MainActivity,progress).toFloat() 175 | } 176 | "sbv_allow_touch_step_to" -> { 177 | my_stepBarView4.allowTouchStepTo = progress 178 | } 179 | } 180 | } 181 | 182 | 183 | override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) { 184 | refreshValueText(progress) 185 | refreshProgress(progress) 186 | } 187 | override fun onStartTrackingTouch(seekBar: SeekBar?){} 188 | override fun onStopTrackingTouch(seekBar: SeekBar?){} 189 | } 190 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 12 | 34 | 35 | 58 | 59 | 60 | 70 | 71 | 90 | 91 | 92 | 93 | 94 | 103 | 104 | 105 | 114 | 115 | 123 | 124 | 140 | 141 | 150 | 151 | 152 | 153 | -------------------------------------------------------------------------------- /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/imaNNeo/StepBarView/c5f7d9bd44f7f910ca50b7925e38a7200cd759aa/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imaNNeo/StepBarView/c5f7d9bd44f7f910ca50b7925e38a7200cd759aa/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imaNNeo/StepBarView/c5f7d9bd44f7f910ca50b7925e38a7200cd759aa/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imaNNeo/StepBarView/c5f7d9bd44f7f910ca50b7925e38a7200cd759aa/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imaNNeo/StepBarView/c5f7d9bd44f7f910ca50b7925e38a7200cd759aa/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imaNNeo/StepBarView/c5f7d9bd44f7f910ca50b7925e38a7200cd759aa/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imaNNeo/StepBarView/c5f7d9bd44f7f910ca50b7925e38a7200cd759aa/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imaNNeo/StepBarView/c5f7d9bd44f7f910ca50b7925e38a7200cd759aa/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imaNNeo/StepBarView/c5f7d9bd44f7f910ca50b7925e38a7200cd759aa/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imaNNeo/StepBarView/c5f7d9bd44f7f910ca50b7925e38a7200cd759aa/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | StepBarViewDemo 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/test/java/ir/neo/stepbarviewdemo/ExampleUnitTest.kt: -------------------------------------------------------------------------------- 1 | package ir.neo.stepbarviewdemo 2 | 3 | import org.junit.Test 4 | 5 | import org.junit.Assert.* 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * See [testing documentation](http://d.android.com/tools/testing). 11 | */ 12 | class ExampleUnitTest { 13 | @Test 14 | fun addition_isCorrect() { 15 | assertEquals(4, 2 + 2) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | ext.kotlin_version = '1.2.31' 5 | ext.kotlin_version = '1.2.21' 6 | repositories { 7 | google() 8 | jcenter() 9 | } 10 | dependencies { 11 | classpath 'com.android.tools.build:gradle:3.0.1' 12 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 13 | 14 | // NOTE: Do not place your application dependencies here; they belong 15 | // in the individual module build.gradle files 16 | } 17 | } 18 | 19 | allprojects { 20 | repositories { 21 | google() 22 | jcenter() 23 | } 24 | } 25 | 26 | task clean(type: Delete) { 27 | delete rootProject.buildDir 28 | } 29 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | org.gradle.jvmargs=-Xmx1536m 13 | 14 | # When configured, Gradle will run in incubating parallel mode. 15 | # This option should only be used with decoupled projects. More details, visit 16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 17 | # org.gradle.parallel=true 18 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imaNNeo/StepBarView/c5f7d9bd44f7f910ca50b7925e38a7200cd759aa/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Apr 10 02:02:21 IRDT 2018 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /repo_files/SbvDemo1-1-0.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imaNNeo/StepBarView/c5f7d9bd44f7f910ca50b7925e38a7200cd759aa/repo_files/SbvDemo1-1-0.apk -------------------------------------------------------------------------------- /repo_files/images/demoo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imaNNeo/StepBarView/c5f7d9bd44f7f910ca50b7925e38a7200cd759aa/repo_files/images/demoo.gif -------------------------------------------------------------------------------- /repo_files/images/scrollable_sample.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imaNNeo/StepBarView/c5f7d9bd44f7f910ca50b7925e38a7200cd759aa/repo_files/images/scrollable_sample.gif -------------------------------------------------------------------------------- /repo_files/keystore.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imaNNeo/StepBarView/c5f7d9bd44f7f910ca50b7925e38a7200cd759aa/repo_files/keystore.jks -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':stepbarview' 2 | -------------------------------------------------------------------------------- /stepbarview/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /stepbarview/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | apply plugin: 'kotlin-android' 3 | 4 | android { 5 | compileSdkVersion 26 6 | 7 | 8 | 9 | defaultConfig { 10 | minSdkVersion 16 11 | targetSdkVersion 26 12 | versionCode 3 13 | versionName "1.0.4" 14 | 15 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 16 | 17 | } 18 | 19 | buildTypes { 20 | release { 21 | minifyEnabled false 22 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 23 | } 24 | } 25 | 26 | } 27 | 28 | dependencies { 29 | implementation fileTree(dir: 'libs', include: ['*.jar']) 30 | 31 | implementation 'com.android.support:appcompat-v7:26.1.0' 32 | testImplementation 'junit:junit:4.12' 33 | androidTestImplementation 'com.android.support.test:runner:1.0.1' 34 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' 35 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 36 | } 37 | repositories { 38 | mavenCentral() 39 | } 40 | -------------------------------------------------------------------------------- /stepbarview/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 | -------------------------------------------------------------------------------- /stepbarview/src/androidTest/java/ir/neo/stepbarview/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package ir.neo.stepbarview; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumented test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("ir.neo.stepbarview.test", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /stepbarview/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | -------------------------------------------------------------------------------- /stepbarview/src/main/java/ir/neo/stepbarview/DpHandler.kt: -------------------------------------------------------------------------------- 1 | package ir.neo.stepbarview 2 | 3 | import android.content.Context 4 | import android.util.DisplayMetrics 5 | import android.util.TypedValue 6 | 7 | /** 8 | * Created by iman. 9 | * iman.neofight@gmail.com 10 | */ 11 | object DpHandler { 12 | fun dpToPx(ctx: Context, dp: Int): Int { 13 | val displayMetrics = ctx.resources.displayMetrics 14 | return Math.round(dp * (displayMetrics.xdpi / DisplayMetrics.DENSITY_DEFAULT)) 15 | } 16 | 17 | fun pxToDp(ctx: Context, px: Int): Int { 18 | val displayMetrics = ctx.resources.displayMetrics 19 | return Math.round(px / (displayMetrics.xdpi / DisplayMetrics.DENSITY_DEFAULT)) 20 | } 21 | 22 | fun spToPx(ctx: Context, sp: Float): Float { 23 | return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, sp, ctx.resources.displayMetrics) 24 | } 25 | 26 | fun pxToSp(ctx : Context, px : Int): Float { 27 | return px / ctx.resources.displayMetrics.scaledDensity 28 | } 29 | } -------------------------------------------------------------------------------- /stepbarview/src/main/java/ir/neo/stepbarview/StepBarView.kt: -------------------------------------------------------------------------------- 1 | package ir.neo.stepbarview 2 | 3 | import android.content.Context 4 | import android.graphics.Canvas 5 | import android.graphics.Paint 6 | import android.graphics.PointF 7 | import android.graphics.Rect 8 | import android.graphics.RectF 9 | import android.os.Parcel 10 | import android.os.Parcelable 11 | import android.support.v4.content.ContextCompat 12 | import android.util.AttributeSet 13 | import android.util.Log 14 | import android.view.MotionEvent 15 | import android.view.View 16 | 17 | /** 18 | * Created by iman. 19 | * iman.neofight@gmail.com 20 | */ 21 | class StepBarView @JvmOverloads 22 | constructor(mContext : Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0) : 23 | View(mContext,attrs, defStyleAttr) { 24 | 25 | companion object { 26 | private val IS_DEBUG = false 27 | 28 | // This is a fixed distance to add space between the circle and the step name 29 | private val NAME_STEP_SEPARATION_PX = 10 30 | } 31 | 32 | private var stepsPaint : Paint 33 | private var stepsStrokePaint : Paint 34 | private var stepsLinePaint : Paint 35 | private var stepsTextPaint : Paint 36 | 37 | private var tmpRect = Rect() 38 | 39 | var onStepChangeListener : OnStepChangeListener? = null 40 | 41 | private val rawHeiht 42 | get() = Math.max(stepsSize,stepsLineHeight) 43 | 44 | private val rawWidth 45 | get() = 46 | (linesWidth * (maxCount - 1)) + // Lines Width 47 | ((stepsLineMarginLeft + stepsLineMarginRight) * (maxCount - 1)) + // Lines Margins 48 | ((stepsSize + stepsStrokeSize) * maxCount) 49 | 50 | 51 | //Lines between steps will drawn based on this variable 52 | //Note that now width is match_parent 53 | private val linesWidth : Float 54 | get() { 55 | return if (isFixedStepsLineWidth) { 56 | stepsLineWidth 57 | } else { 58 | val allStepsSize = (maxCount * stepsSize) 59 | val allMarginsSize = ((maxCount-1) * (stepsLineMarginLeft + stepsLineMarginRight)) 60 | val width = width - paddingLeft - paddingRight 61 | val available = (width - allStepsSize - allMarginsSize) 62 | available / (maxCount-1) 63 | } 64 | } 65 | 66 | //This property used in drawing stuff 67 | private val yPos 68 | get() = ((rawHeiht/2) + paddingTop) 69 | 70 | 71 | var maxCount : Int = 0 72 | set(value) { 73 | if(allowTouchStepTo == field) 74 | allowTouchStepTo = value 75 | field = value 76 | invalidate() 77 | } 78 | 79 | var reachedStep: Int = 0 80 | set(value) { 81 | field = value 82 | onStepChangeListener?.onStepChanged(field) 83 | invalidate() 84 | } 85 | 86 | var stepsReachedColor : Int = 0 87 | set(value) { 88 | field = value 89 | invalidate() 90 | } 91 | 92 | var stepsUnreachedColor : Int = 0 93 | set(value) { 94 | field = value 95 | invalidate() 96 | } 97 | 98 | var stepsLineReachedColor : Int = 0 99 | set(value) { 100 | field = value 101 | invalidate() 102 | } 103 | 104 | var stepsLineUnreachedColor : Int = 0 105 | set(value) { 106 | field = value 107 | invalidate() 108 | } 109 | 110 | var stepsLineHeight : Float = 0f 111 | set(value) { 112 | field = value 113 | requestLayout() 114 | } 115 | 116 | var stepsSize : Float = 0f 117 | set(value) { 118 | field = value 119 | requestLayout() 120 | } 121 | 122 | var stepsTextColor : Int = 0 123 | set(value) { 124 | field = value 125 | invalidate() 126 | } 127 | 128 | var stepsTextSize : Float = 0f 129 | set(value) { 130 | field = value 131 | invalidate() 132 | } 133 | 134 | var stepsLineMarginLeft : Float = 0f 135 | set(value) { 136 | field = value 137 | invalidate() 138 | } 139 | 140 | var stepsLineMarginRight: Float = 0f 141 | set(value) { 142 | field = value 143 | invalidate() 144 | } 145 | 146 | var allowTouchStepTo : Int = 0 147 | 148 | var showStepIndex: Boolean = true 149 | set(value) { 150 | field = value 151 | invalidate() 152 | } 153 | 154 | var showStepName: Boolean = false 155 | set(value) { 156 | field = value 157 | invalidate() 158 | } 159 | 160 | var stepsStrokeSize : Float = 0f 161 | set(value) { 162 | field = value 163 | invalidate() 164 | } 165 | 166 | var stepsStrokeReachedColor : Int = 0 167 | set(value) { 168 | field = value 169 | invalidate() 170 | } 171 | 172 | var stepsStrokeUnReachedColor : Int = 0 173 | set(value) { 174 | field = value 175 | invalidate() 176 | } 177 | 178 | var stepsStrokeCurrentColor : Int = 0 179 | set(value) { 180 | field = value 181 | invalidate() 182 | } 183 | 184 | var showStepStroke : Boolean = true 185 | set(value) { 186 | field = value 187 | invalidate() 188 | } 189 | 190 | var isRtl : Boolean = false 191 | set(value) { 192 | field = value 193 | invalidate() 194 | } 195 | 196 | var isFixedStepsLineWidth : Boolean = false 197 | set(value) { 198 | field = value 199 | invalidate() 200 | } 201 | 202 | var stepsLineWidth : Float = 0f 203 | set(value) { 204 | field = value 205 | invalidate() 206 | } 207 | 208 | 209 | var allowSelectStep = object : AllowSelectStep{ 210 | override fun allowSelectStep(step: Int) = true 211 | } 212 | 213 | var stepsTitleSetter = object : StepsTitleSetter { 214 | 215 | override fun getStepTitle(step: Int) = "Step ${step}" 216 | 217 | } 218 | 219 | init { 220 | maxCount = 8 221 | reachedStep = 1 222 | 223 | stepsReachedColor = ContextCompat.getColor(context,R.color.sbv_step_reached_color) 224 | stepsUnreachedColor = ContextCompat.getColor(context,R.color.sbv_step_unreached_color) 225 | 226 | stepsLineReachedColor = ContextCompat.getColor(context,R.color.sbv_step_line_reached_color) 227 | stepsLineUnreachedColor = ContextCompat.getColor(context,R.color.sbv_step_line_unreached_color) 228 | 229 | stepsLineHeight = DpHandler.dpToPx(context,4).toFloat() 230 | 231 | stepsSize = DpHandler.dpToPx(context,16).toFloat() 232 | stepsTextColor = ContextCompat.getColor(context,R.color.sbv_step_text_color) 233 | stepsTextSize = DpHandler.spToPx(context,14f) 234 | 235 | stepsLineMarginLeft = DpHandler.dpToPx(context,2).toFloat() 236 | stepsLineMarginRight = DpHandler.dpToPx(context,2).toFloat() 237 | 238 | allowTouchStepTo = maxCount 239 | 240 | showStepIndex = true 241 | showStepName = false 242 | 243 | stepsStrokeSize = DpHandler.dpToPx(context,2).toFloat() 244 | 245 | stepsStrokeReachedColor = ContextCompat.getColor(context,R.color.sbv_step_stroke_reached_color) 246 | stepsStrokeUnReachedColor = ContextCompat.getColor(context,R.color.sbv_step_stroke_unreached_color) 247 | stepsStrokeCurrentColor = ContextCompat.getColor(context,R.color.sbv_step_stroke_current_color) 248 | 249 | showStepStroke = false 250 | 251 | isRtl = false 252 | 253 | isFixedStepsLineWidth = false 254 | 255 | stepsLineWidth = DpHandler.dpToPx(context, 24).toFloat() 256 | 257 | attrs.let { 258 | val a = mContext.obtainStyledAttributes(attrs, R.styleable.StepBarView) 259 | 260 | maxCount = a.getInt(R.styleable.StepBarView_sbv_max_count,maxCount) 261 | 262 | stepsReachedColor = a.getColor(R.styleable.StepBarView_sbv_steps_reached_colors,stepsReachedColor) 263 | stepsUnreachedColor = a.getColor(R.styleable.StepBarView_sbv_steps_unreached_colors,stepsUnreachedColor) 264 | 265 | stepsLineReachedColor = a.getColor(R.styleable.StepBarView_sbv_steps_line_reached_colors,stepsLineReachedColor) 266 | stepsLineUnreachedColor = a.getColor(R.styleable.StepBarView_sbv_steps_line_unreached_colors,stepsLineUnreachedColor) 267 | 268 | stepsLineHeight = a.getDimension(R.styleable.StepBarView_sbv_steps_line_height,stepsLineHeight) 269 | 270 | stepsSize = a.getDimension(R.styleable.StepBarView_sbv_steps_size,stepsSize) 271 | stepsTextColor = a.getColor(R.styleable.StepBarView_sbv_steps_text_color,stepsTextColor) 272 | stepsTextSize = a.getDimensionPixelOffset(R.styleable.StepBarView_sbv_steps_text_size, stepsTextSize.toInt()).toFloat() 273 | 274 | stepsLineMarginLeft = a.getDimension(R.styleable.StepBarView_sbv_steps_line_margin_left,stepsLineMarginLeft) 275 | stepsLineMarginRight = a.getDimension(R.styleable.StepBarView_sbv_steps_line_margin_right,stepsLineMarginRight) 276 | 277 | allowTouchStepTo = a.getInt(R.styleable.StepBarView_sbv_allow_touch_step_to,maxCount) 278 | 279 | showStepIndex = a.getBoolean(R.styleable.StepBarView_sbv_show_step_index, showStepIndex) 280 | 281 | showStepName = a.getBoolean(R.styleable.StepBarView_sbv_show_step_name, showStepName) 282 | 283 | stepsStrokeSize = a.getDimension(R.styleable.StepBarView_sbv_steps_stroke_size,stepsStrokeSize) 284 | 285 | stepsStrokeReachedColor = a.getColor(R.styleable.StepBarView_sbv_steps_stroke_reached_color,stepsStrokeReachedColor) 286 | stepsStrokeUnReachedColor = a.getColor(R.styleable.StepBarView_sbv_steps_stroke_unreached_color,stepsStrokeUnReachedColor) 287 | stepsStrokeCurrentColor = a.getColor(R.styleable.StepBarView_sbv_steps_stroke_current_color,stepsStrokeCurrentColor) 288 | 289 | showStepStroke = a.getBoolean(R.styleable.StepBarView_sbv_show_step_stroke, showStepStroke) 290 | 291 | isRtl = a.getBoolean(R.styleable.StepBarView_sbv_is_rtl, isRtl) 292 | 293 | isFixedStepsLineWidth = a.getBoolean(R.styleable.StepBarView_sbv_is_fixed_steps_line_width, isFixedStepsLineWidth) 294 | 295 | stepsLineWidth = a.getDimension(R.styleable.StepBarView_sbv_steps_line_width, stepsLineWidth) 296 | 297 | a.recycle() 298 | } 299 | 300 | stepsPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply { 301 | style = Paint.Style.FILL 302 | } 303 | 304 | stepsStrokePaint = Paint(Paint.ANTI_ALIAS_FLAG).apply { 305 | style = Paint.Style.STROKE 306 | } 307 | 308 | stepsLinePaint = Paint(Paint.ANTI_ALIAS_FLAG).apply { 309 | style = Paint.Style.FILL 310 | } 311 | 312 | stepsTextPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply { 313 | style = Paint.Style.FILL 314 | textAlign = Paint.Align.CENTER 315 | } 316 | 317 | //If showStepName is true we get the text height with a sample text 318 | //to be considered when onMeasure() is called 319 | if (showStepName) { 320 | stepsTextPaint.color = stepsTextColor 321 | stepsTextPaint.textSize = stepsTextSize 322 | } 323 | } 324 | 325 | 326 | override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) { 327 | super.onMeasure(widthMeasureSpec, heightMeasureSpec) 328 | 329 | val widthMeasureMode = MeasureSpec.getMode(widthMeasureSpec) 330 | val widthMeasureSize = MeasureSpec.getSize(widthMeasureSpec) 331 | 332 | val heightMeasureMode = MeasureSpec.getMode(heightMeasureSpec) 333 | val heightMeasureSize = MeasureSpec.getSize(heightMeasureSpec) 334 | 335 | 336 | val mWidth : Float = if (isFixedStepsLineWidth) { 337 | calculateDesireWidth() 338 | } else { 339 | widthMeasureSize.toFloat() 340 | } 341 | val mHeight = calculateDesireHeight() 342 | 343 | setMeasuredDimension(mWidth.toInt(), mHeight.toInt()) 344 | } 345 | 346 | 347 | private fun calculateDesireHeight() : Float = rawHeiht + paddingTop + paddingBottom + titleTextHeight() 348 | private fun calculateDesireWidth() : Float = rawWidth + paddingLeft + paddingRight 349 | 350 | 351 | //To include the steps name height when onMeasure is called 352 | //if showStepName is false, this is 0 353 | private fun titleTextHeight() : Int { 354 | if (!showStepName) return 0 355 | 356 | stepsTextPaint.getTextBounds("sample", 0, "sample".length, tmpRect) 357 | return tmpRect.height() + NAME_STEP_SEPARATION_PX * 2 358 | } 359 | private fun getHorizontalCirclesPosition() : FloatArray { 360 | val stepsHorizontalPositions = FloatArray(maxCount) 361 | val linesSize = linesWidth 362 | 363 | 364 | val range = when(isRtl) { 365 | true -> maxCount-1 downTo 0 366 | false -> 0 until maxCount 367 | } 368 | for(i in range) { 369 | //This offset contains step circle and right line 370 | val oneStepOffset = stepsSize + stepsLineMarginLeft + linesSize + stepsLineMarginRight 371 | val offsetToDraw = paddingLeft + (i * oneStepOffset) 372 | 373 | val pos = if(isRtl) (maxCount-1)-i else i 374 | stepsHorizontalPositions[pos] = offsetToDraw + stepsSize / 2 375 | } 376 | 377 | return stepsHorizontalPositions 378 | } 379 | 380 | override fun onDraw(canvas: Canvas?) { 381 | super.onDraw(canvas) 382 | val linesSize = linesWidth 383 | 384 | for(i in 0 until maxCount) { 385 | if (IS_DEBUG) { 386 | Log.d("SS", "drawing $i step") 387 | } 388 | 389 | val xPos = getHorizontalCirclesPosition()[i] 390 | 391 | //Draw Steps Line 392 | if(i xPos - (stepsSize/2) - stepsLineMarginRight 401 | false -> xPos + (stepsSize/2) + stepsLineMarginLeft 402 | } 403 | 404 | val endXPoint = 405 | when(isRtl){ 406 | false -> startXPoint + linesSize 407 | true -> startXPoint - linesSize 408 | } 409 | 410 | canvas?.drawLine( 411 | startXPoint, 412 | yPos, 413 | endXPoint, 414 | yPos, 415 | stepsLinePaint 416 | ) 417 | } 418 | 419 | //Draw Steps Circle 420 | stepsPaint.color = if(i stepsStrokeReachedColor 432 | i + 1 == reachedStep -> stepsStrokeCurrentColor 433 | else -> stepsStrokeUnReachedColor 434 | } 435 | canvas?.drawCircle( 436 | xPos, 437 | yPos, 438 | (stepsSize / 2) - (stepsStrokePaint.strokeWidth / 2), 439 | stepsStrokePaint) 440 | } 441 | 442 | 443 | //Draw Steps Index 444 | if(showStepIndex) { 445 | stepsTextPaint.color = stepsTextColor 446 | stepsTextPaint.textSize = stepsTextSize 447 | val drawingText = (i + 1).toString() 448 | stepsTextPaint.getTextBounds(drawingText, 0, drawingText.length, tmpRect) 449 | canvas?.drawText( 450 | drawingText, 451 | xPos, 452 | (yPos + (tmpRect.height() / 2)), 453 | stepsTextPaint) 454 | } 455 | 456 | //Draw Steps Names 457 | if(showStepName) { 458 | val name = stepsTitleSetter.getStepTitle(i + 1); 459 | stepsTextPaint.getTextBounds(name, 0, name.length, tmpRect) 460 | canvas?.drawText( 461 | name, 462 | xPos, 463 | yPos*2 + tmpRect.height() + NAME_STEP_SEPARATION_PX, 464 | stepsTextPaint) 465 | } 466 | } 467 | 468 | } 469 | 470 | private var touchDownPoint = PointF() 471 | override fun onTouchEvent(event: MotionEvent?): Boolean { 472 | when(event?.action){ 473 | MotionEvent.ACTION_DOWN -> { 474 | if (isFixedStepsLineWidth) { 475 | touchDownPoint.set(event.x, event.y) 476 | } else { 477 | handleTouchPost(event.x, event.y) 478 | } 479 | } 480 | MotionEvent.ACTION_MOVE -> { 481 | if (isFixedStepsLineWidth) { 482 | return false 483 | } else { 484 | handleTouchPost(event.x, event.y) 485 | } 486 | } 487 | MotionEvent.ACTION_UP -> { //Click Happened 488 | if (touchDownPoint.x == event.x && 489 | touchDownPoint.y == event.y) { 490 | handleTouchPost(event.x, event.y) 491 | } 492 | } 493 | } 494 | return true 495 | } 496 | 497 | private fun handleTouchPost(x: Float, y: Float) { 498 | val lineSize = linesWidth 499 | for(i in 0 until getHorizontalCirclesPosition().size){ 500 | 501 | //Disallow touch more than allowTouchStepTo 502 | if(i >= allowTouchStepTo) continue 503 | 504 | //Disallow touch user prevent steps 505 | if(!allowSelectStep.allowSelectStep(i+1)) continue 506 | 507 | val xDotPos = getHorizontalCirclesPosition()[i] 508 | val yDotPos = yPos 509 | 510 | val stepHalf = stepsSize/2 511 | 512 | //verticalExtraSpace is the extra space for vertical touching 513 | val verticalExtraSpace = (rawHeiht*2) 514 | 515 | val leftArea = 516 | when(isRtl){ 517 | false -> xDotPos-stepHalf-lineSize-stepsLineMarginRight 518 | true -> xDotPos-stepHalf-stepsLineMarginRight 519 | } 520 | 521 | val rightArea = 522 | when(isRtl){ 523 | false -> xDotPos+stepHalf+stepsLineMarginLeft 524 | true -> xDotPos+stepHalf+stepsLineMarginLeft+lineSize 525 | } 526 | 527 | val stepArea = RectF( 528 | leftArea, 529 | yDotPos-stepHalf-verticalExtraSpace, 530 | rightArea, 531 | yDotPos+stepHalf+verticalExtraSpace 532 | ) 533 | 534 | if(stepArea.contains(x, y)){ 535 | //Touched Step (i+1) 536 | reachedStep = (i+1) 537 | } 538 | } 539 | 540 | } 541 | 542 | override fun onSaveInstanceState(): Parcelable { 543 | val superState = super.onSaveInstanceState() 544 | val ss = SavedState(superState) 545 | ss.maxCount = maxCount 546 | ss.reachedStep = reachedStep 547 | ss.stepsReachedColor = stepsReachedColor 548 | ss.stepsUnreachedColor = stepsUnreachedColor 549 | ss.stepsLineReachedColor = stepsLineReachedColor 550 | ss.stepsLineUnreachedColor = stepsLineUnreachedColor 551 | ss.stepsLineHeight = stepsLineHeight 552 | ss.stepsSize = stepsSize 553 | ss.stepsTextColor = stepsTextColor 554 | ss.stepsTextSize = stepsTextSize 555 | ss.stepsLineMarginLeft = stepsLineMarginLeft 556 | ss.stepsLineMarginRight = stepsLineMarginRight 557 | ss.allowTouchStepTo = allowTouchStepTo 558 | ss.showStepIndex = showStepIndex 559 | ss.stepsStrokeSize = stepsStrokeSize 560 | ss.stepsStrokeReachedColor = stepsStrokeReachedColor 561 | ss.stepsStrokeUnReachedColor = stepsStrokeUnReachedColor 562 | ss.stepsStrokeCurrentColor = stepsStrokeCurrentColor 563 | ss.showStepStroke = showStepStroke 564 | ss.isRtl = isRtl 565 | return ss 566 | } 567 | 568 | override fun onRestoreInstanceState(state: Parcelable?) { 569 | val savedState = state as SavedState 570 | super.onRestoreInstanceState(savedState.superState) 571 | maxCount = savedState.maxCount 572 | reachedStep = savedState.reachedStep 573 | stepsReachedColor = savedState.stepsReachedColor 574 | stepsUnreachedColor = savedState.stepsUnreachedColor 575 | stepsLineReachedColor = savedState.stepsLineReachedColor 576 | stepsLineUnreachedColor = savedState.stepsLineUnreachedColor 577 | stepsLineHeight = savedState.stepsLineHeight 578 | stepsSize = savedState.stepsSize 579 | stepsTextColor = savedState.stepsTextColor 580 | stepsTextSize = savedState.stepsTextSize 581 | stepsLineMarginLeft = savedState.stepsLineMarginLeft 582 | stepsLineMarginRight = savedState.stepsLineMarginRight 583 | allowTouchStepTo = savedState.allowTouchStepTo 584 | showStepIndex = savedState.showStepIndex 585 | stepsStrokeSize = savedState.stepsStrokeSize 586 | stepsStrokeReachedColor = savedState.stepsStrokeReachedColor 587 | stepsStrokeUnReachedColor = savedState.stepsStrokeUnReachedColor 588 | stepsStrokeCurrentColor = savedState.stepsStrokeCurrentColor 589 | showStepStroke = savedState.showStepStroke 590 | isRtl = savedState.isRtl 591 | } 592 | 593 | class SavedState : BaseSavedState{ 594 | companion object CREATOR : Parcelable.Creator{ 595 | override fun createFromParcel(source: Parcel?) = SavedState(source) 596 | override fun newArray(size: Int) = arrayOfNulls(size) 597 | } 598 | 599 | 600 | var maxCount : Int = 1 601 | var reachedStep: Int = 1 602 | var stepsReachedColor : Int = 1 603 | var stepsUnreachedColor : Int = 1 604 | var stepsLineReachedColor: Int = 1 605 | var stepsLineUnreachedColor: Int = 1 606 | var stepsLineHeight: Float = 1f 607 | var stepsSize: Float = 1f 608 | var stepsTextColor: Int = 1 609 | var stepsTextSize : Float = 1f 610 | var stepsLineMarginLeft : Float = 1f 611 | var stepsLineMarginRight : Float = 1f 612 | var allowTouchStepTo : Int = 1 613 | var showStepIndex: Boolean = true 614 | var stepsStrokeSize : Float = 1f 615 | var stepsStrokeReachedColor : Int = 1 616 | var stepsStrokeUnReachedColor : Int = 1 617 | var stepsStrokeCurrentColor : Int = 1 618 | var showStepStroke : Boolean = false 619 | var isRtl : Boolean = false 620 | 621 | constructor(parcelable: Parcelable) : super(parcelable) 622 | constructor(parcel : Parcel?) : super(parcel){ 623 | parcel?.let { 624 | maxCount = it.readInt() 625 | reachedStep = it.readInt() 626 | stepsReachedColor = it.readInt() 627 | stepsUnreachedColor = it.readInt() 628 | stepsLineReachedColor = it.readInt() 629 | stepsLineUnreachedColor = it.readInt() 630 | stepsLineHeight = it.readFloat() 631 | stepsSize = it.readFloat() 632 | stepsTextColor = it.readInt() 633 | stepsTextSize = it.readFloat() 634 | stepsLineMarginLeft = it.readFloat() 635 | stepsLineMarginRight = it.readFloat() 636 | allowTouchStepTo = it.readInt() 637 | showStepIndex = it.readInt()==1 638 | stepsStrokeSize = it.readFloat() 639 | stepsStrokeReachedColor = it.readInt() 640 | stepsStrokeUnReachedColor = it.readInt() 641 | stepsStrokeCurrentColor = it.readInt() 642 | showStepStroke = it.readInt()==1 643 | isRtl = it.readInt()==1 644 | } 645 | 646 | } 647 | 648 | override fun writeToParcel(out: Parcel?, flags: Int) { 649 | super.writeToParcel(out, flags) 650 | 651 | out?.let { 652 | it.writeInt(maxCount) 653 | it.writeInt(reachedStep) 654 | it.writeInt(stepsReachedColor) 655 | it.writeInt(stepsUnreachedColor) 656 | it.writeInt(stepsLineReachedColor) 657 | it.writeInt(stepsLineUnreachedColor) 658 | it.writeFloat(stepsLineHeight) 659 | it.writeFloat(stepsSize) 660 | it.writeInt(stepsTextColor) 661 | it.writeFloat(stepsTextSize) 662 | it.writeFloat(stepsLineMarginLeft) 663 | it.writeFloat(stepsLineMarginRight) 664 | it.writeInt(allowTouchStepTo) 665 | it.writeInt(if(showStepIndex) 1 else 0) 666 | it.writeFloat(stepsStrokeSize) 667 | it.writeInt(stepsStrokeReachedColor) 668 | it.writeInt(stepsStrokeUnReachedColor) 669 | it.writeInt(stepsStrokeCurrentColor) 670 | it.writeInt(if(showStepStroke) 1 else 0) 671 | it.writeInt(if(isRtl) 1 else 0) 672 | } 673 | } 674 | } 675 | 676 | interface OnStepChangeListener{ 677 | fun onStepChanged(currentStep:Int) 678 | } 679 | 680 | interface AllowSelectStep{ 681 | fun allowSelectStep(step: Int) : Boolean 682 | } 683 | 684 | interface StepsTitleSetter{ 685 | fun getStepTitle(step: Int) : String 686 | } 687 | } -------------------------------------------------------------------------------- /stepbarview/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /stepbarview/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | #f99b1c 5 | #d6d6d6 6 | @color/sbv_step_reached_color 7 | @color/sbv_step_unreached_color 8 | #fff 9 | #f00 10 | #0f0 11 | #00f 12 | 13 | -------------------------------------------------------------------------------- /stepbarview/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | StepBarView 3 | 4 | -------------------------------------------------------------------------------- /stepbarview/src/test/java/ir/neo/stepbarview/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package ir.neo.stepbarview; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } --------------------------------------------------------------------------------