From d825b2ba5ee145d459c9a067d04230bd1e1a40bd Mon Sep 17 00:00:00 2001 From: John Cordeiro Date: Wed, 11 Jan 2017 12:27:30 -0300 Subject: [PATCH 1/4] Update gradle plugins to the newest --- build.gradle | 3 +-- demo/build.gradle | 3 +-- gradle/wrapper/gradle-wrapper.properties | 4 ++-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/build.gradle b/build.gradle index ee8eb9f..dd27ed1 100644 --- a/build.gradle +++ b/build.gradle @@ -5,8 +5,7 @@ buildscript { mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:1.1.0' - classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.10.+' + classpath 'com.android.tools.build:gradle:2.2.3' } } diff --git a/demo/build.gradle b/demo/build.gradle index bb0cae9..6da9cd3 100644 --- a/demo/build.gradle +++ b/demo/build.gradle @@ -1,5 +1,4 @@ -apply plugin: 'android-sdk-manager' -apply plugin: 'android' +apply plugin: 'com.android.application' android { compileSdkVersion 23 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 7113e2c..a184eb7 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Tue Feb 24 10:50:01 CST 2015 +#Wed Jan 11 12:23:58 BRT 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip From 092493b5f5bb720e784cdb0586591358f42b7c07 Mon Sep 17 00:00:00 2001 From: John Cordeiro Date: Wed, 11 Jan 2017 12:27:54 -0300 Subject: [PATCH 2/4] Add radius attribute on NumberProgressBar --- .../numberprogressbar/NumberProgressBar.java | 20 +++++++++++++++++-- library/src/main/res/values/attrs.xml | 1 + 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/library/src/main/java/com/daimajia/numberprogressbar/NumberProgressBar.java b/library/src/main/java/com/daimajia/numberprogressbar/NumberProgressBar.java index 4379298..126d463 100644 --- a/library/src/main/java/com/daimajia/numberprogressbar/NumberProgressBar.java +++ b/library/src/main/java/com/daimajia/numberprogressbar/NumberProgressBar.java @@ -46,6 +46,11 @@ public class NumberProgressBar extends View { */ private float mTextSize; + /** + * Radius of progress bar + */ + private float mRadius = 0f; + /** * The height of the reached area. */ @@ -72,6 +77,7 @@ public class NumberProgressBar extends View { private final int default_unreached_color = Color.rgb(204, 204, 204); private final float default_progress_text_offset; private final float default_text_size; + private final float default_radius; private final float default_reached_bar_height; private final float default_unreached_bar_height; @@ -85,6 +91,7 @@ public class NumberProgressBar extends View { private static final String INSTANCE_REACHED_BAR_COLOR = "reached_bar_color"; private static final String INSTANCE_UNREACHED_BAR_HEIGHT = "unreached_bar_height"; private static final String INSTANCE_UNREACHED_BAR_COLOR = "unreached_bar_color"; + private static final String INSTANCE_RADIUS = "radius"; private static final String INSTANCE_MAX = "max"; private static final String INSTANCE_PROGRESS = "progress"; private static final String INSTANCE_SUFFIX = "suffix"; @@ -170,6 +177,7 @@ public NumberProgressBar(Context context, AttributeSet attrs) { public NumberProgressBar(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); + default_radius = 0f; default_reached_bar_height = dp2px(1.5f); default_unreached_bar_height = dp2px(1.0f); default_text_size = sp2px(10); @@ -181,9 +189,11 @@ public NumberProgressBar(Context context, AttributeSet attrs, int defStyleAttr) mReachedBarColor = attributes.getColor(R.styleable.NumberProgressBar_progress_reached_color, default_reached_color); mUnreachedBarColor = attributes.getColor(R.styleable.NumberProgressBar_progress_unreached_color, default_unreached_color); + mRadius = attributes.getColor(R.styleable.NumberProgressBar_progress_unreached_color, default_unreached_color); mTextColor = attributes.getColor(R.styleable.NumberProgressBar_progress_text_color, default_text_color); mTextSize = attributes.getDimension(R.styleable.NumberProgressBar_progress_text_size, default_text_size); + mRadius = attributes.getDimension(R.styleable.NumberProgressBar_progress_radius, default_radius); mReachedBarHeight = attributes.getDimension(R.styleable.NumberProgressBar_progress_reached_bar_height, default_reached_bar_height); mUnreachedBarHeight = attributes.getDimension(R.styleable.NumberProgressBar_progress_unreached_bar_height, default_unreached_bar_height); mOffset = attributes.getDimension(R.styleable.NumberProgressBar_progress_text_offset, default_progress_text_offset); @@ -245,11 +255,11 @@ protected void onDraw(Canvas canvas) { } if (mDrawReachedBar) { - canvas.drawRect(mReachedRectF, mReachedBarPaint); + canvas.drawRoundRect(mReachedRectF, mRadius, mRadius, mReachedBarPaint); } if (mDrawUnreachedBar) { - canvas.drawRect(mUnreachedRectF, mUnreachedBarPaint); + canvas.drawRoundRect(mUnreachedRectF, mRadius, mRadius, mUnreachedBarPaint); } if (mIfDrawText) @@ -348,6 +358,10 @@ public int getProgress() { return mCurrentProgress; } + public float getRadius() { + return mRadius; + } + public int getMax() { return mMaxProgress; } @@ -450,6 +464,7 @@ protected Parcelable onSaveInstanceState() { bundle.putFloat(INSTANCE_UNREACHED_BAR_HEIGHT, getUnreachedBarHeight()); bundle.putInt(INSTANCE_REACHED_BAR_COLOR, getReachedBarColor()); bundle.putInt(INSTANCE_UNREACHED_BAR_COLOR, getUnreachedBarColor()); + bundle.putFloat(INSTANCE_RADIUS, getRadius()); bundle.putInt(INSTANCE_MAX, getMax()); bundle.putInt(INSTANCE_PROGRESS, getProgress()); bundle.putString(INSTANCE_SUFFIX, getSuffix()); @@ -468,6 +483,7 @@ protected void onRestoreInstanceState(Parcelable state) { mUnreachedBarHeight = bundle.getFloat(INSTANCE_UNREACHED_BAR_HEIGHT); mReachedBarColor = bundle.getInt(INSTANCE_REACHED_BAR_COLOR); mUnreachedBarColor = bundle.getInt(INSTANCE_UNREACHED_BAR_COLOR); + mRadius = bundle.getFloat(INSTANCE_RADIUS); initializePainters(); setMax(bundle.getInt(INSTANCE_MAX)); setProgress(bundle.getInt(INSTANCE_PROGRESS)); diff --git a/library/src/main/res/values/attrs.xml b/library/src/main/res/values/attrs.xml index 2067749..4e0eeab 100644 --- a/library/src/main/res/values/attrs.xml +++ b/library/src/main/res/values/attrs.xml @@ -7,6 +7,7 @@ + From aba44bd447458b69343f863f494921dc2849d301 Mon Sep 17 00:00:00 2001 From: John Cordeiro Date: Wed, 11 Jan 2017 12:28:41 -0300 Subject: [PATCH 3/4] Add sample with round progress bar --- demo/src/main/res/layout/activity_main.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/demo/src/main/res/layout/activity_main.xml b/demo/src/main/res/layout/activity_main.xml index 6cdc81d..5f71338 100644 --- a/demo/src/main/res/layout/activity_main.xml +++ b/demo/src/main/res/layout/activity_main.xml @@ -17,6 +17,8 @@ android:layout_width="wrap_content" android:padding="20dp" custom:progress_current="0" + custom:progress_reached_bar_height="16dp" + custom:progress_radius="10dp" style="@style/NumberProgressBar_Default" android:layout_height="wrap_content" /> From 689341cdc7416f518f87fe00f819f2adcd6dfc55 Mon Sep 17 00:00:00 2001 From: John Cordeiro Date: Wed, 11 Jan 2017 12:41:38 -0300 Subject: [PATCH 4/4] Update library plugin to com.android.library --- library/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/build.gradle b/library/build.gradle index 1dbdd8c..1b4236d 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -1,4 +1,4 @@ -apply plugin: 'android-library' +apply plugin: 'com.android.library' android { compileSdkVersion 23