Skip to content

Commit

Permalink
[Carousel] Updated MaskableFrameLayout to use Outline path clipping o…
Browse files Browse the repository at this point in the history
…n 33+ only.

PiperOrigin-RevId: 517128236
  • Loading branch information
hunterstich authored and paulfthomas committed Mar 16, 2023
1 parent 3f99392 commit 43c5077
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ public MaskableFrameLayout(
}

private MaskableDelegate createMaskableDelegate() {
if (VERSION.SDK_INT >= VERSION_CODES.R) {
return new MaskableDelegateV30(this);
if (VERSION.SDK_INT >= VERSION_CODES.TIRAMISU) {
return new MaskableDelegateV33(this);
} else if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
return new MaskableDelegateV21(this);
} else {
Expand Down Expand Up @@ -303,7 +303,7 @@ void invalidateClippingMethod(View view) {
}

/**
* A {@link MaskableDelegate} for API 21-29 that uses {@link ViewOutlineProvider} to clip when the
* A {@link MaskableDelegate} for API 21-32 that uses {@link ViewOutlineProvider} to clip when the
* shape being clipped is a round rect with symmetrical corners and canvas clipping for all other
* shapes.
*
Expand Down Expand Up @@ -366,16 +366,16 @@ public void getOutline(View view, Outline outline) {
}

/**
* A {@link MaskableDelegate} for API 30+ that uses {@link ViewOutlineProvider} to clip for
* A {@link MaskableDelegate} for API 33+ that uses {@link ViewOutlineProvider} to clip for
* all shapes.
*
* <p>{@link Outline#setPath(Path)} was added in API 30 and allows using {@link
* <p>{@link Outline#setPath(Path)} was added in API 33 and allows using {@link
* ViewOutlineProvider} to clip for all shapes.
*/
@RequiresApi(VERSION_CODES.R)
private static class MaskableDelegateV30 extends MaskableDelegate {
@RequiresApi(VERSION_CODES.TIRAMISU)
private static class MaskableDelegateV33 extends MaskableDelegate {

MaskableDelegateV30(View view) {
MaskableDelegateV33(View view) {
initMaskOutlineProvider(view);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@ public void testCutCornersApi21_doesNotUseViewOutlineProvider() {
assertThat(maskableFrameLayout.getClipToOutline()).isFalse();
}

@RequiresApi(api = VERSION_CODES.R)
@Config(sdk = VERSION_CODES.R)
@RequiresApi(api = VERSION_CODES.TIRAMISU)
@Config(sdk = VERSION_CODES.TIRAMISU)
@Test
public void testCutCornersApi30_usesViewOutlineProvider() {
public void testCutCornersApi33_usesViewOutlineProvider() {
MaskableFrameLayout maskableFrameLayout = createMaskableFrameLayoutWithSize(50, 50);
ShapeAppearanceModel model =
new ShapeAppearanceModel.Builder()
Expand Down

0 comments on commit 43c5077

Please sign in to comment.