Skip to content

Commit

Permalink
[Fast Checkout] Fix: ripple effect
Browse files Browse the repository at this point in the history
Re-adds ripple effect to all touchable surfaces. Fixes the previous
issues of background re-usage by using a custom RippleDrawable that
prevents sharing.

(cherry picked from commit 03226c2)

Bug: 1334642,1419775
Change-Id: I7ed24e19566494aee0c1eacb6b9f035b2e0ccba7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4288774
Commit-Queue: Wolfgang Billenstein <bwolfgang@google.com>
Reviewed-by: Norge Vizcay <vizcay@google.com>
Cr-Original-Commit-Position: refs/heads/main@{#1110200}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4295278
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Cr-Commit-Position: refs/branch-heads/5615@{#52}
Cr-Branched-From: 9c6408e-refs/heads/main@{#1109224}
  • Loading branch information
Wolfgang Billenstein authored and Chromium LUCI CQ committed Feb 28, 2023
1 parent aa7d518 commit e592e2e
Show file tree
Hide file tree
Showing 12 changed files with 109 additions and 97 deletions.
9 changes: 4 additions & 5 deletions chrome/browser/ui/android/fast_checkout/internal/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ android_library("java") {
"java/src/org/chromium/chrome/browser/ui/fast_checkout/FastCheckoutSheetContent.java",
"java/src/org/chromium/chrome/browser/ui/fast_checkout/FastCheckoutSheetState.java",
"java/src/org/chromium/chrome/browser/ui/fast_checkout/FastCheckoutUserActions.java",
"java/src/org/chromium/chrome/browser/ui/fast_checkout/UnsharableRippleDrawable.java",
"java/src/org/chromium/chrome/browser/ui/fast_checkout/detail_screen/AutofillProfileItemProperties.java",
"java/src/org/chromium/chrome/browser/ui/fast_checkout/detail_screen/AutofillProfileItemViewBinder.java",
"java/src/org/chromium/chrome/browser/ui/fast_checkout/detail_screen/CreditCardItemProperties.java",
Expand Down Expand Up @@ -61,11 +62,9 @@ android_resources("java_resources") {
sources = [
"java/res/anim/fast_checkout_view_flipper_fade_in.xml",
"java/res/anim/fast_checkout_view_flipper_fade_out.xml",
"java/res/drawable/fast_checkout_home_screen_address_background.xml",
"java/res/drawable/fast_checkout_home_screen_cc_background.xml",
"java/res/drawable/fast_checkout_item_background_bottom.xml",
"java/res/drawable/fast_checkout_item_background_top.xml",
"java/res/drawable/fast_checkout_list_view_background_middle.xml",
"java/res/drawable/fast_checkout_background_bottom.xml",
"java/res/drawable/fast_checkout_background_middle.xml",
"java/res/drawable/fast_checkout_background_top.xml",
"java/res/layout/fast_checkout_autofill_profile_item.xml",
"java/res/layout/fast_checkout_bottom_sheet.xml",
"java/res/layout/fast_checkout_credit_card_item.xml",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2023 The Chromium Authors
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<org.chromium.chrome.browser.ui.fast_checkout.UnsharableRippleDrawable
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:color="?android:attr/colorControlHighlight">
<item>
<org.chromium.components.browser_ui.widget.SurfaceColorDrawable
android:shape="rectangle"
app:surfaceElevation="@dimen/default_elevation_1">
<!-- TODO(crbug.com/1354596): Merge background resource for TTF Payments/Passwords and FC. -->
<corners android:topLeftRadius="@dimen/fast_checkout_inner_corner_radius"
android:topRightRadius="@dimen/fast_checkout_inner_corner_radius"
android:bottomLeftRadius="@dimen/fast_checkout_outer_corner_radius"
android:bottomRightRadius="@dimen/fast_checkout_outer_corner_radius" />
</org.chromium.components.browser_ui.widget.SurfaceColorDrawable>
</item>
</org.chromium.chrome.browser.ui.fast_checkout.UnsharableRippleDrawable>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2023 The Chromium Authors
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<org.chromium.chrome.browser.ui.fast_checkout.UnsharableRippleDrawable
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:color="?android:attr/colorControlHighlight">
<item>
<org.chromium.components.browser_ui.widget.SurfaceColorDrawable
android:shape="rectangle"
app:surfaceElevation="@dimen/default_elevation_1">
<corners android:radius="@dimen/fast_checkout_inner_corner_radius" />
</org.chromium.components.browser_ui.widget.SurfaceColorDrawable>
</item>
</org.chromium.chrome.browser.ui.fast_checkout.UnsharableRippleDrawable>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2023 The Chromium Authors
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<org.chromium.chrome.browser.ui.fast_checkout.UnsharableRippleDrawable
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:color="?android:attr/colorControlHighlight">
<item>
<org.chromium.components.browser_ui.widget.SurfaceColorDrawable
android:shape="rectangle"
app:surfaceElevation="@dimen/default_elevation_1">
<!-- TODO(crbug.com/1354596): Merge background resource for TTF Payments/Passwords and FC. -->
<corners android:topLeftRadius="@dimen/fast_checkout_outer_corner_radius"
android:topRightRadius="@dimen/fast_checkout_outer_corner_radius"
android:bottomLeftRadius="@dimen/fast_checkout_inner_corner_radius"
android:bottomRightRadius="@dimen/fast_checkout_inner_corner_radius" />
</org.chromium.components.browser_ui.widget.SurfaceColorDrawable>
</item>
</org.chromium.chrome.browser.ui.fast_checkout.UnsharableRippleDrawable>

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ found in the LICENSE file.
android:layout_width="match_parent"
android:paddingTop="@dimen/fast_checkout_home_sheet_address_card_padding"
android:paddingBottom="@dimen/fast_checkout_home_sheet_address_card_padding"
android:background="@drawable/fast_checkout_home_screen_address_background"
android:background="@drawable/fast_checkout_background_top"
android:orientation="horizontal">
<ImageView
android:layout_width="@dimen/fast_checkout_address_icon"
Expand Down Expand Up @@ -130,7 +130,7 @@ found in the LICENSE file.
android:layout_width="match_parent"
android:gravity="center_vertical"
android:minHeight="@dimen/fast_checkout_sheet_home_screen_cc_min_height"
android:background="@drawable/fast_checkout_home_screen_cc_background">
android:background="@drawable/fast_checkout_background_bottom">

<ImageView
android:id="@+id/fast_checkout_credit_card_icon"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

package org.chromium.chrome.browser.ui.fast_checkout;

import android.content.res.ColorStateList;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.RippleDrawable;

/**
* RippleDrawable that does not allow sharing across views. Returns a constant state of null.
*/
public class UnsharableRippleDrawable extends RippleDrawable {
private static final ColorStateList DUMMY_COLOR = ColorStateList.valueOf(0xFFFFFF);

public UnsharableRippleDrawable(ColorStateList color, Drawable content, Drawable mask) {
super(color, content, mask);
}

/**
* Constructor used for drawable inflation. Ideally this would call `super()` which is package
* private unfortunately. The public constructor's color parameter must not be null. The color
* passed during inflation will be overridden by the color set in the xml. The color xml
* attribute is required so passing any color here should not cause any unintended issues.
*/
public UnsharableRippleDrawable() {
this(DUMMY_COLOR, null, null);
}

@Override
public ConstantState getConstantState() {
// Returning null means that these drawables will not be able to be shared. This avoids
// issues with RecyclerView when backgrounds are shared and as result don't always fully
// cover items of different heights.
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
*/
private static @DrawableRes int getBackgroundDrawable(int position, int itemCount) {
if (position == 0) {
return R.drawable.fast_checkout_item_background_top;
return R.drawable.fast_checkout_background_top;
}

if (position == itemCount - 1) {
return R.drawable.fast_checkout_item_background_bottom;
return R.drawable.fast_checkout_background_bottom;
}

return R.drawable.fast_checkout_list_view_background_middle;
return R.drawable.fast_checkout_background_middle;
}
}

0 comments on commit e592e2e

Please sign in to comment.