From 9d47707e94d8b217f681cd7b0eb153da78943b16 Mon Sep 17 00:00:00 2001 From: chrnie Date: Mon, 14 Jan 2019 21:24:20 +0800 Subject: [PATCH 1/3] Fix "libary" typo in setting.gradle --- settings.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings.gradle b/settings.gradle index 87ed970..d8f14a1 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1 @@ -include ':libary' +include ':library' From cbad3fdc04fb4bce5f371b95b0d305dfc573f841 Mon Sep 17 00:00:00 2001 From: chrnie Date: Mon, 14 Jan 2019 21:36:09 +0800 Subject: [PATCH 2/3] Upgrade AGP -> 3.2.1 & targetVersion -> 28 --- build.gradle | 2 +- library/build.gradle | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index 1b6b868..190699e 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ buildscript { google() } dependencies { - classpath 'com.android.tools.build:gradle:3.0.1' + classpath 'com.android.tools.build:gradle:3.2.1' } } diff --git a/library/build.gradle b/library/build.gradle index 90a2ae6..68753d6 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -1,11 +1,11 @@ apply plugin: 'com.android.library' android { - compileSdkVersion 27 + compileSdkVersion 28 defaultConfig { minSdkVersion 8 - targetSdkVersion 27 + targetSdkVersion 28 } } From 9dc1e02892f33d912c03226ded6b6e73f909d945 Mon Sep 17 00:00:00 2001 From: chrnie Date: Mon, 14 Jan 2019 21:42:22 +0800 Subject: [PATCH 3/3] Fix onTouchEvent handle bug in OpacityBar(ValueBara etc) --- .../holocolorpicker/OpacityBar.java | 3 ++ .../larswerkman/holocolorpicker/SVBar.java | 4 +++ .../holocolorpicker/SaturationBar.java | 5 ++++ .../larswerkman/holocolorpicker/ValueBar.java | 30 +++++++++++-------- 4 files changed, 29 insertions(+), 13 deletions(-) diff --git a/library/src/main/java/com/larswerkman/holocolorpicker/OpacityBar.java b/library/src/main/java/com/larswerkman/holocolorpicker/OpacityBar.java index fccac9a..54c9a7b 100644 --- a/library/src/main/java/com/larswerkman/holocolorpicker/OpacityBar.java +++ b/library/src/main/java/com/larswerkman/holocolorpicker/OpacityBar.java @@ -357,6 +357,9 @@ public boolean onTouchEvent(MotionEvent event) { mBarPointerPosition = Math.round(dimen); calculateColor(Math.round(dimen)); mBarPointerPaint.setColor(mColor); + if (mPicker != null) { + mPicker.setNewCenterColor(mColor); + } invalidate(); } break; diff --git a/library/src/main/java/com/larswerkman/holocolorpicker/SVBar.java b/library/src/main/java/com/larswerkman/holocolorpicker/SVBar.java index 352159f..01a804e 100644 --- a/library/src/main/java/com/larswerkman/holocolorpicker/SVBar.java +++ b/library/src/main/java/com/larswerkman/holocolorpicker/SVBar.java @@ -338,6 +338,10 @@ public boolean onTouchEvent(MotionEvent event) { mBarPointerPosition = Math.round(dimen); calculateColor(Math.round(dimen)); mBarPointerPaint.setColor(mColor); + if (mPicker != null) { + mPicker.setNewCenterColor(mColor); + mPicker.changeOpacityBarColor(mColor); + } invalidate(); } break; diff --git a/library/src/main/java/com/larswerkman/holocolorpicker/SaturationBar.java b/library/src/main/java/com/larswerkman/holocolorpicker/SaturationBar.java index fd736ea..e042307 100644 --- a/library/src/main/java/com/larswerkman/holocolorpicker/SaturationBar.java +++ b/library/src/main/java/com/larswerkman/holocolorpicker/SaturationBar.java @@ -357,6 +357,11 @@ public boolean onTouchEvent(MotionEvent event) { mBarPointerPosition = Math.round(dimen); calculateColor(Math.round(dimen)); mBarPointerPaint.setColor(mColor); + if (mPicker != null) { + mPicker.setNewCenterColor(mColor); + mPicker.changeValueBarColor(mColor); + mPicker.changeOpacityBarColor(mColor); + } invalidate(); } break; diff --git a/library/src/main/java/com/larswerkman/holocolorpicker/ValueBar.java b/library/src/main/java/com/larswerkman/holocolorpicker/ValueBar.java index 93e337e..3f7318e 100644 --- a/library/src/main/java/com/larswerkman/holocolorpicker/ValueBar.java +++ b/library/src/main/java/com/larswerkman/holocolorpicker/ValueBar.java @@ -42,13 +42,13 @@ public class ValueBar extends View { private static final String STATE_COLOR = "color"; private static final String STATE_VALUE = "value"; private static final String STATE_ORIENTATION = "orientation"; - + /** * Constants used to identify orientation. */ private static final boolean ORIENTATION_HORIZONTAL = true; private static final boolean ORIENTATION_VERTICAL = false; - + /** * Default orientation of the bar. */ @@ -108,7 +108,7 @@ public class ValueBar extends View { /** * {@code true} if the user clicked on the pointer to start the move mode.
* {@code false} once the user stops touching the screen. - * + * * @see #onTouchEvent(android.view.MotionEvent) */ private boolean mIsMovingPointer; @@ -143,13 +143,13 @@ public class ValueBar extends View { * Used to toggle orientation between vertical and horizontal. */ private boolean mOrientation; - + /** * Interface and listener so that changes in ValueBar are sent * to the host activity/fragment */ private OnValueChangedListener onValueChangedListener; - + /** * Value of the latest entry of the onValueChangedListener. */ @@ -329,7 +329,7 @@ protected void onDraw(Canvas canvas) { cX = mBarPointerHaloRadius; cY = mBarPointerPosition; } - + // Draw the pointer halo. canvas.drawCircle(cX, cY, mBarPointerHaloRadius, mBarPointerHaloPaint); // Draw the pointer. @@ -358,6 +358,10 @@ public boolean onTouchEvent(MotionEvent event) { mBarPointerPosition = Math.round(dimen); calculateColor(Math.round(dimen)); mBarPointerPaint.setColor(mColor); + if (mPicker != null) { + mPicker.setNewCenterColor(mColor); + mPicker.changeOpacityBarColor(mColor); + } invalidate(); } break; @@ -410,7 +414,7 @@ public boolean onTouchEvent(MotionEvent event) { * Set the bar color.
*
* Its discouraged to use this method. - * + * * @param color */ public void setColor(int color) { @@ -423,7 +427,7 @@ public void setColor(int color) { x1 = mBarThickness; y1 = (mBarLength + mBarPointerHaloRadius); } - + Color.colorToHSV(color, mHSVColor); shader = new LinearGradient(mBarPointerHaloRadius, 0, x1, y1, new int[] { @@ -441,7 +445,7 @@ public void setColor(int color) { /** * Set the pointer on the bar. With the opacity value. - * + * * @param value float between 0 and 1 */ public void setValue(float value) { @@ -456,10 +460,10 @@ public void setValue(float value) { } invalidate(); } - + /** * Calculate the color selected by the pointer on the bar. - * + * * @param coord Coordinate of the pointer. */ private void calculateColor(int coord) { @@ -476,7 +480,7 @@ private void calculateColor(int coord) { /** * Get the currently selected color. - * + * * @return The ARGB value of the currently selected color. */ public int getColor() { @@ -488,7 +492,7 @@ public int getColor() { *
* WARNING: Don't change the color picker. it is done already when the bar * is added to the ColorPicker - * + * * @see com.larswerkman.holocolorpicker.ColorPicker#addSVBar(com.larswerkman.holocolorpicker.SVBar) * @param picker */