Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Rounded Bar #58

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ You can copy the ProgressWheel.java (in the library module) and the attrs.xml co

## Usage

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

```xml
<com.pnikosis.materialishprogress.ProgressWheel
Expand Down
9 changes: 3 additions & 6 deletions library/build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 22
buildToolsVersion "21.1.2"
compileSdkVersion 29

defaultConfig {
minSdkVersion 9
targetSdkVersion 22
targetSdkVersion 29
versionCode 5
versionName "1.4"
versionName "1.8"
}
buildTypes {
release {
Expand All @@ -21,5 +20,3 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}

apply from: '../maven_push.gradle'
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ public class ProgressWheel extends View {
private long lastTimeAnimated = 0;

private boolean linearProgress;

private boolean barRounded;

private float mProgress = 0.0f;
private float mTargetProgress = 0.0f;
Expand Down Expand Up @@ -175,6 +177,10 @@ private void setupPaints() {
barPaint.setAntiAlias(true);
barPaint.setStyle(Style.STROKE);
barPaint.setStrokeWidth(barWidth);

if(barRounded){
barPaint.setStrokeCap(Paint.Cap.ROUND);
}

rimPaint.setColor(rimColor);
rimPaint.setAntiAlias(true);
Expand Down Expand Up @@ -243,6 +249,8 @@ private void parseAttributes(TypedArray a) {
barColor = a.getColor(R.styleable.ProgressWheel_matProg_barColor, barColor);

rimColor = a.getColor(R.styleable.ProgressWheel_matProg_rimColor, rimColor);

barRounded = a.getBoolean(R.styleable.ProgressWheel_matProg_barRounded, false);

linearProgress = a.getBoolean(R.styleable.ProgressWheel_matProg_linearProgress, false);

Expand Down Expand Up @@ -681,6 +689,22 @@ public void setRimWidth(int rimWidth) {
invalidate();
}
}

/**
* @return the current rounded status of the bar
*/
public boolean getBarRounded(){
return this.barRounded;
}

/**
* Sets the rounded status of the bar
*
* @param barRounded the rounded status
*/
public void setBarRounded(boolean barRounded){
this.barRounded = barRounded;
}

public interface ProgressCallback {
/**
Expand Down
3 changes: 2 additions & 1 deletion library/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<attr name="matProg_fillRadius" format="boolean" />
<attr name="matProg_barWidth" format="dimension" />
<attr name="matProg_linearProgress" format="boolean" />
<attr name="matProg_barRounded" format="boolean" />
</declare-styleable>

</resources>
</resources>