793 Commits

Author SHA1 Message Date
markwei
148ccc4274 Make FABs clickable and focusable by default.
PiperOrigin-RevId: 169163245
2017-09-21 14:55:07 -04:00
Material Design Team
47bb0cd722 Make statusBarBackground accept a color reference, to match the support library.
PiperOrigin-RevId: 168869815
2017-09-21 14:54:45 -04:00
markwei
a53014baeb Parameterize FAB's maxImageSize.
PiperOrigin-RevId: 168774497
2017-09-21 14:54:06 -04:00
markwei
40e788f9fd Tests for circularreveal.
PiperOrigin-RevId: 168756711
2017-09-21 14:53:21 -04:00
markwei
ba2928a2a7 Add floatingActionButtonStyle attribute to MaterialComponents theme.
FloatingActionButton now reads this style, if it is set in the theme.

PiperOrigin-RevId: 168455739
2017-09-21 14:52:40 -04:00
afohrman
af0896aa22 Use color ints instead of ColorStateLists for box background.
GradientDrawable#setStroke was only available with color ints pre-21. Using color ints for backwards compatibility.

PiperOrigin-RevId: 168005160
2017-09-21 14:51:35 -04:00
markwei
4daf9b8358 Use ViewCompat to avoid crash on API 15.
Add TODOs in TextInputLayout to use alternative APIs that support pre-21 devices.

PiperOrigin-RevId: 167896013
2017-09-21 14:51:18 -04:00
markwei
b8a827b5a3 FAB to sheet transformation part 2.
Implement motion components for elevation, icon fade, color, and content fade.

PiperOrigin-RevId: 167889744
2017-09-21 14:50:22 -04:00
markwei
8e866cc7da FAB to sheet transformation part 1.
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
2017-09-21 14:48:57 -04:00
markwei
de2b71f389 Automated g4 rollback of changelist 167216268.
*** Reason for rollback ***

Rollforward with fixes.

*** Original change description ***

Automated g4 rollback of changelist 167199573.

*** Reason for rollback ***

Build breakage.

*** Original change description ***

Rename motion package to animation, add new util classes.

Added MotionTiming, Positioning, TranslationTiming, and ArgbEvaluatorCompat.

***

***

PiperOrigin-RevId: 167295026
2017-09-21 14:48:23 -04:00
Kirill Grouchnikov
b43e8f63bb Move textColorError from design to appcompat. Rename to colorError for
consistency with FW.

Bug: 33829062
Test: ./gradlew support-design:connectedCheck --info --daemon
-Pandroid.testInstrumentationRunnerArguments.class=android.support.design.widget.TextInputLayoutTest
Test: visual inspection
Change-Id: I5ca55e34785a1d8926a86a96bf4a8fc441f5ed1c
PiperOrigin-RevId: 167237425
2017-09-21 14:47:48 -04:00
markwei
d8d8a1ad5e Automated g4 rollback of changelist 167199573.
*** Reason for rollback ***

Build breakage.

*** Original change description ***

Rename motion package to animation, add new util classes.

Added MotionTiming, Positioning, TranslationTiming, and ArgbEvaluatorCompat.

***

PiperOrigin-RevId: 167216268
2017-09-21 14:47:14 -04:00
markwei
d23f7ef44d Rename motion package to animation, add new util classes.
Added MotionTiming, Positioning, TranslationTiming, and ArgbEvaluatorCompat.

PiperOrigin-RevId: 167199573
2017-09-21 14:45:09 -04:00
afohrman
7b4e6d356c Improve logic for setting box background mode.
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
2017-09-21 14:44:38 -04:00
markwei
b84bf0b277 Add overlay drawable to CircularRevealWidget.
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
2017-09-21 14:43:37 -04:00
markwei
93f572268e Make FloatingActionButton implement TintableBackgroundView.
This allows FAB to receive background tinting calls from ViewCompat for pre-21 devices.

PiperOrigin-RevId: 167190536
2017-09-21 14:42:59 -04:00
markwei
1a4f43b813 New circularreveal and math packages.
PiperOrigin-RevId: 167187646
2017-09-21 14:41:53 -04:00
gauthams
5e7e4b8c63 Add style for M2 stroked button, and add stroked button demo to Material Components catalog app
PiperOrigin-RevId: 167056087
2017-09-21 14:41:19 -04:00
markwei
8adb365a5a Fix DialogWhenLarge to inherit from the correct FixedSize.
Fix typo.

PiperOrigin-RevId: 166763382
2017-09-21 14:33:38 -04:00
afohrman
fd1da78e7e Add outline text field box.
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
2017-09-21 14:33:13 -04:00
miguely
78fc02e266 Add high level documentation for BackLayerLayout.
Also fixes some missing stuff in javadoc.

PiperOrigin-RevId: 165744096
2017-09-21 14:32:47 -04:00
Material Design Team
feee8126e6 Automated g4 rollback of changelist 165622891.
*** 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
2017-09-21 14:32:18 -04:00
afohrman
84d3d9ef92 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 dimensions will be set once the design is agreed upon, and probably during the dimension parameterization phase.

PiperOrigin-RevId: 165622891
2017-09-21 14:31:54 -04:00
afohrman
a0550d04c5 Add box for text field.
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
2017-09-21 14:31:29 -04:00
miguely
b352fa92f8 BackLayer: Make Sibling Behavior listen to changes inside the BackLayerLayout (views changing size or relayout) to react automatically to changes in content.
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
2017-09-21 14:31:01 -04:00
Alan Viverette
d16cead6c8 Remove unnecessary casts on calls to findViewById
Bug: 24137209
Test: make -j32
Change-Id: I04084b2d05ddd7afaa160a76efe0b0d0c8eb5f00
PiperOrigin-RevId: 165042386
2017-09-21 14:30:28 -04:00
Aurimas Liutikas
c367e56554 Clean up an assortment of Error-Prone warnings.
Test: ./gradlew assembleError prone still works (and now with fewer warnings
TM)
Change-Id: I9e0af18b49a3eff1dd7ac8edc5a2873f93bb844e
PiperOrigin-RevId: 165021145
2017-09-21 14:30:11 -04:00
Kirill Grouchnikov
3c1a8594f5 Don't crash in AppBarLayout inflation
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
2017-09-21 14:25:11 -04:00
Yuichi Araki
a9f3c2b463 Status bar background for BottomSheetDialog
Bug: 31303656
Test: Manual & existing tests on 15, 18, 19, 21 and 25
Change-Id: I72240894848ae1e9505679f2e4517c152fa3c4bf
PiperOrigin-RevId: 164946739
2017-09-21 14:24:45 -04:00
markwei
e02f108d03 Base theme's colorSecondary defaults to colorPrimary.
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
2017-09-21 14:24:25 -04:00
gauthams
6c84bf2a45 Add style for M2 text button, and add text button demo to Material Components catalog app.
PiperOrigin-RevId: 164667764
2017-09-21 14:23:21 -04:00
miguely
4ef1f94011 Backlayer: Keep the value of expanded across activity restarts and config changes using onSaveInstanceState and onRestoreInstanceState.
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
2017-09-21 14:22:28 -04:00
miguely
1a17221ee3 Fix accessibility focus on the back layer and the content layer.
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
2017-09-21 14:21:44 -04:00
markwei
9a32f67d40 Pull AnimationUtils into a new package.
PiperOrigin-RevId: 163743184
2017-09-21 14:21:16 -04:00
markwei
659b5d16bc Roll forward separating ExpandableWidget/TransformationWidget and ExpandableBehavior/ExpandableTransformationBehavior.
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
2017-09-21 14:20:30 -04:00
miguely
5694bee92b Explain the requirement of layout_gravity, gravity and orientation in
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
2017-09-21 14:20:08 -04:00
markwei
f61171a94b Roll back ExpandableTransformation separation.
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
2017-09-21 14:19:37 -04:00
markwei
64f930f2a7 Separate ExpandableWidget and ExpandableTransformationWidget.
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
2017-09-21 14:18:58 -04:00
afohrman
75204528b9 Reformat layout files in lib directory.
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
2017-09-21 13:00:16 -04:00
Material Design Team
fd840cbf9a The foundation part of the Dynamic Persistent Sheet concept implementation
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
2017-09-21 12:13:02 -04:00
afohrman
0c49c64a57 Turn hint/label to error color when error is set.
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
2017-09-21 12:12:31 -04:00
markwei
dbab5c7ef0 Add test for FabTransformation*Behaviors.
PiperOrigin-RevId: 162525305
2017-09-21 12:11:50 -04:00
miguely
384769c827 Internal change to fix github export configuration.
PiperOrigin-RevId: 162521977
2017-09-21 12:11:15 -04:00
markwei
9cabd53c7f Fix for missing BaseSavedState(Parcel, ClassLoader) on APIs < 24.
Inherit from support-lib AbsSavedState instead of the framework BaseSavedState.

PiperOrigin-RevId: 162500649
2017-09-21 12:10:22 -04:00
afohrman
66ff202b44 Fix reference equality comparison warnings for typeface.
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
2017-09-21 12:10:07 -04:00
afohrman
b28f0e0996 Add helper text feature to TextInputLayout.
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
2017-09-21 12:09:20 -04:00
miguely
2d618793dd Adds support for more than one expanded state for the BackLayerLayout.
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
2017-09-21 12:00:21 -04:00
travisc
3ec57f2dab Roll forward ExpandableTransformationBehavior changes since the CL it depends on was rolled forward.
PiperOrigin-RevId: 162002644
2017-09-21 11:59:09 -04:00
travisc
329cc2d267 Roll forward. Fixes the crash on Parcelable restoration.
PiperOrigin-RevId: 161999957
2017-09-21 11:58:17 -04:00
afohrman
10fa73def7 Remove unnecessary looper calls in TextInputLayout's ViewActions.
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
2017-09-21 11:57:37 -04:00