Provides download button progress view for android
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.idea Initial commit Jan 5, 2018
gradle/wrapper Initial commit Jan 5, 2018
library fix: issue #2 Attribute Conflict with AndroidX Upgrade Jan 24, 2019
sample fix: issue #2 Attribute Conflict with AndroidX Upgrade Jan 24, 2019
screenshot Update README Jan 13, 2018
.gitignore Initial commit Jan 5, 2018
LICENSE Create LICENSE Mar 25, 2018
README.md Update readme Jan 24, 2019
build.gradle Initial commit Jan 5, 2018
gradle.properties Initial commit Jan 5, 2018
gradlew Initial commit Jan 5, 2018
gradlew.bat Initial commit Jan 5, 2018
settings.gradle Initial commit Jan 5, 2018

README.md

AndroidButtonProgress

Android Arsenal

This is a combination of button and progress bar. There are 4 states in this view first Idle, Indeterminate, Determinate and Finish. it makes you easy to manage download button state in your app ui.

In a download case you can use this as.

  • 1st show download button to the user
  • 2nd show indeterminate progress bar, it tells the user that the download is connecting.
  • 3rd show determinate progress bar, which tells the user that the download is progressing
  • 4th show finish button/icon

Demo

demo

Usage

Use jitpack

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

Gradle

dependencies {
        implementation 'com.github.abdularis:androidbuttonprogress:1.0.2'
}

Please always use same width and height for this button progress view

<com.github.abdularis.buttonprogress.DownloadButtonProgress
	android:layout_width="45dp"
	android:layout_height="45dp"/>

sc1

You can also

<com.github.abdularis.buttonprogress.DownloadButtonProgress
	android:layout_width="72dp"
	android:layout_height="72dp"
	app:progressIndeterminateSweepAngle="1"
	app:state="INDETERMINATE"/>

demo1

Use custom drawable for every state

<com.github.abdularis.buttonprogress.DownloadButtonProgress
	android:id="@+id/button_progress_2"
	android:layout_width="64dp"
	android:layout_height="64dp"
	android:layout_marginTop="20dp"
	app:idleIconDrawable="@drawable/ic_download"
	app:idleBackgroundDrawable="@drawable/bg_button_progress"
	app:cancelIconDrawable="@drawable/ic_cancel"
	app:indeterminateBackgroundDrawable="@drawable/bg_button_progress"
	app:progressIndeterminateColor="#828282"
	app:determinateBackgroundDrawable="@drawable/bg_button_progress"
	app:progressDeterminateColor="#ef2241"
	app:finishIconDrawable="@drawable/ic_finish"
	app:finishBackgroundDrawable="@drawable/bg_button_progress"/>

sc1

Note: you can use DownloadButtonProgress as upload button too just replace the idle download icon with upload icon! :)

Click listener

DownloadButtonProgress btn = findViewById(R.id.button_progress_id);

btn.addOnClickListener(new DownloadButtonProgress.OnClickListener() {
	@Override
	public void onIdleButtonClick(View view) {
		// called when download button/icon is clicked
	}

	@Override
	public void onCancelButtonClick(View view) {
		// called when cancel button/icon is clicked
	}

	@Override
	public void onFinishButtonClick(View view) {
		// called when finish button/icon is clicked
	}
});

Attributes

attrs for DownloadButtonProgress

<declare-styleable name="DownloadButtonProgress">
	<attr name="state" format="enum">
		<enum name="IDLE" value="1"/>
		<enum name="INDETERMINATE" value="2"/>
		<enum name="DETERMINATE" value="3"/>
		<enum name="FINISHED" value="4"/>			
	</attr>
	<attr name="cancelable" format="boolean"/>
	<attr name="hideOnFinish" format="boolean"/>
	<attr name="progressIndeterminateSweepAngle" format="integer"/>

	<attr name="idleBackgroundColor" format="color"/>
	<attr name="finishBackgroundColor" format="color"/>
	<attr name="indeterminateBackgroundColor" format="color"/>
	<attr name="determinateBackgroundColor" format="color"/>

	<attr name="idleBackgroundDrawable" format="reference"/>
	<attr name="finishBackgroundDrawable" format="reference"/>
	<attr name="indeterminateBackgroundDrawable" format="reference"/>
	<attr name="determinateBackgroundDrawable" format="reference"/>

	<attr name="progress" format="integer"/>
	<attr name="maxProgress" format="integer"/>
	<attr name="progressWidth" format="dimension"/>
	<attr name="progressMargin" format="dimension"/>
	<attr name="progressDeterminateColor" format="color"/>
	<attr name="progressIndeterminateColor" format="color"/>

	<attr name="idleIconDrawable" format="reference"/>
	<attr name="idleIconWidth" format="dimension"/>
	<attr name="idleIconHeight" format="dimension"/>

	<attr name="cancelIconDrawable" format="reference"/>
	<attr name="cancelIconWidth" format="dimension"/>
	<attr name="cancelIconHeight" format="dimension"/>

	<attr name="finishIconDrawable" format="reference"/>
	<attr name="finishIconWidth" format="dimension"/>
	<attr name="finishIconHeight" format="dimension"/>
</declare-styleable>

License

Apache License 2.0