759 Commits

Author SHA1 Message Date
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
travisc
680e3c3a25 Roll back FAB expand/collapse state due to crash it introduces.
PiperOrigin-RevId: 161864354
2017-09-21 11:57:01 -04:00
travisc
9381e4848b Roll back later FAB expansion work because it depends on a change that needs to be rolled back.
PiperOrigin-RevId: 161860435
2017-09-21 11:56:33 -04:00
markwei
02f1e5cb83 ExpandableTransformationBehavior is an abstract base class for all behaviors that react to changes in an ExpandableWidget's expanded state.
FabTransformationSheetBehavior and FabTransformationScrimBehavior implement
specific variations of an ExpandableTransformationBehavior.

These Behavior currently just does a simple fade of the FAB, sheet, and scrim.

PiperOrigin-RevId: 161758301
2017-09-21 11:55:43 -04:00
markwei
8571cd7386 Add expand/collapse state to FloatingActionButton.
After this CL, FAB is able to keep an `expanded` state. When the state changes,
it dispatches an event to dependent Behaviors.

This change does not include any XML attributes.

PiperOrigin-RevId: 161757314
2017-09-21 11:32:17 -04:00
miguely
9acb393c41 Move BackLayerLayout to use LinearLayout instead of RelativeLayout.
In previous code reviews there was a concern over the performance hit of
RelativeLayout's double measurement, and BackLayerLayout's own double measurement.

As a compromise we chose to use LinearLayout instead. Furthermore after
switching to LinearLayout, the EndBackLayerLayoutTest works, so this commit
also commits that new test.

PiperOrigin-RevId: 161720799
2017-09-21 11:31:30 -04:00
miguely
025f75b4cf Generalizes all test logic to abstract the position of the BackLayer.
Adds concrete tests for Start, Top and Bottom backlayers.

Note: EndBackLayerLayoutTest has not been added in this CL because it is
failing over layout issues. These issues are not related directly to the core
functionality of the BackLayerLayout, but it still has to be fixed. Punting
this to a separate CL.
PiperOrigin-RevId: 161667143
2017-09-21 11:29:43 -04:00
Yuichi Araki
b8625c6118 Fix BottomSheetBehaviorTest
BottomSheetBehaviorTest#testNestedScroll was failing on tablet.

Test: This is the test
Bug: 36855751
Change-Id: I1ea95d66aa3a3d8b85964428688c29839d067fb7
PiperOrigin-RevId: 160471346
2017-09-21 11:28:52 -04:00
markwei
d9306c69c1 Create new MaterialComponent themes with new color scheme attributes.
PiperOrigin-RevId: 160319995
2017-09-21 11:26:31 -04:00
miguely
fb9092098a Add the ability to hide and expose the Back Layer.
-The exposure and hide actions are animated, and have before/after callbacks.
-Clicks on the content layer when the backlayer is exposed are hijacked to close the back layer.
-The animations do not relayout, by simply sliding the boundaries (bottom/left/right/top).

PiperOrigin-RevId: 160315361
2017-09-21 11:25:14 -04:00
afohrman
127dfe1255 Add graceful degradation for character counter and label text overflow color.
Previously, the character counter and label overflow color ended up as Color.MAGENTA, which actually is a sickly pink color. This appears to have been happening when the theme doesn't extend from Theme.Design, and therefore doesn't have textErrorColor. On API 23 and above, it gets set to MAGENTA instead of throwing an exception. The only reason this pink color was being used for the character counter and not the error text is because there already a fix for the error text - it just wasn't applied to the character counter.

I pulled the logic for the fix out to make this graceful degradation code reusable for both error and character text, and for future situations like this.

PiperOrigin-RevId: 159229718
2017-09-21 11:23:47 -04:00
afohrman
73cb135c15 Update vertical motion for TextInputLayout's error text.
Motion additions/updates in this change:
- Added animation for error text's translation down
- Updated durations and interpolators for the opacity in and out animations

These changes roll forward changes that were previously rolled back because they broke screenshot tests.

PiperOrigin-RevId: 158881906
2017-06-14 16:38:11 -07:00
travisc
06b88e84ad Remove the split base/ics/lollipop directories.
The implementation in ics/ was the only remaining implementation of that class,
so it made sense to move it directly into src/. Most of the implementations in
base/ were the only remaining implementations, and thus also made sense to move
into src/.

The remaining classes were already post-fixed with Lollipop, so I see very
little value in maintaining separate source directories for them (and I know
these separate directories have also been flagged as confusing). They've all
been moved into src/ as well now. I also renamed FloatingActionButtonLollipop
to FloatingActionButtonImplLollipop here, as that better describes what it is
a version of.

PiperOrigin-RevId: 158187999
2017-06-14 16:37:39 -07:00
afohrman
94947cde8a Broke some screenshot tests.
PiperOrigin-RevId: 157239931
2017-06-14 16:33:59 -07:00
afohrman
63acb542ed Update motion for TextInputLayout's error state.
Motion additions/updates in this change:
- Added animation for error text's translation down
- Updated durations and interpolators for the opacity in and out animations

PiperOrigin-RevId: 157220100
2017-06-14 16:32:30 -07:00
gauthams
9ea1918ef8 Update BottomNavigationViewTest to cover shifting mode cases
PiperOrigin-RevId: 157039884
2017-05-24 16:37:23 -07:00
gauthams
60549808c5 Fix divide-by-zero crash when building BottomNavigationMenu with <2 children and shifting mode enabled.
PiperOrigin-RevId: 156888556
2017-05-24 16:37:07 -07:00
gauthams
c8052c3e2f Modify setShiftingMode() in BottomNavigationItemView to call setChecked() if the item view has already been initialized, so that shifting mode changes are immediately visible without having to re-initialize the view.
Also setting shifting mode before initializing view in BottomNavigationMenuView's updateMenu(), for consistency with buildMenu().

PiperOrigin-RevId: 156800545
2017-05-24 16:36:29 -07:00
afohrman
78eb50a405 Update motion for TextInputLayout's active state.
Motion updates in this change:
- Shortened the duration for the label scale
- Changed the interpolators from linear to FastOutSlowIn

PiperOrigin-RevId: 156553820
2017-05-24 16:35:55 -07:00
miguely
644139fb99 Add a BackLayerLayout and BackLayerSiblingBehavior + tests.
These are the foundation for the back layer functionality. The behavior
does the heavy lifting to measure the adjacent content view.

As of now this only lays out the views correctly in the hidden state, it doesn't support exposing the back layer at all, yet. Full of TODOs, this is just a skeleton.

PiperOrigin-RevId: 156334640
2017-05-24 16:33:21 -07:00
gauthams
08c783554a Update documentation for methods to set and get shifting mode on BottomNavigationView
PiperOrigin-RevId: 156251192
2017-05-24 16:31:55 -07:00
gauthams
eb96b9a358 Fix crash in BottomNavigationMenuView when updateMenuView is called while mMenu or mButtons is null
PiperOrigin-RevId: 156243521
2017-05-16 16:03:49 -07:00
gauthams
8493677be9 Add option to disable shifting mode even on BottomNavigationViews with 3+ children
Fixes #22.

PiperOrigin-RevId: 156126715
2017-05-16 16:02:31 -07:00
Travis Collins
4302673218 Upgrade complete codelab to gradle 2.3.2. 2017-05-16 15:46:21 -07:00
Travis Collins
9596d15435 Fix starter project build, can't use library attributes before we depend on the library. 2017-05-16 15:40:37 -07:00
gauthams
32b1f744e4 Update BottomNavigationView onMeasure to properly measure with invisible children
PiperOrigin-RevId: 155899080
2017-05-12 13:18:19 -07:00
gauthams
71c3e81905 Don't skip adding non-visible children in BottomNavigationView to avoid NPE when accessing those
PiperOrigin-RevId: 155893998
2017-05-12 13:18:02 -07:00
gauthams
d15d791fb7 Fix NPE on bottom nav menu update, and add test for this case.
PiperOrigin-RevId: 155776319
2017-05-11 13:00:34 -07:00
dcarlsson
c6fdfe669e Update headers for Android Material Components documentation to clarify page titles in relation to table of contents/index listings.
- Update page title for each piece of documentation to use the vernacular concept rather
than the class name for the component.
- Treat all instances of class names as proper nouns and mark them as code names.

PiperOrigin-RevId: 155705022
2017-05-11 12:57:38 -07:00
shyndman
01f8349ad1 Changes a number of links to be relative.
PiperOrigin-RevId: 155675090
2017-05-10 14:26:50 -07:00
afohrman
0a157b9975 Fix semi-broken link in TextInputLayout documentation.
The link to a method on Android's doc site had slashes in it, so it linked to the right documentation page, but not the specific method.

PiperOrigin-RevId: 155658544
2017-05-10 12:05:58 -07:00
shyndman
1689aa0f15 Changes a couple absolute paths to relative ones.
Required for the docsite link rewriting.

PiperOrigin-RevId: 155658527
2017-05-10 12:05:39 -07:00
shyndman
cc0114d65f Fixes a broken link.
PiperOrigin-RevId: 155649622
2017-05-10 11:09:41 -07:00
gauthams
e442abe704 Tweak animation for bottom nav hiding behavior
PiperOrigin-RevId: 155563392
2017-05-09 17:20:07 -07:00
shyndman
0627e7d2f8 Updates the docsite index to resemble iOS's.
Uses the correct CSS classes, and names each of the steps. The last two steps were merged, and we added in a click handler.

PiperOrigin-RevId: 155561692
2017-05-09 17:19:49 -07:00