OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.chrome.browser.payments.ui; | 5 package org.chromium.chrome.browser.payments.ui; |
6 | 6 |
7 import org.chromium.base.VisibleForTesting; | 7 import org.chromium.base.VisibleForTesting; |
8 import org.chromium.chrome.R; | 8 import org.chromium.chrome.R; |
9 | 9 |
10 import java.util.ArrayList; | 10 import java.util.ArrayList; |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 if (mDataType == PaymentRequestUI.TYPE_SHIPPING_ADDRESSES) { | 171 if (mDataType == PaymentRequestUI.TYPE_SHIPPING_ADDRESSES) { |
172 return R.string.autofill_create_profile; | 172 return R.string.autofill_create_profile; |
173 } else if (mDataType == PaymentRequestUI.TYPE_CONTACT_DETAILS) { | 173 } else if (mDataType == PaymentRequestUI.TYPE_CONTACT_DETAILS) { |
174 return R.string.payments_add_contact; | 174 return R.string.payments_add_contact; |
175 } else if (mDataType == PaymentRequestUI.TYPE_PAYMENT_METHODS) { | 175 } else if (mDataType == PaymentRequestUI.TYPE_PAYMENT_METHODS) { |
176 return R.string.payments_add_card; | 176 return R.string.payments_add_card; |
177 } | 177 } |
178 return 0; | 178 return 0; |
179 } | 179 } |
180 | 180 |
| 181 /** |
| 182 * Returns the resource Id for generating string to preview options in this
section. |
| 183 * |
| 184 * @return The resource Id. |
| 185 */ |
| 186 public int getPreviewStringResourceId() { |
| 187 int resId = 0; |
| 188 switch (mDataType) { |
| 189 case PaymentRequestUI.TYPE_SHIPPING_ADDRESSES: |
| 190 resId = R.string.payment_request_shipping_addresses_preview; |
| 191 break; |
| 192 case PaymentRequestUI.TYPE_SHIPPING_OPTIONS: |
| 193 resId = R.string.payment_request_shipping_options_preview; |
| 194 break; |
| 195 case PaymentRequestUI.TYPE_PAYMENT_METHODS: |
| 196 resId = R.string.payment_request_payment_methods_preview; |
| 197 break; |
| 198 case PaymentRequestUI.TYPE_CONTACT_DETAILS: |
| 199 resId = R.string.payment_request_contacts_preview; |
| 200 break; |
| 201 } |
| 202 |
| 203 return resId; |
| 204 } |
| 205 |
181 /** @param msg The optional error message to display when the selection is i
nvalid. */ | 206 /** @param msg The optional error message to display when the selection is i
nvalid. */ |
182 public void setErrorMessage(String msg) { | 207 public void setErrorMessage(String msg) { |
183 mErrorMessage = msg; | 208 mErrorMessage = msg; |
184 } | 209 } |
185 | 210 |
186 /** @return The optional error message to display when the selection is inva
lid. */ | 211 /** @return The optional error message to display when the selection is inva
lid. */ |
187 public String getErrorMessage() { | 212 public String getErrorMessage() { |
188 return mErrorMessage; | 213 return mErrorMessage; |
189 } | 214 } |
190 | 215 |
(...skipping 17 matching lines...) Expand all Loading... |
208 int selection, @Nullable Collection<? extends PaymentOption> itemCol
lection) { | 233 int selection, @Nullable Collection<? extends PaymentOption> itemCol
lection) { |
209 if (itemCollection == null || itemCollection.isEmpty()) { | 234 if (itemCollection == null || itemCollection.isEmpty()) { |
210 mSelectedItem = NO_SELECTION; | 235 mSelectedItem = NO_SELECTION; |
211 mItems = null; | 236 mItems = null; |
212 } else { | 237 } else { |
213 mSelectedItem = selection; | 238 mSelectedItem = selection; |
214 mItems = new ArrayList<>(itemCollection); | 239 mItems = new ArrayList<>(itemCollection); |
215 } | 240 } |
216 } | 241 } |
217 } | 242 } |
OLD | NEW |