Revert "Enable Floating Search by default and update tests accordingly."

This reverts commit 952400d2f2.

Reason for revert: b/267743311

Change-Id: I007274cdea1c424c87ddea4592e9e1c7a273bea9
This commit is contained in:
Sam Dubey
2023-02-03 12:45:15 +00:00
committed by Android (Google) Code Review
parent 952400d2f2
commit 29f78a597b
8 changed files with 38 additions and 69 deletions
@@ -473,7 +473,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
}
setupHeader();
if (isBottomSearchBar()) {
if (FeatureFlags.ENABLE_FLOATING_SEARCH_BAR.get()) {
// 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 (isBottomSearchBar()) {
} else if (FeatureFlags.ENABLE_FLOATING_SEARCH_BAR.get()) {
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 (isBottomSearchBar()) {
} else if (FeatureFlags.ENABLE_FLOATING_SEARCH_BAR.get()) {
alignParentTop(mHeader, false /* includeTabsMargin */);
} else {
layoutBelowSearchContainer(mHeader, false /* includeTabsMargin */);
@@ -593,13 +593,6 @@ 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 isBottomSearchBar() {
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;
@@ -898,7 +891,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
setPadding(grid.workspacePadding.left, 0, grid.workspacePadding.right, 0);
} else {
int topPadding = grid.allAppsTopPadding;
if (isBottomSearchBar() && !grid.isTablet) {
if (FeatureFlags.ENABLE_FLOATING_SEARCH_BAR.get() && !grid.isTablet) {
topPadding += getResources().getDimensionPixelSize(
R.dimen.all_apps_additional_top_padding_floating_search);
}
@@ -1099,7 +1092,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 (!isBottomSearchBar() || mUsingTabs) {
if (!FeatureFlags.ENABLE_FLOATING_SEARCH_BAR.get() || mUsingTabs) {
View panel = (View) mBottomSheetBackground;
float translationY = ((View) panel.getParent()).getTranslationY();
mTmpRectF.set(panel.getLeft(), panel.getTop() + translationY, panel.getRight(),
@@ -1141,7 +1134,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 (isBottomSearchBar()) {
if (FeatureFlags.ENABLE_FLOATING_SEARCH_BAR.get()) {
if (mActivityContext.getDeviceProfile().isTablet) {
return bottom + mBottomSheetBackground.getTop();
}
@@ -86,7 +86,7 @@ public final class FeatureFlags {
"ENABLE_DEVICE_SEARCH", true, "Allows on device search in all apps");
public static final BooleanFlag ENABLE_FLOATING_SEARCH_BAR =
new DeviceFlag("ENABLE_FLOATING_SEARCH_BAR", true,
getDebugFlag("ENABLE_FLOATING_SEARCH_BAR", false,
"Keep All Apps search bar at the bottom (but above keyboard if open)");
public static final BooleanFlag ENABLE_HIDE_HEADER = new DeviceFlag("ENABLE_HIDE_HEADER",
@@ -232,13 +232,6 @@ public class TestInformationHandler implements ResourceBasedOverride {
l -> l.getAppsView().getActiveRecyclerView().getClipBounds().top);
}
case TestProtocol.REQUEST_ALL_APPS_BOTTOM_PADDING: {
return getLauncherUIProperty(Bundle::putInt,
l -> l.getAppsView().getBottom()
- l.getAppsView().getActiveRecyclerView().getBottom()
+ l.getAppsView().getActiveRecyclerView().getPaddingBottom());
}
default:
return null;
}
@@ -120,7 +120,6 @@ public final class TestProtocol {
public static final String REQUEST_TASKBAR_ALL_APPS_TOP_PADDING =
"taskbar-all-apps-top-padding";
public static final String REQUEST_ALL_APPS_TOP_PADDING = "all-apps-top-padding";
public static final String REQUEST_ALL_APPS_BOTTOM_PADDING = "all-apps-bottom-padding";
public static final String REQUEST_WORKSPACE_CELL_LAYOUT_SIZE = "workspace-cell-layout-size";
public static final String REQUEST_WORKSPACE_CELL_CENTER = "workspace-cell-center";
@@ -169,9 +169,9 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest {
flingBackwardY < flingForwardY));
// Test scrolling down to YouTube.
assertNotNull("All apps: can't find YouTube", allApps.getAppIcon("YouTube"));
assertNotNull("All apps: can't fine YouTube", allApps.getAppIcon("YouTube"));
// Test scrolling up to Camera.
assertNotNull("All apps: can't find Camera", allApps.getAppIcon("Camera"));
assertNotNull("All apps: can't fine Camera", allApps.getAppIcon("Camera"));
// Test failing to find a non-existing app.
final AllApps allAppsFinal = allApps;
expectFail("All apps: could find a non-existing app",
@@ -263,7 +263,8 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest {
assertNotNull("AppIcon.launch returned null", app.launch(getAppPackageName()));
test.executeOnLauncher(launcher -> assertTrue(
"Launcher activity is the top activity; expecting another activity to be the "
+ "top one",
+ "top "
+ "one",
test.isInLaunchedApp(launcher)));
} finally {
allApps.unfreeze();
@@ -34,9 +34,6 @@ import androidx.test.uiautomator.UiObject2;
import com.android.launcher3.testing.shared.TestProtocol;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
/**
@@ -105,10 +102,10 @@ public abstract class AllApps extends LauncherInstrumentation.VisibleContainer {
iconCenter.x, iconCenter.y);
}
private boolean iconCenterInRecyclerTopPadding(UiObject2 appsListRecycler, UiObject2 icon) {
private boolean iconCenterInRecyclerTopPadding(UiObject2 appListRecycler, UiObject2 icon) {
final Point iconCenter = icon.getVisibleCenter();
return iconCenter.y <= mLauncher.getVisibleBounds(appsListRecycler).top
return iconCenter.y <= mLauncher.getVisibleBounds(appListRecycler).top
+ getAppsListRecyclerTopPadding();
}
@@ -140,11 +137,15 @@ public abstract class AllApps extends LauncherInstrumentation.VisibleContainer {
bottomGestureStartOnScreen)) {
mLauncher.scrollToLastVisibleRow(
allAppsContainer,
getVisibleIcons(allAppsContainer),
mLauncher.getObjectsInContainer(allAppsContainer, "icon")
.stream()
.filter(icon ->
mLauncher.getVisibleBounds(icon).top
< bottomGestureStartOnScreen)
.collect(Collectors.toList()),
mLauncher.getVisibleBounds(appListRecycler).top
+ getAppsListRecyclerTopPadding()
- mLauncher.getVisibleBounds(allAppsContainer).top,
getAppsListRecyclerBottomPadding());
- mLauncher.getVisibleBounds(allAppsContainer).top);
verifyActiveContainer();
final int newScroll = getAllAppsScroll();
mLauncher.assertTrue(
@@ -174,16 +175,6 @@ public abstract class AllApps extends LauncherInstrumentation.VisibleContainer {
}
}
@NonNull
private List<UiObject2> getVisibleIcons(UiObject2 allAppsContainer) {
return mLauncher.getObjectsInContainer(allAppsContainer, "icon")
.stream()
.filter(icon ->
mLauncher.getVisibleBounds(icon).top
< mLauncher.getBottomGestureStartOnScreen())
.collect(Collectors.toList());
}
/**
* Finds an icon. Fails if the icon doesn't exist. Scrolls the app list when needed to make
* sure the icon is visible.
@@ -205,26 +196,20 @@ public abstract class AllApps extends LauncherInstrumentation.VisibleContainer {
protected abstract int getAppsListRecyclerTopPadding();
protected int getAppsListRecyclerBottomPadding() {
return mLauncher.getTestInfo(TestProtocol.REQUEST_ALL_APPS_BOTTOM_PADDING)
.getInt(TestProtocol.TEST_INFO_RESPONSE_FIELD);
}
private void scrollBackToBeginning() {
try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
"want to scroll back in all apps")) {
LauncherInstrumentation.log("Scrolling to the beginning");
final UiObject2 allAppsContainer = verifyActiveContainer();
final UiObject2 highestItem = Collections.min(getVisibleIcons(allAppsContainer),
Comparator.comparingInt(i -> mLauncher.getVisibleBounds(i).top));
final UiObject2 appListRecycler = getAppListRecycler(allAppsContainer);
int attempts = 0;
final Rect margins = new Rect(
/* left= */ 0,
mLauncher.getVisibleBounds(highestItem).bottom,
mLauncher.getVisibleBounds(appListRecycler).top
+ getAppsListRecyclerTopPadding() + 1,
/* right= */ 0,
/* bottom= */ getAppsListRecyclerBottomPadding());
/* bottom= */ 5);
for (int scroll = getAllAppsScroll();
scroll != 0;
@@ -255,7 +240,7 @@ public abstract class AllApps extends LauncherInstrumentation.VisibleContainer {
.getInt(TestProtocol.TEST_INFO_RESPONSE_FIELD);
}
protected UiObject2 getAppListRecycler(UiObject2 allAppsContainer) {
private UiObject2 getAppListRecycler(UiObject2 allAppsContainer) {
return mLauncher.waitForObjectInContainer(allAppsContainer, "apps_list_view");
}
@@ -17,11 +17,15 @@ package com.android.launcher3.tapl;
import static com.android.launcher3.testing.shared.TestProtocol.NORMAL_STATE_ORDINAL;
import android.graphics.Rect;
import androidx.annotation.NonNull;
import androidx.test.uiautomator.UiObject2;
import com.android.launcher3.testing.shared.TestProtocol;
import java.util.Objects;
public class HomeAllApps extends AllApps {
private static final String BOTTOM_SHEET_RES_ID = "bottom_sheet_background";
@@ -41,10 +45,10 @@ public class HomeAllApps extends AllApps {
mLauncher.addContextLayer("want to switch from all apps to workspace")) {
UiObject2 allAppsContainer = verifyActiveContainer();
final int startX = allAppsContainer.getVisibleCenter().x;
final int startY = mLauncher.getVisibleBounds(getAppListRecycler(allAppsContainer)).top
+ getAppsListRecyclerTopPadding()
- mLauncher.getVisibleBounds(allAppsContainer).top + 1;
final Rect searchBoxBounds = Objects.requireNonNull(
mLauncher.getVisibleBounds(getSearchBox(allAppsContainer)));
final int startX = searchBoxBounds.centerX();
final int startY = searchBoxBounds.bottom;
final int endY = mLauncher.getDevice().getDisplayHeight();
LauncherInstrumentation.log(
"switchToWorkspace: startY = " + startY + ", endY = " + endY
@@ -78,7 +78,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Deque;
import java.util.LinkedList;
import java.util.List;
@@ -1491,24 +1490,19 @@ public final class LauncherInstrumentation {
}
void scrollToLastVisibleRow(
UiObject2 container, Collection<UiObject2> items, int topPaddingInContainer,
int appsListBottomPadding) {
final UiObject2 lowestItem = Collections.max(items,
Comparator.comparingInt(i -> getVisibleBounds(i).top));
UiObject2 container, Collection<UiObject2> items, int topPaddingInContainer) {
final UiObject2 lowestItem = Collections.max(items, (i1, i2) ->
Integer.compare(getVisibleBounds(i1).top, getVisibleBounds(i2).top));
final int itemRowCurrentTopOnScreen = getVisibleBounds(lowestItem).top;
final Rect containerRect = getVisibleBounds(container);
final int itemRowNewTopOnScreen = containerRect.top + topPaddingInContainer;
final int distance = itemRowCurrentTopOnScreen - itemRowNewTopOnScreen + getTouchSlop();
scrollDownByDistance(container, distance, appsListBottomPadding);
scrollDownByDistance(container, distance);
}
void scrollDownByDistance(UiObject2 container, int distance) {
scrollDownByDistance(container, distance, 0);
}
void scrollDownByDistance(UiObject2 container, int distance, int bottomPadding) {
final Rect containerRect = getVisibleBounds(container);
final int bottomGestureMarginInContainer = getBottomGestureMarginInContainer(container);
scroll(
@@ -1518,7 +1512,7 @@ public final class LauncherInstrumentation {
0,
containerRect.height() - distance - bottomGestureMarginInContainer,
0,
bottomGestureMarginInContainer + bottomPadding),
bottomGestureMarginInContainer),
/* steps= */ 10,
/* slowDown= */ true);
}