| 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.widget; | 5 package org.chromium.chrome.browser.widget; |
| 6 | 6 |
| 7 import android.content.Context; | 7 import android.content.Context; |
| 8 import android.os.Build; | 8 import android.os.Build; |
| 9 import android.support.design.widget.TextInputLayout; | 9 import android.support.design.widget.TextInputLayout; |
| 10 import android.text.TextUtils; | 10 import android.text.TextUtils; |
| 11 import android.util.AttributeSet; | 11 import android.util.AttributeSet; |
| 12 import android.view.View; | |
| 13 import android.widget.EditText; | |
| 14 | 12 |
| 15 import javax.annotation.Nullable; | 13 import javax.annotation.Nullable; |
| 16 | 14 |
| 17 /** | 15 /** |
| 18 * Handles bugs with the Android Support library's {@link TextInputLayout} until
Chrome can upgrade | 16 * Handles bugs with the Android Support library's {@link TextInputLayout} until
Chrome can upgrade |
| 19 * to a newer version. | 17 * to a newer version. |
| 20 * | 18 * |
| 21 * TODO(dfalcantara): Remove this super gross dirty hack once Chrome can roll ve
rsion 24: | 19 * TODO(dfalcantara): Remove this super gross dirty hack once Chrome can roll ve
rsion 24: |
| 22 * https://crbug.com/603635 | 20 * https://crbug.com/603635 |
| 23 */ | 21 */ |
| (...skipping 23 matching lines...) Expand all Loading... |
| 47 getEditText().setBackground( | 45 getEditText().setBackground( |
| 48 getEditText().getBackground().getConstantState().newDrawable
()); | 46 getEditText().getBackground().getConstantState().newDrawable
()); |
| 49 getEditText().getBackground().mutate(); | 47 getEditText().getBackground().mutate(); |
| 50 mIsBackgroundMutated = true; | 48 mIsBackgroundMutated = true; |
| 51 } | 49 } |
| 52 | 50 |
| 53 super.setError(error); | 51 super.setError(error); |
| 54 if (TextUtils.isEmpty(error)) setErrorEnabled(false); | 52 if (TextUtils.isEmpty(error)) setErrorEnabled(false); |
| 55 } | 53 } |
| 56 | 54 |
| 57 @Override | |
| 58 public void onFinishInflate() { | |
| 59 super.onFinishInflate(); | |
| 60 | |
| 61 if (getChildCount() == 1) { | |
| 62 // If there is a child to this TextInputLayout, automatically set th
e hint. | |
| 63 View child = getChildAt(0); | |
| 64 if (child instanceof EditText && child.getId() > NO_ID) setLabelFor(
child.getId()); | |
| 65 } | |
| 66 } | |
| 67 } | 55 } |
| OLD | NEW |