84 Commits

Author SHA1 Message Date
hunterstich
a295de9728 [TabLayout] Added fade inidcator animation mode.
PiperOrigin-RevId: 417842993
2021-12-22 14:48:54 -05:00
Material Design Team
cfc00aa5a3 Update android core class definitions across material
PiperOrigin-RevId: 414839941
2021-12-08 14:56:25 +00:00
Material Design Team
a487c89185 Internal change
PiperOrigin-RevId: 412135443
2021-11-29 17:35:39 +00:00
conradchen
823c34a90c [Tab] Fix NPE caused by set a position less than 0
If somehow scroll position is set to -1 with and position offset greater than 0.5, we will decide it's a valid scroll position which causes NPE for selected child not found.

Fixes this by checking if position is valid regardless the offset and falling back to 0 if a negative position is given.

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

PiperOrigin-RevId: 408894188
2021-11-10 16:12:49 -05:00
conradchen
328d269e6d [Tab] Fix NPE caused by null tab indicator
PiperOrigin-RevId: 397841987
2021-09-21 08:22:49 -07:00
conradchen
868f8aaba3 [Tab] Fix setting tab indicator and its full-width flag
1. When a new tab indicator drawable is set, we didn't correctly restore the previous set indicator height to the new drawable, or set the drawing bound to the intrinsic height of the drawable, if the indicator height was not specified. This result in a 0-height drawing bound after setting the tab indicator, which makes it disappear and can never go back if the tab indicator gravity is not "stretch" (which will recalculate the height after moving the indicator). Fixes this by correctly set the drawing bounds after a new tab indicator drawable is set.

2. After we set full-width flag of tab indicator, the width won't be updated until we move the tab indicator. Fixes this by explicitly triggering the recalculation of tab indicator's drawing bound after changing the flag.

Resolves: https://github.com/material-components/material-components-android/issues/2354
PiperOrigin-RevId: 397823617
2021-09-21 08:14:25 -07:00
conradchen
8a1f221e39 [Tab] Fix isSelected() may returns incorrect result
Resolves https://github.com/material-components/material-components-android/issues/2379

PiperOrigin-RevId: 397394397
2021-09-20 12:16:44 -07:00
conradchen
126df4c082 [Tab] Fix icon tint not applied on lower SDKs
On SDK < 23 if the icon is not a TintAwareDrawable, DrawableCompat.wrap() will return a new drawable which wraps the original drawable. However in the original logic after we set the tint to the icon, we didn't really set the tinted icon back to the tab or the image view, therefore the tint is not showing.

Moves the tint logic to updateTextAndIcon() to ensure tinted icons will be used in the image view.

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

PiperOrigin-RevId: 391368322
2021-08-18 10:02:28 -07:00
conradchen
e92ebdef09 [Tab] Redraw indicators after their color is updated
Also supports setting indicator color to transparent.

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

PiperOrigin-RevId: 381541396
2021-06-28 13:07:40 -07:00
connieshi
da2d8264d1 [Tabs][BottomNav] Do not show tooltip on long press for L and M devices to avoid freezing devices on repeated long press.
PiperOrigin-RevId: 355428951
2021-02-04 20:54:30 -05:00
connieshi
fd3639092e [Tabs] Show tooltip with tab text or content description (if tab is icon only) when long press.
PiperOrigin-RevId: 342411547
2020-11-14 10:16:08 -05:00
Material Design Team
cf9027f098 [TabLayout] Add a localized a11y string for a tab
PiperOrigin-RevId: 338706340
2020-10-23 12:31:51 -07:00
hunterstich
0afcb48f14 [TabLayout] Automated g4 rollback of changelist 337128442.
*** Reason for rollback ***

[TabLayout] Roll forward with dot indicator fix

*** Original change description ***

Automated g4 rollback of changelist 337092676

PiperOrigin-RevId: 337484043
2020-10-16 05:54:50 -07:00
hunterstich
91589f4c24 Automated g4 rollback of changelist 337092676
PiperOrigin-RevId: 337128442
2020-10-15 13:28:59 -07:00
hunterstich
f0a80c4e41 [TabLayout] Automated g4 rollback of changelist 336764852.
*** Reason for rollback ***

Roll forward with fix

*** Original change description ***

Automated g4 rollback of changelist 336704515

PiperOrigin-RevId: 337092676
2020-10-15 13:25:34 -07:00
connieshi
9487c33b8a Automated g4 rollback of changelist 336347365
PiperOrigin-RevId: 336978123
2020-10-15 13:23:56 -07:00
hunterstich
f743057941 Automated g4 rollback of changelist 336704515
PiperOrigin-RevId: 336764852
2020-10-15 13:16:16 -07:00
hunterstich
f8f3d9086e [TabLayout] Added initial indicator interpolation extensibility.
Added a linear and elastic interpolator to handle specing the indicator at any point between two tabs.

PiperOrigin-RevId: 336704515
2020-10-15 13:14:22 -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
David Sucharda
84fd465cea [TabLayout] Added support for preserving the indicator drawable's intrinsic color
Setting app:tabIndicatorColor="@null" (or app:tabIndicatorColor="@android:color/transparent") will now result in the intrinsic color of the indicator drawable being respected. To hide the indicator completely, instead set app:tabIndicator="@null".

Resolves https://github.com/material-components/material-components-android/issues/1481
Resolves https://github.com/material-components/material-components-android/pull/1483

GIT_ORIGIN_REV_ID=7926b2671fb119a6472cc180b77ea6fe1b63fbd1
PiperOrigin-RevId: 323928586
2020-07-30 00:21:33 -04:00
marianomartin
4e62f960ec [TabLayout] Add a setId method that can be used for espresso
PiperOrigin-RevId: 323570079
2020-07-29 09:14:46 -04:00
marianomartin
555356b03f Internal cleanup
PiperOrigin-RevId: 318134343
2020-06-26 14:06:52 -04:00
connieshi
d3e76d3a61 Alleviate badge being clipped off by calling setClipChildren(false) and setClipToPadding(false) on a tabview's parent.
If a long badge is shown on an end tab with a long string, it could still be clipped off. Current workaround is to adjust the badge offset.

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

PiperOrigin-RevId: 305686535
2020-04-13 09:27:58 -07:00
isabellekim
358f9a7a3d Add @deprecated to javadocs for methods and classes marked @Deprecated.
PiperOrigin-RevId: 300567533
2020-03-13 11:07:17 -04:00
marianomartin
bbd645a341 [TabLayout] Mutate tabSelectedIndicator before tinting
Resolves https://github.com/material-components/material-components-android/issues/1029
Resolves https://github.com/material-components/material-components-android/issues/963

PiperOrigin-RevId: 297866034
2020-02-28 13:02:51 -05:00
isabellekim
1f9de68025 [All] Add support for materialThemeOverlay
Resolves https://github.com/material-components/material-components-android/pull/948

GIT_ORIGIN_REV_ID=5a8bb35a56c1b813df47d964de8482a26e0da66d
PiperOrigin-RevId: 293839172
2020-02-10 09:55:19 -05:00
Material Design Team
f1053dfffb Add roleDescriptions to tabs for accessibility
PiperOrigin-RevId: 292620627
2020-02-03 10:22:49 -05:00
Material Design Team
1febcf94b1 Automated g4 rollback of changelist 292560239
PiperOrigin-RevId: 292606404
2020-01-31 16:53:08 -05:00
Material Design Team
811ea17e60 Add roleDescriptions to tabs for accessibility
PiperOrigin-RevId: 292560239
2020-01-31 13:38:39 -05:00
cketcham
0f18d9084c Prevent setting a height less than requested by using Math.round()
PiperOrigin-RevId: 290707432
2020-01-21 08:40:35 -08:00
marianomartin
3cd591fd71 Change OnTabSelectedListener back to extend BaseOnTabSelectedListener
This brings back binary compatibility with 1.0.0 and 1.1.0-RC.

The reason this broke was because members were removed from the OnTabSelectedListener superclass set.
Which is not supported, regardless of whether tab OnTabSelectedListener still kept the same members.

https://docs.oracle.com/javase/specs/jls/se7/html/jls-13.html#jls-13.4.4

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

PiperOrigin-RevId: 290152502
2020-01-17 13:06:04 -05:00
connieshi
a15d3ea219 Update TabLayout so it takes into account TabGravity in MODE_SCROLLABLE.
Add TabGravity.GRAVITY_START to maintain existing (default) MODE_SCROLLABLE behavior.
MODE_SCROLLABLE currently supports GRAVITY_CENTER and GRAVITY_START
MODE_FIXED does not support GRAVITY_START.

PiperOrigin-RevId: 289910847
2020-01-15 14:25:50 -08:00
marianomartin
17912e0599 Bring back removed TabLayout method for compatibility
Resolves https://github.com/material-components/material-components-android/issues/903

We accidentally removed this since it wasn't in 1.0.0 and it was deprecated. It exists to keep compatibility with version 27.0 of the library.

PiperOrigin-RevId: 289832106
2020-01-15 07:42:50 -08:00
Material Design Team
5de9f01ade Move a11y delegate code from BottomNavigationView and TabLayout to onInitializeA11yNodeInfo.
PiperOrigin-RevId: 286929652
2019-12-23 15:44:28 -05:00
Material Design Team
d548948b9c [TabLayout] Re-introducing TabLayout indicator animator fix from cl/283626239
Includes a preemptive fix for b/145715060, which was introduced in the first attempt.

PiperOrigin-RevId: 284229049
2019-12-08 15:21:33 -05:00
Material Design Team
d8c35d7de9 Automated g4 rollback of changelist 283626239
PiperOrigin-RevId: 284045727
2019-12-08 14:43:33 -05:00
Material Design Team
aa3164d43a [Tabs] Remove unnecessary animator cancellation in SlidingTabIndicator's onLayout method.
PiperOrigin-RevId: 283626239
2019-12-05 14:37:00 -05:00
Material Design Team
cc9b9c1103 Add CollectionInfos and CollectionItemInfos to tabs for accessibility. Also make a tab non-clickable by a11y when it is selected.
PiperOrigin-RevId: 281785987
2019-11-22 21:25:50 +00:00
connieshi
b200a3b6d2 Hardcode classname used to set accessibility item type to avoid being proguarded.
PiperOrigin-RevId: 281120646
2019-11-19 10:27:29 -08:00
ldjesper
a2434cd738 Remove deprecated method setOnTabSelectedListener
PiperOrigin-RevId: 272946975
2019-10-04 16:34:41 -04:00
ldjesper
440fea02c8 Make TabView a public final class since a field of that type is in the 1.0.0 public API
Reference: https://github.com/material-components/material-components-android/blob/master/lib/java/com/google/android/material/tabs/TabLayout.java#L1888

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

PiperOrigin-RevId: 272592933
2019-10-03 11:44:06 -04:00
connieshi
230ed9263f Add null checks to avoid NPE when tabs that have badges are reset .
Resolves https://github.com/material-components/material-components-android/issues/620

PiperOrigin-RevId: 271126107
2019-09-26 17:54:25 -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
cketcham
9aa7c6c5e8 Add @NonNull and @Nullable annotations
PiperOrigin-RevId: 265133335
2019-08-29 11:16:11 -04:00
gauthams
3f4ae91ebc Don't include padding in idealHeight measurement for TabLayout child view
PiperOrigin-RevId: 264194304
2019-08-20 11:13:51 -04:00
gauthams
3085967e11 Enable TabLayout to wrap_content for its height if the tab items are taller than the default TabLayout height
PiperOrigin-RevId: 262462019
2019-08-16 15:37:07 -04:00
dniz
cc73c2a630 Update TODOs
PiperOrigin-RevId: 259535844
2019-07-23 11:21:39 -04:00
isabellekim
a628bf516b Revert the library to compile with Java 7: revert lambdas, add necessary casts, and make some variables final.
Continue compile shrine demo, catalog, and tests with Java 8.

PiperOrigin-RevId: 257874888
2019-07-15 19:19:23 -04:00