Skip to content

Commit

Permalink
Fix and enhance IconDrawable
Browse files Browse the repository at this point in the history
This commit adds lots of enhancements and fixes to IconDrawable:

 - Adds spin animation functionality.
 - Adds constant state in order to work around bugs in the framework and
   support library where this is expected.
 - Handle the case where the width of the icon is not the same as it's
   height by returning the correct intrinsic width, and changing the
   drawing logic to always fit the icon within it's bounds.
 - Adds support for color state lists.
 - Adds support for tint, and sets the default to implement the half
   translucency on disabled state, and removed the custom logic to do it
   by changing the alpha.
 - Modulates the existing alpha from the color instead of replacing it.
 - Removes the changing of the bounds upon size change, as that should
   only be done by the view.
 - Adds a public method to get the icon.
 - Adds missing implementations of base methods.

Note that because we need to be able to generate the drawable without a
Context from the constant state, the methods that resolved resources
(i.e. colors, dimensions) now have to take a Context as a parameter.
This unfortunately makes the change backwards-incompatible.

The spin animation logic is also slightly changed in CustomTypefaceSpan
to initialize the start time upon first draw instead of upon
instantiation, since that is the actual start time of the animation.
This matches it with the implementation in IconDrawable.
  • Loading branch information
1zaman committed Oct 28, 2015
1 parent ce3e73a commit 87eb194
Show file tree
Hide file tree
Showing 2 changed files with 382 additions and 82 deletions.
Loading

0 comments on commit 87eb194

Please sign in to comment.