Merge "Update tests to support floating search." into tm-qpr-dev

This commit is contained in:
TreeHugger Robot
2023-02-06 23:50:49 +00:00
committed by Android (Google) Code Review
7 changed files with 80 additions and 42 deletions

View File

@@ -477,7 +477,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();
@@ -536,7 +536,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);
@@ -571,7 +571,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 */);
@@ -610,6 +610,19 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
(int) (mSearchContainer.getAlpha() * 255));
}
/**
* It is up to the search container view created by {@link #inflateSearchBox()} to use the
* floating search bar flag to move itself to the bottom of this container. This method checks
* if that had been done; otherwise the flag will be ignored.
*
* @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;
@@ -908,7 +921,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);
}
@@ -1109,7 +1122,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(),
@@ -1151,7 +1164,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();
}