From a26e9fff55020ac4602b11080e7890befa561063 Mon Sep 17 00:00:00 2001 From: Michel Tabari Date: Tue, 19 Jun 2018 04:47:44 +0200 Subject: [PATCH] Add support for disabling progress glow (#11) * Add support for disabling progress glow * Add information to README --- README.md | 1 + .../lib/circularseekbar/CircularSeekBar.java | 21 +++++++++++++++---- circularSeekBar/src/main/res/values/attrs.xml | 3 ++- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 72a67d40..eedcd40b 100644 --- a/README.md +++ b/README.md @@ -63,5 +63,6 @@ app:cs_pointer_alpha_ontouch = "integer" app:cs_pointer_angle = "float" app:cs_start_angle = "float" app:cs_end_angle = "float" +app:cs_disable_progress_glow = "boolean" ``` diff --git a/circularSeekBar/src/main/java/me/tankery/lib/circularseekbar/CircularSeekBar.java b/circularSeekBar/src/main/java/me/tankery/lib/circularseekbar/CircularSeekBar.java index f2c5edec..72d8ee9b 100644 --- a/circularSeekBar/src/main/java/me/tankery/lib/circularseekbar/CircularSeekBar.java +++ b/circularSeekBar/src/main/java/me/tankery/lib/circularseekbar/CircularSeekBar.java @@ -86,6 +86,7 @@ public class CircularSeekBar extends View { private static final boolean DEFAULT_LOCK_ENABLED = true; private static final boolean DEFAULT_DISABLE_POINTER = false; private static final boolean DEFAULT_NEGATIVE_ENABLED = false; + private static final boolean DEFAULT_DISABLE_PROGRESS_GLOW = false; /** * {@code Paint} instance used to draw the inactive circle. @@ -102,6 +103,11 @@ public class CircularSeekBar extends View { */ private Paint mCircleProgressPaint; + /** + * If progress glow is disabled, there is no glow from the progress bar when filled + */ + private boolean mDisableProgressGlow; + /** * {@code Paint} instance used to draw the glow from the active circle. */ @@ -435,6 +441,7 @@ private void initAttributes(TypedArray attrArray) { mDisablePointer = attrArray.getBoolean(R.styleable.cs_CircularSeekBar_cs_disable_pointer, DEFAULT_DISABLE_POINTER); negativeEnabled = attrArray.getBoolean(R.styleable.cs_CircularSeekBar_cs_negative_enabled, DEFAULT_NEGATIVE_ENABLED); isInNegativeHalf = false; + mDisableProgressGlow = attrArray.getBoolean(R.styleable.cs_CircularSeekBar_cs_disable_progress_glow, DEFAULT_DISABLE_PROGRESS_GLOW); // Modulo 360 right now to avoid constant conversion mStartAngle = ((360f + (attrArray.getFloat((R.styleable.cs_CircularSeekBar_cs_start_angle), DEFAULT_START_ANGLE) % 360f)) % 360f); @@ -492,9 +499,11 @@ private void initPaints() { mCircleProgressPaint.setStrokeJoin(Paint.Join.ROUND); mCircleProgressPaint.setStrokeCap(mCircleStyle); - mCircleProgressGlowPaint = new Paint(); - mCircleProgressGlowPaint.set(mCircleProgressPaint); - mCircleProgressGlowPaint.setMaskFilter(new BlurMaskFilter((5f * DPTOPX_SCALE), BlurMaskFilter.Blur.NORMAL)); + if (!mDisableProgressGlow) { + mCircleProgressGlowPaint = new Paint(); + mCircleProgressGlowPaint.set(mCircleProgressPaint); + mCircleProgressGlowPaint.setMaskFilter(new BlurMaskFilter((5f * DPTOPX_SCALE), BlurMaskFilter.Blur.NORMAL)); + } mPointerPaint = new Paint(); mPointerPaint.setAntiAlias(true); @@ -620,7 +629,11 @@ protected void onDraw(Canvas canvas) { canvas.translate(this.getWidth() / 2, this.getHeight() / 2); canvas.drawPath(mCirclePath, mCirclePaint); - canvas.drawPath(mCircleProgressPath, mCircleProgressGlowPaint); + + if (!mDisableProgressGlow) { + canvas.drawPath(mCircleProgressPath, mCircleProgressGlowPaint); + } + canvas.drawPath(mCircleProgressPath, mCircleProgressPaint); canvas.drawPath(mCirclePath, mCircleFillPaint); diff --git a/circularSeekBar/src/main/res/values/attrs.xml b/circularSeekBar/src/main/res/values/attrs.xml index ee3753b7..90594060 100644 --- a/circularSeekBar/src/main/res/values/attrs.xml +++ b/circularSeekBar/src/main/res/values/attrs.xml @@ -31,6 +31,7 @@ + - \ No newline at end of file +