38 Commits

Author SHA1 Message Date
Chaoyang0201
632675e1a8 [BadgeDrawable] add horizontal and vertical offset to control position
Resolves https://github.com/material-components/material-components-android/pull/638
Resolves https://github.com/material-components/material-components-android/issues/630

Co-authored-by: wcshi <connieshi@google.com>

GIT_ORIGIN_REV_ID=511c955a11e05fdc0848c74938c4c194da22826e
PiperOrigin-RevId: 275522709
2019-11-01 13:28:23 -07:00
ldjesper
294f12498d Rename setCornerRadius to setAllCornerSizes
PiperOrigin-RevId: 272959729
2019-10-04 20:08:43 -04:00
connieshi
d4d0e7f5e9 Update badge gravity enum values to use Gravity values. Add unit test.
PiperOrigin-RevId: 268485092
2019-09-12 14:09:30 -04:00
marianomartin
215a839598 Internal cleanup
PiperOrigin-RevId: 267504117
2019-09-12 13:48:16 -04:00
marianomartin
0d4515cb46 Internal cleanup
PiperOrigin-RevId: 265971745
2019-08-29 14:59:20 -04:00
connieshi
31d0c08300 Update BadgeDrawble's center coordinate calculation to alleviate anchor content being overlapped by badge content.
Also limit on 1 character to be displayed in a round badge, 2+ characters will now be displayed in a pill shaped badge.

PiperOrigin-RevId: 264904269
2019-08-29 10:19:37 -04:00
cketcham
530f3678d6 Add @NonNull and @Nullable annotations
PiperOrigin-RevId: 264744296
2019-08-26 11:18:29 -04:00
connieshi
e1248f8771 Update BadgeDrawable's documentation to include information about badge's gravity mode.
PiperOrigin-RevId: 259775790
2019-07-24 15:11:50 -04:00
connieshi
0558a36c9a Add support for configuring badge gravity.
PiperOrigin-RevId: 259223232
2019-07-22 12:22:00 -04:00
marianomartin
a648bac7b2 Merge DrawableUtils classes
PiperOrigin-RevId: 257022779
2019-07-09 12:56:12 -04:00
marianomartin
164bf0fabd Internal cleanup
PiperOrigin-RevId: 255609320
2019-07-03 14:02:53 -04:00
connieshi
ccc48904e5 Add BadgeDrawable constructor that takes a xml resource.
PiperOrigin-RevId: 252709395
2019-06-18 13:15:07 -04:00
connieshi
b09336ef45 Reduce scope of a few BadgeDrawable methods.
PiperOrigin-RevId: 252399017
2019-06-18 11:49:54 -04:00
connieshi
4207eec335 Update BadgeDrawable to hold a weak reference to the user specified context.
PiperOrigin-RevId: 251697368
2019-06-10 08:58:40 -07:00
connieshi
63fed94c90 s/clearBadgeNumber/clearNumber
PiperOrigin-RevId: 251693601
2019-06-10 08:57:49 -07:00
connieshi
6aab297f53 Remove context parameter from BadgeDrawable#getContentDescription(Context)
PiperOrigin-RevId: 251492075
2019-06-10 08:55:30 -07:00
connieshi
c7d21aec95 Convenience wrapper method for Drawable#setVisible(boolean, boolean) with the second parameter hardcoded to false.
PiperOrigin-RevId: 249981625
2019-05-29 15:43:19 -04:00
connieshi
ddc56c800d Add convenience method to check if VERSION.SDK_INT < VERSION_CODES.JELLY_BEAN_MR2 in BadgeUtils.
PiperOrigin-RevId: 249855393
2019-05-24 14:28:16 -04:00
connieshi
ebaccf5a85 Add support for badgeStyle, a theme level style attribute for customizing the appearance of badges.
PiperOrigin-RevId: 249338990
2019-05-24 14:16:22 -04:00
connieshi
488f4873bb Add note about BadgeDrawable being under development and not supporting the full range of customization expected of a Material Android component. (e.g. themed attributes)
PiperOrigin-RevId: 246891342
2019-05-06 19:27:34 -04:00
connieshi
71f0a71cc9 s/StringRes/PluralsRes
Add null check before trying to use the PluralsRes containing savedState.contentDescriptionQuantityStrings

PiperOrigin-RevId: 246203433
2019-05-03 10:55:18 -04:00
connieshi
7a4ecb0392 Update TextDrawableHelper's constructor to take a delegate.
Update ChipDrawable and BadgeDrwable to pass a delegate when they instantiate TextDrawbleHelper.

PiperOrigin-RevId: 245469285
2019-04-29 15:56:31 -07:00
connieshi
3ad423e6b9 Update BottomNavigationItemView to include BadgeDrawable's content description.
Add setter for numberless and numbered badge content descriptions.

PiperOrigin-RevId: 244910418
2019-04-29 15:28:30 -07:00
connieshi
9d73854a97 Add SavedState for BadgeDrawable.
PiperOrigin-RevId: 244672502
2019-04-29 15:20:48 -07:00
connieshi
9d488d9208 Begin integrating BadgeDrawable into BottomNavigationView.
TODO:
- update javadocs to provide guidance on how to interact with BottomNavigation + Badging.
- Save badge states.
- Support displaying badges when bottom navigation item doesn't show an icon.
PiperOrigin-RevId: 244197244
2019-04-19 21:51:25 -04:00
connieshi
fd9d884acb Update BadgeDrawable to have public scope.
Update #getNumber to return non-negative integers.
Replace internal references to getNumber() with 'number' field when comparing to ICON_BADGE_NUMBER.

PiperOrigin-RevId: 243633143
2019-04-19 16:28:30 -04:00
connieshi
29f132bcd3 Remove unused methods for getting a badge's default background and text color.
PiperOrigin-RevId: 243615474
2019-04-19 16:26:59 -04:00
connieshi
ac1b2a0a26 Add javadoc for BadgeDrawable.
PiperOrigin-RevId: 243312323
2019-04-19 15:58:20 -04:00
connieshi
94dbf74f08 Add a convenience method to create an instance of BadgeDrawable with default values.
PiperOrigin-RevId: 243272352
2019-04-19 15:56:48 -04:00
connieshi
44f26a8d30 Simplify BadgeDrawable's constructor to not require anchor view or custom parent view.
PiperOrigin-RevId: 243259902
2019-04-19 15:50:59 -04:00
connieshi
a2c5d8956d Add static methods to return BadgeDrawable's default background and text color for the specified context.
PiperOrigin-RevId: 242111627
2019-04-05 16:01:05 -04:00
connieshi
37a62a805b s/clearBadgeValue/clearBadgeNumber
PiperOrigin-RevId: 240199703
2019-03-26 17:35:00 -04:00
connieshi
e4e6052713 Refactor BadgeDrawable so its center coordinates can be updated.
PiperOrigin-RevId: 239433981
2019-03-22 17:02:02 -04:00
connieshi
c6ce174cb8 Call Resources#getDimensionPixelSize instead of Resources#getDimenion.
PiperOrigin-RevId: 238480749
2019-03-22 16:09:54 -04:00
connieshi
b9112b2811 Viewoverlay is only available on API 18+. To support pre API-18, change BadgeDrawable to inherit from Drawable instead of MaterialShapeDrawable. Instead, add an instance of MaterialShapeDrawable as a member variable to BadgeDrawable.
PiperOrigin-RevId: 238289676
2019-03-22 16:06:49 -04:00
connieshi
9594f64985 Implement basic layout and drawing functionality for BadgeDrawable.
PiperOrigin-RevId: 237500680
2019-03-22 15:55:00 -04:00
isabellekim
db94f66f86 Updating MDC library build files to add testing of each target.
PiperOrigin-RevId: 235203056
2019-02-24 14:35:32 -05:00
connieshi
59bc6c3ebe Add boilerplate code (getters, setters, override abstract methods) define custom attributes for new custom drawable, BadgeDrawable.
PiperOrigin-RevId: 235037646
2019-02-24 14:30:54 -05:00