29 Commits

Author SHA1 Message Date
dsn5ft
762835145c [Badge][Toolbar] Fix issue where menu item content description is not reset after clearing badge content
PiperOrigin-RevId: 675531679
2024-09-17 13:27:58 +00:00
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
5e6ea58280 [Badge] Add note in attachBadgeDrawable method docs about menu item views being re-used when there is a structural change in the menu. Since badges are attached to the views, this may change the menu item that the badge is intended for
PiperOrigin-RevId: 566995151
2023-09-21 14:45:39 +00:00
rightnao
9f2e6864d2 [NavigationBar] Set badges to be null instead of removing them from the sparse array so that removing badges before restoring badge states will not override the current state
PiperOrigin-RevId: 546027617
2023-07-07 17:49:34 +00:00
pubiqq
3ca41be8f0 [General] Fix typos
Resolves https://github.com/material-components/material-components-android/pull/2654

GIT_ORIGIN_REV_ID=b8f6728979875629f2c813ef90d2f671cf56b4eb
PiperOrigin-RevId: 442852630
2022-04-19 14:48:55 -04:00
pfthomas
ee49c5aa8b [BadgeDrawable][a11y] Attach/detach badge contentDescription when using menuItem.
Resolves https://github.com/material-components/material-components-android/issues/2429

PiperOrigin-RevId: 439651014
2022-04-07 11:11:54 -04: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
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
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
connieshi
bea697804d [Badge] Fix lint error.
PiperOrigin-RevId: 338072863
2020-10-20 09:23:31 -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
3d01309475 Change annotation on customBadgeParent parameter in BadgeUtils's methods to be @Nullable and add null check before referencing it.
Resolves https://github.com/material-components/material-components-android/issues/1322

PiperOrigin-RevId: 314122111
2020-06-01 17:00:19 -04:00
cketcham
530f3678d6 Add @NonNull and @Nullable annotations
PiperOrigin-RevId: 264744296
2019-08-26 11:18:29 -04:00
marianomartin
164bf0fabd Internal cleanup
PiperOrigin-RevId: 255609320
2019-07-03 14:02:53 -04:00
marianomartin
2de39fafe0 Internal cleanup
PiperOrigin-RevId: 253799644
2019-06-18 13:57:49 -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
fc109fa13b Save badge states in BottomNavigationMenuView.
PiperOrigin-RevId: 245446090
2019-04-29 15:54:12 -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
248e71adb7 Refactor logic to set BadgeDrawable's bounds into its own method.
PiperOrigin-RevId: 243326170
2019-04-19 15:59:16 -04:00
connieshi
7d8b2117a0 Automated g4 rollback of changelist 242675939
PiperOrigin-RevId: 242751222
2019-04-19 13:26:30 -04:00
connieshi
00ffe5eea8 Begin integrating BadgeDrawable into BottomNavigationView.
TODO:
- update javadocs to provide guidance on how to call Badging API.
- Save badge states.
- Support displaying badges when bottom navigation item doesn't show an icon.
PiperOrigin-RevId: 242675939
2019-04-19 13:21:35 -04:00
connieshi
efdf289139 Add helper method to remove a BadgeDrawable from its associated anchor.
PiperOrigin-RevId: 239109585
2019-03-22 16:49:03 -04:00
connieshi
238b658417 Add helper method for attaching a BadgeDrawable to its associated anchor.
For API 18+, the BadgeDrawable will be added as a view overlay.
For pre-API 18, the BadgeDrawable will be set as the foreground of a FrameLayout that is an ancestor of the anchor.

PiperOrigin-RevId: 238661951
2019-03-22 16:15:41 -04:00
connieshi
9594f64985 Implement basic layout and drawing functionality for BadgeDrawable.
PiperOrigin-RevId: 237500680
2019-03-22 15:55:00 -04:00