An easily customisable ProgressDialog Library for Android API 24 and above provided by Techiness Overloaded (Developer name: Arunprasadh C). Quite Useful for showing progress during any operation. Has support for both Determinate and Indeterminate ProgressBar. Also supports Dark Theme. Has javadoc Documentation for all public Constructors, Attributes and Methods, making it easy to learn about the Library from Android Studio IDE.
Note
It is highly recommended to use the Latest Release Version of the Library and it is strongly recommended NOT to use any Pre-release versions of the library as they are used for testing out changes and are not production-ready. It is readily observable that Pre-release versions have "a" or "rc" in their version code (Example: Version 1.4.0a4 or 1.4.4-rc1). It is strictly recommended not to use version 1.4.2 or 1.5.0 as the build artifacts are not properly published. You can instead prefer the latest version (1.5.1).
Usage examples available at Usage Examples
Java Documentation of Class and Methods available at Java Documentation of Library
Kotlin Documentation of Class and Methods available at Kotlin Documentation of Library
You can find the Entire Change Log at ProgressDialog Library Change Log
See the Contributing Guide to learn more about Contributing to this Project.
- Highly Customisable.
- Has support for Dark Theme.
- Has support for AutoTheming from Android 11 (API Level 30).
- Can be set in both Determinate and Indeterminate Mode.
- Has support for Time Tracking in Determinate Mode.
- Has support for Negative Button, Title, and ProgressView.
- Desgined for usage in both Java and Kotlin Android Projects.
- Clear Documentation is available.
- Added Time Tracking feature for Determinate Mode ProgressDialog as suggested by @vzool in Issue #13. Time tracking can be enabled by passing
true
to the first parameter ofsetOnShowListener
method. The time elapsed will be updated until theprogress
reachesmaxValue
.
- Fixed an Issue where unwanted views got displayed on the ProgressDialog, as pointed out by @soenkegissel and @mg2000 in Issue #16.
- Merged Pull Requests #11, #12, #14, #15, #17 given by @dependabot to update Material Version, Gradle Version, Gradle Build Action Version, ConstraintLayout Version and AppCompat Version.
You can find the Entire Change Log at ProgressDialog Library Change Log
Make Sure that you are using JDK Version 11
Include the following code in your Project-level Gradle Build file at the end of repositories:
Gradle Groovy DSL (If you have build.gradle file):
allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}
Gradle Kotlin DSL (If you have build.gradle.kts file):
allprojects {
repositories {
maven { url = uri("https://jitpack.io") }
}
}
Now, include the following dependency in your App-level Gradle Build file:
Note
Current latest version is 1.5.1
Gradle Groovy DSL (If you have build.gradle file):
dependencies {
implementation 'com.github.techinessoverloaded:progress-dialog:1.5.1'
}
Gradle Kotlin DSL (If you have build.gradle.kts file):
dependencies {
implementation("com.github.techinessoverloaded:progress-dialog:1.5.1")
}
Or you can also define the version as a String like this(You can copy either this code or the above one):
Gradle Groovy DSL (If you have build.gradle file):
dependencies {
def latest-version = "1.5.1"
implementation "com.github.techinessoverloaded:progress-dialog:$latest-version"
}
Gradle Kotlin DSL (If you have build.gradle.kts file):
dependencies {
val latest-version = "1.5.1"
implementation("com.github.techinessoverloaded:progress-dialog:$latest-version")
}
Now import ProgressDialog class in your Activity/Fragment:
import com.techiness.progressdialoglibrary.ProgressDialog;
Note
Theme can be changed after Instantiation using setTheme(int themeConstant)
method.
Important
If you want to Instantiate ProgressDialog
Class in a Fragment, use requireContext()
method instead of this
keyword for passing Context
object. Similarly, for Instantiating ProgressDialog
Class in Inner Classes, use YourActivity.this
in Java or this@YourActivity
in Kotlin instead of simple this
keyword for passing Context
object.
ProgressDialog progressDialog = new ProgressDialog(this); //same as new ProgressDialog(this, ProgressDialog.THEME_LIGHT);
val progressDialog = ProgressDialog(this) //same as ProgressDialog(this, ProgressDialog.THEME_LIGHT)
ProgressDialog progressDialog = new ProgressDialog(this, ProgressDialog.THEME_DARK);
val progressDialog = ProgressDialog(this, ProgressDialog.THEME_DARK)
Note
Mode can be changed as and when necessary using in-built methods.
ProgressDialog progressDialog = new ProgressDialog(ProgressDialog.MODE_DETERMINATE,this); // for instantiating with Determinate mode
val progressDialog = ProgressDialog(ProgressDialog.MODE_DETERMINATE,this) // for instantiating with Determinate mode
ProgressDialog progressDialog = new ProgressDialog(ProgressDialog.MODE_DETERMINATE,this,ProgressDialog.THEME_DARK);
val progressDialog = ProgressDialog(ProgressDialog.MODE_DETERMINATE,this,ProgressDialog.THEME_DARK)
Note: These examples are for simple illustration of ProgressDialog Library. For completely knowing about the Library, refer to the JavaDoc/KDoc Documentation of the Library through Android Studio.
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) //Check if Android API Level is greater than or equal to 30
{
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_FOLLOW_SYSTEM); //This is optional. This will enable Android's Autotheming for the entire App
ProgressDialog progressDialog = new ProgressDialog(this,ProgressDialog.THEME_FOLLOW_SYSTEM); // Enables AutoTheming for the ProgressDialog instance.
}
else //Autotheming not compatible
{
ProgressDialog progressDialog = new ProgressDialog(this,ProgressDialog.THEME_DARK); // or any other constructors mentioned above
}
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) //Check if Android API Level is greater than or equal to 30
{
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_FOLLOW_SYSTEM) //This is optional. This will enable Android's Autotheming for the entire App
val progressDialog = ProgressDialog(this,ProgressDialog.THEME_FOLLOW_SYSTEM) // Enables AutoTheming for the ProgressDialog instance.
}
else //Autotheming not compatible
{
val progressDialog = ProgressDialog(this,ProgressDialog.THEME_DARK) // or any other constructors mentioned above
}
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) //Check if Android API Level is greater than or equal to 30
{
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_FOLLOW_SYSTEM); //This is optional. This will enable Android's Autotheming for the entire App
progressDialog.setTheme(ProgressDialog.THEME_FOLLOW_SYSTEM); // Enables AutoTheming for the ProgressDialog instance.
}
else //Autotheming not compatible
{
progressDialog.setTheme(ProgressDialog.THEME_DARK); // or ProgressDialog.THEME_LIGHT
}
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) //Check if Android API Level is greater than or equal to 30
{
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_FOLLOW_SYSTEM) //This is optional. This will enable Android's Autotheming for the entire App
progressDialog.theme = ProgressDialog.THEME_FOLLOW_SYSTEM) // Enables AutoTheming for the ProgressDialog instance.
}
else //Autotheming not compatible
{
progressDialog.theme = ProgressDialog.THEME_DARK // or ProgressDialog.THEME_LIGHT
}
ProgressDialog progressDialog = new ProgressDialog(this);
progressDialog.show();
val progressDialog = ProgressDialog(this)
progressDialog.show()
progressDialog.setTheme(ProgressDialog.THEME_DARK);
progressDialog.show();
with(progressDialog)
{
theme = ProgressDialog.THEME_DARK
show()
}
Determinate ProgressDialog without Title, without ProgressView, with Secondary Progress (Light Theme)
progressDialog.setTheme(ProgressDialog.THEME_LIGHT);
progressDialog.setMode(ProgressDialog.MODE_DETERMINATE);
progressDialog.setProgress(65);
progressDialog.setSecondaryProgress(80);
progressDialog.hideProgressText();
progressDialog.show();
with(progressDialog)
{
theme = ProgressDialog.THEME_LIGHT
mode = ProgressDialog.MODE_DETERMINATE
progress = 65
secondaryProgress = 80
hideProgressText()
show()
}
Determinate ProgressDialog without Title, without ProgressView, with Secondary Progress (Dark Theme)
progressDialog.setTheme(ProgressDialog.THEME_DARK);
progressDialog.setMode(ProgressDialog.MODE_DETERMINATE);
progressDialog.setProgress(65);
progressDialog.setSecondaryProgress(80);
progressDialog.hideProgressText();
progressDialog.show();
with(progressDialog)
{
theme = ProgressDialog.THEME_DARK
mode = ProgressDialog.MODE_DETERMINATE
progress = 65
secondaryProgress = 80
hideProgressText()
show()
}
progressDialog.setTheme(ProgressDialog.THEME_LIGHT);
progressDialog.setMode(ProgressDialog.MODE_DETERMINATE);
progressDialog.setProgress(65);
progressDialog.show();
with(progressDialog)
{
theme = ProgressDialog.THEME_LIGHT
mode = ProgressDialog.MODE_DETERMINATE
setprogress = 65
show()
}
progressDialog.setTheme(ProgressDialog.THEME_DARK);
progressDialog.setMode(ProgressDialog.MODE_DETERMINATE);
progressDialog.setProgress(65);
progressDialog.show();
with(progressDialog)
{
theme = ProgressDialog.THEME_DARK
mode = ProgressDialog.MODE_DETERMINATE
progress = 65
show()
}
progressDialog.setTheme(ProgressDialog.THEME_LIGHT);
progressDialog.setMode(ProgressDialog.MODE_INDETERMINATE);
progressDialog.setTitle("Indeterminate");
progressDialog.show();
with(progressDialog)
{
theme = ProgressDialog.THEME_LIGHT
mode = ProgressDialog.MODE_INDETERMINATE
setTitle("Indeterminate")
show()
}
progressDialog.setTheme(ProgressDialog.THEME_DARK);
progressDialog.setMode(ProgressDialog.MODE_INDETERMINATE);
progressDialog.setTitle("Indeterminate");
progressDialog.show();
with(progressDialog)
{
theme = ProgressDialog.THEME_DARK
mode = ProgressDialog.MODE_INDETERMINATE
setTitle("Indeterminate")
show()
}
Determinate ProgressDialog with Title, Secondary Progress and ProgressView as Fraction (Light Theme)
progressDialog.setTheme(ProgressDialog.THEME_LIGHT);
progressDialog.setMode(ProgressDialog.MODE_DETERMINATE);
progressDialog.setTitle("Determinate");
progressDialog.setProgress(65);
progressDialog.setSecondaryProgress(80);
progressDialog.showProgressTextAsFraction(true);
progressDialog.show();
with(progressDialog)
{
theme = ProgressDialog.THEME_LIGHT
mode = ProgressDialog.MODE_DETERMINATE
setTitle("Determinate")
progress = 65
secondaryProgress = 80
showProgressTextAsFraction(true)
show()
}
progressDialog.setTheme(ProgressDialog.THEME_DARK);
progressDialog.setMode(ProgressDialog.MODE_DETERMINATE);
progressDialog.setTitle("Determinate");
progressDialog.setProgress(65);
progressDialog.setSecondaryProgress(80);
progressDialog.showProgressTextAsFraction(true);
progressDialog.show();
with(progressDialog)
{
theme = ProgressDialog.THEME_DARK
mode = ProgressDialog.MODE_DETERMINATE
setTitle("Determinate")
progress = 65
secondaryProgress = 80
showProgressTextAsFraction(true)
show()
}
Indeterminate ProgressDialog with NegativeButton and Custom OnClickListener for NegativeButton (Light Theme)
Note
Enabling NegativeButton will automatically enable TitleView.
progressDialog.setTheme(ProgressDialog.THEME_LIGHT);
progressDialog.setMode(ProgressDialog.MODE_INDETERMINATE);
progressDialog.setNegativeButton("Dismiss","Indeterminate",v -> {
Toast.makeText(this,"Custom OnClickListener for Indeterminate",Toast.LENGTH_LONG).show();
progressDialog.dismiss();
});
progressDialog.show();
with(progressDialog)
{
theme = ProgressDialog.THEME_LIGHT
mode = ProgressDialog.MODE_INDETERMINATE
setNegativeButton("Dismiss", "Determinate") {
Toast.makeText(this@KotlinActivity, "Custom OnClickListener for Indeterminate", Toast.LENGTH_LONG).show()
dismiss()
}
show()
}
Indeterminate ProgressDialog with NegativeButton and Custom OnClickListener for NegativeButton (Dark Theme)
Note
Enabling NegativeButton will automatically enable TitleView.
progressDialog.setTheme(ProgressDialog.THEME_DARK);
progressDialog.setMode(ProgressDialog.MODE_INDETERMINATE);
progressDialog.setNegativeButton("Dismiss","Indeterminate",v -> {
Toast.makeText(this,"Custom OnClickListener for Indeterminate",Toast.LENGTH_LONG).show();
progressDialog.dismiss();
});
progressDialog.show();
with(progressDialog)
{
theme = ProgressDialog.THEME_DARK
mode = ProgressDialog.MODE_INDETERMINATE
setNegativeButton("Dismiss", "Determinate") {
Toast.makeText(this@KotlinActivity, "Custom OnClickListener for Indeterminate", Toast.LENGTH_LONG).show()
dismiss()
}
show()
}
Determinate ProgressDialog with NegativeButton and Default OnClickListener for NegativeButton (Light Theme)
Note
Enabling NegativeButton will automatically enable TitleView.
progressDialog.setTheme(ProgressDialog.THEME_LIGHT);
progressDialog.setMode(ProgressDialog.MODE_DETERMINATE);
progressDialog.setProgress(54);
progressDialog.showProgressTextAsFraction(true);
progressDialog.setNegativeButton("Cancel","Determinate",null);
progressDialog.show();
with(progressDialog)
{
theme = ProgressDialog.THEME_LIGHT
mode = ProgressDialog.MODE_DETERMINATE
progress = 54
showProgressTextAsFraction(true)
setNegativeButton("Cancel","Determinate",null)
show()
}
Determinate ProgressDialog with NegativeButton and Default OnClickListener for NegativeButton (Dark Theme)
progressDialog.setTheme(ProgressDialog.THEME_DARK);
progressDialog.setMode(ProgressDialog.MODE_DETERMINATE);
progressDialog.setProgress(54);
progressDialog.showProgressTextAsFraction(true);
progressDialog.setNegativeButton("Cancel","Determinate",null);
progressDialog.show();
with(progressDialog)
{
theme = ProgressDialog.THEME_DARK
mode = ProgressDialog.MODE_DETERMINATE
progress = 54
showProgressTextAsFraction(true)
setNegativeButton("Cancel","Determinate",null)
show()
}