78 Commits

Author SHA1 Message Date
Ga\u00ebtan Muller
28dc750cf7 [Badge] Remove BadgeUtils.USE_COMPAT_PARENT
Resolves https://github.com/material-components/material-components-android/pull/4170

GIT_ORIGIN_REV_ID=35f11c97b64f22b9c3994b41b35c955f7a4261ed
PiperOrigin-RevId: 634877849
2024-05-17 21:08:54 +00:00
rightnao
9451acdb05 [Badge] Add badgeFixedEdge attribute to BadgeDrawable.
By default, badges are fixed at their start edge (meaning they grow towards the end). If using a badgeGravity corresponding to the start, you will need to update to badgeFixedEdge=end to maintain the same grow towards the start behavior as before

PiperOrigin-RevId: 632236586
2024-05-13 15:48:21 +00:00
rightnao
0d265b7ca5 [Badge] Deprecate autoAdjustToGrandparentBounds attribute since now badges automatically move within first ancestor view that does not clip children
PiperOrigin-RevId: 630215388
2024-05-03 19:29:13 +00:00
rightnao
3880efefef [Badge] Adjust badges to fit within the bounds of the first ancestor view that clips its children to avoid getting cut off
PiperOrigin-RevId: 629810011
2024-05-02 15:42:17 +00:00
Material Design Team
0c023ec336 Migrate annotation-experimental to aar_import and remove old lint target
Fixes failures in `material3` and `tiles` by opting in.

Fixes failures in `media3` and `protolayout` by disabling the check. This is not ideal, since it does not enable cross-language checks, but it is no worse than it was before.

Adds explicit `kotlin-stdlib` dependency where it was previously implicitly included by a poorly-configured `annotation-experimental` target.

Removes explicit `proguard.txt` reference from Car build, since it is already included in the AAR.

PUBLIC: Handle calls to @RequiresOptIn-annotated APIs
PiperOrigin-RevId: 584657528
2023-11-22 15:38:57 -05:00
rightnao
e3b255b3a0 [Docs] Crosslink github docs in javadocs
PiperOrigin-RevId: 546393704
2023-07-11 19:37:37 +00:00
rightnao
27abfdba4f [Badge] Deprecate bottom badge gravities and update docs and usages in catalog
PiperOrigin-RevId: 543527285
2023-06-27 18:55:22 +00:00
rightnao
2362f4b64b [Badge][NavigationRail] Add new attribute for vertical offset when font is large
PiperOrigin-RevId: 542366571
2023-06-26 23:37:57 +00:00
pubiqq
44a97f4a83 [Badge] Fix table formatting and remove unnecessary badge invalidation
Resolves https://github.com/material-components/material-components-android/pull/3356

GIT_ORIGIN_REV_ID=9f6839aa225d567a26a7db948734c28a1bbae44a
PiperOrigin-RevId: 526735605
2023-04-25 17:06:16 -04:00
conradchen
532b65d008 [Badge] Fix crash caused by non-ascii strings
PiperOrigin-RevId: 523793683
2023-04-13 09:09:49 -07:00
pubiqq
4d50aa41e7 [Badge] Badge cleanup/fixes:
- Allow single digit badges to be non-circular if the label text is too big horizontally.
- Change maxCharacterCount to truncate both strings and numbers, and add new attribute maxNumber to truncate only numbers
- Updated maxCharacterCount so that if it doesn't exist, it does not truncate instead of defaulting to a value

Resolves https://github.com/material-components/material-components-android/pull/3321

GIT_ORIGIN_REV_ID=a8f5866eef5ffd4d949b8c6d7f1451b563536a6e
Co-authored-by: imhappi
PiperOrigin-RevId: 523453145
2023-04-13 09:05:14 -07:00
rightnao
b706506c3d [Badge] Add attribute to automatically adjust badge so that it is within the anchor view's grandparent view's bounds
PiperOrigin-RevId: 523171594
2023-04-11 20:00:06 -07:00
rightnao
a0d0b53472 [Badge] Add getters/setters for vertical and horizontal badge padding
PiperOrigin-RevId: 520969935
2023-03-31 18:35:53 +00:00
pubiqq
c1ef52b8ea [Badge] Allow text strings in badges
Resolves https://github.com/material-components/material-components-android/pull/2978
GIT_ORIGIN_REV_ID=39c9f60cff607fba1e9ca57ae8bc155c5919e503
Co-authored-by: imhappi
PiperOrigin-RevId: 520368686
2023-03-29 19:18:22 +00:00
rightnao
fc0de1ba24 [Badge] Center badge content more correctly
PiperOrigin-RevId: 519835048
2023-03-28 16:14:53 +00:00
rightnao
8499b83ba1 [BadgeDrawable] Add padding in between top and bottom edges of badge and text
PiperOrigin-RevId: 518370027
2023-03-21 20:50:42 +00:00
rightnao
2ddcfe46b7 [Badge] Add shape appearance for badges
PiperOrigin-RevId: 512137782
2023-02-27 20:46:06 +00:00
rightnao
3c1ac05fac [Badge] Update M3 style to match specs. Alignment tweaks, text appearance change
resolves https://github.com/material-components/material-components-android/issues/3175

PiperOrigin-RevId: 506426087
2023-02-02 16:50:22 +00:00
rightnao
d0d0f54018 [Badge] Add new 'offsetAlignmentMode' attribute that determines where the offset starts for the badge.
PiperOrigin-RevId: 505222416
2023-01-30 16:43:42 +00:00
Material Design Team
285fa9de30 Automated g4 rollback of changelist 422930284
PiperOrigin-RevId: 422949121
2022-01-20 10:24:30 -05:00
Material Design Team
c52b95d4d5 Automated g4 rollback of changelist 420096508
PiperOrigin-RevId: 422930284
2022-01-19 19:34:23 -05:00
conradchen
a74675177f [Badge] Internal change
PiperOrigin-RevId: 420376250
2022-01-12 11:20:32 -05:00
conradchen
bbbeacd64e [Badge] Refactor Badge state managing logic
This CL fixes a couple of badge state related issues. First, it prevents the badges created before restoring instance states from being overwritten by the old instance states. Second, it makes badges reload their default style settings everytime when its being recreated so if the environment has been changed, the default values will reflect the environment change.

This CL also fixes that several attributes were not correctly saved/restored or their default values were not correctly loaded.

Resolves https://github.com/material-components/material-components-android/issues/2032

PiperOrigin-RevId: 420096508
2022-01-06 15:51:50 -05:00
conradchen
b8f2dd53e0 [Badge] Support different locale on badges
Resolves https://github.com/material-components/material-components-android/issues/2465

PiperOrigin-RevId: 413738198
2021-12-06 19:32:16 +00:00
Material Design Team
a487c89185 Internal change
PiperOrigin-RevId: 412135443
2021-11-29 17:35:39 +00:00
conradchen
5973920cff [Badge] Update badge position after clearing numbers
Resolves https://github.com/material-components/material-components-android/issues/2123

PiperOrigin-RevId: 381337622
2021-06-28 13:03:50 -07:00
hunterstich
b3b12f9051 Automated g4 rollback of changelist 372931550
PiperOrigin-RevId: 375483052
2021-05-24 17:11:44 -07:00
conradchen
7adfd93d80 [TooltipDrawable] Adding android:textColor support
PiperOrigin-RevId: 374887222
2021-05-20 14:03:30 -07:00
Material Design Team
915336b36c Automated g4 rollback of changelist 372538097
PiperOrigin-RevId: 372931550
2021-05-11 12:55:35 -04:00
hunterstich
bd4914dd8b [Badge] Support differing offsets for badges with/without text, support badge width and padding in styles.
PiperOrigin-RevId: 372538097
2021-05-07 12:25:52 -04:00
connieshi
948738e618 [Badge][Toolbar] Fix badge offset bug when attached and detached from a menu item on a toolbar.
Added switch to toggle show/hide edit menu item and added button to increment badge number.

Moved logic to add badgedrawable to onCreateOptionsMenu so that a new badgedrawable is NOT added every time onPrepareOptionsMenu is called (e.g. opening the overflow menu)

Resolves https://github.com/material-components/material-components-android/issues/2129

PiperOrigin-RevId: 365033209
2021-03-25 11:28:18 -04:00
DHM47
492e50f873 [Badge] Updated getBadgeText to return a string representation of the number formatted using system Locale.
Resolves https://github.com/material-components/material-components-android/issues/1859
Resolves https://github.com/material-components/material-components-android/pull/1860

GIT_ORIGIN_REV_ID=53544cc548c041c7337a257474abdbb4025cb6f3
PiperOrigin-RevId: 341656773
2020-11-10 15:17:10 -05:00
connieshi
bcb148681b [Badge] Save and restore visibility on config change.
Resolves https://github.com/material-components/material-components-android/issues/1779

PiperOrigin-RevId: 337889750
2020-10-19 11:44:23 -07:00
connieshi
9487c33b8a Automated g4 rollback of changelist 336347365
PiperOrigin-RevId: 336978123
2020-10-15 13:23:56 -07:00
Material Design Team
0f717f8cce Automated g4 rollback of changelist 336306885
PiperOrigin-RevId: 336347365
2020-10-15 13:01:02 -07:00
connieshi
5e35d14c18 [Badge] Update badge to support being anchored to any view in pre 18.
In <API18, BadgeDrawable will dynamically 1) wrap the anchor in a FrameLayout and 2) replace the anchor with the FrameLayout in the anchor' view hierarchy. BadgeDrawable will set itself as foreground on the FrameLayout.

If the user does not want BadgeDrawable to manipulate its view hierarchy, the user can pass in an instance of FrameLayout `customBadgeParent` in #attachBadgeDrawable instead.

Labeled BadgeUtils as experimental and removed the RestrictedTo(Scope.Library) annotation.

Updated TopAppBar main demo to show a badge on a toolbar menu item.

PiperOrigin-RevId: 336306885
2020-10-15 12:31:14 -07:00
marianomartin
555356b03f Internal cleanup
PiperOrigin-RevId: 318134343
2020-06-26 14:06:52 -04:00
connieshi
470998c3dd Change string annotation from @StringRes to @PluralRes for parameter passed to. #setContentDescriptionQuantityStringsResource
PiperOrigin-RevId: 314122165
2020-06-01 17:03:28 -04:00
connieshi
eb65ce5b94 Update badge content description to match badge text displayed (when badge number exceeds max badge number).
Currently, when badge number exceeds max badge number, badge will display max badge number++ e.g. badge number == 1000, badge displays 999+ but content descriptions say "1000 new notifications".
This cl changes the content description to be "999 and more new notifications"

PiperOrigin-RevId: 309219315
2020-05-01 14:40:16 -04:00
connieshi
facc94d1a0 Fix javadoc issues in BadgeDrawable
PiperOrigin-RevId: 300421740
2020-03-13 10:54:24 -04:00
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