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 android.text.TextUtils; | 7 import android.text.TextUtils; |
8 import android.util.Pair; | 8 import android.util.Pair; |
9 | 9 |
10 import org.chromium.base.Callback; | 10 import org.chromium.base.Callback; |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 assert label != null; | 191 assert label != null; |
192 assert iconIds != null; | 192 assert iconIds != null; |
193 assert descIds != null; | 193 assert descIds != null; |
194 EditorFieldModel result = new EditorFieldModel(INPUT_TYPE_HINT_ICONS); | 194 EditorFieldModel result = new EditorFieldModel(INPUT_TYPE_HINT_ICONS); |
195 result.mLabel = label; | 195 result.mLabel = label; |
196 result.mIconResourceIds = iconIds; | 196 result.mIconResourceIds = iconIds; |
197 result.mIconDescriptionsForAccessibility = descIds; | 197 result.mIconDescriptionsForAccessibility = descIds; |
198 return result; | 198 return result; |
199 } | 199 } |
200 | 200 |
| 201 /** Constructs a dropdown field model. */ |
| 202 public static EditorFieldModel createDropdown() { |
| 203 return new EditorFieldModel(INPUT_TYPE_HINT_DROPDOWN); |
| 204 } |
| 205 |
201 /** | 206 /** |
202 * Constructs a dropdown field model. | 207 * Constructs a dropdown field model. |
203 * | 208 * |
204 * @param label The human-readable label for user to understand
the type of data | 209 * @param label The human-readable label for user to understand
the type of data |
205 * that should be entered into this field. | 210 * that should be entered into this field. |
206 * @param dropdownKeyValues The keyed values to display in the dropdown. | 211 * @param dropdownKeyValues The keyed values to display in the dropdown. |
207 * @param hint The optional hint to be displayed when no value
is selected. | 212 * @param hint The optional hint to be displayed when no value
is selected. |
208 */ | 213 */ |
209 public static EditorFieldModel createDropdown( | 214 public static EditorFieldModel createDropdown( |
210 @Nullable CharSequence label, List<DropdownKeyValue> dropdownKeyValu
es, | 215 @Nullable CharSequence label, List<DropdownKeyValue> dropdownKeyValu
es, |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 assert isTextField(); | 330 assert isTextField(); |
326 return mActionIconAction; | 331 return mActionIconAction; |
327 } | 332 } |
328 | 333 |
329 /** @return The value icon generator or null if not exist. */ | 334 /** @return The value icon generator or null if not exist. */ |
330 public EditorValueIconGenerator getValueIconGenerator() { | 335 public EditorValueIconGenerator getValueIconGenerator() { |
331 assert isTextField(); | 336 assert isTextField(); |
332 return mValueIconGenerator; | 337 return mValueIconGenerator; |
333 } | 338 } |
334 | 339 |
335 private boolean isTextField() { | 340 /** @return Whether the input is a text field. */ |
| 341 public boolean isTextField() { |
336 return mInputTypeHint >= INPUT_TYPE_HINT_MIN_INCLUSIVE | 342 return mInputTypeHint >= INPUT_TYPE_HINT_MIN_INCLUSIVE |
337 && mInputTypeHint < INPUT_TYPE_HINT_MAX_TEXT_INPUT_EXCLUSIVE; | 343 && mInputTypeHint < INPUT_TYPE_HINT_MAX_TEXT_INPUT_EXCLUSIVE; |
338 } | 344 } |
339 | 345 |
| 346 /** @return Whether the input is a dropdown field. */ |
| 347 public boolean isDropdownField() { |
| 348 return mInputTypeHint == INPUT_TYPE_HINT_DROPDOWN; |
| 349 } |
| 350 |
340 /** @return The type of input, for example, INPUT_TYPE_HINT_PHONE. */ | 351 /** @return The type of input, for example, INPUT_TYPE_HINT_PHONE. */ |
341 public int getInputTypeHint() { | 352 public int getInputTypeHint() { |
342 return mInputTypeHint; | 353 return mInputTypeHint; |
343 } | 354 } |
344 | 355 |
345 /** @return Whether the checkbox is checked. */ | 356 /** @return Whether the checkbox is checked. */ |
346 public boolean isChecked() { | 357 public boolean isChecked() { |
347 assert mInputTypeHint == INPUT_TYPE_HINT_CHECKBOX; | 358 assert mInputTypeHint == INPUT_TYPE_HINT_CHECKBOX; |
348 return ContextUtils.getAppSharedPreferences().getBoolean(mValue.toString
(), true); | 359 return ContextUtils.getAppSharedPreferences().getBoolean(mValue.toString
(), true); |
349 } | 360 } |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
539 /** | 550 /** |
540 * Sets whether this input field should take up the full line. All fields ta
ke up the full line | 551 * Sets whether this input field should take up the full line. All fields ta
ke up the full line |
541 * by default. | 552 * by default. |
542 * | 553 * |
543 * @param isFullLine Whether the input field should take up the full line. | 554 * @param isFullLine Whether the input field should take up the full line. |
544 */ | 555 */ |
545 public void setIsFullLine(boolean isFullLine) { | 556 public void setIsFullLine(boolean isFullLine) { |
546 mIsFullLine = isFullLine; | 557 mIsFullLine = isFullLine; |
547 } | 558 } |
548 } | 559 } |
OLD | NEW |