Commit 82c85bef authored by Marian Fechete's avatar Marian Fechete Committed by Commit Bot

[Autofill Assistant] Fix animation rendering crash on Payment Request.

Summary: The animation crashes on the payment section when switching
between billing addresses with and without a postcode.

When switching the require_billing_postal_code flag to true,
and using a profile with a billing address that does not have a
postcode, the Payment Request section will show an error message
requiring a billing postcode.
If users then edit the payment method and choose a billing address with
a postcode, the animation of the payment method section causes the app
to crash because the error message TextView is also being hidden (using
View.GONE). This is an animation rendering bug.

Fix: Disable animation on the payment method section for children of
the section choice list. The animation is not required and causes the
crash. Also setting the text of the error message to empty string when
there is no missing information.

Bug: b/139265901
Change-Id: I4b81b3dcbc08690a372748f2bb09d74968b33ccd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1753005Reviewed-by: default avatarJordan Demeulenaere <jdemeulenaere@chromium.org>
Commit-Queue: Marian Fechete <marianfe@google.com>
Cr-Commit-Position: refs/heads/master@{#686782}
parent 7d383387
...@@ -129,6 +129,15 @@ class AssistantBottomBarCoordinator ...@@ -129,6 +129,15 @@ class AssistantBottomBarCoordinator
mLayoutTransition.excludeChildren(mSuggestionsCoordinator.getView(), /* exclude= */ true); mLayoutTransition.excludeChildren(mSuggestionsCoordinator.getView(), /* exclude= */ true);
mLayoutTransition.excludeChildren(mActionsCoordinator.getView(), /* exclude= */ true); mLayoutTransition.excludeChildren(mActionsCoordinator.getView(), /* exclude= */ true);
// do not animate the contents of the payment method section inside the section choice list,
// since the animation is not required and causes a rendering crash.
mLayoutTransition.excludeChildren(
mPaymentRequestCoordinator.getView()
.findViewWithTag(
AssistantTagsForTesting.PAYMENT_REQUEST_PAYMENT_METHOD_SECTION_TAG)
.findViewById(R.id.section_choice_list),
/* exclude= */ true);
// Add child views to bottom bar container. We put all child views in the scrollable // Add child views to bottom bar container. We put all child views in the scrollable
// container, except the actions and suggestions. // container, except the actions and suggestions.
bottomBarView.addView(mHeaderCoordinator.getView(), 0); bottomBarView.addView(mHeaderCoordinator.getView(), 0);
......
...@@ -115,11 +115,8 @@ public class AssistantPaymentRequestPaymentMethodSection ...@@ -115,11 +115,8 @@ public class AssistantPaymentRequestPaymentMethodSection
hideIfEmpty(cardExpirationView); hideIfEmpty(cardExpirationView);
TextView methodIncompleteView = summaryView.findViewById(R.id.incomplete_error); TextView methodIncompleteView = summaryView.findViewById(R.id.incomplete_error);
if (!isComplete(method)) { setIncompleteErrorMessage(methodIncompleteView, method);
setIncompleteErrorMessage(methodIncompleteView, method); hideIfEmpty(methodIncompleteView);
} else {
methodIncompleteView.setVisibility(View.GONE);
}
} }
void onProfilesChanged(List<PersonalDataManager.AutofillProfile> profiles) { void onProfilesChanged(List<PersonalDataManager.AutofillProfile> profiles) {
...@@ -167,7 +164,7 @@ public class AssistantPaymentRequestPaymentMethodSection ...@@ -167,7 +164,7 @@ public class AssistantPaymentRequestPaymentMethodSection
mEditor.updateBillingAddressIfComplete(new AutofillAddress(mContext, profile)); mEditor.updateBillingAddressIfComplete(new AutofillAddress(mContext, profile));
} }
private boolean isComplete(AutofillPaymentInstrument method) { private boolean hasAllRequiredFields(AutofillPaymentInstrument method) {
if (!method.isComplete()) { if (!method.isComplete()) {
return false; return false;
} }
...@@ -190,6 +187,11 @@ public class AssistantPaymentRequestPaymentMethodSection ...@@ -190,6 +187,11 @@ public class AssistantPaymentRequestPaymentMethodSection
private void setIncompleteErrorMessage( private void setIncompleteErrorMessage(
TextView methodIncompleteView, AutofillPaymentInstrument method) { TextView methodIncompleteView, AutofillPaymentInstrument method) {
if (hasAllRequiredFields(method)) {
methodIncompleteView.setText("");
return;
}
// we have to show an error message either because the payment method is incomplete (missing // we have to show an error message either because the payment method is incomplete (missing
// information), or because a postcode is required and the billing address does not have // information), or because a postcode is required and the billing address does not have
// one. // one.
...@@ -198,7 +200,5 @@ public class AssistantPaymentRequestPaymentMethodSection ...@@ -198,7 +200,5 @@ public class AssistantPaymentRequestPaymentMethodSection
} else { } else {
methodIncompleteView.setText(R.string.autofill_assistant_payment_information_missing); methodIncompleteView.setText(R.string.autofill_assistant_payment_information_missing);
} }
methodIncompleteView.setVisibility(View.VISIBLE);
} }
} }
\ No newline at end of file
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