[revert ^2] Enable Floating Search and update tests accordingly.

Tests need to be updated to account for the new placement of the
searchbar because it overlapped with touch events for scrolling:
 - Scroll back to top: Instead of scrolling from the top of the
   container which could overlap status bar in landscape, scroll
   from the bottom of the top-most visible app icon.
 - Scroll down: swipe up from bottom padding to top of top-most
   visible icon.
 - Close all apps: swipe down more quickly from top icon insetad
   of the search bar (more quickly helps it be detected as a
   fling on more cramped devices).

For Launcher3, the floating flag is not fully supported yet, so
there were some layout issues which are now resolved by ignoring
the flag if the searchbar is still at the top.

Fix: 261873937
Test: Ran tests, manual
Change-Id: I406fbcbe12acddb1dd4b862a380576a48cabbebc
This commit is contained in:
Andy Wickham committed 2023-02-03 14:24:22 -08:00
1 parent eb8c32e009
commit 346771550e
8 files changed
+75 -43

No files matched your search

@@ -473,7 +473,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
}
setupHeader();
if (FeatureFlags.ENABLE_FLOATING_SEARCH_BAR.get()) {
if (isSearchBarOnBottom()) {
// Keep the scroller above the search bar.
RelativeLayout.LayoutParams scrollerLayoutParams =
(LayoutParams) findViewById(R.id.fast_scroller).getLayoutParams();
@@ -519,7 +519,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
removeCustomRules(getSearchRecyclerView());
if (!isSearchSupported()) {
layoutWithoutSearchContainer(rvContainer, showTabs);
} else if (FeatureFlags.ENABLE_FLOATING_SEARCH_BAR.get()) {
} else if (isSearchBarOnBottom()) {
alignParentTop(rvContainer, showTabs);
alignParentTop(getSearchRecyclerView(), /* tabs= */ false);
layoutAboveSearchContainer(rvContainer);
@@ -554,7 +554,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
removeCustomRules(mHeader);
if (!isSearchSupported()) {
layoutWithoutSearchContainer(mHeader, false /* includeTabsMargin */);
} else if (FeatureFlags.ENABLE_FLOATING_SEARCH_BAR.get()) {
} else if (isSearchBarOnBottom()) {
alignParentTop(mHeader, false /* includeTabsMargin */);
} else {
layoutBelowSearchContainer(mHeader, false /* includeTabsMargin */);
@@ -593,6 +593,13 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
(int) (mSearchContainer.getAlpha() * 255));
}
/** @return true if the search bar is at the bottom of the container (as opposed to the top). */
private boolean isSearchBarOnBottom() {
return FeatureFlags.ENABLE_FLOATING_SEARCH_BAR.get()
&& ((RelativeLayout.LayoutParams) mSearchContainer.getLayoutParams()).getRule(
ALIGN_PARENT_BOTTOM) == RelativeLayout.TRUE;
}
private void layoutBelowSearchContainer(View v, boolean includeTabsMargin) {
if (!(v.getLayoutParams() instanceof RelativeLayout.LayoutParams)) {
return;
@@ -891,7 +898,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
setPadding(grid.workspacePadding.left, 0, grid.workspacePadding.right, 0);
} else {
int topPadding = grid.allAppsTopPadding;
if (FeatureFlags.ENABLE_FLOATING_SEARCH_BAR.get() && !grid.isTablet) {
if (isSearchBarOnBottom() && !grid.isTablet) {
topPadding += getResources().getDimensionPixelSize(
R.dimen.all_apps_additional_top_padding_floating_search);
}
@@ -1092,7 +1099,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
FloatingHeaderView headerView = getFloatingHeaderView();
if (isTablet) {
// Start adding header protection if search bar or tabs will attach to the top.
if (!FeatureFlags.ENABLE_FLOATING_SEARCH_BAR.get() || mUsingTabs) {
if (!isSearchBarOnBottom() || mUsingTabs) {
View panel = (View) mBottomSheetBackground;
float translationY = ((View) panel.getParent()).getTranslationY();
mTmpRectF.set(panel.getLeft(), panel.getTop() + translationY, panel.getRight(),
@@ -1134,7 +1141,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
/** Returns the position of the bottom edge of the header */
public int getHeaderBottom() {
int bottom = (int) getTranslationY() + mHeader.getClipTop();
if (FeatureFlags.ENABLE_FLOATING_SEARCH_BAR.get()) {
if (isSearchBarOnBottom()) {
if (mActivityContext.getDeviceProfile().isTablet) {
return bottom + mBottomSheetBackground.getTop();
}