48 Commits

Author SHA1 Message Date
conradchen
44d4c3ea3f [TopAppBar] Correctly set letter spacing when expanding titles
We recreated title text layout when expanding from the collapsed state but didn't correctly set the letter spacing to the expanded one. The letter spacing being used will be a interpolated value between collapsed and expanded letter spacing (close to the collapsed one due to the implementation). This will cause the text layout incorrectly calculate the line count from the wrong letter spacing and result in a broken layout.

Correctly sets the letter spacing to fix the issue.

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

PiperOrigin-RevId: 408910555
2021-11-10 16:54:12 -05:00
conradchen
34cce18d4a [TextField] Correctly calculate hint text offset
We changes letter spacing during expanding/collapsing animations, which causes us use letter spacing during animation while calculating final expanded/collapsed offset instead of final letter spacing. This in turn causes hints be drawn at the wrong positions. Uses final letter spacing during calculating offset instead to fix the problem.

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

PiperOrigin-RevId: 408904991
2021-11-10 16:52:14 -05:00
conradchen
e6db8a4d31 [TopAppBar] Fix text alignment of multi-line title in collapsing toolbar
In single line mode, we implement the expanded title alignment by calculating the expected x-coordinate of expanded title and translate the canvas so the title will be aligned. However, when maxLines > 1, the static layout will always occupy the full available width, therefore the text alignment need to be done by the static layout instead.

Provides text alignment other than NORMAL when it's in multi-line mode to solve the issue.

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

PiperOrigin-RevId: 408895140
2021-11-10 16:13:26 -05:00
conradchen
c80177d062 [CollapsingTextHelper] Small clean-up of CollapsingTextHelper
PiperOrigin-RevId: 408644009
2021-11-10 16:04:13 -05:00
serniebanders
a290c38cfd [AppBar] Defines collapsing text alpha value to be at most as transparent as the user defines.
This enables the user to set the expanded text as fully transparent, as well as any other text alpha value.

Fixes: https://github.com/material-components/material-components-android/issues/2293
PiperOrigin-RevId: 402829737
2021-10-13 16:36:27 -04:00
conradchen
79ae9b1351 [TextInputLayout] Create label cutout only on borders
When a collapsed label is showing, we cutout part of the border of an outlined text input box according to the exact stroke width. However when using rounded corners, there can be slight offsets from where the border is really drawn. Also, if the corner size is large, the part of border we need to cutout might not just be a straight line but contains part of the corner.

However, with the existing cutout logic, we cannot just cutout the whole label area, which will cause the area inside the border also gets cutout, if it has color. This CL changes the cutout drawing logic to only apply the cutout on stroke drawing to fix the issue.

This CL also fixes the bug that when the label is too long, we didn't take the ellipsized text length into account. Creates a variable to store the calculated collapsed text width to fix the issue.

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

PiperOrigin-RevId: 402316057
2021-10-12 11:26:21 -04:00
Riccardo Ciovati
1b8fb30370 [CollapsingToolbarLayout] Allow customizing the title position interpolator
Resolves https://github.com/material-components/material-components-android/pull/1757

GIT_ORIGIN_REV_ID=87dea3a74d8a8f460cc9beb32bcb783f71ee6e63
PiperOrigin-RevId: 401826042
2021-10-11 10:59:08 -04:00
pfthomas
ec3f96cbb9 [CollapsingToolbarLayout] Fix expanded height incorrect after rotation
PiperOrigin-RevId: 391547762
2021-08-18 10:27:05 -07:00
dniz
655dde062a [CollapsingToolbarLayout] Added option to add extra height when title text spans across multiple lines
PiperOrigin-RevId: 382716405
2021-07-02 08:16:09 -04:00
dniz
af35dfb86b [CollapsingToolbarLayout] Fixed multiline RTL collapsed title text position
PiperOrigin-RevId: 382073266
2021-07-01 06:46:14 -07:00
conradchen
7adfd93d80 [TooltipDrawable] Adding android:textColor support
PiperOrigin-RevId: 374887222
2021-05-20 14:03:30 -07:00
hunterstich
0ef2e910ce [TopAppBar] Fix title fade mode collapsing title position errors.
Flinging the AppBarLayout can cause a negative number to be passed to CollapsingTextHelper#calculateOffsets, causing the collapsed title in fade mode to be positioned incorrectly.

PiperOrigin-RevId: 374704850
2021-05-19 13:21:52 -07:00
dniz
841f229592 [CollapsingToolbarLayout] Fixed RTL text only laying out as RTL when actual text is RTL
PiperOrigin-RevId: 374663684
2021-05-19 11:00:25 -07:00
hunterstich
c7541833b7 [CollapsingToolbarLayout] Updated fade mode to allow expanded title to translate 1:1 with scrolling content.
PiperOrigin-RevId: 372565826
2021-05-07 12:27:54 -04:00
dniz
f0ce498108 [CollapsingToolbarLayout] Added title line spacing and hyphenation frequency setters
PiperOrigin-RevId: 371920600
2021-05-05 09:40:38 -04:00
dniz
be85a92a73 [CollapsingToolbarLayout] Added getLineCount() method
PiperOrigin-RevId: 368630070
2021-04-16 17:48:59 -04:00
Material Design Team
7fc9df5399 Automated g4 rollback of changelist 368429312
PiperOrigin-RevId: 368474895
2021-04-16 12:44:38 -04:00
dniz
2b2c69f773 [CollapsingToolbarLayout] Added getLineCount() method
PiperOrigin-RevId: 368429312
2021-04-16 12:43:47 -04:00
dniz
f0ac362968 [CollapsingToolbarLayout] Added support for multiline RTL when using fade title mode
PiperOrigin-RevId: 368237684
2021-04-13 14:24:14 -04:00
dniz
5a35bf7d38 [CollapsingToolbarLayout] Fixed multiline animation for fade title collapse mode
PiperOrigin-RevId: 367285477
2021-04-08 20:41:37 -04:00
dniz
9c75ad07f7 [CollapsingToolbarLayout] Added support for fade out/in title collapse mode
PiperOrigin-RevId: 365629647
2021-03-30 14:48:19 -04:00
cketcham
d4a019359c Update TextAppearance and CollapsingTextHelper to respect letterSpacing set with TextAppearance styles
PiperOrigin-RevId: 328985766
2020-08-28 18:06:30 -04:00
Frantisek Nagy
8210b3ac01 [CollapsingToolbarLayout] Fix CollapsingToolbar multiline position
GIT_ORIGIN_REV_ID=7dbd8905bf58eb5811c4661ee77512d4d9c59c19

Co-authored-by: ymarian <38727469+ymarian@users.noreply.github.com>
PiperOrigin-RevId: 321294325
2020-07-15 09:49:15 -07:00
Robert Williams
77a0a87fb1 [CollapsingToolbarLayout] Use correct layout to calculate expanded bounds
Resolves https://github.com/material-components/material-components-android/pull/1432

GIT_ORIGIN_REV_ID=6041d791702d16e7501289f939fa01874b16b32c
PiperOrigin-RevId: 318639226
2020-06-29 09:28:40 -04:00
marianomartin
555356b03f Internal cleanup
PiperOrigin-RevId: 318134343
2020-06-26 14:06:52 -04:00
Sven Obser
74508c89c8 [CollapsingToolbarLayout] Fixed slight misalignment during transition in multiline mode
Resolves https://github.com/material-components/material-components-android/pull/1408

GIT_ORIGIN_REV_ID=9b29f85a8f9e9c52b256fbb4ce3148e19ee503fc
PiperOrigin-RevId: 317322732
2020-06-19 14:09:34 -04:00
Material Design Team
342ea9ad25 Internal cleanup
PiperOrigin-RevId: 317147378
2020-06-19 13:42:35 -04:00
marianomartin
83e4e47d22 Initial support for Multiline CollapsingToolbarLayout
This cl adds the capabilities to set multiline on CollapsingToolbarLayout while keeping single line toolbars unchanged.

Co-Authored-By: johan12345 <johan.forstner@gmail.com>
PiperOrigin-RevId: 294256516
2020-02-10 14:32:15 -05:00
marianomartin
50b020aec7 Resubmit Modify CollapsingTextHelper to use a StaticLayout instead of canvas.drawText.
PiperOrigin-RevId: 293443677
2020-02-05 17:30:20 -05:00
marianomartin
1673924a23 Automated g4 rollback of changelist 293151496
PiperOrigin-RevId: 293184366
2020-02-04 17:33:05 -05:00
marianomartin
7822b6d05e Modify CollapsingTextHelper to use a StaticLayout instead of canvas.drawText.
This will allow to support multiple lines.

PiperOrigin-RevId: 293151496
2020-02-04 17:32:07 -05:00
johan12345
8dd8acecd9 Mutate gravity horizontal value on setExpandedTextGravity and setCollapsedTextGravity, so the code can assume they are set.
PiperOrigin-RevId: 286392235
2019-12-19 15:41:45 -05:00
leticiars
9dcb12169f [TextInputLayout] Fixing cutout not working with CENTER_HORIZONTAL.
Resolves https://github.com/material-components/material-components-android/issues/822

PiperOrigin-RevId: 285781713
2019-12-16 16:01:50 -05:00
leticiars
20f113212d [TextInputLayout] Adding support for the collapsed label position to be determined via the edit text gravity, such as center_horizontal.
Resolves https://github.com/material-components/material-components-android/pull/311
Resolves https://github.com/material-components/material-components-android/issues/609

PiperOrigin-RevId: 279998938
2019-11-12 16:23:41 -05:00
marianomartin
0d4515cb46 Internal cleanup
PiperOrigin-RevId: 265971745
2019-08-29 14:59:20 -04:00
cketcham
81e708e1bb Add @NonNull and @Nullable annotations
PiperOrigin-RevId: 264745164
2019-08-26 11:19:28 -04:00
isabellekim
a628bf516b Revert the library to compile with Java 7: revert lambdas, add necessary casts, and make some variables final.
Continue compile shrine demo, catalog, and tests with Java 8.

PiperOrigin-RevId: 257874888
2019-07-15 19:19:23 -04:00
marianomartin
367b295624 Internal cleanup
PiperOrigin-RevId: 254414602
2019-06-24 17:12:42 -04:00
cketcham
bff75f2d3e Update to lamdas
PiperOrigin-RevId: 252846439
2019-06-18 13:21:02 -04:00
dniz
1f244318d8 Add @hide to all @RestrictTo annotations that are missing it
PiperOrigin-RevId: 243646339
2019-04-19 16:29:30 -04:00
afohrman
4476564820 Vertically center the filled text field's expanded label.
PiperOrigin-RevId: 241791031
2019-04-05 15:46:27 -04:00
afohrman
e847a22103 Remove @VisibleForTesting annotation from CollapsingTextHelper#getCurrentCollapsedTextColor.
The annotation was only necessary for the method in TextInputLayout that calls CollapsingTextHelper#getCurrentCollapsedTextColor.

PiperOrigin-RevId: 230616582
2019-01-25 13:57:02 -05:00
cketcham
dc72aaeed4 Migrate Gradle build and sources to androidx
PiperOrigin-RevId: 225551505
2018-12-21 11:07:45 -05:00
leticiars
df551410c4 Fixing padding of hint label when there is a leading icon
PiperOrigin-RevId: 213277053
2018-09-28 14:49:23 -04:00
dniz
461101bc5b Fix Gradle build by removing Java 8 method reference
PiperOrigin-RevId: 212685609
2018-09-14 11:00:30 -04:00
Material Design Team
850795da31 Delegates CollapsingTextHelper text attributes processing to TextAppearance.
This removes duplication between the 2 implementations and automatically fixes font loading bug in CollapsingToolbarLayout & TextInputLayout. It has a side effect of changing font loading from sync to async but it shouldn't affect anyone since font loading wasn't really working in the first place. It may affect the UIs that were affected by the original bug though.

To alleviate possible "font flickering" due to async loading, CollapsingTextHelper defers the TextPaint changes until the font is actually loaded.

Another scenario the async loading would have an impact on is when the font is manually overwritten with CollapsingTextHelper.setTypeface() while async op is still ongoing. The result of async load would then overwrite the font back to the originally requested. This happens in TextInputLayout which overwrites its own font setting to this of its child whenever its added. This may happen before async op completes. To guard against that, any direct font setting automatically cancels the async load (cancels == ignores the result when it comes).

PiperOrigin-RevId: 212328671
2018-09-14 10:53:39 -04:00
dniz
b4529d2a88 Remove unused MathUtils methods and add documentation. Also replace
MathUtils#constrain with Support Library MathUtils#clamp

PiperOrigin-RevId: 197905324
2018-05-30 17:31:27 -04:00
dniz
9ca33544ac Update package name to com.google.android.material
PiperOrigin-RevId: 193236235
2018-04-30 11:24:23 -04:00