-
Notifications
You must be signed in to change notification settings - Fork 43
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
Add outlineColor attribute, so it can be user defined #41
base: master
Are you sure you want to change the base?
Changes from 20 commits
fcd4597
7efc130
a38c21e
5e69ccf
3c57fde
a13d2ec
0aa7777
d8ab799
045ed6c
446ac4f
98e61b8
a2a05b3
21c97d2
4c640c9
6f970d1
9e11bc9
a4bc874
e562573
1538fc1
8f3567f
f63672d
6b036cb
d8a4b8c
bf68d4d
0a21c3e
b8dc3ab
784869c
44849d2
ea08282
dca0744
a47f1e6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,6 +53,7 @@ public class SpectrumPreferenceCompat extends DialogPreference { | |
private boolean mValueSet = false; | ||
private View mColorView; | ||
private int mOutlineWidth = 0; | ||
private @ColorInt int mOutlineColor; | ||
private int mFixedColumnCount = -1; | ||
|
||
private SharedPreferences.OnSharedPreferenceChangeListener mListener = new SharedPreferences.OnSharedPreferenceChangeListener() { | ||
|
@@ -75,6 +76,7 @@ public SpectrumPreferenceCompat(Context context, AttributeSet attrs) { | |
} | ||
mCloseOnSelected = a.getBoolean(R.styleable.SpectrumPreference_spectrum_closeOnSelected, true); | ||
mOutlineWidth = a.getDimensionPixelSize(R.styleable.SpectrumPalette_spectrum_outlineWidth, 0); | ||
mOutlineWidth = a.getColor(R.styleable.SpectrumPalette_spectrum_outlineColor, -1); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be |
||
mFixedColumnCount = a.getInt(R.styleable.SpectrumPalette_spectrum_columnCount, -1); | ||
} finally { | ||
a.recycle(); | ||
|
@@ -157,6 +159,7 @@ private void updateColorView() { | |
} | ||
ColorCircleDrawable drawable = new ColorCircleDrawable(mCurrentValue); | ||
drawable.setOutlineWidth(mOutlineWidth); | ||
drawable.setOutlineColor(mOutlineColor); | ||
if (!isEnabled()) { | ||
// Show just a gray circle outline | ||
drawable.setColor(Color.WHITE); | ||
|
@@ -207,6 +210,10 @@ public void setColor(@ColorInt int value) { | |
public int getOutlineWidth() { | ||
return mOutlineWidth; | ||
} | ||
|
||
public int getOutlineColor() { | ||
return mOutlineColor; | ||
} | ||
|
||
public int getFixedColumnCount() { | ||
return mFixedColumnCount; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ public class ColorCircleDrawable extends Drawable { | |
private final Paint mPaint; | ||
private int mRadius = 0; | ||
private int mOutlineWidth = 0; | ||
private @ColorInt int mOutlineColor = -1; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm pretty sure this isn't necessary. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Whoops, forgot to remove that, that was before I realized there was already a setOutlineColor method in that class |
||
private final Paint mOutlinePaint; | ||
|
||
public ColorCircleDrawable(final @ColorInt int color) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,7 @@ public class ColorItem extends FrameLayout implements View.OnClickListener { | |
private @ColorInt int mColor; | ||
private boolean mIsSelected = false; | ||
private int mOutlineWidth = 0; | ||
private @ColorInt int mOutlineColor = -1; | ||
|
||
public ColorItem(Context context, @ColorInt int color, boolean isSelected, EventBus eventBus) { | ||
super(context); | ||
|
@@ -85,6 +86,16 @@ public void setOutlineWidth(int width) { | |
mOutlineWidth = width; | ||
updateDrawables(); | ||
} | ||
|
||
/** | ||
* Force an outline color instead of setting | ||
* to black or white (default behavior) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This description should be able to fit on one line. |
||
* @param color | ||
*/ | ||
public void setOutlineColor(@ColorInt int color) { | ||
mOutlineColor = color; | ||
updateDrawables(); | ||
} | ||
|
||
public void setChecked(boolean checked) { | ||
boolean oldChecked = mIsSelected; | ||
|
@@ -163,7 +174,12 @@ private Drawable createBackgroundDrawable() { | |
GradientDrawable mask = new GradientDrawable(); | ||
mask.setShape(GradientDrawable.OVAL); | ||
if (mOutlineWidth != 0) { | ||
mask.setStroke(mOutlineWidth, ColorUtil.isColorDark(mColor) ? Color.WHITE : Color.BLACK); | ||
if (mOutlineColor != -1) { | ||
mask.setStroke(mOutlineWidth, mOutlineColor); | ||
} | ||
else { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Keep your There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Man that hurts to look at - this is the last time I make changes with the Github online editor :) |
||
mask.setStroke(mOutlineWidth, ColorUtil.isColorDark(mColor) ? Color.WHITE : Color.BLACK); | ||
} | ||
} | ||
mask.setColor(mColor); | ||
return mask; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll want to default this to -1.