Commit 3bb48361 authored by Jordan Demeulenaere's avatar Jordan Demeulenaere Committed by Commit Bot

[Autofill Assistant] Progress bar starts with initial progress of 10%.

Change-Id: I6eedb76b32a2ea78b7779daab37785bff0e00174
Reviewed-on: https://chromium-review.googlesource.com/c/1312478Reviewed-by: default avatarStephane Zermatten <szermatt@chromium.org>
Commit-Queue: Jordan Demeulenaere <jdemeulenaere@chromium.org>
Cr-Commit-Position: refs/heads/master@{#604633}
parent 624867ab
......@@ -81,7 +81,11 @@ public class AnimatedProgressBar {
mProgressBar.setVisibility(View.INVISIBLE);
}
public void setProgress(int progress) {
/**
* Set the progress to {@code progress} if it is higher than the current progress, or do nothing
* if it is not (hence it is OK to call this method with the same value multiple times).
*/
public void maybeIncreaseProgress(int progress) {
if (progress > mLastProgress) {
ObjectAnimator progressAnimation =
ObjectAnimator.ofInt(mProgressBar, PROGRESS_PROPERTY, mLastProgress, progress);
......
......@@ -45,6 +45,7 @@ import java.util.Locale;
class AutofillAssistantUiDelegate {
private static final String FEEDBACK_CATEGORY_TAG =
"com.android.chrome.USER_INITIATED_FEEDBACK_REPORT_AUTOFILL_ASSISTANT";
private static final int PROGRESS_BAR_INITIAL_PROGRESS = 10;
// TODO(crbug.com/806868): Use correct user locale.
private static final SimpleDateFormat sDetailsTimeFormat =
......@@ -233,15 +234,11 @@ class AutofillAssistantUiDelegate {
* @param message Message to display.
*/
public void showStatusMessage(@Nullable String message) {
ensureFullContainerIsShown();
show();
mStatusMessageView.setText(message);
}
private void ensureFullContainerIsShown() {
if (!mFullContainer.isShown()) show();
}
/**
* Updates the list of scripts in the bar.
*
......@@ -274,7 +271,7 @@ class AutofillAssistantUiDelegate {
}
setChipViewContainerGravity(hasHighlightedScript);
ensureFullContainerIsShown();
show();
}
private boolean hasHighlightedScript(ArrayList<ScriptHandle> scripts) {
......@@ -333,7 +330,13 @@ class AutofillAssistantUiDelegate {
}
public void show() {
if (!mFullContainer.isShown()) {
mFullContainer.setVisibility(View.VISIBLE);
// Set the initial progress. It is OK to make multiple calls to this method as it will
// have an effect only on the first one.
mProgressBar.maybeIncreaseProgress(PROGRESS_BAR_INITIAL_PROGRESS);
}
}
public void hide() {
......@@ -384,7 +387,7 @@ class AutofillAssistantUiDelegate {
mDetailsImage.setVisibility(View.INVISIBLE);
mDetails.setVisibility(View.VISIBLE);
setCarouselTopPadding();
ensureFullContainerIsShown();
show();
String url = details.getUrl();
if (!url.isEmpty()) {
......@@ -434,9 +437,9 @@ class AutofillAssistantUiDelegate {
}
public void showProgressBar(int progress, String message) {
ensureFullContainerIsShown();
show();
mProgressBar.show();
mProgressBar.setProgress(progress);
mProgressBar.maybeIncreaseProgress(progress);
if (!message.isEmpty()) {
mStatusMessageView.setText(message);
......@@ -481,7 +484,7 @@ class AutofillAssistantUiDelegate {
}
setChipViewContainerGravity(false);
ensureFullContainerIsShown();
show();
}
private void clearChipsViewContainer() {
......@@ -515,7 +518,7 @@ class AutofillAssistantUiDelegate {
}
setChipViewContainerGravity(false);
ensureFullContainerIsShown();
show();
}
private Promise<Bitmap> downloadImage(String url) {
......
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