Skip to content

TutorialsAndroid/progressx

Repository files navigation

ProgressX Maven Central API Known Vulnerabilities License

A material style progress wheel that you can integrate into your app

Library available at JitPack.io and MavenCentral

Latest version of this library is migrated to androidx

And Don't Forget To Follow Me On Instagram

Follow me on instagram to stay up-to-date https://instagram.com/coderx09

Sample Screen

Download

Upgrade to maven central as newer versions are released on maven

Step 1. Add it in your root build.gradle at the end of repositories:

allprojects {
	repositories {
		...
		maven { url 'https://jitpack.io' }
	}
}

Step 2. Add the dependency (Recommend to use maven instead of jitpack)

dependencies {
        implementation 'com.github.TutorialsAndroid:progressx:v7.0.5'
}

Download Maven Central

Step 1. Add it in your root build.gradle at the end of repositories:

allprojects {
    repositories {
        //...
        mavenCentral()
    }
}

Step 2. Add the dependency

dependencies {
    implementation 'io.github.tutorialsandroid:progressx:7.0.5'
}

⚠️ Important: compileSdk Requirement

Starting from the latest versions of ProgressX, this library is built with the latest Android SDK.

If you are using:

implementation 'io.github.tutorialsandroid:progressx:7.0.5'

your app must compile against Android API 37 or higher.

Required configuration

In your app-level build.gradle, make sure your compileSdk is set to 37 or higher:

android {
    compileSdk 37

    defaultConfig {
        minSdk 23
        targetSdk 36
    }
}

For Kotlin DSL:

android {
    compileSdk = 37

    defaultConfig {
        minSdk = 23
        targetSdk = 36
    }
}

Why is this required?

If your project is using an older compileSdk, for example:

compileSdk 36

you may see an error like this:

Dependency 'io.github.tutorialsandroid:progressx:7.0.5' requires libraries and applications
that depend on it to compile against version 37 or later of the Android APIs.

:app is currently compiled against android-36.1.

This happens because the latest version of ProgressX is compiled with Android API 37.

Important note

Updating compileSdk is safe and different from updating targetSdk or minSdk.

  • compileSdk allows your app to compile with the latest Android APIs.
  • targetSdk controls which Android runtime behavior changes your app opts into.
  • minSdk controls the minimum Android version your app can be installed on.

So you can update only compileSdk to 37 while keeping your existing targetSdk and minSdk.

Solution

Update your app-level Gradle file:

android {
    compileSdk 37
}

Then sync the project again in Android Studio.

If Android Studio asks to install Android API 37, install it from:

Tools > SDK Manager > Android SDK

After updating compileSdk, the AAR metadata error should be resolved.

Usage

You can create your own progress wheel in xml like this (remeber to add xmlns:wheel="http://schemas.android.com/apk/res-auto"):

<com.developer.progressx.ProgressWheel
        android:id="@+id/progress_wheel"
        android:layout_width="80dp"
        android:layout_height="80dp"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        wheel:matProg_barColor="#5588FF"
        wheel:matProg_progressIndeterminate="true" />

Or in code:

ProgressWheel wheel = new ProgressWheel(context);
wheel.setBarColor(Color.BLUE);
...

Callback

Use setCallback(ProgressCallback) to assign a callback that will be called each time the progress changes. This way you can update a value on the progress alongside with the progress animation, or execute an action once the progress reaches a certain value. in the indeterminatge wheel, the callback is called with a value of -1.0f every time the animation cycle finishes (when the wheel shrinks back to its smaller size).

Indeterminate wheel

For making the wheel indeterminate, just call the spin() method. If you set a progress value, the wheel will stop spinning.

You have two methods for setting the progress:

progressWheel.setProgress(float value)

Sets the value, and the wheel will smoothly animate to that value. The speed of the animation is defined by the spinSpeed (can be set with setSpinSpeed, which number is the number of full turns per second)

progressWheel.setInstantProgress(float value)

Sets the value, and the wheel will instantly move to that value.

You can change other wheel properties such as the progress bar color, the wheel's background or the wheel's size and width.

Fill radius

In case you want the spinning wheel to fill the whole layout instead of having a fixed size, you can use matProg_fillRadius.

<com.developer.progressx.ProgressWheel
        android:id="@+id/progress_wheel"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        wheel:matProg_barColor="#5588FF"
        wheel:matProg_progressIndeterminate="true"
        wheel:matProg_fillRadius="true" />

This way, the wheel will be as big as the parent layout. Be warned though, if the parentlayout is not square, the wheel will become an oval since the wheel will always adapt to fill the parent view.

Other options

In the xml definition, besides the fillRadius property, you can set:

  • matProg_progressIndeterminate: boolean, if you want the wheel to spin right away.
  • matProg_barColor: color, sets the small bar's color (the spinning bar in the indeterminate wheel, or the progress bar)
  • matProg_barWidth: dimension, the width of the spinning bar
  • matProg_rimColor: color, the wheel's border color
  • matProg_rimWidth: dimension, the wheel's width (not the bar)
  • matProg_spinSpeed: float, the base speed for the bar in indeterminate mode, and the animation speed when setting a value on progress. The speed is in full turns per second, this means that if you set speed as 1.0, means that the bar will take one second to do a full turn.
  • matProg_barSpinCycleTime: integer, the time in milliseconds the indeterminate progress animation takes to complete (extending and shrinking the bar while spinning)
  • matProg_circleRadius: dimension, the radius of the progress wheel, it will be ignored if you set fillRadius to true
  • matProg_fillRadius: boolean, set to true if you want the progress wheel to fill the whole layout
  • matProg_linearProgress: boolean, set to true if you want a linear animation on the determinate progress (instead of the interpolated default one).
Copyright 2019 ProgressX

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Packages

 
 
 

Contributors

Languages