This is the first step in adding states to the outline text box. The states implementation plan is to handle the box's states similar to how TextInputLayout already handles states, and moving the box stroke color to be a color int sets the stage for that change.
In a nutshell, the states implementation plan is to add an updateBoxState() method in TextInputLayout's overridden drawableStateChanged(), and change the parameters affected by state in that method. Since updateBoxState() will handle changing the colors, and since GradientDrawable doesn't have support for ColorStateLists pre-21, it makes more sense for mBoxStrokeColor to be a color int. That way, TextInputLayout can handle all of the states the same way, instead of flagging different versions and essentially building states twice.
This commit changes the mBoxStrokeColor reference to point to a color int resource, and updates the getters, setters, documentation, the catalog demo entry, and the relevant tests to reflect the new variable type.
PiperOrigin-RevId: 171831287
Fix bug in FAB Transformation where drawable.setAlpha() was called without mutate().
This affected other demos that used the same resource.
PiperOrigin-RevId: 171614982
Move updateImageMatrixScale() call from setImageResource() to setImageDrawable() to catch all image drawable changes.
Minor name changes for consistency.
This change should result in identical behavior if previous scale was 1f.
PiperOrigin-RevId: 171204342
There were two major bugs:
1. The temp instance toValue passed to ObjectAnimator.ofObject(view, prop, eval, toValue) does not get read right away.
Instead, ObjectAnimator stores it as a reference. This is problematic because the temp instance is used to make other calculations, and its value overwritten before ObjectAnimator reads it.
2. ImageMatrixProperty#get was returning the instance from ImageView#getImageMatrix(), which is not a copy, but the ImageView's instance itself.
This is problematic because ObjectAnimator stores it as the fromValue and reads from it on each frame. However, the ObjectAnimator is also setting new values on the same instance each frame due to animation.
The fix is to make a copy of the temp instance when it is not read right away. This way, ObjectAnimator stores a copy which is not subject to being overwritten.
PiperOrigin-RevId: 171169919
BackLayerLayout:
- Expanded state is saved and restored via ExpandableWidgetHelper across configuration changes.
- BackLayerLayout and BackLayerSiblingBehavior no longer keep references to each other, minimizing stale state.
- All state changes now go through CoordinatorLayout.dispatchDependentViewsChanged(), mirroring other MDC-Android components like FAB Transformation and dynamic persistent sheet.
BackLayerSiblingBehavior:
- The behavior is now an ExpandableBehavior, mirroring other MDC-Android components like FAB Transformation and dynamic persistent sheet.
- Animates state changes using both position and translation, better separating its semantic meanings:
- BLL's collapsed size determines the sibling's position, which never changes.
- BLL's expanded size determines its translation, which is animated.
PiperOrigin-RevId: 171064071
Use PorterDuff modes to create a cutout for the label when using the outline box version of TextInputLayout.
This commit focuses on creating the cutout functionality. The padding and bounds aren't the focus of this commit, and they aren't quite right yet. Measurements will be addressed in a future commit.
PiperOrigin-RevId: 170855509
Consolidate calculations for the top margin offset into label calculation methods. This work will make it easier to set the cutout bounds, and to do other dimension work (height parameter, padding work, etc.).
PiperOrigin-RevId: 170779660
The screenshot tests showed a diff because of a change in the way the collapsed height was being measured. It used to be measured as -ascent, but it was changed to measure the text using the more traditional descent - ascent. This commit changes the collapsed text measurement back to -ascent, and should result in no diff.
PiperOrigin-RevId: 170737363
- FAB show/hide animations are now using MotionSpec API.
- New motion specs for FAB show/hide has been created and should behave
identical to before.
- FAB now supports a new iconScale animation that animates the image matrix of
the icon to scale it. The new motion specs are crafted so that iconScale
animations do not play, but jump immediately to the desired scale (1f or 0f) for show/hide.
PiperOrigin-RevId: 170569077
This is necessary for new FAB animations that animate the icon size.
The image matrix is now manually maintained such that the FAB should look
identical to the previous scale type FIT_CENTER.
PiperOrigin-RevId: 170568882
I've run into the same AnimatorSet bug 3 times, so it's worth fixing this in one place.
I've changed all instances of AnimatorSet#playTogether to use this compat class.
PiperOrigin-RevId: 170568456
Support inflating a MotionSpec from a R.animator resource.
Create a few backwards compatible R.interpolator resources that clients can use for this API.
PiperOrigin-RevId: 170567793
Incorporate more robust measurement methods into CollapsingTextHelper, and use those to measure the extra top margin in TextInputLayout.
Before, there was no method to find the exact height of the text in TextInputLayout. All CollapsingTextHelper offered was a getter for the collapsed/expanded text sizes. However, this was not an accurate measurement, since the typeface could change the text dimensions. The expanded and collapsed bounds are also not reliable, because they could be set to a bigger area than the text actually takes up.
This commit adds methods to check the actual measurements of the text, rather than approximations.
PiperOrigin-RevId: 170486018
The motion spec should be independent of the source and destination widgets.
Add context parameter so we can inflate the motion spec from resources.
PiperOrigin-RevId: 170306303
Adds an attribute for the box's stroke (outline) color. Includes a public and private attribute, setters, getters, documentation, and tests.
PiperOrigin-RevId: 170239224
This commit improves the box creation process and adds initial padding parameters for the box. For now, these values are only set on the EditText, but to truly update the padding throughout the box, the padding should be adjusted in other places (for example, the label's collapsed and expanded bounds should be updated based on the padding values). Also, some of the official values (top and bottom) don't look quite right at this stage, so they are set to values that look better for now. When padding is addressed fully, these will be set to the correct values.
This commit also adds padding back in where it would get wiped out in API 21 and 22 in ensureBackgroundDrawableStateWorkaround().
The box creation improvements prevent some unnecessary calls to box-specific methods, and a new mEditTextBoundsUpdated flag ensures that the EditText bounds are not repeatedly updated.
PiperOrigin-RevId: 170111678
- `./gradlew uploadArchives` generates a maven repository with all the libraries that MDC requires and generates.
- Adds a new argument to pass to gradle, -PmavenRepoUrl to customize the maven repository location (it defaults to /tmp/myRepo otherwise). For example `./gradlew uploadArchives -PmavenRepoUrl=file://localhost/Users/miguelandres/myRepo`).
- Added a rootProject.ext.mdcLibraryVersion variable to set all libraries to a matching version when building the maven repository.
- Added a getArchivesBaseName(projectName) function to main build.gradle to generate all of the maven artifactIds programatically.
- Removes Source Jar and javadoc generation, since they have to be adapted to use droiddoc and to contain the entire source across gradle project boundaries (see b111021813 for an example of cross-project boundary javadoc generation)
Closes#45
PiperOrigin-RevId: 169956436
Legacy FAB has no intermediary elevation states, so hovered_focused matches pressed.
Attributes are not yet read by FAB, will come in later CL.
PiperOrigin-RevId: 169755456
Modify FAB Transformation to use theme attribute rather than hardcoded value.
Fix scrim's alpha value to actually reflect 32% black.
PiperOrigin-RevId: 169620100
Since our source roots are the project's root directory, generated output falls inside it, unless properly excluded, all intermediate output such as R classes gets recompiled with each gradle pass.
This causes failures because of duplicate R classes.
PiperOrigin-RevId: 169588457
We have subprojects of :lib: because our internal builds are bazel-based. Gradle does not support more than one project at any level with the same name, which is a staple of bazel-based builds, so gradle projects have to be renamed in runtime to include their whole path (see settings.gradle).
Furthermore since every node includes the path up until that node in its name, writing dependencies can get tedious, for this purpose there is a new method in build.gradle called getTransformedProjectPath which takes /-separated project path and turns it into the correct project path, after the rename.
This also updates versions for TargetSdk and SupportLibrary to 26, which is required by the newer code.
PiperOrigin-RevId: 169457686
-DrawableAlphaProperty has a method that can be restructured in a way that the static analysis run by android lint knows that it checks for the right api before using a newer method.
-A method in FabTransformationBehavior had to be annotated with the right TargetApi.
-CollapsedBackLayerLayout needed a @TargetApi on a newer constructor.
-BackLayerLayout needed to switch one method to ViewCompat.
PiperOrigin-RevId: 169446404
Publicizing the box mode attribute. Box mode was previously kept internal, since it wasn't yet determined whether the box would act as mode-agnostic, and this attribute would go away, or whether there would be a concept of modes, and different behaviors to follow. This has now been decided: the box will use modes to determine functionality (although it won't rely exclusively on the mode - it will still check for null backgrounds, for example). This is the first step in supporting changing the box mode programmatically and at runtime.
PiperOrigin-RevId: 169305486
Use pre-L compatible methods for setting the background color to avoid a crash, and set the background color to default to Color.TRANSPARENT. Previously, in cases where there was no background color, the color defaulted to black in versions before 17. Now when there is no color set, the color is set to Color.TRANSPARENT instead of no color.
The Color.TRANSPARENT default color could have been restricted to pre-17, but I thought it made sense to set a transparent color for all versions, to provide a more consistent way of checking that there is no background color. I'm open to other perspectives on this.
PiperOrigin-RevId: 169300417