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

[PaymentHandler] Drop bottomsheet content height calculation hack

The PaymentHandler UI used to have a workaround to get the bottomsheet
padding for content height computation. Now that CL[1] has fixed the
bottom-sheet height computation issue, the workaround caused "overfix"
and so need to be dropped.

[1] https://chromium-review.googlesource.com/c/chromium/src/+/2372811

Bug: 1125515, 1059269
Change-Id: I9fd7701c5cd658ebb9ea87fe0825e0ce050a49a5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2398959Reviewed-by: default avatarSahel Sharify <sahel@chromium.org>
Reviewed-by: default avatarMatthew Jones <mdjones@chromium.org>
Commit-Queue: Liquan (Max) Gu <maxlg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#804970}
parent e8a4f85f
......@@ -4,9 +4,6 @@
package org.chromium.chrome.browser.payments.handler;
import android.content.Context;
import android.view.View;
import androidx.annotation.VisibleForTesting;
import org.chromium.chrome.browser.ChromeVersionInfo;
......@@ -15,7 +12,6 @@ import org.chromium.chrome.browser.app.ChromeActivity;
import org.chromium.chrome.browser.payments.handler.toolbar.PaymentHandlerToolbarCoordinator;
import org.chromium.components.browser_ui.bottomsheet.BottomSheetController;
import org.chromium.components.browser_ui.bottomsheet.BottomSheetControllerProvider;
import org.chromium.components.browser_ui.styles.R;
import org.chromium.components.embedder_support.view.ContentView;
import org.chromium.components.payments.PaymentFeatureList;
import org.chromium.components.thinwebview.ThinWebView;
......@@ -91,7 +87,6 @@ public class PaymentHandlerCoordinator {
PaymentHandlerMediator mediator = new PaymentHandlerMediator(model, this::hide,
mWebContents, uiObserver, activity.getActivityTab().getView(),
mToolbarCoordinator.getToolbarHeightPx(),
calculateBottomSheetToolbarContainerTopPadding(activity),
activity.getLifecycleDispatcher(),
BottomSheetControllerProvider.from(activity.getWindowAndroid()));
activity.getWindow().getDecorView().addOnLayoutChangeListener(mediator);
......@@ -139,18 +134,6 @@ public class PaymentHandlerCoordinator {
mWebContents.getNavigationController().loadUrl(new LoadUrlParams(url.getSpec()));
}
// TODO(crbug.com/1059269): This approach introduces coupling by assuming BottomSheet toolbar's
// layout. Remove it once we can calculate visible content height with better ways.
/**
* @return bottom_sheet_toolbar_container's top padding. This is used to calculate the visible
* content height.
*/
private int calculateBottomSheetToolbarContainerTopPadding(Context context) {
View view = new View(context);
view.setBackgroundResource(R.drawable.top_round);
return view.getPaddingTop();
}
/**
* Get the WebContents of the Payment Handler for testing purpose. In other situations,
* WebContents should not be leaked outside the Payment Handler.
......
......@@ -60,7 +60,6 @@ import java.lang.annotation.RetentionPolicy;
private final View mTabView;
private final BottomSheetController mBottomSheetController;
private final int mToolbarViewHeightPx;
private final int mContainerTopPaddingPx;
private @CloseReason int mCloseReason = CloseReason.OTHERS;
/** A token held while the payment sheet is obscuring all visible tabs. */
......@@ -87,15 +86,13 @@ import java.lang.annotation.RetentionPolicy;
* @param observer The {@link PaymentHandlerUiObserver} that observes this Payment Handler UI.
* @param tabView The view of the main tab.
* @param toolbarViewHeightPx The height of the toolbar view in px.
* @param containerTopPaddingPx The padding top of bottom_sheet_toolbar_container in px
* @param activityLifeCycleDispatcher The lifecycle dispatcher of the activity where this UI
* lives.
* @param sheetController A {@link BottomSheetController} to show UI in.
*/
/* package */ PaymentHandlerMediator(PropertyModel model, Runnable hider,
WebContents webContents, PaymentHandlerUiObserver observer, View tabView,
int toolbarViewHeightPx, int containerTopPaddingPx,
ActivityLifecycleDispatcher activityLifeCycleDispatcher,
int toolbarViewHeightPx, ActivityLifecycleDispatcher activityLifeCycleDispatcher,
BottomSheetController sheetController) {
super(webContents);
assert webContents != null;
......@@ -107,7 +104,6 @@ import java.lang.annotation.RetentionPolicy;
mModel.set(PaymentHandlerProperties.BACK_PRESS_CALLBACK, this::onSystemBackButtonClicked);
mHider = hider;
mPaymentHandlerUiObserver = observer;
mContainerTopPaddingPx = containerTopPaddingPx;
mModel.set(PaymentHandlerProperties.CONTENT_VISIBLE_HEIGHT_PX, contentVisibleHeight());
mActivityLifecycleDispatcher = activityLifeCycleDispatcher;
......@@ -144,8 +140,7 @@ import java.lang.annotation.RetentionPolicy;
/** @return The height of visible area of the bottom sheet's content part. */
private int contentVisibleHeight() {
return (int) (mTabView.getHeight() * FULL_HEIGHT_RATIO) - mToolbarViewHeightPx
- mContainerTopPaddingPx;
return (int) (mTabView.getHeight() * FULL_HEIGHT_RATIO) - mToolbarViewHeightPx;
}
// Implement BottomSheetObserver:
......
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