-
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?
Conversation
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.
Thanks for the PR! Looks great overall, just a few things that need addressing before I merge.
If you could also add a demo to both dialogs and preferences that shows off this feature, that would be awesome!
@@ -39,6 +40,7 @@ | |||
private boolean mShouldDismissOnColorSelected = true; | |||
private OnColorSelectedListener mListener; | |||
private int mOutlineWidth = 0; | |||
private @ColorInt int mOutlineColor; |
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.
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
This should be mOutlineColor
.
@@ -13,6 +13,7 @@ | |||
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 comment
The 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 comment
The 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
if (mOutlineColor != -1) { | ||
mask.setStroke(mOutlineWidth, mOutlineColor); | ||
} | ||
else { |
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.
Keep your else
on the same line as the preceding curly brace to match our coding style :)
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.
Man that hurts to look at - this is the last time I make changes with the Github online editor :)
|
||
/** | ||
* 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 comment
The reason will be displayed to describe this comment to others. Learn more.
This description should be able to fit on one line.
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.
Changes made
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.
Changes made
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.
Fixed outline color, open to other colors. Picked purple so it was noticeable
build.gradle
Outdated
@@ -2,17 +2,19 @@ | |||
|
|||
buildscript { | |||
repositories { | |||
google() |
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.
This line produces the following error in Studio 2.3.3:
Gradle DSL method not found: 'google()'
Are you running the 3.0 beta, or do I have to check my Gradle config?
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.
Oh, yeah that's Studio 3
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.
I'd prefer not to use features from 3.0 until it hits stable, let's revert this for now.
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.
It's a shortcut for google's maven - I just wasn't able to download the support libraries from gradle without it - so just ignore it and do what works for you on Studio 2
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.
google() repo removed
Looks like we still need to following for support lib
|
@@ -20,6 +20,16 @@ | |||
app:spectrum_colors="@array/demo_colors_expanded" /> | |||
|
|||
<com.thebluealliance.spectrum.SpectrumPreferenceCompat | |||
android:defaultValue="@color/md_indigo_500" | |||
android:key="demo_preference_6" | |||
android:summary="You can make all the colors have the same color border or your choosing" |
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.
Typo, should be "of your choosing". Also, can you stick with one title/summary for both the dialog and preference demos?
android:defaultValue="@color/md_indigo_500" | ||
android:key="demo_preference_6" | ||
android:summary="You can make all the colors have the same color border or your choosing" | ||
android:title="Color preference with purple outlines" |
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.
Let's go with something more generic like "Color preference with custom outline color"
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.
Text changed
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.
Dialog and pref now have same description
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.
Let me know if there's any other changes you'd like!
Think I got all the changes in, let me know if there's anything else |
In response to #17
This adds a 'outlineColor' attribute that will override the black/white border that the library sets. If user does not define 'outlineColor' then nothing changes, but if they do, the outline will always have that color (assuming that width is set)