├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── values
│ │ │ │ ├── dimens.xml
│ │ │ │ ├── strings.xml
│ │ │ │ ├── colors.xml
│ │ │ │ └── styles.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
│ │ │ ├── mipmap-anydpi-v26
│ │ │ │ ├── ic_launcher.xml
│ │ │ │ └── ic_launcher_round.xml
│ │ │ ├── menu
│ │ │ │ └── menu_main.xml
│ │ │ ├── layout
│ │ │ │ ├── my_progress_item.xml
│ │ │ │ ├── activity_main.xml
│ │ │ │ └── content_main.xml
│ │ │ ├── drawable-v24
│ │ │ │ └── ic_launcher_foreground.xml
│ │ │ └── drawable
│ │ │ │ └── ic_launcher_background.xml
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ │ └── com
│ │ │ └── mckrpk
│ │ │ └── animatedprogressbar
│ │ │ └── sample
│ │ │ └── MainActivity.kt
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── mckrpk
│ │ │ └── animatedprogressbar
│ │ │ └── sample
│ │ │ └── ExampleUnitTest.kt
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── mckrpk
│ │ └── animatedprogressbar
│ │ └── sample
│ │ └── ExampleInstrumentedTest.kt
├── proguard-rules.pro
└── build.gradle
├── animatedprogressbar
├── consumer-rules.pro
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ └── values
│ │ │ │ ├── strings.xml
│ │ │ │ ├── colors.xml
│ │ │ │ ├── dimens.xml
│ │ │ │ └── attrs.xml
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ │ └── com
│ │ │ └── mckrpk
│ │ │ └── animatedprogressbar
│ │ │ ├── ShapeDrawer.kt
│ │ │ ├── TrackDrawer.kt
│ │ │ ├── Utils.kt
│ │ │ ├── ProgressDrawer.kt
│ │ │ ├── ViewProperties.kt
│ │ │ ├── SnakeDrawer.kt
│ │ │ └── AnimatedProgressBar.kt
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── mckrpk
│ │ │ └── animatedprogressbar
│ │ │ └── ExampleUnitTest.kt
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── mckrpk
│ │ └── animatedprogressbar
│ │ └── ExampleInstrumentedTest.kt
├── proguard-rules.pro
└── build.gradle
├── images
├── simple.gif
├── snake.gif
├── snakes.gif
├── styles.gif
├── track.gif
├── lineWidth.gif
├── progress.gif
├── animDuration.gif
├── progressTip.gif
└── progressTipColor.gif
├── settings.gradle
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .idea
├── compiler.xml
├── kotlinc.xml
├── vcs.xml
├── codeStyles
│ ├── codeStyleConfig.xml
│ └── Project.xml
├── migrations.xml
├── misc.xml
├── deploymentTargetSelector.xml
├── gradle.xml
└── other.xml
├── .gitignore
├── gradlew.bat
├── README.md
├── gradlew
└── LICENSE
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/animatedprogressbar/consumer-rules.pro:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/animatedprogressbar/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/images/simple.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mckrpk/AnimatedProgressBar/HEAD/images/simple.gif
--------------------------------------------------------------------------------
/images/snake.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mckrpk/AnimatedProgressBar/HEAD/images/snake.gif
--------------------------------------------------------------------------------
/images/snakes.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mckrpk/AnimatedProgressBar/HEAD/images/snakes.gif
--------------------------------------------------------------------------------
/images/styles.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mckrpk/AnimatedProgressBar/HEAD/images/styles.gif
--------------------------------------------------------------------------------
/images/track.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mckrpk/AnimatedProgressBar/HEAD/images/track.gif
--------------------------------------------------------------------------------
/images/lineWidth.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mckrpk/AnimatedProgressBar/HEAD/images/lineWidth.gif
--------------------------------------------------------------------------------
/images/progress.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mckrpk/AnimatedProgressBar/HEAD/images/progress.gif
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':animatedprogressbar'
2 | rootProject.name='AnimatedProgressBar'
3 |
--------------------------------------------------------------------------------
/images/animDuration.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mckrpk/AnimatedProgressBar/HEAD/images/animDuration.gif
--------------------------------------------------------------------------------
/images/progressTip.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mckrpk/AnimatedProgressBar/HEAD/images/progressTip.gif
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 | 16dp
3 |
4 |
--------------------------------------------------------------------------------
/images/progressTipColor.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mckrpk/AnimatedProgressBar/HEAD/images/progressTipColor.gif
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mckrpk/AnimatedProgressBar/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/animatedprogressbar/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | AnimatedProgressBar
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mckrpk/AnimatedProgressBar/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mckrpk/AnimatedProgressBar/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mckrpk/AnimatedProgressBar/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mckrpk/AnimatedProgressBar/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mckrpk/AnimatedProgressBar/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mckrpk/AnimatedProgressBar/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mckrpk/AnimatedProgressBar/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mckrpk/AnimatedProgressBar/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mckrpk/AnimatedProgressBar/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mckrpk/AnimatedProgressBar/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/animatedprogressbar/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/kotlinc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | ProgressBarDemo
3 | Simple
4 | Snakes
5 |
6 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/.idea/codeStyles/codeStyleConfig.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/animatedprogressbar/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | #008577
5 | #D1DCDC
6 | #D81B60
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/migrations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
10 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/animatedprogressbar/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 | 32dp
3 | 4dp
4 | 2dp
5 | 1200
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #4CAF50
4 | #00574B
5 | #E91E63
6 |
7 | #D1DCDC
8 | #673AB7
9 |
10 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/deploymentTargetSelector.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/animatedprogressbar/src/main/java/com/mckrpk/animatedprogressbar/ShapeDrawer.kt:
--------------------------------------------------------------------------------
1 | package com.mckrpk.animatedprogressbar
2 |
3 | import android.graphics.Canvas
4 |
5 | internal abstract class ShapeDrawer {
6 | abstract fun onSizeChanged()
7 | /**
8 | * @targetProgress should be normalized to value from 0 to 1
9 | */
10 | abstract fun startAnimation(targetProgress: Float)
11 | abstract fun draw(canvas: Canvas)
12 | abstract fun cancel()
13 |
14 | }
--------------------------------------------------------------------------------
/app/src/test/java/com/mckrpk/animatedprogressbar/sample/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.mckrpk.animatedprogressbar.sample
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 |
--------------------------------------------------------------------------------
/animatedprogressbar/src/test/java/com/mckrpk/animatedprogressbar/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.mckrpk.animatedprogressbar
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 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_main.xml:
--------------------------------------------------------------------------------
1 |
14 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/animatedprogressbar/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/my_progress_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/animatedprogressbar/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 |
--------------------------------------------------------------------------------
/animatedprogressbar/src/androidTest/java/com/mckrpk/animatedprogressbar/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.mckrpk.animatedprogressbar
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.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.getInstrumentation().targetContext
22 | assertEquals("com.mckrpk.animatedprogressbar.test", appContext.packageName)
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/mckrpk/animatedprogressbar/sample/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.mckrpk.animatedprogressbar.sample
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.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.getInstrumentation().targetContext
22 | assertEquals("com.mckrpk.animatedprogressbar.sample", appContext.packageName)
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/animatedprogressbar/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'com.vanniktech.maven.publish'
4 |
5 | android {
6 | compileSdk 34
7 |
8 | namespace 'com.mckrpk.animatedprogressbar'
9 |
10 |
11 | defaultConfig {
12 | minSdkVersion 14
13 | targetSdkVersion 34
14 |
15 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
16 | consumerProguardFiles 'consumer-rules.pro'
17 | }
18 |
19 | buildTypes {
20 | release {
21 | minifyEnabled false
22 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
23 | }
24 | }
25 |
26 | buildFeatures {
27 | viewBinding true
28 | }
29 |
30 | compileOptions {
31 | sourceCompatibility JavaVersion.VERSION_17
32 | targetCompatibility JavaVersion.VERSION_17
33 | }
34 |
35 | kotlinOptions {
36 | jvmTarget = '17'
37 | }
38 |
39 | }
40 |
41 | dependencies {
42 | implementation fileTree(dir: 'libs', include: ['*.jar'])
43 |
44 | testImplementation 'junit:junit:4.12'
45 | androidTestImplementation 'androidx.test.ext:junit:1.1.1'
46 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
47 | }
48 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Built application files
2 | *.apk
3 | *.ap_
4 |
5 | # Files for the ART/Dalvik VM
6 | *.dex
7 |
8 | # Java class files
9 | *.class
10 |
11 | # Generated files
12 | bin/
13 | gen/
14 | out/
15 |
16 | # Gradle files
17 | .gradle/
18 | build/
19 | /gradle.properties
20 |
21 | # Local configuration file (sdk path, etc)
22 | local.properties
23 |
24 | # Proguard folder generated by Eclipse
25 | proguard/
26 |
27 | # Log Files
28 | *.log
29 |
30 | # Android Studio Navigation editor temp files
31 | .navigation/
32 |
33 | # Android Studio captures folder
34 | captures/
35 |
36 | # IntelliJ
37 | *.iml
38 | .idea/workspace.xml
39 | .idea/tasks.xml
40 | .idea/gradle.xml
41 | .idea/assetWizardSettings.xml
42 | .idea/dictionaries
43 | .idea/libraries
44 | .idea/caches
45 | .idea/modules.xml
46 | .idea/navEditor.xml
47 |
48 | # Keystore files
49 | # Uncomment the following line if you do not want to check your keystore files in.
50 | #*.jks
51 |
52 | # External native build folder generated in Android Studio 2.2 and later
53 | .externalNativeBuild
54 |
55 | # Google Services (e.g. APIs or Firebase)
56 | google-services.json
57 |
58 | # Freeline
59 | freeline.py
60 | freeline/
61 | freeline_project_description.json
62 |
63 | # fastlane
64 | fastlane/report.xml
65 | fastlane/Preview.html
66 | fastlane/screenshots
67 | fastlane/test_output
68 | fastlane/readme.md
69 |
70 | .cxx
71 | .DS_Store
72 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
20 |
21 |
22 |
23 |
26 |
27 |
35 |
36 |
--------------------------------------------------------------------------------
/animatedprogressbar/src/main/java/com/mckrpk/animatedprogressbar/TrackDrawer.kt:
--------------------------------------------------------------------------------
1 | package com.mckrpk.animatedprogressbar
2 |
3 | import android.animation.ValueAnimator
4 | import android.graphics.Canvas
5 | import android.graphics.RectF
6 | import android.view.animation.DecelerateInterpolator
7 |
8 | internal open class TrackDrawer(private val listener: DrawingView, val attrs: ViewProperties) :
9 | ShapeDrawer() {
10 |
11 | private lateinit var trackRect: RectF
12 | private var trackAnimator: ValueAnimator? = null
13 |
14 | override fun onSizeChanged() {
15 | val lineTopY = attrs.drawRect.top + (attrs.drawRect.height() - attrs.lineWidth) / 2
16 | val lineBottomY = lineTopY + attrs.lineWidth
17 | trackRect = RectF(attrs.drawRect.left, lineTopY, attrs.drawRect.left, lineBottomY)
18 | }
19 |
20 | override fun startAnimation(targetProgress: Float) {
21 | trackAnimator?.cancel()
22 |
23 | trackAnimator = ValueAnimator.ofFloat(attrs.drawRect.left, attrs.drawRect.right).apply {
24 | duration = attrs.animDuration.toLong() / 2
25 | interpolator = DecelerateInterpolator(1f)
26 | addUpdateListener { animation ->
27 | trackRect.right = animation.animatedValue as Float
28 | listener.requestInvalidate()
29 | }
30 | }
31 | trackAnimator?.start()
32 | }
33 |
34 | override fun draw(canvas: Canvas) {
35 | canvas.drawRoundRect(trackRect, attrs.cornerRadius, attrs.cornerRadius, attrs.trackPaint)
36 | }
37 |
38 | override fun cancel() {
39 | trackAnimator?.cancel()
40 | }
41 |
42 | }
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'com.vanniktech.maven.publish'
4 |
5 | android {
6 | compileSdkVersion 34
7 | namespace 'com.mckrpk.animatedprogressbar.sample'
8 |
9 | defaultConfig {
10 | applicationId "com.mckrpk.animatedprogressbar.sample"
11 | minSdkVersion 14
12 | targetSdkVersion 34
13 | versionCode 1
14 | versionName "0.1.0"
15 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
16 | }
17 | buildTypes {
18 | release {
19 | minifyEnabled false
20 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
21 | }
22 | }
23 | buildFeatures {
24 | viewBinding true
25 | }
26 | compileOptions {
27 | sourceCompatibility JavaVersion.VERSION_17
28 | targetCompatibility JavaVersion.VERSION_17
29 | }
30 |
31 | kotlinOptions {
32 | jvmTarget = '17'
33 | }
34 | }
35 |
36 | dependencies {
37 | implementation fileTree(dir: 'libs', include: ['*.jar'])
38 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
39 | implementation 'androidx.appcompat:appcompat:1.1.0'
40 | implementation 'androidx.core:core-ktx:1.1.0'
41 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
42 | implementation 'com.google.android.material:material:1.0.0'
43 | testImplementation 'junit:junit:4.12'
44 | androidTestImplementation 'androidx.test.ext:junit:1.1.1'
45 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
46 | implementation project(path: ':animatedprogressbar')
47 | }
48 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/animatedprogressbar/src/main/java/com/mckrpk/animatedprogressbar/Utils.kt:
--------------------------------------------------------------------------------
1 | package com.mckrpk.animatedprogressbar
2 |
3 | import android.content.Context
4 | import android.os.Build
5 | import android.util.DisplayMetrics
6 | import android.util.TypedValue
7 | import androidx.annotation.AttrRes
8 | import androidx.annotation.ColorRes
9 |
10 |
11 | fun getThemeColor(context: Context, @AttrRes resName: Int, @ColorRes fallbackColorRes: Int): Int {
12 | val outValue = TypedValue()
13 | val wasResolved = context.theme.resolveAttribute(resName, outValue, true)
14 | return if (wasResolved)
15 | outValue.data
16 | else
17 | context.resources.getColor(fallbackColorRes)
18 | }
19 |
20 | fun getThemeAccentColor(context: Context, @ColorRes fallbackColorRes: Int): Int {
21 | return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
22 | getThemeColor(context, android.R.attr.colorAccent, fallbackColorRes)
23 | } else {
24 | val colorAttr = context.resources
25 | .getIdentifier("colorAccent", "attr", context.packageName)
26 | getThemeColor(context, colorAttr, fallbackColorRes)
27 | }
28 | }
29 |
30 | fun getThemePrimaryColor(context: Context, @ColorRes fallbackColorRes: Int): Int {
31 | return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
32 | getThemeColor(context, android.R.attr.colorPrimary, fallbackColorRes)
33 | } else {
34 | val colorAttr = context.resources
35 | .getIdentifier("colorPrimary", "attr", context.packageName)
36 | getThemeColor(context, colorAttr, fallbackColorRes)
37 | }
38 | }
39 |
40 | fun getThemePrimaryDarkColor(context: Context, @ColorRes fallbackColorRes: Int): Int {
41 | return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
42 | getThemeColor(context, android.R.attr.colorPrimaryDark, fallbackColorRes)
43 | } else {
44 | val colorAttr = context.resources
45 | .getIdentifier("colorPrimaryDark", "attr", context.packageName)
46 | getThemeColor(context, colorAttr, fallbackColorRes)
47 | }
48 | }
49 |
50 | fun dpToPx(dp: Int, context: Context): Float {
51 | return dp * (context.resources.displayMetrics.densityDpi.toFloat() / DisplayMetrics.DENSITY_DEFAULT)
52 | }
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34 |
35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37 |
38 | @rem Find java.exe
39 | if defined JAVA_HOME goto findJavaFromJavaHome
40 |
41 | set JAVA_EXE=java.exe
42 | %JAVA_EXE% -version >NUL 2>&1
43 | if "%ERRORLEVEL%" == "0" goto execute
44 |
45 | echo.
46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47 | echo.
48 | echo Please set the JAVA_HOME variable in your environment to match the
49 | echo location of your Java installation.
50 |
51 | goto fail
52 |
53 | :findJavaFromJavaHome
54 | set JAVA_HOME=%JAVA_HOME:"=%
55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56 |
57 | if exist "%JAVA_EXE%" goto execute
58 |
59 | echo.
60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61 | echo.
62 | echo Please set the JAVA_HOME variable in your environment to match the
63 | echo location of your Java installation.
64 |
65 | goto fail
66 |
67 | :execute
68 | @rem Setup the command line
69 |
70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71 |
72 |
73 | @rem Execute Gradle
74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75 |
76 | :end
77 | @rem End local scope for the variables with windows NT shell
78 | if "%ERRORLEVEL%"=="0" goto mainEnd
79 |
80 | :fail
81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82 | rem the _cmd.exe /c_ return code!
83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84 | exit /b 1
85 |
86 | :mainEnd
87 | if "%OS%"=="Windows_NT" endlocal
88 |
89 | :omega
90 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/content_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
22 |
23 |
37 |
38 |
52 |
53 |
54 |
55 |
68 |
69 |
--------------------------------------------------------------------------------
/animatedprogressbar/src/main/java/com/mckrpk/animatedprogressbar/ProgressDrawer.kt:
--------------------------------------------------------------------------------
1 | package com.mckrpk.animatedprogressbar
2 |
3 | import android.animation.ValueAnimator
4 | import android.graphics.Canvas
5 | import android.graphics.Path
6 | import android.graphics.RectF
7 | import android.view.animation.DecelerateInterpolator
8 | import kotlin.math.max
9 |
10 | internal class ProgressDrawer(
11 | private val listener: DrawingView,
12 | private val attrs: ViewProperties
13 | ) : ShapeDrawer() {
14 |
15 | private lateinit var progressRect: RectF
16 | private lateinit var trackRect: RectF
17 | private lateinit var progressTipRect: RectF
18 | private val clipPath: Path = Path()
19 |
20 | protected var progressAnimator: ValueAnimator? = null
21 |
22 | override fun onSizeChanged() {
23 | val lineTopY = attrs.drawRect.top + (attrs.drawRect.height() - attrs.lineWidth) / 2
24 | val lineBottomY = lineTopY + attrs.lineWidth
25 | progressRect = RectF(attrs.drawRect.left, lineTopY, attrs.drawRect.left, lineBottomY)
26 | trackRect = RectF(attrs.drawRect.left, lineTopY, attrs.drawRect.right, lineBottomY)
27 | progressTipRect = RectF(attrs.drawRect.left, lineTopY, attrs.drawRect.left, lineBottomY)
28 | clipPath.addRoundRect(trackRect, attrs.cornerRadius, attrs.cornerRadius, Path.Direction.CW)
29 | }
30 |
31 | override fun startAnimation(targetProgress: Float) {
32 | progressAnimator?.cancel()
33 |
34 | val endValX = attrs.drawRect.left + targetProgress * attrs.drawRect.width()
35 | progressAnimator = ValueAnimator.ofFloat(attrs.drawRect.left, endValX).apply {
36 | duration = attrs.animDuration.toLong()
37 | interpolator = DecelerateInterpolator(1f)
38 | addUpdateListener { animation ->
39 | val animatedValue = animation.animatedValue as Float
40 | progressRect.right = animatedValue
41 | if (attrs.progressTipEnabled) {
42 | progressTipRect.right = animatedValue
43 | progressTipRect.left =
44 | max(attrs.drawRect.left, progressTipRect.right - attrs.lineWidth)
45 | }
46 | listener.requestInvalidate()
47 | }
48 | }
49 | progressAnimator?.start()
50 | }
51 |
52 | override fun draw(canvas: Canvas) {
53 | val checkpoint = canvas.save()
54 | canvas.clipPath(clipPath)
55 | try {
56 | canvas.drawRoundRect(
57 | progressRect,
58 | attrs.cornerRadius,
59 | attrs.cornerRadius,
60 | attrs.progressPaint
61 | )
62 | if (attrs.progressTipEnabled) {
63 | canvas.drawRoundRect(
64 | progressTipRect,
65 | attrs.cornerRadius,
66 | attrs.cornerRadius,
67 | attrs.progressTipPaint
68 | )
69 | }
70 | } finally {
71 | canvas.restoreToCount(checkpoint)
72 | }
73 | }
74 |
75 | override fun cancel() {
76 | progressAnimator?.cancel()
77 | }
78 |
79 | }
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## AnimatedProgressBar
2 |
3 | Animated determinate horizontal Progress Bar for Android.
4 |
5 | [](https://opensource.org/licenses/Apache-2.0)
6 |
7 | 
8 |
9 | 
10 |
11 | 
12 |
13 | ## 💻 Installation
14 |
15 | Your app's build.gradle:
16 | ```groovy
17 | dependencies {
18 | implementation 'io.github.mckrpk:AnimatedProgressBar:1.0.0'
19 | }
20 | ```
21 |
22 | Minimum required SDK version is 14.
23 | ## ❔ Usage
24 |
25 | ``` xml
26 |
40 | ```
41 |
42 | or programmaticaly
43 |
44 | ``` kotlin
45 | val progressBar = AnimatedProgressBar(this)
46 | progressBar.setMax(100)
47 | progressBar.setProgress(75)
48 | progressBar.setTrackColor(Color.GRAY)
49 | progressBar.setProgressColor(Color.GREEN)
50 | progressBar.setProgressTipEnabled(true)
51 | progressBar.setProgressTipColor(Color.RED)
52 | progressBar.setAnimDuration(1200)
53 | progressBar.setProgressStyle(AnimatedProgressBar.ProgressStyle.SNAKE)
54 | progressBar.setLineWidth(dpToPx(5, this).toInt())
55 | ```
56 | ## 🎨 Attributes
57 |
58 | | name | type | default | example |
59 | |--------------------|--------------------|-----------------|---------|
60 | | max | Int | 100 | 100 |
61 | | progress | Int | 0 | 75 |
62 | | style | Enum: Line, Snake | Line | |
63 | | trackColor | Int | GREY | |
64 | | progressColor | Int | Theme's primary | |
65 | | progressTipColor | Int | Theme's accent | |
66 | | progressTipEnabled | Boolean | true | |
67 | | animDuration | Int | 1200ms | |
68 | | lineWidth | Int | 4dp | |
69 |
70 | ## 📃 License
71 |
72 | Copyright 2019 Michał Karpiuk
73 |
74 | Licensed under the Apache License, Version 2.0 (the "License");
75 | you may not use this file except in compliance with the License.
76 | You may obtain a copy of the License at
77 |
78 | http://www.apache.org/licenses/LICENSE-2.0
79 |
80 | Unless required by applicable law or agreed to in writing, software
81 | distributed under the License is distributed on an "AS IS" BASIS,
82 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
83 | See the License for the specific language governing permissions and
84 | limitations under the License.
85 |
86 | **Please don't hesitate to star the library if you find it useful or interesting.** 😊
87 |
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | xmlns:android
17 |
18 | ^$
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 | xmlns:.*
28 |
29 | ^$
30 |
31 |
32 | BY_NAME
33 |
34 |
35 |
36 |
37 |
38 |
39 | .*:id
40 |
41 | http://schemas.android.com/apk/res/android
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 | .*:name
51 |
52 | http://schemas.android.com/apk/res/android
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 | name
62 |
63 | ^$
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 | style
73 |
74 | ^$
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 | .*
84 |
85 | ^$
86 |
87 |
88 | BY_NAME
89 |
90 |
91 |
92 |
93 |
94 |
95 | .*
96 |
97 | http://schemas.android.com/apk/res/android
98 |
99 |
100 | ANDROID_ATTRIBUTE_ORDER
101 |
102 |
103 |
104 |
105 |
106 |
107 | .*
108 |
109 | .*
110 |
111 |
112 | BY_NAME
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
--------------------------------------------------------------------------------
/animatedprogressbar/src/main/java/com/mckrpk/animatedprogressbar/ViewProperties.kt:
--------------------------------------------------------------------------------
1 | package com.mckrpk.animatedprogressbar
2 |
3 | import android.content.Context
4 | import android.content.res.TypedArray
5 | import android.graphics.Paint
6 | import android.graphics.RectF
7 | import kotlin.math.min
8 |
9 | internal class ViewProperties(attrs: TypedArray, context: Context) {
10 |
11 | var maxProgress: Float = 100f
12 | var progress: Float = 0f
13 |
14 | var animDuration: Int
15 | var progressTipEnabled: Boolean = false
16 | var progressStyle: AnimatedProgressBar.Style = AnimatedProgressBar.Style.LINE
17 |
18 | var progressColor: Int = 0
19 | set(value) {
20 | field = value
21 | progressPaint.color = value
22 | }
23 | var trackColor: Int = 0
24 | set(value) {
25 | field = value
26 | trackPaint.color = value
27 | }
28 | var progressTipColor: Int = 0
29 | set(value) {
30 | field = value
31 | progressTipPaint.color = value
32 | }
33 |
34 | var lineWidth: Float = 0f
35 | set(value) {
36 | field = value
37 | cornerRadius = lineWidth / 2
38 | progressTipWidth = lineWidth
39 | }
40 | var cornerRadius: Float = 0f
41 | var progressTipWidth: Float = 0f
42 |
43 | var trackPaint: Paint = Paint(Paint.ANTI_ALIAS_FLAG)
44 | var progressPaint: Paint = Paint(Paint.ANTI_ALIAS_FLAG)
45 | var progressTipPaint: Paint = Paint(Paint.ANTI_ALIAS_FLAG)
46 | var snakePaint: Paint = Paint(Paint.ANTI_ALIAS_FLAG)
47 |
48 | var drawRect: RectF = RectF()
49 | set(value) {
50 | field = value
51 | lineWidth = min(drawRect.height(), lineWidth)
52 | }
53 |
54 | init {
55 | //PROGRESS
56 | maxProgress = attrs.getInt(R.styleable.AnimatedProgressBar_max, 100).toFloat()
57 | progress = attrs.getInt(R.styleable.AnimatedProgressBar_progress, 0).toFloat()
58 |
59 | //OTHERS
60 | val styleIndex = attrs.getInt(R.styleable.AnimatedProgressBar_animationStyle, 0)
61 | progressStyle = AnimatedProgressBar.Style.values()[styleIndex]
62 | progressTipEnabled =
63 | attrs.getBoolean(R.styleable.AnimatedProgressBar_progressTipEnabled, true)
64 |
65 | animDuration = attrs.getInt(
66 | R.styleable.AnimatedProgressBar_animationDurationInMs,
67 | context.resources.getInteger(R.integer.animation_duration)
68 | )
69 |
70 | //COLORS
71 | progressTipColor = attrs.getColor(
72 | R.styleable.AnimatedProgressBar_progressTipColor,
73 | getThemeAccentColor(context, R.color.defaultTip)
74 | )
75 | progressColor = attrs.getColor(
76 | R.styleable.AnimatedProgressBar_progressColor,
77 | getThemePrimaryColor(context, R.color.defaultProgress)
78 | )
79 | trackColor = attrs.getColor(
80 | R.styleable.AnimatedProgressBar_trackColor,
81 | context.resources.getColor(R.color.defaultTrack)
82 | )
83 |
84 | progressTipWidth =
85 | context.resources.getDimensionPixelSize(R.dimen.animated_progress_bar_progress_tip_width)
86 | .toFloat()
87 | lineWidth = attrs.getDimensionPixelSize(
88 | R.styleable.AnimatedProgressBar_lineWidth,
89 | context.resources.getDimensionPixelSize(R.dimen.animated_progress_bar_line_width)
90 | ).toFloat()
91 | cornerRadius = lineWidth / 2
92 | progressTipWidth = lineWidth
93 |
94 | //PAINTS
95 | progressPaint.color = progressColor
96 | trackPaint.color = trackColor
97 | progressTipPaint.color = progressTipColor
98 | snakePaint.color = progressColor
99 | snakePaint.style = Paint.Style.STROKE
100 | snakePaint.strokeWidth = lineWidth
101 | snakePaint.strokeCap = Paint.Cap.ROUND
102 | snakePaint.strokeJoin = Paint.Join.ROUND
103 | }
104 |
105 | fun getProgressNormalized() = progress / maxProgress
106 |
107 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/mckrpk/animatedprogressbar/sample/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.mckrpk.animatedprogressbar.sample
2 |
3 | import android.graphics.Color
4 | import android.os.Bundle
5 | import android.view.LayoutInflater
6 | import android.view.Menu
7 | import android.view.MenuItem
8 | import android.view.ViewGroup
9 | import android.widget.LinearLayout
10 | import androidx.appcompat.app.AppCompatActivity
11 | import androidx.recyclerview.widget.RecyclerView
12 | import com.mckrpk.animatedprogressbar.AnimatedProgressBar
13 | import com.mckrpk.animatedprogressbar.dpToPx
14 | import com.mckrpk.animatedprogressbar.sample.databinding.ActivityMainBinding
15 | import kotlin.math.roundToInt
16 |
17 | class MainActivity : AppCompatActivity() {
18 |
19 | var style = AnimatedProgressBar.Style.SNAKE
20 | private lateinit var binding: ActivityMainBinding
21 |
22 | override fun onCreate(savedInstanceState: Bundle?) {
23 | super.onCreate(savedInstanceState)
24 | binding = ActivityMainBinding.inflate(layoutInflater)
25 | setContentView(binding.root)
26 | setSupportActionBar(binding.toolbar)
27 |
28 | binding.fab.setOnClickListener {
29 | addViewProgrammatically()
30 | }
31 |
32 | binding.mainContent.recyclerView.setHasFixedSize(true)
33 | binding.mainContent.recyclerView.adapter = MyAdapter(50)
34 | }
35 |
36 | private fun addViewProgrammatically() {
37 | val progressBar = AnimatedProgressBar(this)
38 | progressBar.setMax(100)
39 | progressBar.setProgress((Math.random() * 100).toInt())
40 | progressBar.setTrackColor(getRandomColor())
41 | progressBar.setProgressColor(getRandomColor())
42 | progressBar.setProgressTipEnabled(Math.random() < 0.5)
43 | progressBar.setProgressTipColor(getRandomColor())
44 | progressBar.setAnimDuration(500 + (Math.random() * 2000).toInt())
45 | progressBar.setProgressStyle(if (Math.random() < 0.5) AnimatedProgressBar.Style.LINE else AnimatedProgressBar.Style.SNAKE)
46 | progressBar.setLineWidth(
47 | dpToPx(3 + (Math.random() * 10).roundToInt(), this).roundToInt()
48 | )
49 |
50 | val params = LinearLayout.LayoutParams(
51 | ViewGroup.LayoutParams.MATCH_PARENT,
52 | ViewGroup.LayoutParams.WRAP_CONTENT
53 | )
54 |
55 | val marginTopBottom = dpToPx(4, this).toInt()
56 | params.setMargins(0, marginTopBottom, 0, marginTopBottom)
57 | binding.mainContent.barsContainer.addView(progressBar, params)
58 | }
59 |
60 | private fun getRandomColor(): Int {
61 | return Color.rgb(
62 | (Math.random() * 255).toInt(),
63 | (Math.random() * 255).toInt(),
64 | (Math.random() * 255).toInt()
65 | )
66 | }
67 |
68 | override fun onCreateOptionsMenu(menu: Menu): Boolean {
69 | menuInflater.inflate(R.menu.menu_main, menu)
70 | return true
71 | }
72 |
73 | override fun onOptionsItemSelected(item: MenuItem): Boolean {
74 | return when (item.itemId) {
75 | R.id.action_simple -> {
76 | style = AnimatedProgressBar.Style.LINE
77 | binding.mainContent.recyclerView.adapter?.notifyDataSetChanged()
78 | true
79 | }
80 | R.id.action_snakes -> {
81 | style = AnimatedProgressBar.Style.SNAKE
82 | binding.mainContent.recyclerView.adapter?.notifyDataSetChanged()
83 | true
84 | }
85 | else -> super.onOptionsItemSelected(item)
86 | }
87 | }
88 |
89 | inner class MyAdapter(private val itemSize: Int) :
90 | RecyclerView.Adapter() {
91 |
92 | inner class MyViewHolder(val progressBar: AnimatedProgressBar, var number: Int) :
93 | RecyclerView.ViewHolder(progressBar)
94 |
95 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyViewHolder {
96 | val animatedProgressBar = LayoutInflater.from(parent.context)
97 | .inflate(R.layout.my_progress_item, parent, false) as AnimatedProgressBar
98 | animatedProgressBar.setProgressStyle(style)
99 |
100 | return MyViewHolder(animatedProgressBar, 0)
101 | }
102 |
103 | override fun onBindViewHolder(holder: MyViewHolder, position: Int) {
104 | holder.number = position
105 | holder.progressBar.setProgressStyle(style)
106 | holder.progressBar.setProgress((Math.random() * 100).toInt())
107 | }
108 |
109 | override fun getItemCount() = itemSize
110 | }
111 | }
112 |
--------------------------------------------------------------------------------
/animatedprogressbar/src/main/java/com/mckrpk/animatedprogressbar/SnakeDrawer.kt:
--------------------------------------------------------------------------------
1 | package com.mckrpk.animatedprogressbar
2 |
3 | import android.animation.ValueAnimator
4 | import android.graphics.Canvas
5 | import android.graphics.Path
6 | import android.graphics.RectF
7 | import android.view.animation.DecelerateInterpolator
8 | import kotlin.math.*
9 |
10 | internal class SnakeDrawer(private val listener: DrawingView, private val attrs: ViewProperties) :
11 | ShapeDrawer() {
12 |
13 | private var snakePath: Path = Path()
14 | private lateinit var snakeClipPath: Path
15 | private lateinit var snakeTipRect: RectF
16 |
17 | private val snakePoints = mutableListOf()
18 | private var progressAnimator: ValueAnimator? = null
19 |
20 | private var middleY: Float = 0f
21 | private var longLine = true
22 |
23 | override fun onSizeChanged() {
24 | middleY = (attrs.drawRect.top + attrs.drawRect.bottom) / 2
25 | attrs.snakePaint.strokeWidth = attrs.lineWidth
26 |
27 | val lineTopY = attrs.drawRect.top + (attrs.drawRect.height() - attrs.lineWidth) / 2
28 | val lineBottomY = lineTopY + attrs.lineWidth
29 |
30 | snakeTipRect = RectF(attrs.drawRect.left, lineTopY, attrs.drawRect.left, lineBottomY)
31 |
32 | val trackRect = RectF(attrs.drawRect.left, lineTopY, attrs.drawRect.right, lineBottomY)
33 |
34 | snakeClipPath = Path().apply {
35 | addRoundRect(trackRect, attrs.cornerRadius, attrs.cornerRadius, Path.Direction.CW)
36 | }
37 | }
38 |
39 | override fun startAnimation(targetProgress: Float) {
40 | val angleMax = 5f * PI.toFloat()
41 | val isInverse = Math.random() < 0.5
42 | val progressFactor = min(max(ln(targetProgress + 0.2) + 1.5, 0.0), 1.0).toFloat()
43 | val amplitudeMax = ((attrs.drawRect.height() / 2) - attrs.cornerRadius) * progressFactor
44 | val targetLineWidth = targetProgress * attrs.drawRect.width()
45 | var currentDrawProgress: Float
46 |
47 | longLine = targetLineWidth > attrs.lineWidth
48 |
49 | val progressRange = if (longLine) targetLineWidth - attrs.lineWidth else targetLineWidth
50 | val xCoordStart = attrs.drawRect.left + (attrs.cornerRadius * if (longLine) 1 else -1)
51 |
52 | progressAnimator?.cancel()
53 | snakePoints.clear()
54 | snakePath.reset()
55 |
56 | if (targetProgress == 0f) {
57 | snakeTipRect = RectF(0.0f,0.0f,0.0f,0.0f)
58 | return
59 | }
60 |
61 | progressAnimator = ValueAnimator.ofFloat(0f, angleMax).apply {
62 | duration = attrs.animDuration.toLong()
63 | interpolator = DecelerateInterpolator(1f)
64 | addUpdateListener { animation ->
65 | snakePath.rewind()
66 | snakePath.moveTo(xCoordStart, middleY)
67 |
68 | val angle = animation.animatedValue as Float
69 | val animProgress = angle / angleMax
70 |
71 | snakePoints.forEachIndexed { index, mutablePoint ->
72 | val positionFactor = index.toFloat() / snakePoints.size
73 | snakePath.lineTo(
74 | mutablePoint.x,
75 | middleY + mutablePoint.y * (1 - animProgress) * positionFactor
76 | )
77 | }
78 |
79 | currentDrawProgress = animProgress * progressRange
80 |
81 | val xCoord = xCoordStart + currentDrawProgress
82 | val sineValue = sin(if (isInverse) -1 * angle else angle)
83 | val yVal = sineValue * amplitudeMax
84 | val yCoord = middleY + yVal * (1 - animProgress)
85 |
86 | snakePoints.add(MutablePoint(xCoord, yVal))
87 | snakePath.lineTo(xCoord, yCoord)
88 |
89 | snakeTipRect.top = yCoord - attrs.cornerRadius
90 | snakeTipRect.bottom = yCoord + attrs.cornerRadius
91 | snakeTipRect.left = xCoord - attrs.cornerRadius
92 | snakeTipRect.right = xCoord + attrs.cornerRadius
93 |
94 | listener.requestInvalidate()
95 | }
96 | }
97 | progressAnimator?.start()
98 |
99 | }
100 |
101 | override fun draw(canvas: Canvas) {
102 | canvas.save()
103 | if (!longLine) {
104 | canvas.clipPath(snakeClipPath)
105 | }
106 |
107 | canvas.drawPath(snakePath, attrs.snakePaint)
108 | if (attrs.progressTipEnabled) {
109 | canvas.drawOval(snakeTipRect, attrs.progressTipPaint)
110 | }
111 |
112 | canvas.restore()
113 | }
114 |
115 | override fun cancel() {
116 | progressAnimator?.cancel()
117 | }
118 |
119 |
120 | class MutablePoint(var x: Float, var y: Float)
121 | }
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/animatedprogressbar/src/main/java/com/mckrpk/animatedprogressbar/AnimatedProgressBar.kt:
--------------------------------------------------------------------------------
1 | package com.mckrpk.animatedprogressbar
2 |
3 | import android.content.Context
4 | import android.graphics.Canvas
5 | import android.graphics.RectF
6 | import android.util.AttributeSet
7 | import android.util.Log
8 | import android.view.View
9 |
10 | class AnimatedProgressBar @JvmOverloads constructor(
11 | context: Context,
12 | attrs: AttributeSet? = null,
13 | defStyleAttr: Int = 0
14 | ) : View(context, attrs, defStyleAttr), DrawingView {
15 |
16 | private var shouldStartAnimation = true
17 |
18 | private var lastDraw = System.currentTimeMillis()
19 |
20 | //Elements to draw
21 | private var trackDrawer: TrackDrawer?
22 | private var progressDrawer: ProgressDrawer? = null
23 | private var snakeDrawer: SnakeDrawer? = null
24 |
25 | private var attrs: ViewProperties
26 |
27 | init {
28 | context.theme.obtainStyledAttributes(attrs, R.styleable.AnimatedProgressBar, 0, 0).apply {
29 | try {
30 | this@AnimatedProgressBar.attrs = ViewProperties(this, context)
31 | } finally {
32 | recycle()
33 | }
34 | }
35 | trackDrawer = TrackDrawer(this, this.attrs)
36 | if (Style.SNAKE == this.attrs.progressStyle) {
37 | snakeDrawer = SnakeDrawer(this, this.attrs)
38 | } else {
39 | progressDrawer = ProgressDrawer(this, this.attrs)
40 | }
41 | }
42 |
43 | fun setProgressColor(color: Int) {
44 | attrs.progressColor = color
45 | postInvalidate()
46 | }
47 |
48 | fun setProgressTipColor(color: Int) {
49 | attrs.progressTipColor = color
50 | postInvalidate()
51 | }
52 |
53 | fun setTrackColor(color: Int) {
54 | attrs.trackColor = color
55 | postInvalidate()
56 | }
57 |
58 | fun setAnimDuration(duration: Int) {
59 | attrs.animDuration = duration
60 | postInvalidate()
61 | }
62 |
63 | fun setProgressTipEnabled(enabled: Boolean) {
64 | attrs.progressTipEnabled = enabled
65 | postInvalidate()
66 | }
67 |
68 | fun setProgressStyle(progressStyle: Style) {
69 | if (attrs.progressStyle == progressStyle) {
70 | return
71 | }
72 | attrs.progressStyle = progressStyle
73 | if (Style.SNAKE == this.attrs.progressStyle) {
74 | progressDrawer?.cancel()
75 | progressDrawer = null
76 | snakeDrawer = SnakeDrawer(this, this.attrs)
77 | } else {
78 | snakeDrawer?.cancel()
79 | snakeDrawer = null
80 | progressDrawer = ProgressDrawer(this, this.attrs)
81 | }
82 | postInvalidate()
83 | }
84 |
85 | /**
86 | * @width in pixels
87 | */
88 | fun setLineWidth(width: Int) {
89 | attrs.lineWidth = width.toFloat()
90 |
91 | trackDrawer?.onSizeChanged()
92 | progressDrawer?.onSizeChanged()
93 | snakeDrawer?.onSizeChanged()
94 | postInvalidate()
95 | }
96 |
97 | fun setProgress(progress: Int) {
98 | setProgress(progress, true)
99 | }
100 |
101 | fun setProgress(progress: Int, animate: Boolean) {
102 | attrs.progress = progress.toFloat()
103 | shouldStartAnimation = animate
104 | postInvalidate()
105 | }
106 |
107 | fun setMax(maxProgress: Int) {
108 | attrs.maxProgress = maxProgress.toFloat()
109 | }
110 |
111 | private fun startAnimation() {
112 | shouldStartAnimation = false
113 | trackDrawer?.startAnimation(attrs.getProgressNormalized())
114 | progressDrawer?.startAnimation(attrs.getProgressNormalized())
115 | snakeDrawer?.startAnimation(attrs.getProgressNormalized())
116 | }
117 |
118 | //TODO hide from outside
119 | override fun requestInvalidate() {
120 | invalidate()
121 | }
122 |
123 | override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
124 | super.onSizeChanged(w, h, oldw, oldh)
125 | val mDrawStartPosX = paddingLeft.toFloat()
126 | val mDrawEndPosX = (w - paddingRight).toFloat()
127 | val mDrawStartPosY = paddingTop.toFloat()
128 | val mDrawEndPosY = (h - paddingBottom).toFloat()
129 |
130 | attrs.drawRect = RectF(mDrawStartPosX, mDrawStartPosY, mDrawEndPosX, mDrawEndPosY)
131 | snakeDrawer?.onSizeChanged()
132 | trackDrawer?.onSizeChanged()
133 | progressDrawer?.onSizeChanged()
134 |
135 | Log.i("customView", "onSizeChanged: $oldw -> $w, $oldh -> $h")
136 | }
137 |
138 | //Method doesn't need to be overridden if we don't have particular requirements
139 | override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
140 | Log.i("customView", "onMeasure")
141 | // MeasureSpecs contain size and specs that can be obtained in the following way:
142 | // val specMode = View.MeasureSpec.getMode(widthMeasureSpec)
143 | // val specSize = View.MeasureSpec.getSize(widthMeasureSpec)
144 |
145 | val defaultHeight =
146 | context.resources.getDimensionPixelSize(R.dimen.animated_progress_bar_min_height)
147 | val minHeight = defaultHeight.coerceAtLeast((attrs.lineWidth * 3).toInt())
148 |
149 | //Remember to take paddings into account
150 | val minw = paddingLeft + suggestedMinimumWidth + paddingRight
151 | val minh = paddingTop + minHeight + paddingBottom
152 |
153 | //Call this to get final width and height with respect of measure spec
154 | val w = resolveSizeAndState(minw, widthMeasureSpec, 1)
155 | val h = resolveSizeAndState(minh, heightMeasureSpec, 0)
156 |
157 | //This call is required
158 | setMeasuredDimension(w, h)
159 | }
160 |
161 | override fun onDraw(canvas: Canvas) {
162 | super.onDraw(canvas)
163 | val time = System.currentTimeMillis() - lastDraw
164 | // Log.i("customView", "Previous draw: $time${if (time > 25) "<----------------" else ""}")
165 | if (shouldStartAnimation) {
166 | startAnimation()
167 | }
168 |
169 | lastDraw = System.currentTimeMillis()
170 |
171 | trackDrawer?.draw(canvas)
172 | snakeDrawer?.draw(canvas)
173 | progressDrawer?.draw(canvas)
174 | }
175 |
176 | enum class Style {
177 | LINE,
178 | SNAKE
179 | }
180 | }
181 |
182 | internal interface DrawingView {
183 | fun requestInvalidate()
184 | }
185 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # Copyright © 2015-2021 the original authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | ##############################################################################
20 | #
21 | # Gradle start up script for POSIX generated by Gradle.
22 | #
23 | # Important for running:
24 | #
25 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
26 | # noncompliant, but you have some other compliant shell such as ksh or
27 | # bash, then to run this script, type that shell name before the whole
28 | # command line, like:
29 | #
30 | # ksh Gradle
31 | #
32 | # Busybox and similar reduced shells will NOT work, because this script
33 | # requires all of these POSIX shell features:
34 | # * functions;
35 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
36 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»;
37 | # * compound commands having a testable exit status, especially «case»;
38 | # * various built-in commands including «command», «set», and «ulimit».
39 | #
40 | # Important for patching:
41 | #
42 | # (2) This script targets any POSIX shell, so it avoids extensions provided
43 | # by Bash, Ksh, etc; in particular arrays are avoided.
44 | #
45 | # The "traditional" practice of packing multiple parameters into a
46 | # space-separated string is a well documented source of bugs and security
47 | # problems, so this is (mostly) avoided, by progressively accumulating
48 | # options in "$@", and eventually passing that to Java.
49 | #
50 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
51 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
52 | # see the in-line comments for details.
53 | #
54 | # There are tweaks for specific operating systems such as AIX, CygWin,
55 | # Darwin, MinGW, and NonStop.
56 | #
57 | # (3) This script is generated from the Groovy template
58 | # https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
59 | # within the Gradle project.
60 | #
61 | # You can find Gradle at https://github.com/gradle/gradle/.
62 | #
63 | ##############################################################################
64 |
65 | # Attempt to set APP_HOME
66 |
67 | # Resolve links: $0 may be a link
68 | app_path=$0
69 |
70 | # Need this for daisy-chained symlinks.
71 | while
72 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
73 | [ -h "$app_path" ]
74 | do
75 | ls=$( ls -ld "$app_path" )
76 | link=${ls#*' -> '}
77 | case $link in #(
78 | /*) app_path=$link ;; #(
79 | *) app_path=$APP_HOME$link ;;
80 | esac
81 | done
82 |
83 | APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
84 |
85 | APP_NAME="Gradle"
86 | APP_BASE_NAME=${0##*/}
87 |
88 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
89 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
90 |
91 | # Use the maximum available, or set MAX_FD != -1 to use that value.
92 | MAX_FD=maximum
93 |
94 | warn () {
95 | echo "$*"
96 | } >&2
97 |
98 | die () {
99 | echo
100 | echo "$*"
101 | echo
102 | exit 1
103 | } >&2
104 |
105 | # OS specific support (must be 'true' or 'false').
106 | cygwin=false
107 | msys=false
108 | darwin=false
109 | nonstop=false
110 | case "$( uname )" in #(
111 | CYGWIN* ) cygwin=true ;; #(
112 | Darwin* ) darwin=true ;; #(
113 | MSYS* | MINGW* ) msys=true ;; #(
114 | NONSTOP* ) nonstop=true ;;
115 | esac
116 |
117 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
118 |
119 |
120 | # Determine the Java command to use to start the JVM.
121 | if [ -n "$JAVA_HOME" ] ; then
122 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
123 | # IBM's JDK on AIX uses strange locations for the executables
124 | JAVACMD=$JAVA_HOME/jre/sh/java
125 | else
126 | JAVACMD=$JAVA_HOME/bin/java
127 | fi
128 | if [ ! -x "$JAVACMD" ] ; then
129 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
130 |
131 | Please set the JAVA_HOME variable in your environment to match the
132 | location of your Java installation."
133 | fi
134 | else
135 | JAVACMD=java
136 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
137 |
138 | Please set the JAVA_HOME variable in your environment to match the
139 | location of your Java installation."
140 | fi
141 |
142 | # Increase the maximum file descriptors if we can.
143 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
144 | case $MAX_FD in #(
145 | max*)
146 | MAX_FD=$( ulimit -H -n ) ||
147 | warn "Could not query maximum file descriptor limit"
148 | esac
149 | case $MAX_FD in #(
150 | '' | soft) :;; #(
151 | *)
152 | ulimit -n "$MAX_FD" ||
153 | warn "Could not set maximum file descriptor limit to $MAX_FD"
154 | esac
155 | fi
156 |
157 | # Collect all arguments for the java command, stacking in reverse order:
158 | # * args from the command line
159 | # * the main class name
160 | # * -classpath
161 | # * -D...appname settings
162 | # * --module-path (only if needed)
163 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
164 |
165 | # For Cygwin or MSYS, switch paths to Windows format before running java
166 | if "$cygwin" || "$msys" ; then
167 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
168 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
169 |
170 | JAVACMD=$( cygpath --unix "$JAVACMD" )
171 |
172 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
173 | for arg do
174 | if
175 | case $arg in #(
176 | -*) false ;; # don't mess with options #(
177 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
178 | [ -e "$t" ] ;; #(
179 | *) false ;;
180 | esac
181 | then
182 | arg=$( cygpath --path --ignore --mixed "$arg" )
183 | fi
184 | # Roll the args list around exactly as many times as the number of
185 | # args, so each arg winds up back in the position where it started, but
186 | # possibly modified.
187 | #
188 | # NB: a `for` loop captures its iteration list before it begins, so
189 | # changing the positional parameters here affects neither the number of
190 | # iterations, nor the values presented in `arg`.
191 | shift # remove old arg
192 | set -- "$@" "$arg" # push replacement arg
193 | done
194 | fi
195 |
196 | # Collect all arguments for the java command;
197 | # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
198 | # shell script including quotes and variable substitutions, so put them in
199 | # double quotes to make sure that they get re-expanded; and
200 | # * put everything else in single quotes, so that it's not re-expanded.
201 |
202 | set -- \
203 | "-Dorg.gradle.appname=$APP_BASE_NAME" \
204 | -classpath "$CLASSPATH" \
205 | org.gradle.wrapper.GradleWrapperMain \
206 | "$@"
207 |
208 | # Use "xargs" to parse quoted args.
209 | #
210 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed.
211 | #
212 | # In Bash we could simply go:
213 | #
214 | # readarray ARGS < <( xargs -n1 <<<"$var" ) &&
215 | # set -- "${ARGS[@]}" "$@"
216 | #
217 | # but POSIX shell has neither arrays nor command substitution, so instead we
218 | # post-process each arg (as a line of input to sed) to backslash-escape any
219 | # character that might be a shell metacharacter, then use eval to reverse
220 | # that process (while maintaining the separation between arguments), and wrap
221 | # the whole thing up as a single "set" statement.
222 | #
223 | # This will of course break if any of these variables contains a newline or
224 | # an unmatched quote.
225 | #
226 |
227 | eval "set -- $(
228 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
229 | xargs -n1 |
230 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
231 | tr '\n' ' '
232 | )" '"$@"'
233 |
234 | exec "$JAVACMD" "$@"
235 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/.idea/other.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 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
254 |
255 |
256 |
257 |
258 |
259 |
260 |
261 |
262 |
263 |
264 |
265 |
266 |
267 |
268 |
269 |
270 |
271 |
272 |
273 |
274 |
275 |
276 |
277 |
278 |
279 |
280 |
281 |
282 |
283 |
284 |
285 |
286 |
287 |
288 |
289 |
290 |
291 |
292 |
293 |
294 |
295 |
296 |
297 |
298 |
299 |
300 |
301 |
302 |
303 |
304 |
305 |
306 |
307 |
308 |
309 |
310 |
311 |
312 |
313 |
314 |
315 |
316 |
317 |
318 |
--------------------------------------------------------------------------------