ExpandableBehavior:
onExpandedStateChange() is now guaranteed to be called after the dependency and child have both been laid out.
The first-layout case does this by using a pre draw listener.
ExpandableTransformationBehavior:
onCreateExpandedStateChangeAnimation() now has a currentlyAnimating hint,
which when false can be used by subclasses to initialize the sheet during expansion.
FabTransformationBehavior:
Contains translation and expansion, with scaffolding for other motion components.
FabTransformationSheetBehavior:
Contains the MotionTiming for each motion component for FAB to sheet transformation.
Demo in catalog is now draggable.
You can reposition the FAB and the sheet to see how it affects the transformation.
PiperOrigin-RevId: 167796529
Using a switch statement to ensure that the box background mode is only ever set to one of the BoxBackgroundMode constants. Also pulled the logic out into its own method to improve readability in the already large constructor, and added a check to make sure that the box background's GradientDrawable is only created if a background is requested.
PiperOrigin-RevId: 167194185
Now, CircularRevealWidget draws three things in order: content, scrim, and overlay drawable.
This allows CircularRevealWidget to reproduce a FAB's looks.
Fix some cases where Bitmap.createBitmap() was being called with 0 width/height.
PiperOrigin-RevId: 167190832
This commit adds the initial outline version of the text field box. The box drawable is now created programmatically based on early versions of parameters. Parameters at this point are just hardcoded variables.
Also included: skeleton styles and attributes for the filled and outline box. These are very basic for now. Eventually, the styles will each set parameters for the box attributes, and Widget.Design.TextInputLayout.Box will set the values that each box style has in common (like height). For now, the styles pretty much just say whether the box is filled or outlined, and the setBoxAttributes() method fills in the missing information.
Not included in this commit:
- Padding
- Actual parameters set via styles/attributes
- States
PiperOrigin-RevId: 166736640
*** Reason for rollback ***
Breaks GMM
*** Original change description ***
Reposition label to adapt to box surroundings.
Move the collapsed and expanded bounds of the floating label towards where each belongs. This commit is the first stage in setting the floating label's bounds, so it avoids calculating the exact dimensions based on internal dimensions. The label positioning work is being broken up into stages since the internal dimensions of the text field will likely change either in an upcoming design rethink and while adding the dimension parameters. The final d...
***
PiperOrigin-RevId: 165664978
Move the collapsed and expanded bounds of the floating label towards where each belongs. This commit is the first stage in setting the floating label's bounds, so it avoids calculating the exact dimensions based on internal dimensions. The label positioning work is being broken up into stages since the internal dimensions of the text field will likely change either in an upcoming design rethink and while adding the dimension parameters. The final dimensions will be set once the design is agreed upon, and probably during the dimension parameterization phase.
PiperOrigin-RevId: 165622891
Add a background box for text field to create the text field box. This does not upgrade all "line" text fields, it simply adds another style for text fields that users can opt in to in order to get the box version.
This commit adds a basic grey background box. Not included in this commit:
- Padding/positioning for the label to adjust to being in the box
- Dark/light theme versions
- Exact dimensions and colors
PiperOrigin-RevId: 165596665
Before, if there was any change to the layout inside BackLayerLayout while the back layer was already expanded, the developer had to manually call setExpanded(true) for it to animate to the new size.
Now, the behavior reacts automatically and animates the size change on its own, simplifying the code path and allowing more flexibility.
PiperOrigin-RevId: 165175310
Test: ./gradlew assembleError prone still works (and now with fewer warnings
TM)
Change-Id: I9e0af18b49a3eff1dd7ac8edc5a2873f93bb844e
PiperOrigin-RevId: 165021145
Specific attributes used in AppBarLayout's theme will cause
the super constructor to call onCreateDrawableState before
class-level fields are initialized. Move the creation of temp
array to be on-demand.
Bug: 37460722
Test: ./gradlew support-design:connectedCheck --info --daemon
-Pandroid.testInstrumentationRunnerArguments.class=android.support.design.widget.AppBarWithScrollbarsTest
Change-Id: I086f25c676201876fd76cd3684afcab7e09436d0
PiperOrigin-RevId: 165010107
This allows an app theme to only define colorPrimary variants, and get have that be applied by default to all controls.
Legacy apps overwrite colorAccent, which controls will still honor.
PiperOrigin-RevId: 164890003
This CL also changes the API from a explicit expand()/collapse() method duo to a single setExpanded(boolean) to match other expandable widgets in MDC, for consistency.
This is a breaking change but there has been no release of MDC that contains BackLayerLayout in a usable state, so this is the right time to do this kind of change.
PiperOrigin-RevId: 164664813
Problem 1. The back layer contains all views for an expanded experience, even
if they are hidden behind the content layer, this makes them accessible through
Talkback when the back layer is collapsed when all views outside of
CollapsedBackLayerContents must be for all intents and purposes disabled. They
still need to remain visible to accomodate for semi transparent views, so
changing their visibility to GONE is not an option.
Solution: Add ChildViewAccessibilityHelper that keeps track of the
importantForAccessibility property for subviews of the BackLayer and overrides
them to IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDENTS when collapsed and then
reverts them to their original values when the back layer is expanded.
- Caveat: This new object has to implement ViewGroup.OnHierarchyChangeListener
so it can remove mappings for removed views, this way guaranteeing there is no
memory leak. This also means users of BackLayerLayout MUST NOT set their own
OnHierarchyChangeListener.
- Caveat 2: this new object does not modify any CollapsedBackLayerContents,
since views in that subview must still be accessible when collapsed.
Problem 2. When the backlayer expands, the content layer remains active through
accessibility services, we want to completely disable it. Furthermore a content
description needs to be set on the content layer view that may not match what
it already has.
Solution: Add ContentViewAccessibilityPropertiesHelper that overrides the
content layer's contentDescription, importantForAccessibility and focusable
properties (and reverts them once the back layer is collapsed), and reuses the
ChildViewAccessibilityHelper to make its child views not focusable.
Tested: Sadly this is too hard to test on Espresso, I tested this manually, I'm
trying to find a way to test them automatically.
PiperOrigin-RevId: 164661912
Removes onSaveInstanceState() and onRestoreInstanceState() from the ExpandableWidget interface. Those methods required all descendent subclass Views to declare those methods to be public, which is not ideal given how many FAB subclasses there are.
Those interface methods were mostly used for their javadoc, which is now moved into the interface javadoc.
PiperOrigin-RevId: 163440160
BackLayerLayout.
This change also adds details on why all of these could not be consolidated
into less attributes and generally improves the usage guide.
PiperOrigin-RevId: 163094493
This broke clients that subclassed ExpandableFloatingActionButton and overrode onSaveInstanceState(). Because those subclasses declared the methods as protected, it conflicts with this commit which makes them public.
Will roll-forward with client fixes.
PiperOrigin-RevId: 162844548
Separate ExpandableBehavior and ExpandableTransformationBehavior.
ExpandableWidget - for widgets that have expanded state, like BackLayerLayout:
{g,s}etExpanded()
on{Save,Restore}InstanceState()
ExpandableBehavior - for behaviors that want to react to expanded state change, like BackLayerSiblingBehavior:
onLayoutChild() // Layouts the content, and animates the content to a new expanded position when BLL's expanded children change size.
onExpandedStateChange() // Animates the content position when expanded state changes.
ExpandableTransformationWidget - for widgets that transform during expansion, like FAB:
{g,s}etExpandedComponentIdHint()
Will also include these in the future:
getBackgroundDrawable() // Shape drawable includes color, bounds, shape, elevation
getForegroundDrawable()
etc
ExpandableTransformationBehavior - for behaviors that want to react to expanded state change by transforming, like FabTransformationSheetBehavior:
onCreateExpandedStateChangeAnimation() // Animates the FAB and sheet when expanded state changes.
PiperOrigin-RevId: 162809090
Most of the layout files were not following our code style and followed an attribute ordering scheme that didn't make very much sense (ex: putting an attribute's format before its name).
Reformatting these files in a separate commit will help prevent formatting changes distracting from the main point of commits.
PiperOrigin-RevId: 162670506
This change adds all the foundation code needed:
+ demo in the Catalog,
+ persistentsheet package with 2 classes:
* PersistentSheet,
* PersistentSheetTransformationBehavior
Instead of a proper expansion animation, a placeholder animation copied from FAB transformations is added. Proper animations to be added later.
PiperOrigin-RevId: 162641104
Adds functionality to turn the floating label, or "hint", to the error color when the error is set. The error color for the label will match whatever the error color is set to via app:errorTextAppearance. In the case where no custom errorTextAppearance is set, the label gets set to the error color's default color, which is red/dark pink, depending on whether the text field is used in a dark or light theme.
PiperOrigin-RevId: 162553182
The typeface comparisons in CollapsingTextHelper were triggering a ReferenceEquality warning. Changing to an Objects.equals comparison did not fix the problem, because Objects is not available down to API level 15. I added a SuppressWarnings annotation to match the way this already is addressed in TextInputLayout.
PiperOrigin-RevId: 162399064
This commit adds functionality to TextInputLayout to support helper text, as outlined in spec: https://material.io/guidelines/components/text-fields.html#text-fields-layout.
This is an initial implementation of helper text. It is a large commit, and in order to avoid making it any larger, it does not include the following things:
- Setting helper text via XML attribute
PiperOrigin-RevId: 162390341
The content for the backlayer should be able to change in runtime to allow for multiple experiences in the backlayer. Furthermore, changing to a different experience should not imply collapsing and re-expanding the backlayer, it should happen in-place with the content layer sliding to accommodate the size of the new content.
If expand is called when the backlayer is already expanded then the backlayer
animates a possible size change.
If there is no need to change the size then the duration for the animation is
zero.
On the side, this changes BackLayer to be a LinearLayout.
PiperOrigin-RevId: 162277051
Espresso does not need the uiController.loopMainThreadUntilIdle() calls, so I removed them. Verified that removing these calls didn't add flakiness by running them with --runs_per_test=100.
PiperOrigin-RevId: 161989235