69 Commits

Author SHA1 Message Date
momt99
ee93fc15c4 [TextInputLayout] Added id for errorIconView
Resolves https://github.com/material-components/material-components-android/pull/1624
Resolves https://github.com/material-components/material-components-android/issues/1623

GIT_ORIGIN_REV_ID=acf854dc995d734383ed25689b8efd7606f75537
PiperOrigin-RevId: 327673226
2020-08-20 16:48:23 -04:00
leticiars
bc4c6e47ae [TextFields] Adjusted label position and edit text padding of filled text field for large font support. Also removed margin of icons when font is large.
PiperOrigin-RevId: 326486771
2020-08-13 16:50:06 -04:00
leticiars
1f8e76b3a1 [TextInputLayout] Fixed helper text position for large font sizes.
PiperOrigin-RevId: 325521228
2020-08-10 13:18:03 -04:00
leticiars
99c6a28b10 [TextInputLayout] Flipping password icon behavior so that it shows the action (what's going to happen after the click) instead of the current status.
PiperOrigin-RevId: 307878068
2020-04-22 17:42:45 -04:00
leticiars
2df71d156b [TextInputLayout] Fixing counter RTL not working for all languages.
PiperOrigin-RevId: 305286488
2020-04-09 05:19:45 -07:00
leticiars
d1850a3d78 [ExposedDropdownMenu] Implement workaround to inputType=none not working + move MaterialAutoCompleteTextView to textfield/ directory.
The alternative to android:editable="false" (which is deprecated) is to set inputType="none", however due to a framework bug that has no effect. This change makes it so it works as expected.

PiperOrigin-RevId: 299411110
2020-03-09 09:36:24 -07:00
leticiars
9d71db9717 Adding textInputLayoutFocusedRectEnabled attr to disable using the TextInputLayout's rect by default.
PiperOrigin-RevId: 291747634
2020-01-28 16:09:58 -05:00
leticiars
237f0f3c56 Adding nullness annotations and fixing some other lint issues.
PiperOrigin-RevId: 289110313
2020-01-10 10:23:03 -08:00
leticiars
2084fd3f70 [Text Fields] Pan window so that keyboard doesn't hide helper/error views.
It doesn't pan if the user can already scroll (for example if it's in a scroll view).

PiperOrigin-RevId: 286424421
2019-12-19 15:47:57 -05:00
afohrman
201ec6241c Add support for placeholder text in TextInputLayout.
This is the initial implementation of placeholder text; it does not contain motion. At this stage, TextInputLayout sets the placeholder text visibility based on whether or not it should show.

PiperOrigin-RevId: 284808331
2019-12-11 17:06:57 -05:00
leticiars
eabbfa2aa5 Limiting helper/error view width so that counter view doesn't get pushed out.
Resolves: https://github.com/material-components/material-components-android/issues/689
PiperOrigin-RevId: 284594896
2019-12-10 07:21:56 -05:00
leticiars
aeb9eea9d8 Allow a content description to be set on a text field error view. This is useful for when the error message has special characters that TalkBack cannot read.
PiperOrigin-RevId: 280508115
2019-11-15 15:12:03 -05:00
Mahdi Hosseinzadeh
d0ddeb05c3 [TextField] Fix documentation errors
Resolves https://github.com/material-components/material-components-android/pull/749

GIT_ORIGIN_REV_ID=b019c4846473655df0f3ca9a2b9ef8a4fbf66334
PiperOrigin-RevId: 279996234
2019-11-12 16:23:14 -05:00
leticiars
61c00d746e Updating boxBackgroundColor filled text fields attr documentation to specify that default colors are used for hover and disabled states when a non stateful resource is specified.
PiperOrigin-RevId: 277983799
2019-11-04 13:04:16 -05:00
nkotula
8ca8e1bbdd [TextInputLayout] Add support for focused background color
Resolves https://github.com/material-components/material-components-android/pull/724

GIT_ORIGIN_REV_ID=8b272d736167cd0bff236b47049e247e3ec383a5
PiperOrigin-RevId: 277959398
2019-11-04 13:03:21 -05:00
leticiars
5a57937111 Automated g4 rollback of changelist 276353549
PiperOrigin-RevId: 276701861
2019-11-01 13:28:40 -07:00
leticiars
3f170183cb Automated g4 rollback of changelist 276320000
PiperOrigin-RevId: 276353549
2019-11-01 13:28:40 -07:00
leticiars
625f608012 Adding android:enabled attribute to the TextInputLayout.
Resolves https://github.com/material-components/material-components-android/issues/646

PiperOrigin-RevId: 276320000
2019-11-01 13:28:40 -07:00
ldjesper
7dc56dfcdd Simplify TextField drawable resources
https://github.com/material-components/material-components-android/issues/611

PiperOrigin-RevId: 273544807
2019-10-10 15:48:39 -04:00
leticiars
c74120d3d7 Automated g4 rollback of changelist 271432476
PiperOrigin-RevId: 272057811
2019-10-01 04:10:55 -04:00
leticiars
544c2af103 Adding hintTextErrorColor color attribute to be used for the collapsed hint text color when an error is being displayed.
PiperOrigin-RevId: 271432476
2019-09-26 17:58:11 -04:00
leticiars
107294f810 Fix stroke not using stroke error color when in overflow state (noop).
PiperOrigin-RevId: 271406453
2019-09-26 17:57:07 -04:00
leticiars
88d316e0f4 Adding boxStrokeErrorColor color attribute to be used for the outlined text field stroke color when an error is being displayed.
PiperOrigin-RevId: 270088868
2019-09-20 11:00:03 -04:00
leticiars
6e5ddcfb0e Adding support for prefix and suffix in text fields.
Prefix text can be set via the prefixText attribute or via the setPrefixText(CharSequence) method.
Similarly, suffix text can be set via the suffixText attribute or via setSuffixText(CharSequence)

PiperOrigin-RevId: 269799139
2019-09-18 14:21:37 -04:00
leticiars
6f35a22359 Automated g4 rollback of changelist 268680301
PiperOrigin-RevId: 268740076
2019-09-18 13:53:59 -04:00
leticiars
55f85bcc6e Adding support for prefix and suffix in text fields.
Prefix text can be set via the prefixText attribute or via the setPrefixText(CharSequence) method.
Similarly, suffix text can be set via the suffixText attribute or via setSuffixText(CharSequence)

PiperOrigin-RevId: 268680301
2019-09-12 14:26:15 -04:00
Material Design Team
322cbaae8a Automated g4 rollback of changelist 264230778
PiperOrigin-RevId: 264382083
2019-08-20 11:22:09 -04:00
afohrman
04955f6421 Add placeholder text functionality to TextInputLayout.
This is the initial implementation of placeholder text; it does not contain motion. At this stage, TextInputLayout sets the placeholder text visibility based on whether or not it should show.

PiperOrigin-RevId: 264230778
2019-08-20 11:19:02 -04:00
leticiars
58ccce1211 Fixing TextInputLayout not parsing boxStrokeWidth attr and adding boxFocusedStrokeWidth attr.
For the outlined textfields, those attrs control the outline stroke, while for the filled textfields, they control the underline width.

PiperOrigin-RevId: 262933557
2019-08-16 15:57:25 -04:00
leticiars
3f73804b57 Implementing error icon for text fields.
They are set by default when the text field is on error state, but can be disabled by setting the error icon drawable to null via the errorIconDrawable attribute or the setErrorIconDrawable method.

PiperOrigin-RevId: 260495196
2019-07-29 16:43:16 -04:00
leticiars
6a88f2b7d7 Adding option to set TextInputLayout icons to be not checkable.
Also updating clear text end icon to be not checkable, so that screen readers don't announce the icon's checked state as it's not relevant (differently from the password toggle icon, for example).

PiperOrigin-RevId: 259532643
2019-07-23 11:14:44 -04:00
leticiars
650c8ae063 Fixing typo in dropdown content description string.
PiperOrigin-RevId: 247306870
2019-05-16 12:36:32 -04:00
leticiars
c71b6ccb13 Exposed Dropdown Menu (https://material.io/design/components/menus.html#exposed-dropdown-menu).
An AutoCompleteTextView should be used in the place of a TextInputEditText, along with with a Widget.MaterialComponents.TextInputLayout.(...).ExposedMenuDropdown style.

PiperOrigin-RevId: 246343749
2019-05-03 10:58:36 -04:00
leticiars
9a53656172 Renaming clear text button drawable file for consistency.
PiperOrigin-RevId: 245057763
2019-04-29 15:35:11 -07:00
leticiars
27eac541b0 Fixing end and start icon ripples appearing behind text input layout.
PiperOrigin-RevId: 242660816
2019-04-19 13:09:03 -04:00
afohrman
a17e4373ad Delete unused padding resource from text field's dimens.xml file.
This resource is not in the public.xml file. This means that they are not intended to be shipped as part of our library and are fine to delete.

PiperOrigin-RevId: 241732718
2019-04-05 15:45:31 -04:00
afohrman
36fc2c66c6 Make sure that the ShapeAppearanceModel is always read from the TextInputLayout styles.
The boxCornerRadius attributes were still in the MDC styles, which means that the shapeAppearance and shapeAppearanceOverlay attributes were not respected. This commit removes the boxCornerRadius attributes to ensure that changes to shapeAppearance or shapeAppearanceOverlay are respected where shape theming is enabled.

PiperOrigin-RevId: 239214930
2019-03-22 16:53:04 -04:00
afohrman
e2c8d0fbd2 Fix TextInputLayouts used with a Widget.MaterialComponents style and a non-Widget.MaterialComponents EditText child.
NOTE: This case is not supported. Limited support is provided when feasible in order to avoid breaking existing usages, but all TextInputLayouts used with a Widget.MaterialComponents style and a non-Widget.MaterialComponents input child should update the input child to use a Widget.MaterialComponents.TextInputEditText style to avoid future breakages.
PiperOrigin-RevId: 239047527
2019-03-22 16:30:47 -04:00
leticiars
2642ff2697 Adding support for TextInputLayout start icon. It can be set to be just a drawable or, if a OnClickListener is set to it, a button.
For that reason, users should opt to use the start icon API instead of setting a start/left compound drawable on the text field's edit text.

PiperOrigin-RevId: 238984066
2019-03-22 16:19:36 -04:00
leticiars
168a468f29 Refactoring TextInputLayout's end icon initialization to always have the end icon view ready. Also refactoring OnEndIconInitializedListener to OnEditTextAttached listener.
PiperOrigin-RevId: 235781672
2019-02-27 17:59:10 -05:00
leticiars
56859415e8 Adding support for a custom end icon for the TextInputLayout.
A user-specified icon can now be set via app:endIconMode="custom" and attributes app:endIconDrawable and app:endIconContentDescription. It is also possible to set a custom OnClickListener via TextInputLayout's end icon API.

PiperOrigin-RevId: 234671237
2019-02-24 14:23:57 -05:00
leticiars
4882a4f131 Adding clear text button end icon to TextInputLayout.
PiperOrigin-RevId: 234141273
2019-02-24 14:15:28 -05:00
leticiars
4c2e9c4004 Changing the TextInputLayout's password toggle implementation into a generic API implementation, which will allow for easier support of future end icons. Also deprecating current password toggle end icon methods and attributes.
This change doesn't include support of a custom end icon yet.

PiperOrigin-RevId: 233645798
2019-02-24 14:07:11 -05:00
afohrman
41d919ae55 Fix double underline that appears when using non-TextInputEditText styles on
TextInputLayout's EditText child.

Set the ?attr/editTextBackground attribute to null in TextInputLayout's materialThemeOverlay to make sure that ?attr/editTextBackground is @null no matter what EditText subclass or style is used for the TextInputLayout's input text child.

PiperOrigin-RevId: 233407060
2019-02-11 11:19:16 -08:00
afohrman
beee015feb Use EditText's background for the filled text field and fix underline flakiness.
PiperOrigin-RevId: 231857938
2019-02-11 11:08:22 -08:00
afohrman
19039f7772 Automated g4 rollback of changelist 231246920
PiperOrigin-RevId: 231313735
2019-02-01 12:37:35 -05:00
afohrman
ef919e870a Use EditText's background for the filled text field and fix underline flakiness.
Use the EditText's background for the filled box text field and a MaterialShapeDrawable drawn to the canvas for the underline. This allows for many improvements to the filled text field.

This commit:
- Fixes the underline flakiness, where the underline used to not meet the edges until drawableStateChanged() was called after a layout pass (because TextInputLayout was attempting to use EditText's pre-existing underline, and the bounds of that Drawable weren't known in order to modify them until after drawableStateChanged())
- Removes the hard-coded box offset since it was only necessary when trying to use EditText's background drawable
- Brings the expanded label/hint a bit closer to the vertical center. Any more than this will require changing the bounds set on the expanded hint text and create misalignment between the expanded hint and any compound drawable that might be set

Specs: https://material.io/design/components/text-fields.html#spec

There is a possible alternative to drawing the underline manually: including the underline as part of the EditText's background. I investigated this option and rejected it, since it would require a re-architecture of the way TextInputLayout handles the box logic and many layers of box drawable nesting. It is much more straightforward and performant to draw the underline directly to the canvas than to convert the boxBackground to {LayerDrawable{MaterialShapeDrawable,{InsetDrawable{MaterialShapeDrawable}}}}.

This commit should only change the visuals of the filled text field; the outline text field should be visually untouched.

PiperOrigin-RevId: 231246920
2019-02-01 12:35:48 -05:00
afohrman
0aa470af86 Support custom backgrounds for outline text fields and use EditText's background for the text field's outline.
The outline box styles previously didn't allow a custom drawable to be set. The box background was handled by TextInputLayout, which nulled out the EditText's background and drew the boxBackground directly to the canvas. That meant that a call to TextInputEditText#setBackground() would not actually do anything - it would result in the same outline text field.

In order to respect the background drawable, TextInputEditText's background is set to null in the style. Then, TextInputLayout programmatically sets the custom outline drawable if the background is already null. This avoids overwriting a drawable that may have already been set on the TextInputEditText.

This change does pretty much nothing to the filled box style; since the EditText's underline is still being used, the background of the EditText was never set to null for that style. This change should be a no-op for that style.

This move to using the EditText's background for the outline also improves the bounds of the outline text field and gets rid of the cutoff that was appearing at the top of the outline when TextInputLayout's hint was disabled and a hint was set on the EditText.

PiperOrigin-RevId: 230538561
2019-01-25 13:55:36 -05:00
leticiars
ef0ca8d774 Updating default colors of password toggle in text fields.
PiperOrigin-RevId: 230401355
2019-01-22 17:06:37 -05:00
leticiars
872cae3400 Updating MDC text field text appearance.
PiperOrigin-RevId: 228150532
2019-01-10 16:34:41 -05:00