171 Commits

Author SHA1 Message Date
afohrman
8a72126daa Use color int instead of ColorStateList for box stroke color.
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
2017-11-14 13:38:36 -05:00
Kirill Grouchnikov
559d400937 Fix dodge constants for CoordinatorLayout
Use consistent values for right dodging + add test coverage

Bug: 65976973
Test: ./gradlew design:connectedCheck --info --daemon
-Pandroid.testInstrumentationRunnerArguments.class=android.support.design.widget.AppBarWithDodgingTest
Change-Id: I48b5f4ec9b8e5d5484fcd846fd2f305d1987a5ef
PiperOrigin-RevId: 171615802
2017-11-14 13:38:08 -05:00
Material Design Team
a317be9150 Update Espresso package name
PiperOrigin-RevId: 171415474
2017-11-14 13:35:17 -05:00
markwei
1f3fb664cc MotionSpec API change.
Now it contains two static factory methods: loadFromAttribute() and loadFromResource().

PiperOrigin-RevId: 171216945
2017-11-13 14:23:49 -05:00
markwei
5edfba0242 BackLayerLayout cleanup.
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
2017-11-13 14:19:07 -05:00
afohrman
e97e947173 Create label cutout for outline box.
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
2017-11-13 14:18:15 -05:00
afohrman
78ec4eb97d Fix screenshot test failures.
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
2017-11-10 15:55:42 -05:00
markwei
57b25026ca Automated g4 rollback of changelist 170569328
PiperOrigin-RevId: 170730468
2017-11-10 15:55:14 -05:00
Material Design Team
7f6fe75b9f Automated g4 rollback of changelist 170569077
PiperOrigin-RevId: 170569328
2017-11-10 15:54:24 -05:00
markwei
d48039b988 Parameterize FAB showMotionSpec and hideMotionSpec.
- 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
2017-11-10 15:52:59 -05:00
markwei
c89dfef597 New MotionSpec API.
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
2017-11-10 15:50:23 -05:00
afohrman
8003f22530 Add color parameter for outline box.
Adds an attribute for the box's stroke (outline) color. Includes a public and private attribute, setters, getters, documentation, and tests.

PiperOrigin-RevId: 170239224
2017-11-10 15:47:23 -05:00
markwei
1f90669495 Actually change FAB elevation on API 21.
Listen for onDrawableStateChanged() and manually set the correct elevation without animation.

PiperOrigin-RevId: 170127224
2017-11-10 15:43:53 -05:00
miguely
289ccd7577 Add explicit exclusions to "**/build/**" in gradle files.
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
2017-09-21 16:13:59 -04:00
miguely
befb1996a6 Fix NewApi Lint error on backlayer test project
PiperOrigin-RevId: 169587243
2017-09-21 16:13:42 -04:00
miguely
713ac062ad Update Gradle build to fit our new code structure.
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
2017-09-21 15:09:52 -04:00
miguely
461430fb89 Fix lack of final qualifier for inner class
PiperOrigin-RevId: 169447663
2017-09-21 15:09:29 -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
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
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
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
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
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
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
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
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
gauthams
9ea1918ef8 Update BottomNavigationViewTest to cover shifting mode cases
PiperOrigin-RevId: 157039884
2017-05-24 16:37:23 -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
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
gauthams
5c9ac9798b Suppress flaky AppBarLayout tests on API 15
PiperOrigin-RevId: 155236892
2017-05-05 16:42:16 -07:00
gauthams
0d29fa6a89 Add default scrolling behavior to BottomNavigationView
PiperOrigin-RevId: 155029168
2017-05-05 16:38:46 -07:00
travisc
838d1c2d6e Fix various problems preventing MDC from building with gradle.
- AppBarWithCollapsingToolbarStateRestoreTest needed a variable used inside a closure to be marked as final (No idea why Bazel was okay with this)
- BottomNavigationViewTest/TabLayoutTest needed TargetApi annotations for tests that run on N+
- Every Shrine build.gradle file needs to specify values for Java includes and srcDirs, regardless of whether they contain Java. If they don't they get the default library values (which includes every subdirectory recursively), and result in duplicate classes being generated.
- Various styles.xml files in Shrine were using attributes only available in v17 or v21+

This also updates the main build.gradle file to print lint errors on stdout, so they're easier to look at in TravisCI.

PiperOrigin-RevId: 153389041
2017-04-17 14:52:28 -07:00
Chris Banes
c1506d4568 Fix CollapsingToolbarLayout height when wrap_content
If there is a top window inset we need to make sure
that we expand our height to allow the Toolbar
to be offset.

BUG: 36126318
Test: included
Change-Id: I179fc6764166d80d92a8a995c93d54650365c2bf
PiperOrigin-RevId: 152452065
2017-04-12 17:43:05 -07:00
Aurimas Liutikas
1985a0c0dd Use PollingCheck instead of sleep in AppBarWithCollapsingToolbarTest.
Bug: 30701044
Test: I was unable to repro this locally, but this should fix the flakiness
Change-Id: I58b143c5aeec13941b28bac6136f28215a8efbab
PiperOrigin-RevId: 152432632
2017-04-12 17:41:30 -07:00
Aurimas Liutikas
04adec8ed3 Unflake AppBar tests
AppBarWithCollapsingToolbarStateRestoreTest has been rotating the activity
without rotating it back causing tests that follow it to flake due to
unexpected
orientation change back to original orientation.

Bug: 36130096
Test: Test still passes locally
Change-Id: I642a72d8a90ae5c16df4ef3710a4fd3057bd3043
PiperOrigin-RevId: 152411001
2017-04-12 17:40:05 -07:00
Aurimas Liutikas
43ec3dd052 Remove usage of MotionEventCompat methods.
We bumped our minSdk to 14 and now most of MotionEventCompat methods and
constants are no longer needed.

Bug: 32794064
Test: ./gradlew assemble assembleAndroidTest
Change-Id: I5fc698fc8243107cd969743b7500163818f8c258
PiperOrigin-RevId: 152201817
2017-04-12 17:37:17 -07:00
Aurimas Liutikas
0ce16ad50e Update test sizes for all currently @SmallTest.
SmallTests are supposed to complete in <200ms, Medium in <1s, and Large in
<30s.
This CL updates the size of all the SmallTest based on excecution times from
presubmit test runners.

Test: None
Bug: 34854821
Change-Id: Iec73f7b6ef63b27cd3d8b19a8e8c7a9b91ff6729
PiperOrigin-RevId: 152174653
2017-04-12 17:32:48 -07:00
Aurimas Liutikas
8428f09805 Remove ViewCompat method usages for things that were added in API 11.
Bug: 32794064
Test: ./gradlew assemble assembleAndroidTest still works
Change-Id: I18fb0cc1ebc67c911eeb30aada7b8315afc15835
PiperOrigin-RevId: 152030798
2017-04-12 17:31:18 -07:00
Kassim Maguire
45120e4f07 Use enabled scrolling child in BottomSheetBehavior
Modification of findScrollingChild() that only returns a view if
it has nested scrolling enabled (instead of just implementing
NestedScrollingChild). As to prevent an incorrect view being
referrenced, leading to incorrect behavior when scrolling.

Test: added BottomSheetBehaviorTest.testFindScrollingChildEnabled()
that tests that an enabled NestedScrollView contained within a disabled
NestedScrollView parent is returned by findScrollingChild(parent)
Change-Id: I9841db9c67520f858913a5109dc08ffed9e53568
PiperOrigin-RevId: 151889793
2017-04-12 17:26:05 -07:00
Aurimas Liutikas
d32ba949a8 Move to using ValueAnimator directly instead of compat versions.
ValueAnimator can now be used directly given that our minSdk is 14.

Bug: 32794064
Test: ./gradlew clean assemble still works
Change-Id: Ibf0111b104eaea10acf33c8d54a3275fdfa0c1a4
PiperOrigin-RevId: 151641145
2017-04-12 17:22:06 -07:00
Aurimas Liutikas
96436e4d8d Bump minSdkVersion to API 14.
First step in moving minSdkVersion to API 14 for design library.

Bug: 32794064
Test: gradlew clean assemble assembleAndroidTest still works
Change-Id: I113834cc6e3c088cdf606a86fe7a35faa192b801
PiperOrigin-RevId: 151608161
2017-04-12 17:21:22 -07:00