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

[PaymentHandler] Set minimum load progress

Context: This is regarding the Bottom-sheet Payment Handler UI.
In slow connection, the toolbar on the UI appears empty and shows no
indicator of the current loading status, hardly distinguishing from
a state of freezing.

Old behavior: upon opening the PaymentHandlerUI, its toolbar shows
nothing but the payment app's url.

Change: set the minimum loading progress to be 5%. Apply it to the
initialization and the progress update.

New behavior: upon opening the PaymentHandlerUI, its toolbar shows
the payment app's url as well as a progress bar starting from at least
5%, which reassures users that the UI is busy loading the page.

Bug: 1029815
Change-Id: I05147c15e9c732c75a039c9c20fd021382ec8a72
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1951649Reviewed-by: default avatarRouslan Solomakhin <rouslan@chromium.org>
Commit-Queue: Liquan (Max) Gu <maxlg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#722498}
parent ebc60412
...@@ -48,7 +48,8 @@ public class PaymentHandlerToolbarCoordinator { ...@@ -48,7 +48,8 @@ public class PaymentHandlerToolbarCoordinator {
mToolbarView = new PaymentHandlerToolbarView(context, observer); mToolbarView = new PaymentHandlerToolbarView(context, observer);
PropertyModel model = new PropertyModel.Builder(PaymentHandlerToolbarProperties.ALL_KEYS) PropertyModel model = new PropertyModel.Builder(PaymentHandlerToolbarProperties.ALL_KEYS)
.with(PaymentHandlerToolbarProperties.PROGRESS_VISIBLE, true) .with(PaymentHandlerToolbarProperties.PROGRESS_VISIBLE, true)
.with(PaymentHandlerToolbarProperties.LOAD_PROGRESS, 0) .with(PaymentHandlerToolbarProperties.LOAD_PROGRESS,
PaymentHandlerToolbarMediator.MINIMUM_LOAD_PROGRESS)
.with(PaymentHandlerToolbarProperties.SECURITY_ICON, .with(PaymentHandlerToolbarProperties.SECURITY_ICON,
ConnectionSecurityLevel.NONE) ConnectionSecurityLevel.NONE)
.build(); .build();
......
...@@ -30,6 +30,11 @@ import java.net.URISyntaxException; ...@@ -30,6 +30,11 @@ import java.net.URISyntaxException;
private static final String TAG = "PaymentHandlerTb"; private static final String TAG = "PaymentHandlerTb";
/** The delay (four video frames - for 60Hz) after which the hide progress will be hidden. */ /** The delay (four video frames - for 60Hz) after which the hide progress will be hidden. */
private static final long HIDE_PROGRESS_BAR_DELAY_MS = (1000 / 60) * 4; private static final long HIDE_PROGRESS_BAR_DELAY_MS = (1000 / 60) * 4;
/**
* The minimum load progress that can be shown when a page is loading. This is not 0 so that
* it's obvious to the user that something is attempting to load.
*/
/* package */ static final float MINIMUM_LOAD_PROGRESS = 0.05f;
private final PropertyModel mModel; private final PropertyModel mModel;
private final PaymentHandlerToolbarObserver mObserver; private final PaymentHandlerToolbarObserver mObserver;
...@@ -102,6 +107,7 @@ import java.net.URISyntaxException; ...@@ -102,6 +107,7 @@ import java.net.URISyntaxException;
@Override @Override
public void loadProgressChanged(float progress) { public void loadProgressChanged(float progress) {
assert progress <= 1.0;
if (progress == 1.0) return; if (progress == 1.0) return;
// If the load restarts when the progress bar is waiting to hide, cancel the handler // If the load restarts when the progress bar is waiting to hide, cancel the handler
// callbacks. // callbacks.
...@@ -110,7 +116,8 @@ import java.net.URISyntaxException; ...@@ -110,7 +116,8 @@ import java.net.URISyntaxException;
mHideProgressBarHandler = null; mHideProgressBarHandler = null;
} }
mModel.set(PaymentHandlerToolbarProperties.PROGRESS_VISIBLE, true); mModel.set(PaymentHandlerToolbarProperties.PROGRESS_VISIBLE, true);
mModel.set(PaymentHandlerToolbarProperties.LOAD_PROGRESS, progress); mModel.set(PaymentHandlerToolbarProperties.LOAD_PROGRESS,
Math.max(progress, MINIMUM_LOAD_PROGRESS));
} }
@DrawableRes @DrawableRes
......
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