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
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
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
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
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
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
The annotation was only necessary for the method in TextInputLayout that calls CollapsingTextHelper#getCurrentCollapsedTextColor.
PiperOrigin-RevId: 230616582
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