230 Commits

Author SHA1 Message Date
rightnao
7f01739644 [TextInputLayout] Add hintMaxLines attribute
PiperOrigin-RevId: 685884472
2024-10-15 16:51:14 +00:00
rightnao
246fa677b3 [TextInputLayout] Start outline cutout bounds at a y location of 0 to encompass any possible vertical shifts due to a size difference between the placeholder text and the edit text
PiperOrigin-RevId: 679308079
2024-10-01 18:39:27 +00:00
pubiqq
23aca03255 [Internal] Remove pre-Lollipop checks
Resolves https://github.com/material-components/material-components-android/pull/4266

GIT_ORIGIN_REV_ID=1de7808e66dd6666c893217c76c7499afe2df6a3
PiperOrigin-RevId: 669688797
2024-09-03 13:31:29 +00:00
pubiqq
204811089d [Internal] Replace deprecated androidx.core.view.* methods
Resolves https://github.com/material-components/material-components-android/pull/4180

GIT_ORIGIN_REV_ID=8e4ec29abacc33cde748b8f07f0ba5c251cef395
PiperOrigin-RevId: 656004130
2024-07-25 19:09:36 +00:00
pubiqq
510881a469 [Internal] Stop using deprecated androidx.core.view.* methods
Resolves https://github.com/material-components/material-components-android/pull/4117

GIT_ORIGIN_REV_ID=dd157e8360c2511810496693cec1616fce578655
PiperOrigin-RevId: 632284856
2024-05-13 17:37:38 +00:00
Ga\u00ebtan Muller
b3fe6a7f61 [Cleanup] Remove redundant version checks for api <= 19.
Resolves https://github.com/material-components/material-components-android/pull/3849

GIT_ORIGIN_REV_ID=47bb2fcc8031740e5a7d4f741f1ada2af025e126
PiperOrigin-RevId: 632154861
2024-05-09 18:46:02 +00:00
pekingme
9b9449cde1 [TextInputLayout] Limited the min height reset in text change listener only when line count changes.
PiperOrigin-RevId: 582049113
2023-11-13 20:58:05 +00:00
pekingme
4a2654a3f3 [TextInputLayout] Fixed unnecessary min height when losing focus with multiple lines.
Resolves https://github.com/material-components/material-components-android/issues/3451

PiperOrigin-RevId: 579017528
2023-11-06 14:00:10 +00:00
pubiqq
2590c42764 [TextInputLayout] Fix editText paddings on pre-Lollipop
Resolves https://github.com/material-components/material-components-android/pull/3583
Resolves https://github.com/material-components/material-components-android/issues/3582

GIT_ORIGIN_REV_ID=356f7488505470656d26b0452dae78ae01475022
PiperOrigin-RevId: 574833205
2023-10-19 11:34:21 -07:00
Material Design Team
93360a5a5d [TextInputLayout] Fix onMeasure() infinite loop bug caused by posting requestLayout() before endLayout is fully rendered.
Brief explanation: in TextInputLayout#onMeasure, TextInputLayout will try to send a post to trigger requestLayout() method based on the boolean value returned from updateDummyDrawbles() method, but in shouldUpdateEndDummyDrawable(), we try to get the endLayout.getMeasureWidth() which is not reliable, if the endLayout hasn't rendered fully, the getMeasureWidth() will return 0 making the updateDummyDrawables() to return TRUE to trigger requestLayout() in an infinite loop.

To fix this issue, we need to introduce ViewTreeObserver to help us to run posing the requstLayout() after endLayout/startLayout is fully rendered.

PiperOrigin-RevId: 571765829
2023-10-10 10:21:12 -07:00
leticiars
9a4888f958 [TextInputLayout] Mutate cursor drawable before tinting it.
Resolves https://github.com/material-components/material-components-android/issues/3491

PiperOrigin-RevId: 561722342
2023-08-31 15:11:02 -04:00
rightnao
e3b255b3a0 [Docs] Crosslink github docs in javadocs
PiperOrigin-RevId: 546393704
2023-07-11 19:37:37 +00:00
pekingme
1562d0b64f [ExposedDropdownMenu] Added attribute to set dropdown menu's container.
PiperOrigin-RevId: 528578402
2023-05-02 16:10:48 -04:00
leticiars
c598ccd51e [TextInputLayout] Added API to set cursor colors for API 28+.
This is useful if the cursor color should be set in runtime, where setting ?attr/colorControlActivated for the edit text is not possible. Using the added APIs will take precedence over the value of ?attr/colorControlActivated.

This API is limited to APIs 28+ due to the framework getTextCursorDrawable() method being 28+.

Resolves https://github.com/material-components/material-components-android/issues/3255
Resolves https://github.com/material-components/material-components-android/issues/3311

PiperOrigin-RevId: 521448134
2023-04-10 14:23:58 +00:00
conradchen
d9b97b42ff [TextField] Make collapsed hint aligned with prefix and suffix text
The original logic prevents displaying the collapsed hint on top of suffix text. The behavior looks not consistent with the case of prefix text or outline variants of text fields.

This CL also fixes the issue that when drawable paddings are set on EditText, the collapsed hint is not aligned with the prefix anymore.

Resolves https://github.com/material-components/material-components-android/issues/2800

PiperOrigin-RevId: 511390069
2023-02-23 03:45:40 -08:00
pfthomas
e1688f3d19 [MaterialDatePicker][a11y] Improve date input validation feedback
Resolves https://github.com/material-components/material-components-android/issues/2223

Add `TextInputLayout.setErrorAccessibilityLiveRegion` and `TextInputLayout.getErrorAccessibilityLiveRegion` to allow controlling the way the TextInputLayout error is announced.

Example:

```
textInputLayout.setErrorAccessibilityLiveRegion(ViewCompat.ACCESSIBILITY_LIVE_REGION_NONE);
```

PiperOrigin-RevId: 497323465
2022-12-29 00:19:00 -05:00
conradchen
a3521784e8 [TextField] Fix label cutout doesn't work on API < 18
Android framework Canvas.clipRect() has a bug with Region.Op.DIFFERENCE when handling bounds.left on APIs lower than 18, which causes text field outlines are still drawn over the label on lower APIs, despite the label area is supposed to be cut out.

Fixes this by bringing back the old solution we were using - "painting out" the label area after the stroke is drawn. Since the implementation is quite complicated, this CL also splits the CutoutDrawable to two inner impl classes to have a better code structure.

Resolves https://github.com/material-components/material-components-android/issues/2811#issuecomment-1196016169

PiperOrigin-RevId: 482013070
2022-10-19 09:20:41 -07:00
pubiqq
e76eaff716 [TextInputLayout] Fixed counter overflow text color getter
Resolves https://github.com/material-components/material-components-android/pull/3002

GIT_ORIGIN_REV_ID=b9f8e26840e02df2529561cf464e347fe220065d
PiperOrigin-RevId: 478059617
2022-10-03 19:14:09 +00:00
Material Design Team
e804957628 [TextInputLayout] Fix code formatting.
PiperOrigin-RevId: 474180631
2022-09-15 14:18:55 -04:00
leticiars
e7697c235b [TextInputLayout] Integrated tokens for text fields and the exposed dropdown menu.
PiperOrigin-RevId: 474105090
2022-09-15 14:15:10 -04:00
leticiars
fbd75ec5b0 [TextInputLayout] Updated cursor color on error for APIs >= 29.
Resolves https://github.com/material-components/material-components-android/issues/2719

PiperOrigin-RevId: 472535969
2022-09-08 13:41:59 -04:00
rightnao
c98480c019 [TextInputLayout] Update motion attributes for textfield animations
PiperOrigin-RevId: 472525831
2022-09-08 13:24:09 -04:00
leticiars
a85204eb75 [TextInputLayout] Updated expanded label color to take error color when on error.
Partially fixes https://github.com/material-components/material-components-android/issues/2719

PiperOrigin-RevId: 471799584
2022-09-02 12:54:09 -07:00
leticiars
08c40d85e5 [TextInputLayout] Added method to set corner family programmatically and a setShapeAppearanceModel method for greater customizability of the box background shape.
Resolves https://github.com/material-components/material-components-android/issues/1957

PiperOrigin-RevId: 470826160
2022-08-30 11:28:55 -04:00
rightnao
6b53f62aa2 [TextInputLayout] Update motion specs for hint animation
PiperOrigin-RevId: 469753395
2022-08-24 14:41:36 -07:00
rightnao
e284e57d64 [TextInputLayout] Add scale type setters/getters for start and end image buttons in the TextInputLayout
Resolves https://github.com/material-components/material-components-android/issues/2080

PiperOrigin-RevId: 463381963
2022-07-28 17:36:31 -04:00
rightnao
633b3cecfa [TextInputLayout] Adding set/get methods to control minimum width and height for start/end icons
Resolves https://github.com/material-components/material-components-android/issues/2080

PiperOrigin-RevId: 461939723
2022-07-20 21:44:40 +00:00
pubiqq
15fa4db616 [TextInputLayout] Fix "android:enabled" attribute support
Resolves https://github.com/material-components/material-components-android/issues/2766
Resolves https://github.com/material-components/material-components-android/pull/2769

GIT_ORIGIN_REV_ID=9e60355679855b57ab63edf63944d3e23d2aec9a
PiperOrigin-RevId: 458516880
2022-07-06 05:03:16 -07:00
conradchen
051410b7ef [TextField] Stop saving/restoring TextInputLayout's themeable fields
Saving/restoring themeable fields will cause problems when the view is recreated, because those fields will be restored to the value resolved from the context before the recreation, instead of the current context. For example, when the device locale changes, those fields will still be restored to the previous locale instead of the new one.

It's a general practice in Android framework and AndroidX not to save/restore themeable fields. If clients need this, they should implement their own logic.

Resolves https://github.com/material-components/material-components-android/issues/2075

PiperOrigin-RevId: 454708278
2022-06-13 16:15:10 -07:00
rightnao
4ded01ed3f [TextInputLayout] Add a new custom length counter field and getters/setters to switch how text length is calculated for the counter.
Resolves https://github.com/material-components/material-components-android/issues/2418

PiperOrigin-RevId: 449842640
2022-05-23 10:21:23 -04:00
conradchen
73cb1b6e78 [TextField] Fix hint is not displayed when expanding space is limited
In CollapsingTextHelper we are checking both the expanded bound and the collapsed bound to be larger than 0 to decide if we are going to draw the collapsing text. However this can result in a situation that when there's no space to display expanded hint, the collapsed hint won't be drawn either, even if the hint is not expandable at all.

This CL fixes the issue in a more generic way - whenever draw() is called, we check if the current bound (should be calculated whenever the collapsing fraction is changed) is larger than 0 to decide if we need to draw the collapsing text.

This CL also adds the logic to ensure the cutout bound will never be larger than the collapsed bound.

Resolves https://github.com/material-components/material-components-android/issues/2573

PiperOrigin-RevId: 449597658
2022-05-18 21:14:13 -04:00
conradchen
d3ab6d7bf1 [CleanUp][TextField] Centralize accessibility event dispatching logic for drop-downs
This also fixes the bug that clients cannot use custom AccessibilityDelegate with drop-down mode.

PiperOrigin-RevId: 447748501
2022-05-10 15:04:34 -04:00
conradchen
1a42c743fe [CleanUp][TextField] Move drop-down background and ripple creation to TextInputLayout class
This CL also cleans up and fixes the edit text background setting logic - when the edit text is an autocomplete text view and provides its own background, we won't override the background by trying to add ripples to it.

Later they should be split again from the main class with other box-background-relevant logic.

Resolves https://github.com/material-components/material-components-android/issues/1431

PiperOrigin-RevId: 445486075
2022-05-02 09:19:04 -04:00
pubiqq
3ca41be8f0 [General] Fix typos
Resolves https://github.com/material-components/material-components-android/pull/2654

GIT_ORIGIN_REV_ID=b8f6728979875629f2c813ef90d2f671cf56b4eb
PiperOrigin-RevId: 442852630
2022-04-19 14:48:55 -04:00
leticiars
784f901135 [TextInputLayout] Fixed regression bug of prefix spacing being shown and making expanded label be in the wrong position when text field is not focused.
Resolves https://github.com/material-components/material-components-android/issues/2612

PiperOrigin-RevId: 437745108
2022-03-28 16:48:28 +00:00
leticiars
1c02b62eaf [ExposedDropdownMenu] Update background when setInputType is called so that ripple is or isn't present properly.
PiperOrigin-RevId: 437345929
2022-03-28 16:47:36 +00:00
conradchen
7c160c86fb [CleanUp][TextField] Create EndIconDelegates in an on-demand fashion
This should slightly improve the text field rendering performance.

PiperOrigin-RevId: 435411420
2022-03-18 18:50:15 +00:00
conradchen
6cdf7b5155 [CleanUp][TextField] Extract end components from TextInputLayout
PiperOrigin-RevId: 435390505
2022-03-17 18:51:39 +00:00
conradchen
9a46af2af2 [CleanUp][TextField] Extract start components from TextInputLayout
PiperOrigin-RevId: 432953110
2022-03-09 21:07:45 +00:00
afohrman
108558326d [TextInputLayout] Added class documentation to use TextInputLayout's context to construct the child TextInputEditText.
We already had class documentation that explains that TextInputEditText should be instantiated with the parent TextInputLayout's context for proper theming, but this  information is important enough to the basic usage of TextInputLayout and TextInputEditText that it's best to have it the class documentation, as well.

Added the guidance in both TextInputLayout and TextInputEditText because it's relevant to both classes.

PiperOrigin-RevId: 432244388
2022-03-04 13:03:37 -05:00
conradchen
9789f2e286 [CleanUp][TextField] Split icon tinting logic to a helper class
PiperOrigin-RevId: 431477762
2022-03-01 08:55:44 -08:00
leticiars
b6901275d9 [TextInputLayout][a11y] Fixed prefix/suffix not being properly announced when the text field is focused and they show up. Also improved their screen reader focus order to align with the visual order of the elements: navigating to the left will focus on the prefix and navigating to the right will focus on the suffix.
Resolves https://github.com/material-components/material-components-android/issues/2497

PiperOrigin-RevId: 430208388
2022-02-23 11:13:30 -08:00
leticiars
1b7e92d99c [TextInputLayout] Updated documentation to clarify end icon mode's expected usage and behaviors relating to the icon's drawable.
Resolves https://github.com/material-components/material-components-android/issues/2528

PiperOrigin-RevId: 427506995
2022-02-11 15:41:02 +00:00
leticiars
ae16efd5da [TextInputLayout] Fixed icons behaving unexpectedly when switching modes + bug of wrong icon tint state when setting an icon programmatically.
Resolves https://github.com/material-components/material-components-android/issues/503
Resolves https://github.com/material-components/material-components-android/issues/1849

PiperOrigin-RevId: 427268349
2022-02-09 15:58:45 +00:00
afohrman
2463946d24 [TextInputLayout] Add line mask expansion animation to filled box underline.
Add an expanding animation for the focused underline that's triggered when the edit text gains focus. The line mask animation is built to calculate its bounds based on the hint CollapsingTextHelper's expansion fraction, so it seamlessly follows that animation.

PiperOrigin-RevId: 424703815
2022-01-28 11:55:08 -08:00
pfthomas
7d46b95e9e [TextInputLayout] Add support for minEms and maxEms
Resolves https://github.com/material-components/material-components-android/issues/2269

PiperOrigin-RevId: 423118234
2022-01-24 14:48:13 -05:00
Vyacheslav
26d862bc54 [TextInputLayout] Speedup simple inflate.
Changes are mostly to keep start/end layouts and icon views hidden (visibility = gone) when they are not needed.

Resolves https://github.com/material-components/material-components-android/pull/2326

GIT_ORIGIN_REV_ID=0393ac65d562bc87d340ec7bb260ebba99a1ac3b
Co-authored-by: leticiarossi <9288695+leticiarossi@users.noreply.github.com>
PiperOrigin-RevId: 418038435
2021-12-28 08:54:28 -05:00
conradchen
88eb089021 [TextField] Apply edit text's letter spacing to expanded hints
Resolves https://github.com/material-components/material-components-android/issues/2202

PiperOrigin-RevId: 417863400
2021-12-23 13:54:06 -05:00
Material Design Team
cfc00aa5a3 Update android core class definitions across material
PiperOrigin-RevId: 414839941
2021-12-08 14:56:25 +00:00
jeremymuhia
e8bde7546b [TextInputLayout] text field should comply with system level bold
PiperOrigin-RevId: 413194807
2021-11-30 20:48:48 +00:00