153 Commits

Author SHA1 Message Date
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
Vladislav Kaznacheev
c5a67bc8a7 Pointer icon tests for support library
Expanding BottomNavigationViewTest and
TabLayoutTest to cover pointer icon setting.

Bug: 32178074
Change-Id: I6deab8ed0d702ccb32ab906d91c72c7abb78656d
Test: the affected tests should pass
PiperOrigin-RevId: 151519710
2017-04-12 17:14:12 -07:00
travisc
104513acdf Fix another lint error.
This one seems like something the lint tool could infer from the test annotation, but oh well.

PiperOrigin-RevId: 150239380
2017-03-15 14:08:39 -07:00
Yuichi Araki
ddcda55a30 Fix restore of actionView state in NavigationView
NavigationView was crashing on restoring its states when an action view
outside the screen gets inside the screen by screen orientation change
or similar.

Test: NavigationViewTest#testActionViewState
Bug: 34796332
Change-Id: Id2c150fce4d6cc4695c50d57523243975c4f2ef0

PiperOrigin-RevId: 150128785
2017-03-14 17:33:48 -07:00
Jonathan Koren
6cbee8658b Add item reselected listener to BottomNavigationView
Adds an additional listener in for developers that want to discern
between item selection and reselection without tracking the current
selection. This maintains backward compatibility with existing uses
of OnNavigationItemSelectedListener by itself in client code; new
behavior is only observed if an OnNavigationItemReselectedListener is
added.

Bug: 34576220
Test: Modified tests in BottomNavigationViewTest, Updated support-design-demos
Change-Id: Id48cde6395dd73a01ce68e3be1783161229f8939

PiperOrigin-RevId: 150119002
2017-03-14 17:33:32 -07:00
Jonathan Koren
98e5ed2e43 Add setSelectedItemId() to BottomNavigationView
Also fixes a bug where programmatic selection of an item (previously
by calling setChecked(true) on a menu item) does not invoke the
OnNavigationItemSelectedListener and does not animate properly.

Bug: 34627065
Bug: 33002556
Test: Added new tests in BottomNavigationViewTest
Change-Id: I2acbacaedb6cf7a05135ba90137f939b690190da

PiperOrigin-RevId: 150107208
2017-03-14 17:33:14 -07:00
Chris Banes
e11302bda7 Fix Snackbar touch handling
This fixes the issue where the timeout is
not restored when the user swipes up
from the Snackbar.

Test: included (and passing)
BUG: 33931084
Change-Id: I2a10936bed97c0344cc3dac66b908e2733f2ffa0

PiperOrigin-RevId: 149605717
2017-03-14 17:32:29 -07:00
Jonathan Koren
9e2c201185 Fix BottomNavigationView not saving state
Bug: 32995862
Test: Added new test to BottomNavigationViewTest
Change-Id: Id66e262e8264c2d09c01580f4f0055d026300684

PiperOrigin-RevId: 149586534
2017-03-14 17:32:12 -07:00
Jonathan Koren
5ec569f17e Fix TabLayout#setScrollPosition() in RTL
Also includes Ib494e97ee482f6b221ad957518af8b4885e88d89, as the added
test fails pre-M otherwise.

Bug: 34686900
Test: Added new test in TabLayoutTest
Change-Id: I2bdee71d55e8b68377124fc4d8a7b94a01a567ba

PiperOrigin-RevId: 149492933
2017-03-14 17:31:48 -07:00
Yuichi Araki
871b4d139b Fix BottomSheetDialog after swiping it down
BottomSheetDialog now collapses the bottom sheet when it is shown,
making it possible to use the same instance more than once after user
swipes it down.

Test: BottomSheetDialogTest#testHideThenShow on 15, 18, 19, and 25
Bug: 34214747
Change-Id: I464625eadb41cf42fdaacafe12e32324c21903cb

PiperOrigin-RevId: 149463377
2017-03-14 17:31:13 -07:00
Chris Banes
d5f104f1c8 Fix scroll|enterAlways when we have a top inset
Currently AppBarLayout scrolls too far. This
CL fixes that.

Test: included
BUG: 33934454
Change-Id: Id835c255dddef3ce4fdedd5a4e18a7bd493c5f9a

PiperOrigin-RevId: 149335184
2017-03-14 17:30:49 -07:00
Yuichi Araki
2cf31d94d3 Fix gravity handling in CoordinatorLayout
When a child without behavior or anchor has only one axis specified as
its layout_gravity, CoL was centering the child for the other axis.

Bug: 33655774
Test: CoordinatorLayoutTest#testLayoutChildren on 9, 15, 19, 25
Change-Id: Ie56afa62491251b01355b269c9f4c0d79658da4d

PiperOrigin-RevId: 149329258
2017-03-14 17:30:18 -07:00
Andrei Stingaceanu
45d961bf72 support:design fix possible flakiness in tests
activity.setTitle(..) run now on UI thread.

Bug: 35273478
Change-Id: I01568cbb50a8b7ad40e450bfaf8bf6b78e965716

PiperOrigin-RevId: 149173220
2017-03-14 17:29:58 -07:00
Chris Banes
8dc79e22e4 Stop nested scolling calling onDependentViewChanged
onDependentViewChanged() should only be called if
the dependent view has moved or changed size.
Theres currently a code path where the method
can be called if a nested scroll is in progress.
This CL fixes it by gating the movement bounds
check more widely.

Test: included
BUG: 33655283
Change-Id: I06d34147c4ff6136168b1cfd6568a6fce336566e

PiperOrigin-RevId: 149068329
2017-03-14 17:28:36 -07:00
travisc
15f9ce0dd3 Rolling AppBarLayout fixes forward, since the test breakage is now fixed.
PiperOrigin-RevId: 148942854
2017-03-14 17:27:49 -07:00
Chris Banes
db70ec1e76 Rolling back for test breakage.
PiperOrigin-RevId: 148722460
2017-03-14 17:27:23 -07:00
Chris Banes
3fe5df16e1 Fix various AppBarLayout restoration bugs
- Not restoring elevation
- Not restoring on min-height with status bar insets
- Not restoring when expanded="true" set in layout

Test: included
BUG: 33471543
BUG: 33510949
BUG: 33511540
Change-Id: I43b2afeaf1c2cebf0a87045314830064554e2c5d

PiperOrigin-RevId: 148701728
2017-03-14 17:26:55 -07:00
Yuichi Araki
3969d48119 Fix BottomSheetBehavior settling state
BottomSheetBehavior#checkSetState was stuck in settling state if the
peek height is as tall as the expanded state.

Test: BottomSheetBehaviorTest#testExpandedPeekHeight
Bug: 31756143
Change-Id: I6e3c4145d545d799b028e5f4fb0ff205f4ec1d0f

PiperOrigin-RevId: 148686097
2017-03-14 17:26:35 -07:00
Chris Banes
b57c6a3a24 Add onClick listener test for FABs
Got a report that OnClickListeners we not working
in 25.1. Wrote this test to confirm that they are
working fine (which they are).

Test: wallah
Change-Id: I684188e1de8389bca9b27c3a2c78de6bc1e2c6b0

PiperOrigin-RevId: 148668701
2017-03-14 17:24:58 -07:00