Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
castorflex committed Mar 17, 2015
2 parents 676f066 + 6a5dc5b commit 271855f
Show file tree
Hide file tree
Showing 22 changed files with 92 additions and 49 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
##1.1.0

- Fixed Circular bugs (flashes)
- Added material themes (mainly for determinate support)
- Fixed exception bug in preview mode
- **/!\\** Removed a weird 48dp height in the SmoothProgressBar style

##1.0.0

- Added CircularProgressDrawable (min API 14)
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.13.3'
classpath 'com.android.tools.build:gradle:1.1.0'
}
}

Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
VERSION_NAME=1.1.0
VERSION_CODE=21
BUILD_TOOLS_VERSION=20
VERSION_CODE=22
BUILD_TOOLS_VERSION=21.1.2
COMPILE_SDK_VERSION=21
GROUP=com.github.castorflex.smoothprogressbar

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 @@
#Wed Oct 08 23:53:45 PDT 2014
#Sun Feb 01 23:44:10 CET 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
2 changes: 1 addition & 1 deletion library-circular/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ android {

defaultConfig {
minSdkVersion 14
targetSdkVersion 20
targetSdkVersion 21
versionName project.VERSION_NAME
versionCode Integer.parseInt(project.VERSION_CODE)
}
Expand Down
2 changes: 1 addition & 1 deletion library-circular/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ POM_ARTIFACT_ID=library-circular
POM_PACKAGING=aar
POM_DESCRIPTION=Android Library make smooth circular indeterminate progress bars

VERSION_NAME=1.0.2
VERSION_NAME=1.1.0
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public CircularProgressBar(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);

if (isInEditMode()) {
setIndeterminateDrawable(new CircularProgressDrawable.Builder(context).build());
setIndeterminateDrawable(new CircularProgressDrawable.Builder(context, true).build());
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* Created by castorflex on 8/14/14.
*/
class CircularProgressBarUtils {

private CircularProgressBarUtils() {
}

Expand All @@ -31,8 +32,8 @@ static void checkPositiveOrZero(float number, String name) {
throw new IllegalArgumentException(String.format("%s %d must be positive", name, number));
}

static void checkPositive(int number, String name){
if(number <= 0)
static void checkPositive(int number, String name) {
if (number <= 0)
throw new IllegalArgumentException(String.format("%s must not be null", name));
}

Expand All @@ -42,9 +43,8 @@ static void checkNotNull(Object o, String name) {
}

static float getAnimatedFraction(ValueAnimator animator) {
float fraction = animator.getDuration() > 0 ? ((float) animator.getCurrentPlayTime()) / animator.getDuration() : 1f;
float fraction = animator.getDuration() > 0 ? ((float) animator.getCurrentPlayTime()) / animator.getDuration() : 0f;

fraction %= 1f;
fraction = min(fraction, 1f);
fraction = animator.getInterpolator().getInterpolation(fraction);
return fraction;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,24 @@
import android.animation.ValueAnimator;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.ColorFilter;
import android.graphics.Paint;
import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.drawable.Animatable;
import android.graphics.drawable.Drawable;
import android.util.Log;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.Interpolator;
import android.view.animation.LinearInterpolator;

import static fr.castorflex.android.circularprogressbar.CircularProgressBarUtils.checkAngle;
import static fr.castorflex.android.circularprogressbar.CircularProgressBarUtils.getAnimatedFraction;
import static fr.castorflex.android.circularprogressbar.CircularProgressBarUtils.checkColors;
import static fr.castorflex.android.circularprogressbar.CircularProgressBarUtils.checkNotNull;
import static fr.castorflex.android.circularprogressbar.CircularProgressBarUtils.checkPositiveOrZero;
import static fr.castorflex.android.circularprogressbar.CircularProgressBarUtils.checkSpeed;
import static fr.castorflex.android.circularprogressbar.CircularProgressBarUtils.getAnimatedFraction;

public class CircularProgressDrawable extends Drawable
implements Animatable {
Expand Down Expand Up @@ -395,16 +395,26 @@ public static class Builder {
private Interpolator mAngleInterpolator = DEFAULT_ROTATION_INTERPOLATOR;

public Builder(Context context) {
initValues(context);
this(context, false);
}

private void initValues(Context context) {
public Builder(Context context, boolean editMode) {
initValues(context, editMode);
}

private void initValues(Context context, boolean editMode) {
mStrokeWidth = context.getResources().getDimension(R.dimen.cpb_default_stroke_width);
mSweepSpeed = 1f;
mRotationSpeed = 1f;
mColors = new int[]{context.getResources().getColor(R.color.cpb_default_color)};
mMinSweepAngle = context.getResources().getInteger(R.integer.cpb_default_min_sweep_angle);
mMaxSweepAngle = context.getResources().getInteger(R.integer.cpb_default_max_sweep_angle);
if (editMode) {
mColors = new int[]{Color.BLUE};
mMinSweepAngle = 20;
mMaxSweepAngle = 300;
} else {
mColors = new int[]{context.getResources().getColor(R.color.cpb_default_color)};
mMinSweepAngle = context.getResources().getInteger(R.integer.cpb_default_min_sweep_angle);
mMaxSweepAngle = context.getResources().getInteger(R.integer.cpb_default_max_sweep_angle);
}
mStyle = Style.ROUNDED;
}

Expand Down
5 changes: 5 additions & 0 deletions library-circular/src/main/res/values-v21/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="CPB" parent="android:Widget.Material.ProgressBar">
</style>
</resources>
5 changes: 4 additions & 1 deletion library-circular/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
<item name="cpbStyle">@style/CircularProgressBar</item>
</style>

<style name="CircularProgressBar" parent="android:Widget.Holo.ProgressBar">
<style name="CPB" parent="android:Widget.Holo.ProgressBar">
</style>

<style name="CircularProgressBar" parent="CPB">
<item name="cpb_color">@color/cpb_default_color</item>
<item name="cpb_stroke_width">@dimen/cpb_default_stroke_width</item>
<item name="cpb_min_sweep_angle">@integer/cpb_default_min_sweep_angle</item>
Expand Down
2 changes: 1 addition & 1 deletion library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ android {

defaultConfig {
minSdkVersion 7
targetSdkVersion 20
targetSdkVersion 21
versionName project.VERSION_NAME
versionCode Integer.parseInt(project.VERSION_CODE)
}
Expand Down
2 changes: 1 addition & 1 deletion library/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ POM_ARTIFACT_ID=library
POM_PACKAGING=aar
POM_DESCRIPTION=Android Library make smooth horizontal indeterminate progress bars

VERSION_NAME=1.0.0
VERSION_NAME=1.1.0
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public SmoothProgressBar(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);

if (isInEditMode()) {
setIndeterminateDrawable(new SmoothProgressDrawable.Builder(context).build());
setIndeterminateDrawable(new SmoothProgressDrawable.Builder(context, true).build());
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,11 @@ public static class Builder {
private Callbacks mOnProgressiveStopEndedListener;

public Builder(Context context) {
initValues(context);
this(context, false);
}

public Builder(Context context, boolean editMode) {
initValues(context, editMode);
}

public SmoothProgressDrawable build() {
Expand All @@ -651,18 +655,28 @@ public SmoothProgressDrawable build() {
return ret;
}

private void initValues(Context context) {
private void initValues(Context context, boolean editMode) {
Resources res = context.getResources();
mInterpolator = new AccelerateInterpolator();
mSectionsCount = res.getInteger(R.integer.spb_default_sections_count);
mColors = new int[]{res.getColor(R.color.spb_default_color)};
mSpeed = Float.parseFloat(res.getString(R.string.spb_default_speed));
if (!editMode) {
mSectionsCount = res.getInteger(R.integer.spb_default_sections_count);
mSpeed = Float.parseFloat(res.getString(R.string.spb_default_speed));
mReversed = res.getBoolean(R.bool.spb_default_reversed);
mProgressiveStartActivated = res.getBoolean(R.bool.spb_default_progressiveStart_activated);
mColors = new int[]{res.getColor(R.color.spb_default_color)};
mStrokeSeparatorLength = res.getDimensionPixelSize(R.dimen.spb_default_stroke_separator_length);
mStrokeWidth = res.getDimensionPixelOffset(R.dimen.spb_default_stroke_width);
} else {
mSectionsCount = 4;
mSpeed = 1f;
mReversed = false;
mProgressiveStartActivated = false;
mColors = new int[]{0xff33b5e5};
mStrokeSeparatorLength = 4;
mStrokeWidth = 4;
}
mProgressiveStartSpeed = mSpeed;
mProgressiveStopSpeed = mSpeed;
mReversed = res.getBoolean(R.bool.spb_default_reversed);
mStrokeSeparatorLength = res.getDimensionPixelSize(R.dimen.spb_default_stroke_separator_length);
mStrokeWidth = res.getDimensionPixelOffset(R.dimen.spb_default_stroke_width);
mProgressiveStartActivated = res.getBoolean(R.bool.spb_default_progressiveStart_activated);
mGradients = false;
}

Expand Down
12 changes: 1 addition & 11 deletions library/src/main/res/values-v11/styles.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="SmoothProgressBar" parent="android:Widget.Holo.ProgressBar.Horizontal">
<item name="spb_color">@color/spb_default_color</item>
<item name="spb_sections_count">@integer/spb_default_sections_count</item>
<item name="spb_speed">@string/spb_default_speed</item>
<item name="spb_stroke_width">@dimen/spb_default_stroke_width</item>
<item name="spb_stroke_separator_length">@dimen/spb_default_stroke_separator_length</item>
<item name="spb_reversed">@bool/spb_default_reversed</item>
<item name="spb_mirror_mode">@bool/spb_default_mirror_mode</item>
<item name="spb_interpolator">@integer/spb_default_interpolator</item>
<item name="android:minHeight">48dp</item>
<item name="android:maxHeight">48dp</item>
<style name="SPB" parent="android:Widget.Holo.ProgressBar.Horizontal">
</style>
</resources>
5 changes: 5 additions & 0 deletions library/src/main/res/values-v21/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="SPB" parent="android:Widget.Material.ProgressBar.Horizontal">
</style>
</resources>
7 changes: 3 additions & 4 deletions library/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
<style name="Theme.SmoothProgressBarDefaults" parent="android:Theme">
<item name="spbStyle">@style/SmoothProgressBar</item>
</style>

<style name="SmoothProgressBar" parent="android:Widget.ProgressBar.Horizontal">
<style name="SPB" parent="android:Widget.ProgressBar.Horizontal">
</style>
<style name="SmoothProgressBar" parent="SPB">
<item name="spb_color">@color/spb_default_color</item>
<item name="spb_sections_count">@integer/spb_default_sections_count</item>
<item name="spb_speed">@string/spb_default_speed</item>
Expand All @@ -14,7 +15,5 @@
<item name="spb_reversed">@bool/spb_default_reversed</item>
<item name="spb_mirror_mode">@bool/spb_default_mirror_mode</item>
<item name="spb_interpolator">@integer/spb_default_interpolator</item>
<item name="android:minHeight">48dp</item>
<item name="android:maxHeight">48dp</item>
</style>
</resources>
1 change: 1 addition & 0 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ apply plugin: 'com.android.application'

repositories {
mavenCentral()
mavenLocal()
}

dependencies {
Expand Down
3 changes: 2 additions & 1 deletion sample/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@

<activity
android:name=".MakeCustomActivity"
android:label="Make your own"/>
android:label="Make your own"
android:parentActivityName=".MainActivity"/>
</application>

</manifest>
5 changes: 5 additions & 0 deletions sample/src/main/res/values-v21/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="BaseTheme" parent="android:Theme.Material">
</style>
</resources>
5 changes: 4 additions & 1 deletion sample/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<resources>

<style name="AppTheme" parent="android:Theme.Holo">
<style name="AppTheme" parent="BaseTheme">
<item name="spbStyle">@style/SmoothProgressBar</item>
<item name="cpbStyle">@style/CircularProgressBar</item>
</style>
Expand Down Expand Up @@ -49,4 +49,7 @@
<item name="spb_generate_background_with_colors">false</item>
</style>

<style name="BaseTheme" parent="android:Theme.Holo">
</style>

</resources>

0 comments on commit 271855f

Please sign in to comment.