Commit 63d2e113 authored by Friedrich Horschig's avatar Friedrich Horschig Committed by Commit Bot

[TouchToFill][Android] Set correct peeking height

The Peeking state became customizable. With that, we can now show 1.5
suggestions initially and allow expanding the sheet. It is alsow
prerequisite for the footer which we only show in FULL state.

The flow of scrolling is now:
1) Keyboard opens in Peek state.
2) swipe up motion expands to Full state.
3) swipe up motion scrolls the list to the bottom.
4) swipe down motion scrolls the list to the top.
5) swipe down shrinks/dismisses the sheet.

Btw: the minimum height of the sheet could be smarter: instead of
using the fixed size of 340dp, the header size plus 1.5 suggestion
heights fit better. This smartness should be added AFTER the issue
1012219 is resolved.

Screenshots showing differences in states are in https://crbug.com/957532#c47.

Bug: 1012219, 1013257, 957532
Change-Id: I74b7209e447b474815f21a4aafed8672fc57889a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1857128
Commit-Queue: Friedrich [CET] <fhorschig@chromium.org>
Reviewed-by: default avatarBoris Sazonov <bsazonov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#706875}
parent 7e027936
...@@ -7,8 +7,9 @@ ...@@ -7,8 +7,9 @@
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:layout_width="match_parent" android:layout_width="match_parent"
android:minHeight="340dp"
android:orientation="vertical" android:orientation="vertical"
android:paddingStart="16dp" android:paddingStart="16dp"
android:paddingEnd="16dp"> android:paddingEnd="16dp">
......
...@@ -103,7 +103,7 @@ class TouchToFillView implements BottomSheet.BottomSheetContent { ...@@ -103,7 +103,7 @@ class TouchToFillView implements BottomSheet.BottomSheetContent {
@Override @Override
public int getVerticalScrollOffset() { public int getVerticalScrollOffset() {
return 0; return mSheetItemListView.computeVerticalScrollOffset();
} }
@Override @Override
...@@ -123,12 +123,13 @@ class TouchToFillView implements BottomSheet.BottomSheetContent { ...@@ -123,12 +123,13 @@ class TouchToFillView implements BottomSheet.BottomSheetContent {
@Override @Override
public int getPeekHeight() { public int getPeekHeight() {
return BottomSheet.HeightMode.DISABLED; return Math.min(mContentView.getMinimumHeight(),
(int) mBottomSheetController.getBottomSheet().getSheetContainerHeight());
} }
@Override @Override
public boolean wrapContentEnabled() { public boolean wrapContentEnabled() {
return true; return false;
} }
@Override @Override
......
...@@ -82,7 +82,7 @@ public class TouchToFillIntegrationTest { ...@@ -82,7 +82,7 @@ public class TouchToFillIntegrationTest {
runOnUiThreadBlocking(() -> { runOnUiThreadBlocking(() -> {
mTouchToFill.showCredentials(EXAMPLE_URL, true, Collections.singletonList(ANA)); mTouchToFill.showCredentials(EXAMPLE_URL, true, Collections.singletonList(ANA));
}); });
pollUiThread(() -> getBottomSheetState() == SheetState.FULL); pollUiThread(() -> getBottomSheetState() == SheetState.PEEK);
pollUiThread(() -> getCredentials().getChildAt(0) != null); pollUiThread(() -> getCredentials().getChildAt(0) != null);
TouchCommon.singleClickView(getCredentials().getChildAt(0)); TouchCommon.singleClickView(getCredentials().getChildAt(0));
...@@ -98,7 +98,7 @@ public class TouchToFillIntegrationTest { ...@@ -98,7 +98,7 @@ public class TouchToFillIntegrationTest {
runOnUiThreadBlocking(() -> { runOnUiThreadBlocking(() -> {
mTouchToFill.showCredentials(EXAMPLE_URL, true, Arrays.asList(ANA, BOB)); mTouchToFill.showCredentials(EXAMPLE_URL, true, Arrays.asList(ANA, BOB));
}); });
pollUiThread(() -> getBottomSheetState() == SheetState.FULL); pollUiThread(() -> getBottomSheetState() == SheetState.PEEK);
Espresso.pressBack(); Espresso.pressBack();
......
...@@ -95,7 +95,7 @@ public class TouchToFillViewTest { ...@@ -95,7 +95,7 @@ public class TouchToFillViewTest {
public void testVisibilityChangedByModel() { public void testVisibilityChangedByModel() {
// After setting the visibility to true, the view should exist and be visible. // After setting the visibility to true, the view should exist and be visible.
TestThreadUtils.runOnUiThreadBlocking(() -> mModel.set(VISIBLE, true)); TestThreadUtils.runOnUiThreadBlocking(() -> mModel.set(VISIBLE, true));
pollUiThread(() -> getBottomSheetState() == SheetState.FULL); pollUiThread(() -> getBottomSheetState() == SheetState.PEEK);
assertThat(mTouchToFillView.getContentView().isShown(), is(true)); assertThat(mTouchToFillView.getContentView().isShown(), is(true));
// After hiding the view, the view should still exist but be invisible. // After hiding the view, the view should still exist but be invisible.
...@@ -116,7 +116,7 @@ public class TouchToFillViewTest { ...@@ -116,7 +116,7 @@ public class TouchToFillViewTest {
.build())); .build()));
mModel.set(VISIBLE, true); mModel.set(VISIBLE, true);
}); });
pollUiThread(() -> getBottomSheetState() == SheetState.FULL); pollUiThread(() -> getBottomSheetState() == SheetState.PEEK);
TextView subtitle = TextView subtitle =
mTouchToFillView.getContentView().findViewById(R.id.touch_to_fill_sheet_subtitle); mTouchToFillView.getContentView().findViewById(R.id.touch_to_fill_sheet_subtitle);
...@@ -135,7 +135,7 @@ public class TouchToFillViewTest { ...@@ -135,7 +135,7 @@ public class TouchToFillViewTest {
.build())); .build()));
mModel.set(VISIBLE, true); mModel.set(VISIBLE, true);
}); });
pollUiThread(() -> getBottomSheetState() == SheetState.FULL); pollUiThread(() -> getBottomSheetState() == SheetState.PEEK);
TextView subtitle = TextView subtitle =
mTouchToFillView.getContentView().findViewById(R.id.touch_to_fill_sheet_subtitle); mTouchToFillView.getContentView().findViewById(R.id.touch_to_fill_sheet_subtitle);
...@@ -152,7 +152,7 @@ public class TouchToFillViewTest { ...@@ -152,7 +152,7 @@ public class TouchToFillViewTest {
buildCredentialItem(BOB))); buildCredentialItem(BOB)));
}); });
pollUiThread(() -> getBottomSheetState() == SheetState.FULL); pollUiThread(() -> getBottomSheetState() == SheetState.PEEK);
assertThat(getCredentials().getChildCount(), is(3)); assertThat(getCredentials().getChildCount(), is(3));
assertThat(getCredentialOriginAt(0).getVisibility(), is(View.GONE)); assertThat(getCredentialOriginAt(0).getVisibility(), is(View.GONE));
assertThat(getCredentialNameAt(0).getText(), is(ANA.getFormattedUsername())); assertThat(getCredentialNameAt(0).getText(), is(ANA.getFormattedUsername()));
...@@ -180,7 +180,7 @@ public class TouchToFillViewTest { ...@@ -180,7 +180,7 @@ public class TouchToFillViewTest {
mModel.get(SHEET_ITEMS).addAll(Collections.singletonList(buildCredentialItem(ANA))); mModel.get(SHEET_ITEMS).addAll(Collections.singletonList(buildCredentialItem(ANA)));
mModel.set(VISIBLE, true); mModel.set(VISIBLE, true);
}); });
pollUiThread(() -> getBottomSheetState() == SheetState.FULL); pollUiThread(() -> getBottomSheetState() == SheetState.PEEK);
assertNotNull(getCredentials().getChildAt(0)); assertNotNull(getCredentials().getChildAt(0));
...@@ -193,7 +193,7 @@ public class TouchToFillViewTest { ...@@ -193,7 +193,7 @@ public class TouchToFillViewTest {
@MediumTest @MediumTest
public void testDismissesWhenHidden() { public void testDismissesWhenHidden() {
TestThreadUtils.runOnUiThreadBlocking(() -> mModel.set(VISIBLE, true)); TestThreadUtils.runOnUiThreadBlocking(() -> mModel.set(VISIBLE, true));
pollUiThread(() -> getBottomSheetState() == SheetState.FULL); pollUiThread(() -> getBottomSheetState() == SheetState.PEEK);
TestThreadUtils.runOnUiThreadBlocking(() -> mModel.set(VISIBLE, false)); TestThreadUtils.runOnUiThreadBlocking(() -> mModel.set(VISIBLE, false));
pollUiThread(() -> getBottomSheetState() == SheetState.HIDDEN); pollUiThread(() -> getBottomSheetState() == SheetState.HIDDEN);
verify(mDismissHandler).onResult(StateChangeReason.NONE); verify(mDismissHandler).onResult(StateChangeReason.NONE);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment