Force keeping BottomSheetBehavior to STATE_EXPANDED

The shortcuts list in the new keyboard shortcuts UI cannot be scrolled
down easily, so we should keeping BottomSheetBehavior to STATE_EXPANDED.

Demo:https://screencast.googleplex.com/cast/NTExMzkyNTMxNTA2NzkwNHxhZTgwZjFkNC02ZA

Bug: 277139155
Test: manual
Change-Id: Ic6e6fdd27eaa1577a1977e398bb2e76218f94aca
This commit is contained in:
danielwbhuang
2023-04-06 17:53:24 +08:00
parent 4d93facc7f
commit 5ca3547d8e

View File

@@ -841,6 +841,19 @@ public final class KeyboardShortcutListSearch {
BottomSheetBehavior<FrameLayout> behavior = BottomSheetBehavior.from(bottomSheet);
behavior.setState(BottomSheetBehavior.STATE_EXPANDED);
behavior.setSkipCollapsed(true);
behavior.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
@Override
public void onStateChanged(@NonNull View bottomSheet, int newState) {
if (newState == BottomSheetBehavior.STATE_DRAGGING) {
behavior.setState(BottomSheetBehavior.STATE_EXPANDED);
}
}
@Override
public void onSlide(@NonNull View bottomSheet, float slideOffset) {
// Do nothing.
}
});
mKeyboardShortcutsBottomSheetDialog.setCanceledOnTouchOutside(true);
Window keyboardShortcutsWindow = mKeyboardShortcutsBottomSheetDialog.getWindow();