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

Adds support for setting the controler enabled and disabled. #59

Merged
merged 3 commits into from
Nov 10, 2020
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,26 @@ public ColorPickerView(Context context, AttributeSet attrs, int defStyleAttr) {
onCreate();
}

@Override
public boolean isEnabled() {
return super.isEnabled();
}
JimmyBjorklund marked this conversation as resolved.
Show resolved Hide resolved

@Override
public void setEnabled(boolean enabled) {
super.setEnabled(enabled);

selector.setVisibility(enabled ? VISIBLE : INVISIBLE);
alphaSlideBar.setEnabled(enabled);
brightnessSlider.setEnabled(enabled);
JimmyBjorklund marked this conversation as resolved.
Show resolved Hide resolved
if (enabled) {
palette.clearColorFilter();
} else {
int color = Color.argb(70, 255, 255, 255);
palette.setColorFilter(color);
}
}

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public ColorPickerView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
Expand Down Expand Up @@ -265,6 +285,9 @@ protected void onCreateByBuilder(Builder builder) {
@SuppressLint("ClickableViewAccessibility")
@Override
public boolean onTouchEvent(MotionEvent event) {
if (!this.isEnabled()) {
return false;
}
switch (event.getActionMasked()) {
case MotionEvent.ACTION_DOWN:
case MotionEvent.ACTION_MOVE:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ public AbstractSlider(Context context) {
onCreate();
}

@Override
public void setEnabled(boolean enabled) {
super.setEnabled(enabled);
selector.setVisibility(enabled ? VISIBLE : INVISIBLE);
this.setClickable(enabled);
}

public AbstractSlider(Context context, AttributeSet attrs) {
super(context, attrs);
getAttrs(attrs);
Expand Down Expand Up @@ -130,6 +137,10 @@ public void notifyColor() {
@SuppressLint("ClickableViewAccessibility")
@Override
public boolean onTouchEvent(MotionEvent event) {
if (!this.isEnabled()) {
return false;
}

if (colorPickerView != null) {
switch (event.getActionMasked()) {
case MotionEvent.ACTION_UP:
Expand Down