Skip to content
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
3 changes: 1 addition & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
}

Expand Down
3 changes: 1 addition & 2 deletions demo/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
apply plugin: 'android-sdk-manager'
apply plugin: 'android'
apply plugin: 'com.android.application'

android {
compileSdkVersion 23
Expand Down
2 changes: 2 additions & 0 deletions demo/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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" />

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 @@
#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
2 changes: 1 addition & 1 deletion library/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apply plugin: 'android-library'
apply plugin: 'com.android.library'

android {
compileSdkVersion 23
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand All @@ -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;

Expand All @@ -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";
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -348,6 +358,10 @@ public int getProgress() {
return mCurrentProgress;
}

public float getRadius() {
return mRadius;
}

public int getMax() {
return mMaxProgress;
}
Expand Down Expand Up @@ -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());
Expand All @@ -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));
Expand Down
1 change: 1 addition & 0 deletions library/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<attr name="progress_unreached_color" format="color"/>
<attr name="progress_reached_color" format="color"/>

<attr name="progress_radius" format="dimension"/>
<attr name="progress_reached_bar_height" format="dimension"/>
<attr name="progress_unreached_bar_height" format="dimension"/>

Expand Down