Skip to content

Commit

Permalink
Added rounded progress
Browse files Browse the repository at this point in the history
Gradle update
Version bump
  • Loading branch information
GuilhE committed Apr 27, 2019
1 parent f5fed02 commit b11c695
Show file tree
Hide file tree
Showing 12 changed files with 52 additions and 18 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
A fancy CircularProgressView.

#### Version 1.x
- **Apr, 2019** - Added rounded progress
- **Jun, 2018** - Added reverse progress
- **May, 2018** - Added _"multiple-arc-progress"_
- **February, 2018** - Background alpha enable/disable
Expand Down Expand Up @@ -37,6 +38,7 @@ Attributes accepted in xml:
<attr name="progress" format="integer"/>
<attr name="progressBarThickness" format="dimension"/>
<attr name="progressBarColor" format="color"/>
<attr name="progressBarRounded" format="boolean"/>
<attr name="backgroundColor" format="color"/>
<attr name="backgroundAlphaEnabled" format="boolean"/>
<attr name="reverse" format="boolean"/>
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.android.tools.build:gradle:3.4.0'
}
}

Expand Down
2 changes: 1 addition & 1 deletion circular-progress-view/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ android {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.3.2"
versionName "1.3.3"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public class CircularProgressView extends View {
private int mBackgroundColor;
private boolean mBackgroundAlphaEnabled;
private boolean mReverseEnabled;
private boolean mProgressRounded;
private List<Float> mValuesToDrawList = new ArrayList<>();

private RectF mProgressRectF;
Expand Down Expand Up @@ -123,6 +124,7 @@ private void init(Context context, AttributeSet attrs) {
mProgress = typedArray.getFloat(R.styleable.CircularProgressView_progress, 0);
mProgressStrokeThickness = typedArray.getDimension(R.styleable.CircularProgressView_progressBarThickness, mDefaultStrokeThickness);
mProgressColor = typedArray.getInt(R.styleable.CircularProgressView_progressBarColor, DEFAULT_PROGRESS_COLOR);
mProgressRounded = typedArray.getBoolean(R.styleable.CircularProgressView_progressBarRounded, false);
mBackgroundColor = typedArray.getInt(R.styleable.CircularProgressView_backgroundColor, mProgressColor);
mBackgroundAlphaEnabled = typedArray.getBoolean(R.styleable.CircularProgressView_backgroundAlphaEnabled, true);
mReverseEnabled = typedArray.getBoolean(R.styleable.CircularProgressView_reverse, false);
Expand All @@ -138,11 +140,14 @@ private void init(Context context, AttributeSet attrs) {
mBackgroundColor = mProgressColor;
mBackgroundAlphaEnabled = true;
mReverseEnabled = false;
mProgressRounded = false;
}

resetBackgroundPaint();
mProgressPaint.setColor(mProgressColor);
mProgressPaint.setStrokeCap(mProgressRounded ? Paint.Cap.ROUND : Paint.Cap.SQUARE);
mShadowPaint.setColor(adjustAlpha(Color.BLACK, 0.2f));
mShadowPaint.setStrokeCap(mProgressPaint.getStrokeCap());
setThickness(mProgressStrokeThickness, false);
}

Expand Down Expand Up @@ -263,6 +268,17 @@ public boolean isReverseEnabled() {
return mReverseEnabled;
}

public boolean isProgressRounded() {
return mProgressRounded;
}

public void setProgressRounded(boolean enabled) {
mProgressRounded = enabled;
mProgressPaint.setStrokeCap(mProgressRounded ? Paint.Cap.ROUND : Paint.Cap.SQUARE);
mShadowPaint.setStrokeCap(mProgressPaint.getStrokeCap());
invalidate();
}

/**
* You can simulate the use of this method with by calling {@link #setBackgroundColor(int)} with ContextCompat:
* setBackgroundColor(ContextCompat.getColor(resId));
Expand Down Expand Up @@ -341,14 +357,15 @@ public void setProgress(float progress, boolean animate, long duration) {
}

/**
* This method will activate the "multiple-arc-progress" and disable the progress thumb and background.
* This method will activate the "multiple-arc-progress" and disable the progress thumb, progress round and background.
* This method disables the "single-arc-progress".
*
* @param progressList - list containing all the progress "step-per-arc". Their sum most be less or equal to {@link #getMax()}.
* @param progressColorList - list containing the progress "step-per-arc" color. If progressColorList.size() is less than progressList.size(), Color.TRANSPARENT will be used for the missing colors.
* @throws RuntimeException - will be thrown if progress entities sum is greater than max value.
*/
public void setProgress(@NonNull List<Float> progressList, @NonNull List<Integer> progressColorList) throws RuntimeException {
setProgressRounded(false);
mProgress = mProgressListTotal = 0;
for (float value : progressList) {
mProgressListTotal += value;
Expand Down
1 change: 1 addition & 0 deletions circular-progress-view/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<attr name="progress" format="integer"/>
<attr name="progressBarThickness" format="dimension"/>
<attr name="progressBarColor" format="color"/>
<attr name="progressBarRounded" format="boolean"/>
<attr name="backgroundColor" format="color"/>
<attr name="backgroundAlphaEnabled" format="boolean"/>
<attr name="reverse" format="boolean"/>
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ bintrayName = circular-progress-view

libraryName = CircularProgressView
libraryDescription = A fancy CircularProgressView
libraryVersion = 1.3.2
libraryVersion = 1.3.3

siteUrl = https://github.com/GuilhE/android-circular-progress-view
gitUrl = https://github.com/GuilhE/android-circular-progress-view.git
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Fri Nov 02 01:07:39 WET 2018
#Sat Apr 27 03:16:37 WEST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
9 changes: 3 additions & 6 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "com.github.guilhe.cicularprogressview.sample"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 4
versionName "1.3.1"
versionCode 5
versionName "1.3.3"
}

dataBinding {
Expand Down Expand Up @@ -37,8 +37,5 @@ dependencies {
implementation project(':circular-progress-view')
implementation "com.android.support:appcompat-v7:$rootProject.supportLibraryVersion"
implementation "com.android.support:design:$rootProject.supportLibraryVersion"
implementation 'com.android.support.constraint:constraint-layout:1.1.0'

// https://issuetracker.google.com/issues/64909326
// implementation "com.android.support:support-v4:$rootProject.supportLibraryVersion"
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
}
8 changes: 4 additions & 4 deletions sample/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.github.guilhe.circularprogressview_sample">
xmlns:tools="http://schemas.android.com/tools"
package="com.github.guilhe.circularprogressview.sample">

<application android:allowBackup="true"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher"
android:supportsRtl="true"
android:theme="@style/AppTheme">
android:theme="@style/AppTheme" tools:ignore="GoogleAppIndexingWarning">

<activity
android:name="SampleActivity">
<activity android:name="sample.SampleActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package sample;

import android.databinding.DataBindingUtil;
import android.graphics.Color;
import android.os.Bundle;
Expand All @@ -6,8 +8,8 @@
import android.widget.SeekBar;
import android.widget.Toast;
import com.github.guilhe.views.CircularProgressView;
import com.github.guilhe.circularprogressview_sample.R;
import com.github.guilhe.circularprogressview_sample.databinding.ActivitySampleEditorBinding;
import com.github.guilhe.circularprogressview.sample.R;
import com.github.guilhe.circularprogressview.sample.databinding.ActivitySampleEditorBinding;

import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -39,6 +41,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
mBinding.bgGSeekBar.setOnSeekBarChangeListener(this);
mBinding.bgBSeekBar.setOnSeekBarChangeListener(this);

mBinding.roundedSwitch.setOnCheckedChangeListener((compoundButton, checked) -> mBinding.sampleCircularProgressView.setProgressRounded(checked));
mBinding.shadowSwitch.setOnCheckedChangeListener((compoundButton, checked) -> mBinding.sampleCircularProgressView.setShadowEnabled(checked));
mBinding.thumbSwitch.setOnCheckedChangeListener((compoundButton, checked) -> mBinding.sampleCircularProgressView.setProgressThumbEnabled(checked));
mBinding.reverseSwitch.setOnCheckedChangeListener((compoundButton, checked) -> mBinding.sampleCircularProgressView.setReverseEnabled(checked));
Expand Down
13 changes: 13 additions & 0 deletions sample/src/main/res/layout/activity_sample_editor.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,19 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/symbol_closing"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="10dp"
android:text="@string/hint_for_progress_rounded"/>

<Switch
android:id="@+id/rounded_Switch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:checked="false"/>
</LinearLayout>

<SeekBar
Expand Down
1 change: 1 addition & 0 deletions sample/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<string name="hint_for_size">Size</string>
<string name="hint_for_progress_thickness">Thickness</string>
<string name="hint_for_progress">Progress (animated: </string>
<string name="hint_for_progress_rounded">Rounded: </string>
<string name="hint_for_angle">Starting angle</string>
<string name="hint_for_color">Color RGB (Progress &amp; Background:</string>
<string name="hint_for_shadow">Shadow:</string>
Expand Down

0 comments on commit b11c695

Please sign in to comment.