-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Issue/drawables with tint (Part 1) #8881
Conversation
…ron image style" This reverts commit d36165e.
...rc/main/java/org/wordpress/android/ui/prefs/notifications/NotificationsSettingsFragment.java
Show resolved
Hide resolved
@@ -20,23 +20,23 @@ enum class QuickStartMySitePrompts constructor( | |||
R.id.my_site_scroll_view_root, | |||
R.id.row_view_site, | |||
R.string.quick_start_dialog_view_site_message_short, | |||
R.drawable.ic_globe_grey_24dp, | |||
R.drawable.ic_globe_white_24dp, |
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.
Now that we rely on the tint to have the final color, I find it a little confusing to see the "white" in the drawable name. It feels minor but, I think I'd suggest to completely remove the color mention in the resource name so to avoid "misleading" the reader of the code here. The reader will have to hunt down the setting of the tint to understand what the color will be. WDYT?
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 agree. I considered removing the color from the file name as well, but decided to leave it since we will not be able to use tinting for all drawables yet (e.g. the android:drawableTint
attribute requires minSdkVersion 23
). I thought leaving the color for icon variations would help avoid confusion by being more explicit.
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.
Hmm, but, is ic_globe_white_24dp
ever going to be used as white
indeed? My understanding is that we will always tint it (maybe via code it is as compat as possible) to some color and so, the "white" in its name will never actually apply. Is my assumption wrong?
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.
The two instances included in these changes, QuickStartMySitePrompts
and my_site_fragment
, tint the icon from grey
to blue_light
and grey_darken_30
, respectively. There are two other instances, menu/reader_detail
and menu/webview
, which were using the ic_globe_white_24dp
icon before these changes.
Ideally, we can reuse an existing drawable resource and delete an unnecessary drawable resource by replacing ic_globe_grey_24dp
with ic_globe_white_24dp
. In the case of ic_globe_grey_24dp
, it is used by the wpIconDrawable
attribute in WPLoginInputRow
views, which currently doesn't support tinting. I tried to differentiate tinted and non-tinted icons with white and non-white naming, respectively.
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.
Ah, I see, thanks for the extra context Tyler.
I tried to differentiate tinted and non-tinted icons with white and non-white naming, respectively.
I think that's the subtle detail we'd like to find a good way to convey to the other devs, including our future selves :). I.e. we'd like to encourage the use of the _white_
variant and tint it, unless tinting is cumbersome or unsupported. Any ideas on how to do this encouragement?
Some options that come to mind:
- Remove the
_white_
specifier to make the name look more general and thus, more "default" to chose or - Add an extra specifier in the name, like
_untinted_
or_generic_
or - Investigate whether the linter can help out and warn when
_white_
is used untinted
In any case, I think the current PR is OK as is and additional work can be done in follow up PR(s) so, will ✅ this PR.
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 agree. I plan to write a post and update the Drawable Resources section in the CONTRIBUTING.md
file to help other developers and our future selves with the tinting, naming, etc.
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.
Sounds good to me!
@@ -353,7 +353,7 @@ void updateNotificationSuccessForPost(@NonNull PostModel post, @NonNull SiteMode | |||
isFirstTimePublish, true, false); | |||
PendingIntent pendingIntent = PendingIntent.getService(mContext, 0, publishIntent, | |||
PendingIntent.FLAG_CANCEL_CURRENT); | |||
notificationBuilder.addAction(R.drawable.ic_posts_grey_24dp, mContext.getString(R.string.button_publish), | |||
notificationBuilder.addAction(R.drawable.ic_posts_white_24dp, mContext.getString(R.string.button_publish), |
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.
Having trouble finding where do we set the tint for this one, any quick pointers @theck13 ?
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.
We don't actually tint these icons in our code. They are automagically tinted by the operating system. You can see the share icon just above this change is white also. Some icons aren't even displayed on certain API versions. See the screenshots below for illustration.
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 pointer Tyler!
Not a blocker but, do you think we could add a line comment to add this detail? Feel free to if you agree, or leave as is otherwise 👍.
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.
Since the ic_posts_grey_24dp
drawable used before these changes didn't actually correspond to the color used by the notification and all the other vector icons in PostUploadNotifier
class are white, I don't think a comment is needed.
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.
Nice job here @theck13 !
I only left a few comments but none is a blocker. Let me know what you think, thanks!
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 review! I believe I replied to all of your comments. Let me know if I missed anything.
@@ -20,23 +20,23 @@ enum class QuickStartMySitePrompts constructor( | |||
R.id.my_site_scroll_view_root, | |||
R.id.row_view_site, | |||
R.string.quick_start_dialog_view_site_message_short, | |||
R.drawable.ic_globe_grey_24dp, | |||
R.drawable.ic_globe_white_24dp, |
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 agree. I considered removing the color from the file name as well, but decided to leave it since we will not be able to use tinting for all drawables yet (e.g. the android:drawableTint
attribute requires minSdkVersion 23
). I thought leaving the color for icon variations would help avoid confusion by being more explicit.
@@ -353,7 +353,7 @@ void updateNotificationSuccessForPost(@NonNull PostModel post, @NonNull SiteMode | |||
isFirstTimePublish, true, false); | |||
PendingIntent pendingIntent = PendingIntent.getService(mContext, 0, publishIntent, | |||
PendingIntent.FLAG_CANCEL_CURRENT); | |||
notificationBuilder.addAction(R.drawable.ic_posts_grey_24dp, mContext.getString(R.string.button_publish), | |||
notificationBuilder.addAction(R.drawable.ic_posts_white_24dp, mContext.getString(R.string.button_publish), |
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.
We don't actually tint these icons in our code. They are automagically tinted by the operating system. You can see the share icon just above this change is white also. Some icons aren't even displayed on certain API versions. See the screenshots below for illustration.
...rc/main/java/org/wordpress/android/ui/prefs/notifications/NotificationsSettingsFragment.java
Show resolved
Hide resolved
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 left a comment in #8881 (comment) but otherwise, LGTM!
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 thorough review! I replied to your last comment. If you agree and there is nothing remaining, I think we're good to merge this one.
@@ -20,23 +20,23 @@ enum class QuickStartMySitePrompts constructor( | |||
R.id.my_site_scroll_view_root, | |||
R.id.row_view_site, | |||
R.string.quick_start_dialog_view_site_message_short, | |||
R.drawable.ic_globe_grey_24dp, | |||
R.drawable.ic_globe_white_24dp, |
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 agree. I plan to write a post and update the Drawable Resources section in the CONTRIBUTING.md
file to help other developers and our future selves with the tinting, naming, etc.
Fix
Update drawable usages with tint so that resources can be consolidated and minimized. Since the
minSdkVersion
is now21
, we can use theandroid:tint="color"
attribute andImageView.setImageTintList(ColorStateList)
method for all drawables. That allows us combine all drawables with the same path into a single file, which removes redundant files and reduces the app footprint. Using tint also helps us with theming and app-wide color changes in the future.I chose to make
white
(#ffffff
) the default color for drawables since white is the absence of pigment and that correlates to the absence of tint. It makes differentiating tinted and non-tinted icons easier also.Note
This is the first installment of the Drawables with Tint series.
Test
Sites
Quick Start
Stats
Site Pages
Plugins
Sharing
Reader
Me
Notification Settings
Review
Only one developer is required to review these changes, but anyone can perform the review.