Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix OpacityBar(ValueBara etc) touch handle bug #92

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
}

Expand Down
4 changes: 2 additions & 2 deletions library/build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 27
compileSdkVersion 28

defaultConfig {
minSdkVersion 8
targetSdkVersion 27
targetSdkVersion 28
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
30 changes: 17 additions & 13 deletions library/src/main/java/com/larswerkman/holocolorpicker/ValueBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -108,7 +108,7 @@ public class ValueBar extends View {
/**
* {@code true} if the user clicked on the pointer to start the move mode. <br>
* {@code false} once the user stops touching the screen.
*
*
* @see #onTouchEvent(android.view.MotionEvent)
*/
private boolean mIsMovingPointer;
Expand Down Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -410,7 +414,7 @@ public boolean onTouchEvent(MotionEvent event) {
* Set the bar color. <br>
* <br>
* Its discouraged to use this method.
*
*
* @param color
*/
public void setColor(int color) {
Expand All @@ -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[] {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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() {
Expand All @@ -488,7 +492,7 @@ public int getColor() {
* <br>
* 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
*/
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1 @@
include ':libary'
include ':library'