62 Commits

Author SHA1 Message Date
rightnao
9a2347bda5 [Carousel] Force hero strategy to be start-aligned if there are not enough items to make it center-aligned
Resolves https://github.com/material-components/material-components-android/issues/3626

PiperOrigin-RevId: 572641635
2023-10-12 11:03:50 -07:00
rightnao
cbb380df61 [Carousel] Add logic for multibrowse strategy to change strategy when number of items is less than the number of keylines
Resolves https://github.com/material-components/material-components-android/issues/3598

PiperOrigin-RevId: 572078262
2023-10-10 10:46:28 -07:00
hunterstich
0356f24a63 [Carousel] Fixed focus order when using keyboard navigation for hero carousels.
When using the keybaord to move between items, FocusFinder would occasionally skip an item because it was using the unmasked bounds of each item to compare their distance.

PiperOrigin-RevId: 572025177
2023-10-10 10:44:21 -07:00
rightnao
ed4647d5df [Carousel] Cleaning up multi-browse strategy and removing compact arrangement
PiperOrigin-RevId: 572006115
2023-10-10 10:43:37 -07:00
rightnao
d5d604d0cc [Carousel] Disallowing center aligned hero strategy with only 2 items since it does not make any sense. With only 2 items there can only be a start state and end state with the hero strategy.
Resolves https://github.com/material-components/material-components-android/issues/3589

PiperOrigin-RevId: 568965460
2023-10-02 13:36:53 +00:00
rightnao
8cb444b268 [Carousel] Fix issue with uncontained carousel not having a proper end scroll value due to assumption made in end scroll calculation
resolves https://github.com/material-components/material-components-android/issues/3599

PiperOrigin-RevId: 568948116
2023-10-02 13:36:19 +00:00
rightnao
4a6ae4d0b6 [Carousel] Update scroll offset to scroll to the estimated position that it was at upon an initial load
Resolves https://github.com/material-components/material-components-android/issues/3590

PiperOrigin-RevId: 568642330
2023-09-26 20:55:25 -04:00
hunterstich
c418063205 [Carousel] Fixed strategies crashing when there is not enough available space for a large and a small item
If the carousel container is not large enough to fit a small item and large item that is at least as large as the minimum small item size, mutli-browse and hero strategies will create an arrangment with a single, large item.

PiperOrigin-RevId: 568610428
2023-09-26 20:54:33 -04:00
rightnao
93660d4241 [Carousel] Tweak uncontained strategy logic to adjust medium size items to improve motion
PiperOrigin-RevId: 566720825
2023-09-19 20:29:10 +00:00
hunterstich
b80d9a5ef4 [Carousel] Fixed formatted for KeylineState and KeylineStateList
PiperOrigin-RevId: 565711087
2023-09-15 17:26:58 -04:00
hunterstich
7151714711 [Carousel] Fixed keyline shifting in RTL for uncontained carousels
Resolves https://github.com/material-components/material-components-android/issues/3554
Resolves https://github.com/material-components/material-components-android/issues/3580

PiperOrigin-RevId: 565654556
2023-09-15 17:26:05 -04:00
pubiqq
4ce7e4c8fa [Carousel] Reduce the number of truncations in intermediate calculations
Resolves https://github.com/material-components/material-components-android/pull/3581
Resolves https://github.com/material-components/material-components-android/issues/3579

GIT_ORIGIN_REV_ID=1bcb42de0535edac134a6fc27dcb14b22f7dc1a5
PiperOrigin-RevId: 565653783
2023-09-15 17:25:17 -04:00
rightnao
c6ea2d4040 [Carousel] Update vertical scroll speed to be faster
PiperOrigin-RevId: 559888221
2023-08-25 19:21:59 +00:00
rightnao
3d84841cad [Carousel][A11y] Fix some a11y bugs in Carousel
PiperOrigin-RevId: 559881261
2023-08-25 17:51:59 +00:00
rightnao
b6f6eb555a [Carousel] Center aligned uncontained carousel
PiperOrigin-RevId: 559215330
2023-08-23 19:31:24 +00:00
rightnao
9d81cac125 [Carousel] Add left-aligned uncontained strategy
PiperOrigin-RevId: 559197283
2023-08-23 19:28:53 +00:00
rightnao
966f7daec9 [Carousel] Fix orientation not correct in item decoration calculations
Resolves https://github.com/material-components/material-components-android/issues/3500

PiperOrigin-RevId: 558825973
2023-08-21 19:11:40 +00:00
pubiqq
dc91b39d7c [Carousel] Update mask size on size change if mask x percentage has been set
Resolves https://github.com/material-components/material-components-android/pull/3450

GIT_ORIGIN_REV_ID=df8a325da6e4a796ab33d93e2ba165e40da8733e
Co-authored-by: imhappi
PiperOrigin-RevId: 558207460
2023-08-18 22:40:13 +00:00
rightnao
a16f180ce7 [Carousel] Fix issue with next carousel item not being masked properly
PiperOrigin-RevId: 551644125
2023-07-28 17:04:35 +00:00
rightnao
ff528621b3 [Carousel] Add a layout listener to recyclerview to refresh keyline state upon size change
PiperOrigin-RevId: 551280769
2023-07-27 22:50:16 +00:00
rightnao
547156e497 [Carousel] Add carousel alignment attribute
PiperOrigin-RevId: 548719675
2023-07-18 16:50:16 +00:00
rightnao
674ec44429 [Carousel] Fix issue with not refreshing keylines
PiperOrigin-RevId: 547956870
2023-07-17 15:58:09 +00:00
hunterstich
64b066a0c4 Automated g4 rollback of changelist 546859519
PiperOrigin-RevId: 547258405
2023-07-11 19:39:14 +00:00
hunterstich
14023d2c85 [Carousel] Fixed MaskableFrameLayout not updating mask after size change when setting the mask using setMaskXPercentage.
This also fixes the default list catalog demo not displaying any items due to every item's mask having an empty maskRect.

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

PiperOrigin-RevId: 546859519
2023-07-11 19:38:42 +00:00
rightnao
e3b255b3a0 [Docs] Crosslink github docs in javadocs
PiperOrigin-RevId: 546393704
2023-07-11 19:37:37 +00:00
rightnao
bc54f2e4b3 [Carousel] Add full screen strategy
PiperOrigin-RevId: 544471620
2023-07-05 13:39:56 +00:00
rightnao
7822ef827b [Carousel] Add orientation helper to clean up CarouselLayoutManager orientation differences
PiperOrigin-RevId: 543813088
2023-06-27 19:17:07 +00:00
rightnao
6b48d3bb80 [Carousel] Add vertical scrolling capability
PiperOrigin-RevId: 542943240
2023-06-27 13:37:53 +00:00
rightnao
29d8742917 [Carousel] Deprecate set/get mask x percentages in Maskable as they are no longer used anywhere, and is a misleading method due to these methods not actually having any effect on the Carousel as CarouselLayoutManager overrides the values.
PiperOrigin-RevId: 542347361
2023-06-26 21:40:18 +00:00
rightnao
9486de5f2f [Carousel] Ensure that masks are pushed out beyond the parent bounds if they are _on_ the parent bounds
PiperOrigin-RevId: 540105089
2023-06-14 15:14:54 +00:00
rightnao
16c1575758 [Carousel] Carousel updates and fixes
- If item width is more than twice the item height, limit the width to twice the item height and add a medium item to the hero variant of the carousel.
- Fix snaphelper to snap to closest keyline state instead of always the default keyline state
- Add new KeylineStatePositionList to keep track of which keyline states to be in for each position. Update scrollToPosition methods to take the correct keyline instead of default keyline

PiperOrigin-RevId: 537955672
2023-06-06 15:56:43 +00:00
rightnao
7d6a977d50 [Carousel] Fix contained mask logic to only update masks when it is still in view, and remove restrictions on mask size with childWidth/2F. The only restriction is that the right of the mask must be greater than the left of the mask.
PiperOrigin-RevId: 537080963
2023-06-05 18:42:52 +00:00
hunterstich
85b6d5018d [Carousel] Fixed multi browse strategy clipping extra small items before being fully collapsed
This moves mask rect calculation from MaskableFrameLayout into CarouselLayoutManager so CarouselLayoutManager can change the offsetting of the mask inside a child and clip according to both the keylines and the carousel container boundary.

PiperOrigin-RevId: 533082558
2023-05-22 18:34:32 +00:00
rightnao
340cd44b07 [Carousel] Add Hero carousel strategy
PiperOrigin-RevId: 531247503
2023-05-11 19:14:21 +00:00
rightnao
8938da8c28 [Carousel] Add CarouselSnapHelper
PiperOrigin-RevId: 529457461
2023-05-04 17:00:56 -04:00
rightnao
1c27404fc5 [Carousel] Refactor to reuse logic between different Carousel strategy classes
- Moved Arrangement class outside of MultiBrowseStrategy
- Added helper class CarouselStrategyHelper and moved common logic in MultiBrowseStrategy to CarouselStrategyHelper

PiperOrigin-RevId: 528924778
2023-05-03 16:06:57 -04:00
hunterstich
c031144d26 [NavigationView] Updated NavigationView to use ViewOutlineProvider to handle corner clipping when possible and remove drawerLayoutCornerClippingEnabled attribute.
PiperOrigin-RevId: 527633449
2023-04-27 16:38:17 -04:00
pubiqq
7bc26e5070 [Carousel] Fix item masking for API 21
Resolves https://github.com/material-components/material-components-android/pull/3330

GIT_ORIGIN_REV_ID=1c46e2882b074e35ab1f19af0af00f88dee84f4c
PiperOrigin-RevId: 523119333
2023-04-11 19:55:10 -07:00
hunterstich
0184b5baa9 [Carousel] Updated MultiBrowseCarouselStrategy to find best arrangments using a cost function
This changes the way arrangements are found by:
* Finding all possible arrangements of items
* Sort the arrangement candidates using a cost function that optimizes for total space fit, large item size retention, and adherence to other input params
* Fit and use the top arrangement to work within the carousel's available space

PiperOrigin-RevId: 522568015
2023-04-10 15:03:52 +00:00
hunterstich
93ceb7edee [Carousel] Add support for transitions by forcing canvas clipping when detaching from the window.
PiperOrigin-RevId: 517963541
2023-03-20 21:24:55 +00:00
hunterstich
43c507775f [Carousel] Updated MaskableFrameLayout to use Outline path clipping on 33+ only.
PiperOrigin-RevId: 517128236
2023-03-16 15:26:15 +00:00
hunterstich
3856af1b65 [Carousel] Updated setForceCompatClipping visibility for testing.
PiperOrigin-RevId: 516584087
2023-03-14 22:09:22 +00:00
hunterstich
733c9e08c2 [Carousel] Updated MaskableFrameLayout to clip more performantly.
Clipping is now handled differently depending on the shape being used and API level.
* 30+ always uses a ViewOutlineProvider
* 21+ uses a ViewOutlineProvider when the shape is a round rect
* All other API levels and cases fall back to canvas clipping

PiperOrigin-RevId: 516297199
2023-03-13 21:21:48 +00:00
hunterstich
359580b6c1 [Carousel] Changed Maskable.add/removeOnMaskChangedListener to Maskable.setOnMaskChangedListener.
This change is to prevent the case of items in a RecyclerView.Adapter being recycled and re-bound and having more and more listeners added to a MaskableFrameLayout.

PiperOrigin-RevId: 515048125
2023-03-08 21:30:15 +00:00
hunterstich
9d0732be9e [Carousel] Fixed child index bug causing items to be ordered incorrectly.
When filling the RecyclerView, views need to be added at the correct index (either begginning or end) depending on the direction of fill.

PiperOrigin-RevId: 513510079
2023-03-03 16:25:30 +00:00
hunterstich
112a0bd20e [Carousel] Restricted MultiBrowseCarouselStrategy's forceCompactArrangement constructor.
This parameter is experimental and planning to be removed in the future.

PiperOrigin-RevId: 510211297
2023-02-17 04:51:36 -08:00
hunterstich
6166e73d36 [Carousel] Implemented smoothScrollToPosition
PiperOrigin-RevId: 509873609
2023-02-17 04:32:27 -08:00
hunterstich
bdf73bf54a [Carousel] Minor javadoc working fixes
PiperOrigin-RevId: 509185650
2023-02-13 13:28:29 +00:00
hunterstich
220415d3c1 [Carousel] Fixed scroll offset calculation error when last focal keyline comes after the last child
Calculating end scroll offset was using the distance between the last child and the last focal keyline. When the last child came before the last keyline, an unexpected scroll offset was returned. This also adds a dropdown to the catalog demo to allow setting the number of items in the carousel.

PiperOrigin-RevId: 508739119
2023-02-10 22:52:03 +00:00
hunterstich
795979c283 [Carousel] Fixed MultiBrowseCarouselStrategy method visibility.
PiperOrigin-RevId: 508728594
2023-02-10 22:51:19 +00:00