Commit 9d304d7e authored by Jordan Demeulenaere's avatar Jordan Demeulenaere Committed by Commit Bot

[Autofill Assistant] Show cancellable snackbar when stopping AA.

Screenshot: https://screenshot.googleplex.com/kgCWVfNQx5e.png
Issue: b/118246783

Bug: 806868
Change-Id: I20f38afdbcdeb66c14b747aaa7b92f03ebf460a6
Reviewed-on: https://chromium-review.googlesource.com/c/1299159Reviewed-by: default avatarTheresa <twellington@chromium.org>
Reviewed-by: default avatarMathias Carlen <mcarlen@chromium.org>
Commit-Queue: Jordan Demeulenaere <jdemeulenaere@chromium.org>
Cr-Commit-Position: refs/heads/master@{#603104}
parent 8b3c4223
...@@ -29,6 +29,8 @@ import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile; ...@@ -29,6 +29,8 @@ import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile;
import org.chromium.chrome.browser.autofill.PersonalDataManager.CreditCard; import org.chromium.chrome.browser.autofill.PersonalDataManager.CreditCard;
import org.chromium.chrome.browser.help.HelpAndFeedback; import org.chromium.chrome.browser.help.HelpAndFeedback;
import org.chromium.chrome.browser.profiles.Profile; import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.snackbar.Snackbar;
import org.chromium.chrome.browser.snackbar.SnackbarManager;
import org.chromium.chrome.browser.widget.MaterialProgressBar; import org.chromium.chrome.browser.widget.MaterialProgressBar;
import java.io.InputStream; import java.io.InputStream;
...@@ -192,7 +194,8 @@ class AutofillAssistantUiDelegate { ...@@ -192,7 +194,8 @@ class AutofillAssistantUiDelegate {
mOverlay = mFullContainer.findViewById(R.id.overlay); mOverlay = mFullContainer.findViewById(R.id.overlay);
mOverlay.setOnClickListener(unusedView -> mClient.onClickOverlay()); mOverlay.setOnClickListener(unusedView -> mClient.onClickOverlay());
mBottomBar = mFullContainer.findViewById(R.id.bottombar); mBottomBar = mFullContainer.findViewById(R.id.bottombar);
mBottomBar.findViewById(R.id.close_button).setOnClickListener(unusedView -> shutdown()); mBottomBar.findViewById(R.id.close_button)
.setOnClickListener(unusedView -> mClient.onDismiss());
mBottomBar.findViewById(R.id.feedback_button) mBottomBar.findViewById(R.id.feedback_button)
.setOnClickListener(unusedView .setOnClickListener(unusedView
-> HelpAndFeedback.getInstance(mActivity).showFeedback(mActivity, -> HelpAndFeedback.getInstance(mActivity).showFeedback(mActivity,
...@@ -227,7 +230,7 @@ class AutofillAssistantUiDelegate { ...@@ -227,7 +230,7 @@ class AutofillAssistantUiDelegate {
} }
private void ensureFullContainerIsShown() { private void ensureFullContainerIsShown() {
if (!mFullContainer.isShown()) mFullContainer.setVisibility(View.VISIBLE); if (!mFullContainer.isShown()) show();
} }
/** /**
...@@ -288,6 +291,27 @@ class AutofillAssistantUiDelegate { ...@@ -288,6 +291,27 @@ class AutofillAssistantUiDelegate {
return chipView; return chipView;
} }
public void show() {
mFullContainer.setVisibility(View.VISIBLE);
}
public void hide() {
mFullContainer.setVisibility(View.GONE);
}
public void showAutofillAssistantStoppedSnackbar(
SnackbarManager.SnackbarController controller) {
int durationMs = SnackbarManager.DEFAULT_SNACKBAR_DURATION_MS;
Snackbar snackBar =
Snackbar.make(mActivity.getString(
R.string.autofill_assistant_stopped, durationMs / 1_000),
controller, Snackbar.TYPE_ACTION,
Snackbar.UMA_AUTOFILL_ASSISTANT_STOP_UNDO)
.setAction(mActivity.getString(R.string.undo), /* actionData= */ null);
snackBar.setDuration(durationMs);
mActivity.getSnackbarManager().showSnackbar(snackBar);
}
/** Called to show overlay. */ /** Called to show overlay. */
public void showOverlay() { public void showOverlay() {
mOverlay.setVisibility(View.VISIBLE); mOverlay.setVisibility(View.VISIBLE);
...@@ -367,14 +391,6 @@ class AutofillAssistantUiDelegate { ...@@ -367,14 +391,6 @@ class AutofillAssistantUiDelegate {
mProgressBar.setVisibility(View.INVISIBLE); mProgressBar.setVisibility(View.INVISIBLE);
} }
/**
* Shuts down the Autofill Assistant. The UI disappears and any associated state goes away.
*/
public void shutdown() {
mFullContainer.setVisibility(View.GONE);
mClient.onDismiss();
}
/** /**
* Show profiles in the bar. * Show profiles in the bar.
* *
......
...@@ -76,6 +76,7 @@ public class Snackbar { ...@@ -76,6 +76,7 @@ public class Snackbar {
public static final int UMA_FEED_NTP_STREAM = 26; public static final int UMA_FEED_NTP_STREAM = 26;
public static final int UMA_WEBAPK_PRIVACY_DISCLOSURE = 27; public static final int UMA_WEBAPK_PRIVACY_DISCLOSURE = 27;
public static final int UMA_TWA_PRIVACY_DISCLOSURE = 28; public static final int UMA_TWA_PRIVACY_DISCLOSURE = 28;
public static final int UMA_AUTOFILL_ASSISTANT_STOP_UNDO = 29;
private SnackbarController mController; private SnackbarController mController;
private CharSequence mText; private CharSequence mText;
......
...@@ -58,7 +58,7 @@ public class SnackbarManager implements OnClickListener, InfoBarContainer.InfoBa ...@@ -58,7 +58,7 @@ public class SnackbarManager implements OnClickListener, InfoBarContainer.InfoBa
default void onDismissNoAction(Object actionData) { } default void onDismissNoAction(Object actionData) { }
} }
private static final int DEFAULT_SNACKBAR_DURATION_MS = 3000; public static final int DEFAULT_SNACKBAR_DURATION_MS = 3000;
private static final int ACCESSIBILITY_MODE_SNACKBAR_DURATION_MS = 6000; private static final int ACCESSIBILITY_MODE_SNACKBAR_DURATION_MS = 6000;
// Used instead of the constant so tests can override the value. // Used instead of the constant so tests can override the value.
......
...@@ -3921,6 +3921,10 @@ However, you aren’t invisible. Going private doesn’t hide your browsing from ...@@ -3921,6 +3921,10 @@ However, you aren’t invisible. Going private doesn’t hide your browsing from
Close other incognito tabs Close other incognito tabs
</message> </message>
<!-- Autofill Assistant -->
<message name="IDS_AUTOFILL_ASSISTANT_STOPPED" desc="Text label that is shown when stopping the Autofill Assistant. DURATION_SECONDS is a number representing a duration in seconds, which is why it is appended with 's'.">
Autofill Assistant will stop in <ph name="DURATION_SECONDS">%1$s<ex>3</ex></ph>s…
</message>
</messages> </messages>
</release> </release>
</grit> </grit>
dccd747756f872e773b6b728c35bd264656efac2
\ No newline at end of file
...@@ -46264,6 +46264,7 @@ Called by update_net_trust_anchors.py.--> ...@@ -46264,6 +46264,7 @@ Called by update_net_trust_anchors.py.-->
<int value="26" label="FEED_NTP_STREAM"/> <int value="26" label="FEED_NTP_STREAM"/>
<int value="27" label="UMA_WEBAPK_PRIVACY_DISCLOSURE"/> <int value="27" label="UMA_WEBAPK_PRIVACY_DISCLOSURE"/>
<int value="28" label="UMA_TWA_PRIVACY_DISCLOSURE"/> <int value="28" label="UMA_TWA_PRIVACY_DISCLOSURE"/>
<int value="29" label="UMA_AUTOFILL_ASSISTANT_STOP_UNDO"/>
</enum> </enum>
<enum name="SnippetOpenMethod"> <enum name="SnippetOpenMethod">
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