Commit 0a0ad92f authored by Michele Mancina's avatar Michele Mancina Committed by Commit Bot

[Autofill Assistant] Fix for sticky buttons not always showing

Bug: b/156707484
Change-Id: I4903aadb5e1b2d8455c868b07c2abcca874e7c1d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2352822
Commit-Queue: Michele Mancina <micantox@google.com>
Reviewed-by: default avatarMathias Carlen <mcarlen@chromium.org>
Reviewed-by: default avatarClemens Arbesser <arbesser@google.com>
Cr-Commit-Position: refs/heads/master@{#798565}
parent 4e31d46a
...@@ -265,7 +265,12 @@ class AssistantBottomBarCoordinator implements AssistantPeekHeightCoordinator.De ...@@ -265,7 +265,12 @@ class AssistantBottomBarCoordinator implements AssistantPeekHeightCoordinator.De
model.getHeaderModel().addObserver((source, propertyKey) -> { model.getHeaderModel().addObserver((source, propertyKey) -> {
if (propertyKey == AssistantHeaderModel.CHIPS_VISIBLE if (propertyKey == AssistantHeaderModel.CHIPS_VISIBLE
|| propertyKey == AssistantHeaderModel.CHIPS) { || propertyKey == AssistantHeaderModel.CHIPS) {
animateChildren(rootView); // The PostTask is necessary as a workaround for the sticky button occasionally not
// showing, since the chip changes are now issued in the following UI iteration, the
// same needs to be done for the corresponding animations.
// TODO(b/164389932): Figure out a better fix that doesn't require issuing the
// change in the following UI iteration.
PostTask.postTask(UiThreadTaskTraits.DEFAULT, () -> animateChildren(rootView));
} }
}); });
......
...@@ -14,6 +14,7 @@ import androidx.annotation.Nullable; ...@@ -14,6 +14,7 @@ import androidx.annotation.Nullable;
import androidx.recyclerview.widget.DefaultItemAnimator; import androidx.recyclerview.widget.DefaultItemAnimator;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import org.chromium.base.task.PostTask;
import org.chromium.chrome.autofill_assistant.R; import org.chromium.chrome.autofill_assistant.R;
import org.chromium.chrome.browser.autofill_assistant.AssistantTextUtils; import org.chromium.chrome.browser.autofill_assistant.AssistantTextUtils;
import org.chromium.chrome.browser.autofill_assistant.carousel.AssistantChipAdapter; import org.chromium.chrome.browser.autofill_assistant.carousel.AssistantChipAdapter;
...@@ -22,6 +23,7 @@ import org.chromium.chrome.browser.settings.SettingsLauncherImpl; ...@@ -22,6 +23,7 @@ import org.chromium.chrome.browser.settings.SettingsLauncherImpl;
import org.chromium.chrome.browser.sync.settings.SyncAndServicesSettings; import org.chromium.chrome.browser.sync.settings.SyncAndServicesSettings;
import org.chromium.chrome.browser.util.ChromeAccessibilityUtil; import org.chromium.chrome.browser.util.ChromeAccessibilityUtil;
import org.chromium.components.browser_ui.widget.textbubble.TextBubble; import org.chromium.components.browser_ui.widget.textbubble.TextBubble;
import org.chromium.content_public.browser.UiThreadTaskTraits;
import org.chromium.ui.modelutil.PropertyKey; import org.chromium.ui.modelutil.PropertyKey;
import org.chromium.ui.modelutil.PropertyModelChangeProcessor; import org.chromium.ui.modelutil.PropertyModelChangeProcessor;
import org.chromium.ui.widget.ViewRectProvider; import org.chromium.ui.widget.ViewRectProvider;
...@@ -134,15 +136,21 @@ class AssistantHeaderViewBinder ...@@ -134,15 +136,21 @@ class AssistantHeaderViewBinder
} }
private void maybeShowChips(AssistantHeaderModel model, ViewHolder view) { private void maybeShowChips(AssistantHeaderModel model, ViewHolder view) {
if (model.get(AssistantHeaderModel.CHIPS_VISIBLE) // The PostTask is necessary as a workaround for the sticky button occasionally not showing,
&& !model.get(AssistantHeaderModel.CHIPS).isEmpty()) { // this makes sure that the change happens after any possibly clashing animation currently
view.mChipsContainer.setVisibility(View.VISIBLE); // happening.
view.mProfileIconView.setVisibility(View.GONE); // TODO(b/164389932): Figure out a better fix that doesn't require issuing the change in the
} else { // following UI iteration.
view.mChipsContainer.setVisibility(View.GONE); PostTask.postTask(UiThreadTaskTraits.DEFAULT, () -> {
if (model.get(AssistantHeaderModel.CHIPS_VISIBLE)
view.mProfileIconView.setVisibility(View.VISIBLE); && !model.get(AssistantHeaderModel.CHIPS).isEmpty()) {
} view.mChipsContainer.setVisibility(View.VISIBLE);
view.mProfileIconView.setVisibility(View.GONE);
} else {
view.mChipsContainer.setVisibility(View.GONE);
view.mProfileIconView.setVisibility(View.VISIBLE);
}
});
} }
private void setProfileMenuListener(ViewHolder view, @Nullable Runnable feedbackCallback) { private void setProfileMenuListener(ViewHolder view, @Nullable Runnable feedbackCallback) {
......
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