Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1141)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/payments/ui/PaymentRequestSection.java

Issue 2081533002: Edit contacts UI for PaymentRequest (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@contactDetails
Patch Set: Addressed comments Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/payments/ui/PaymentRequestSection.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/payments/ui/PaymentRequestSection.java b/chrome/android/java/src/org/chromium/chrome/browser/payments/ui/PaymentRequestSection.java
index 080d9b642662cde3b31b24a0b179dc571531dfe4..3636378029eae9b41db028919c9ca6a91ee47946 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/payments/ui/PaymentRequestSection.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/payments/ui/PaymentRequestSection.java
@@ -131,6 +131,7 @@ public abstract class PaymentRequestSection extends LinearLayout {
private PaymentRequestSection(Context context, String sectionName, SectionDelegate delegate) {
super(context);
mDelegate = delegate;
+ setId(R.id.payments_section);
setOnClickListener(delegate);
setOrientation(HORIZONTAL);
setGravity(Gravity.CENTER_VERTICAL);
@@ -553,6 +554,11 @@ public abstract class PaymentRequestSection extends LinearLayout {
mLabel.setText(stringId);
}
+ /** Set the button identifier for the option. */
+ public void setId(int id) {
+ mButton.setId(id);
+ }
+
private View createButton(
GridLayout parent, int rowIndex, boolean isSelected, boolean isEnabled) {
Context context = parent.getContext();
@@ -690,16 +696,22 @@ public abstract class PaymentRequestSection extends LinearLayout {
public void onClick(View v) {
if (!mDelegate.isAcceptingUserInput()) return;
+ // Handle click on the "ADD THING" button.
for (int i = 0; i < mOptionRows.size(); i++) {
OptionRow row = mOptionRows.get(i);
-
boolean wasClicked = row.mButton == v || row.mLabel == v || row.mIcon == v;
- if (row.mOption == null) {
- if (wasClicked) mDelegate.onAddPaymentOption(this);
- } else {
- row.setChecked(wasClicked);
+ if (row.mOption == null && wasClicked) {
+ mDelegate.onAddPaymentOption(this);
+ return;
}
}
+
+ // Update the radio button state: checked/unchecked.
+ for (int i = 0; i < mOptionRows.size(); i++) {
+ OptionRow row = mOptionRows.get(i);
+ boolean wasClicked = row.mButton == v || row.mLabel == v || row.mIcon == v;
+ if (row.mOption != null) row.setChecked(wasClicked);
+ }
}
@Override
@@ -841,10 +853,15 @@ public abstract class PaymentRequestSection extends LinearLayout {
mOptionRows.add(new OptionRow(mOptionLayout, i, item, item == selectedItem));
}
+ // For testing.
+ if (!mOptionRows.isEmpty()) mOptionRows.get(0).setId(R.id.payments_first_radio_button);
+
// If the user is allowed to add new options, show the button for it.
if (information.getAddStringId() != 0) {
- mOptionRows.add(new OptionRow(mOptionLayout, information.getSize(), null, false));
- mOptionRows.get(mOptionRows.size() - 1).setLabel(information.getAddStringId());
+ OptionRow addRow = new OptionRow(mOptionLayout, information.getSize(), null, false);
+ addRow.setLabel(information.getAddStringId());
+ addRow.setId(R.id.payments_add_option_button);
+ mOptionRows.add(addRow);
}
}

Powered by Google App Engine
This is Rietveld 408576698