Issue/888 woo aztec toolbar design changes#900
Merged
Conversation
This was referenced Apr 6, 2020
0nko
approved these changes
Apr 8, 2020
Contributor
0nko
left a comment
There was a problem hiding this comment.
Awesome work @anitaa1990! 🎖Tested on different emulator APIs and everything works perfectly.
![]()
0nko
suggested changes
Apr 8, 2020
Contributor
Author
|
Hey @0nko! Thanks so much for the review! I'm not sure why that test class is failing. I ran them locally and all of them are passing 🤔It looks like those tests are to test the functionality of the toolbar and this PR doesn't touch any of that. Are there any steps to reproducing them locally? |
0nko
approved these changes
Apr 9, 2020
Contributor
0nko
left a comment
There was a problem hiding this comment.
¯_(ツ)_/¯ weird. The tests were failing in your branch for me and when I switched to develop they passed, so I thought that something got broken here. But they're passing on CircleCI so it's probably some local issue.
4 real now
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

This PR fixes #888 by providing an option to customise the Aztec toolbar colors.
Changes
AztecToolbar:toolbarBackgroundColor- to change the background color of the Aztec Toolbar.toolbarBorderColor- to change the color of the divider above the Aztec toolbar.toolbarIconNormalColor,toolbarIconHighlightColor,toolbarIconDisabledColor- to change the color of the Aztec toolbar button icons.The third point from the above change took a lot longer than expected and is the reason for a lot of changes in this PR. To explain more clearly, vector assets are not supported below API 21 and since Aztec supports a minimum version of API 16, we needed to make changes to the project to accommodate this.
Changes added to support vector drawables for < API 21 devices
AndroidX vector supportin the app by addingvectorDrawables.useSupportLibrary = truetoaztec,appandwordpress-commentsmodules. This flag prevents the Android Gradle Plugin from generating PNG versions of the vector assets if the minSdkVersion is < 21.?attr/colorPrimary) to specify colors. I went with this approach to change the color of the tooolbar icons. So I modified all the vector drawables to usetoolbarIconNormalColor,toolbarIconHighlightColorandtoolbarIconDisabledColor. Then defined the attributes underAztecToolbarStyle. This style can be overridden in the calling app to change the colors.AppCompatResources.getDrawableand specifying the theme we need to use. In this case:AztecToolbarStyle. Example can be found here.StateListDrawablecontaining multiple vectors (for normal state, highlighted state and disabled state), when we askAppCompatResourcesto fetch the drawable, it will see the<selector>tag, shrug, and hand it to the platform to load. It therefore will not get a chance to load the nested<vector>so this will either fail (on API <21) or just fall back to the platform support. In order to fix this in lower version devices, I modified all the<selector>to use<animated-selector>.ContextCompat.getDrawableto useAppCompatResources.getDrawable(taking suggestion from this SO answer) since this was causing a crash issue in devices below API 21.I know the PR file size looks big but most of the changes are modifying
selectortoanimated-selectorand changing the static colors defined in the drawables to use theme colors so I felt it shouldn't be a problem.To test
AztecToolbarStylein ourapp/styles.xml.activity_main.xmlandv17/activity_main.xml:app/v21/styles.xml:Screenshots
API 16 - Default view (before overriding styles)
API 16 - Customised view (after overriding styles)
API 19 - Default view (before overriding styles)
API 19 - Customised view (after overriding styles)
API 21 - Default view (before overriding styles)
API 21 - Customised view (after overriding styles)
API 23 - Default view (before overriding styles)
API 23 - Customised view (after overriding styles)
API 28 - Default view (before overriding styles)
API 28 - Customised view (after overriding styles)
API 29 - Default view (before overriding styles)
API 29 - Customised view (after overriding styles)
Make sure strings will be translated:
strings.xmlas a part of the integration PR.