Commit 12212761 authored by Liquan (Max) Gu's avatar Liquan (Max) Gu Committed by Commit Bot

[PaymentHandler] Tapping on scrim not to dismiss sheet

Context: The Bottom-sheet based PaymentHandler UI is based on the
bottom-sheet, as its name suggested. For a ChromeActivity's
bottom-sheet, when users tap on the scrim, the default behavior is
dismissing the sheet. This behavior, however, would increase the avg
time for users to finish a transaction, because users may accidentally
tap to close the sheet and has to redo the transaction.

Old behavior: tapping the scrim of Payment Handler UI dismisses the
sheet.

Change: Since the sheet dismissal behavior is defined in the
onScrimClick method of the BottomSheet's default scrim-observer,
we override this method to bypass the dismissal.

New behavior: tapping the scrim of Payment Handler UI wouldn't dismiss
the sheet.

Bug: 1029815

Change-Id: If15ab2c7f293387fbc546c79006b2d2e811d6b38
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1935431Reviewed-by: default avatarMatthew Jones <mdjones@chromium.org>
Commit-Queue: Liquan (Max) Gu <maxlg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#723447}
parent 13ec987c
......@@ -52,6 +52,9 @@ import org.chromium.chrome.browser.tabmodel.TabModelObserver;
import org.chromium.chrome.browser.tabmodel.TabModelSelector;
import org.chromium.chrome.browser.tabmodel.TabModelSelectorObserver;
import org.chromium.chrome.browser.util.UrlConstants;
import org.chromium.chrome.browser.widget.ScrimView;
import org.chromium.chrome.browser.widget.ScrimView.EmptyScrimObserver;
import org.chromium.chrome.browser.widget.ScrimView.ScrimParams;
import org.chromium.chrome.browser.widget.prefeditor.Completable;
import org.chromium.chrome.browser.widget.prefeditor.EditableOption;
import org.chromium.components.payments.CurrencyFormatter;
......@@ -1421,11 +1424,20 @@ public class PaymentRequestImpl
public void onPaymentHandlerUiClosed() {
mPaymentUisShowStateReconciler.onPaymentHandlerUiClosed();
mPaymentHandlerUi = null;
ChromeActivity.fromWebContents(mWebContents).getScrim().hideScrim(true);
}
@Override
public void onPaymentHandlerUiShown() {
assert mPaymentHandlerUi != null;
mPaymentUisShowStateReconciler.onPaymentHandlerUiShown();
// Using an empty scrim observer is to avoid the dismissal of the bottom-sheet on tapping.
ScrimParams params = ChromeActivity.fromWebContents(mWebContents)
.getBottomSheetController()
.createScrimParams(new EmptyScrimObserver());
ScrimView scrim = ChromeActivity.fromWebContents(mWebContents).getScrim();
scrim.showScrim(params);
scrim.setViewAlpha(0);
}
@Override
......
......@@ -102,6 +102,11 @@ import org.chromium.ui.base.ActivityWindowAndroid;
return mToolbarView;
}
@Override
public boolean hasCustomScrimLifecycle() {
return true;
}
@Override
public int getVerticalScrollOffset() {
return 0;
......
......@@ -137,6 +137,17 @@ public class ScrimView extends View implements View.OnClickListener {
void onScrimVisibilityChanged(boolean visible);
}
/**
* An empty implementation of the ScrimObserver interface.
*/
public static class EmptyScrimObserver implements ScrimObserver {
@Override
public void onScrimClick() {}
@Override
public void onScrimVisibilityChanged(boolean visible) {}
}
/** The duration for the fading animation. */
private static final int FADE_DURATION_MS = 300;
......
......@@ -365,6 +365,15 @@ public class BottomSheetController implements Destroyable {
mSheetInitializer = null;
}
/**
* Create a ScrimParams anchoring on the bottom-sheet view.
* @param scrimObserver The scrimObserver to set for the ScrimParams.
*/
public ScrimParams createScrimParams(ScrimObserver scrimObserver) {
return new ScrimParams(/*anchorView=*/mBottomSheet, /*showInFrontOfAnchorView=*/false,
/*affectsStatusBar=*/true, /*topMargin=*/0, /*observer*/ scrimObserver);
}
// Destroyable implementation.
@Override
public void destroy() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment