Commit 6b430bef authored by Clemens Arbesser's avatar Clemens Arbesser Committed by Commit Bot

[Autofill Assistant] Fixed small bugs in payment request.

This fixes a bug with the chevron alignment and also a bug where the last (rather than the first) complete item was preselected in some cases.

Screenshot after change (chevron in payment method is now vertically centered): https://screenshot.googleplex.com/buOn4neaRxZ.png

Bug: b/138643986
Bug: b/138643669
Change-Id: Idf61e667a5290a2314d3d95d62f45cab9e0e0bc3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1729227
Auto-Submit: Clemens Arbesser <arbesser@google.com>
Reviewed-by: default avatarJordan Demeulenaere <jdemeulenaere@chromium.org>
Commit-Queue: Jordan Demeulenaere <jdemeulenaere@chromium.org>
Cr-Commit-Position: refs/heads/master@{#682738}
parent b5eb6934
...@@ -142,6 +142,7 @@ public abstract class AssistantPaymentRequestSection<T extends EditableOption> { ...@@ -142,6 +142,7 @@ public abstract class AssistantPaymentRequestSection<T extends EditableOption> {
for (int i = 0; i < options.size(); i++) { for (int i = 0; i < options.size(); i++) {
if (options.get(i).isComplete()) { if (options.get(i).isComplete()) {
selectedItemIndex = i; selectedItemIndex = i;
break;
} }
} }
// Fallback: if there are no complete items, select the first (incomplete) one. // Fallback: if there are no complete items, select the first (incomplete) one.
...@@ -227,16 +228,20 @@ public abstract class AssistantPaymentRequestSection<T extends EditableOption> { ...@@ -227,16 +228,20 @@ public abstract class AssistantPaymentRequestSection<T extends EditableOption> {
} }
private void updatePaddings() { private void updatePaddings() {
View titleView = mSectionExpander.getTitleView();
if (isEmpty()) { if (isEmpty()) {
// Section is empty, i.e., the title is the bottom-most widget. // Section is empty, i.e., the title is the bottom-most widget.
mSectionExpander.setTitlePadding(mTopPadding, mBottomPadding); titleView.setPadding(titleView.getPaddingLeft(), mTopPadding,
titleView.getPaddingRight(), mBottomPadding);
} else if (mSectionExpander.isExpanded()) { } else if (mSectionExpander.isExpanded()) {
// Section is expanded, i.e., the expanded widget is the bottom-most widget. // Section is expanded, i.e., the expanded widget is the bottom-most widget.
mSectionExpander.setTitlePadding(mTopPadding, mTitleToContentPadding); titleView.setPadding(titleView.getPaddingLeft(), mTopPadding,
titleView.getPaddingRight(), mTitleToContentPadding);
// No need to set additional bottom padding, expanded sections have enough already. // No need to set additional bottom padding, expanded sections have enough already.
} else { } else {
// Section is non-empty and collapsed -> collapsed widget is the bottom-most widget. // Section is non-empty and collapsed -> collapsed widget is the bottom-most widget.
mSectionExpander.setTitlePadding(mTopPadding, mTitleToContentPadding); titleView.setPadding(titleView.getPaddingLeft(), mTopPadding,
titleView.getPaddingRight(), mTitleToContentPadding);
setBottomPadding(mSectionExpander.getCollapsedView(), mBottomPadding); setBottomPadding(mSectionExpander.getCollapsedView(), mBottomPadding);
} }
} }
......
...@@ -146,18 +146,6 @@ public class AssistantVerticalExpander extends LinearLayout { ...@@ -146,18 +146,6 @@ public class AssistantVerticalExpander extends LinearLayout {
mExpandedContainer.setVisibility(visible ? View.VISIBLE : View.GONE); mExpandedContainer.setVisibility(visible ? View.VISIBLE : View.GONE);
} }
/**
* Sets the top/bottom padding of the title bar. This method should be used instead of manually
* setting a padding on the title view, because that would result in misalignment between title
* view and the expand chevron.
*/
public void setTitlePadding(int topPadding, int bottomPadding) {
mTitleContainer.setPadding(mTitleContainer.getPaddingLeft(), topPadding,
mTitleContainer.getPaddingRight(), bottomPadding);
mChevronButton.setPadding(mChevronButton.getPaddingLeft(), topPadding,
mChevronButton.getPaddingRight(), bottomPadding);
}
public View getChevronButton() { public View getChevronButton() {
return mChevronButton; return mChevronButton;
} }
......
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