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

Issue/drawables with tint (Part 1) #8881

Merged
merged 53 commits into from
Jan 4, 2019
Merged

Conversation

theck13
Copy link
Contributor

@theck13 theck13 commented Dec 28, 2018

Fix

Update drawable usages with tint so that resources can be consolidated and minimized. Since the minSdkVersion is now 21, we can use the android:tint="color" attribute and ImageView.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

  1. Go to Sites tab.
  2. Notice icons are shown on screen.

Quick Start

  1. Select site with Quick Start in progress.
  2. Go to Sites tab.
  3. Tap Quick Start item.
  4. Tap View your site task.
  5. Notice View Site icon is shown in snackbar.
  6. Tap Quick Start item.
  7. Tap Choose a theme task.
  8. Notice Themes icon is shown in snackbar.
  9. Tap Quick Start item.
  10. Tap Customize your site task.
  11. Notice Themes icon is shown in snackbar.

Stats

  1. Select site with statistics.
  2. Go to Sites tab.
  3. Tap Stats item.
  4. Tap Insights tab.
  5. Tap View More button in Latest Post Summary card.
  6. Notice chevron and other icons are shown in cards.
  7. Tap back arrow action in toolbar.
  8. Notice Posts, Views, Visitors, and Best Views Ever icons are shown in All Time Stats card.
  9. Tap Years tab.
  10. Notice page and post icons are shown in Posts and Pages card.
  11. Notice chevron icons are shown in Authors card.

Site Pages

  1. Select site with at least one page.
  2. Go to Sites tab.
  3. Tap Site Pages under Publish section.
  4. Tap tab with page(s).
  5. Notice ellipsis icon is shown for each page list item.

Plugins

  1. Select site able to install plugins.
  2. Go to Sites tab.
  3. Tap Plugins item under Configuration section.
  4. Tap plugin.
  5. Notice external chevron icons are shown in plugin detail screen.

Sharing

  1. Go to Sites tab.
  2. Tap Sharing item under Configuration section.
  3. Notice cog icon is shown in Sharing Buttons section.

Reader

  1. Select account with at least one site followed.
  2. Go to Reader tab.
  3. Notice ellipsis button is shown on post.
  4. Select Discover in toolbar filter.
  5. Tap post header of unfollowed site.
  6. Notice Follow icon is shown.
  7. Tap X action in toolbar.
  8. Tap ellipsis button on post from site not followed.
  9. Notice Follow, Share, and Block this site icons are shown in menu.
  10. Select Followed Sites in toolbar filter.
  11. Tap post header of followed site.
  12. Tap X action in toolbar.
  13. Tap ellipsis button on post.
  14. Notice Following, Turn on site notifications or Turn off site notifications, Share, and Block this site icons are shown in menu.
  15. Tap Edit tags and sites action in toolbar.
  16. Notice Follow icon is shown in Enter a URL or tag to follow field.

Me

  1. Go to Me tab.
  2. Notice icons are shown on screen.

Notification Settings

  1. Select account with at least one site.
  2. Go to Me tab.
  3. Tap Notification Settings item.
  4. Tap site under Your Sites section.
  5. Notice Notifications tab, Email, and All notifications icons are shown on screen.

Review

Only one developer is required to review these changes, but anyone can perform the review.

@@ -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,
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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:

  1. Remove the _white_ specifier to make the name look more general and thus, more "default" to chose or
  2. Add an extra specifier in the name, like _untinted_ or _generic_ or
  3. 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.

Copy link
Contributor Author

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.

Copy link
Contributor

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),
Copy link
Contributor

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 ?

Copy link
Contributor Author

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.

notification_actions

Copy link
Contributor

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 👍.

Copy link
Contributor Author

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.

Copy link
Contributor

@hypest hypest left a 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!

Copy link
Contributor Author

@theck13 theck13 left a 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,
Copy link
Contributor Author

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),
Copy link
Contributor Author

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.

notification_actions

Copy link
Contributor

@hypest hypest left a 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!

Copy link
Contributor Author

@theck13 theck13 left a 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,
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants