From 2ea01e4871c346222a83ea91fb9a3c091e85b07b Mon Sep 17 00:00:00 2001 From: Samuel Fufa Date: Wed, 2 Dec 2020 13:48:18 -0600 Subject: [PATCH] Separate QSB from on device search Bug: 175125073 [Preview attached to BR] Change-Id: If967d95e32b58263ede5eb8a3c1b773cef789f28 --- res/values/config.xml | 1 + src/com/android/launcher3/Hotseat.java | 18 +++++++++++++++--- src/com/android/launcher3/LauncherState.java | 18 +++++++++++------- .../launcher3/ShortcutAndWidgetContainer.java | 7 ++++--- .../search/AppsSearchContainerLayout.java | 4 +++- 5 files changed, 34 insertions(+), 14 deletions(-) diff --git a/res/values/config.xml b/res/values/config.xml index 46b8c23a62..41d1a12059 100644 --- a/res/values/config.xml +++ b/res/values/config.xml @@ -111,6 +111,7 @@ + diff --git a/src/com/android/launcher3/Hotseat.java b/src/com/android/launcher3/Hotseat.java index e4bdb395e1..4f4f2a75dd 100644 --- a/src/com/android/launcher3/Hotseat.java +++ b/src/com/android/launcher3/Hotseat.java @@ -27,6 +27,8 @@ import android.widget.FrameLayout; import androidx.annotation.Nullable; +import com.android.launcher3.config.FeatureFlags; + import java.util.function.Consumer; /** @@ -38,7 +40,8 @@ public class Hotseat extends CellLayout implements Insettable { private boolean mHasVerticalHotseat; private Workspace mWorkspace; private boolean mSendTouchToWorkspace; - @Nullable private Consumer mOnVisibilityAggregatedCallback; + @Nullable + private Consumer mOnVisibilityAggregatedCallback; public Hotseat(Context context) { this(context, null); @@ -73,8 +76,9 @@ public class Hotseat extends CellLayout implements Insettable { if (hasVerticalHotseat) { setGridSize(1, idp.numHotseatIcons); } else { - setGridSize(idp.numHotseatIcons, 1); + setGridSize(idp.numHotseatIcons, FeatureFlags.ENABLE_DEVICE_SEARCH.get() ? 2 : 1); } + showInlineQsb(); } @Override @@ -97,7 +101,11 @@ public class Hotseat extends CellLayout implements Insettable { lp.height = grid.hotseatBarSizePx + insets.bottom; } Rect padding = grid.getHotseatLayoutPadding(); - setPadding(padding.left, padding.top, padding.right, padding.bottom); + int paddingBottom = padding.bottom; + if (FeatureFlags.ENABLE_DEVICE_SEARCH.get() && !grid.isVerticalBarLayout()) { + paddingBottom -= grid.hotseatBarBottomPaddingPx; + } + setPadding(padding.left, padding.top, padding.right, paddingBottom); setLayoutParams(lp); InsettableFrameLayout.dispatchInsets(this, insets); @@ -148,4 +156,8 @@ public class Hotseat extends CellLayout implements Insettable { public void setOnVisibilityAggregatedCallback(@Nullable Consumer callback) { mOnVisibilityAggregatedCallback = callback; } + + protected void showInlineQsb() { + //Does nothing + } } diff --git a/src/com/android/launcher3/LauncherState.java b/src/com/android/launcher3/LauncherState.java index eba0ac9633..79476fc536 100644 --- a/src/com/android/launcher3/LauncherState.java +++ b/src/com/android/launcher3/LauncherState.java @@ -29,6 +29,7 @@ import static com.android.launcher3.testing.TestProtocol.SPRING_LOADED_STATE_ORD import android.content.Context; import android.view.animation.Interpolator; +import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.statemanager.BaseState; import com.android.launcher3.statemanager.StateManager; import com.android.launcher3.states.HintState; @@ -168,9 +169,9 @@ public abstract class LauncherState implements BaseState { /** * Returns an array of two elements. - * The first specifies the scale for the overview - * The second is the factor ([0, 1], 0 => center-screen; 1 => offscreen) by which overview - * should be shifted horizontally. + * The first specifies the scale for the overview + * The second is the factor ([0, 1], 0 => center-screen; 1 => offscreen) by which overview + * should be shifted horizontally. */ public float[] getOverviewScaleAndOffset(Launcher launcher) { return launcher.getNormalOverviewScaleAndOffset(); @@ -185,10 +186,12 @@ public abstract class LauncherState implements BaseState { } public int getVisibleElements(Launcher launcher) { - if (launcher.getDeviceProfile().isVerticalBarLayout()) { - return HOTSEAT_ICONS | VERTICAL_SWIPE_INDICATOR; + int flags = HOTSEAT_ICONS | VERTICAL_SWIPE_INDICATOR; + if (!FeatureFlags.ENABLE_DEVICE_SEARCH.get() + && !launcher.getDeviceProfile().isVerticalBarLayout()) { + flags |= HOTSEAT_SEARCH_BOX; } - return HOTSEAT_ICONS | HOTSEAT_SEARCH_BOX | VERTICAL_SWIPE_INDICATOR; + return flags; } /** @@ -229,6 +232,7 @@ public abstract class LauncherState implements BaseState { /** * Returns the amount of blur and wallpaper zoom for this state with {@param isMultiWindowMode}. + * * @see #getDepth(Context). */ public final float getDepth(Context context, boolean isMultiWindowMode) { @@ -255,7 +259,7 @@ public abstract class LauncherState implements BaseState { return new PageAlphaProvider(ACCEL_2) { @Override public float getPageAlpha(int pageIndex) { - return pageIndex != centerPage ? 0 : 1f; + return pageIndex != centerPage ? 0 : 1f; } }; } diff --git a/src/com/android/launcher3/ShortcutAndWidgetContainer.java b/src/com/android/launcher3/ShortcutAndWidgetContainer.java index 6326b7ac6d..ee0c7bb2f9 100644 --- a/src/com/android/launcher3/ShortcutAndWidgetContainer.java +++ b/src/com/android/launcher3/ShortcutAndWidgetContainer.java @@ -36,7 +36,8 @@ public class ShortcutAndWidgetContainer extends ViewGroup { // return an (x, y) value from helper functions. Do NOT use them to maintain other state. private final int[] mTmpCellXY = new int[2]; - @ContainerType private final int mContainerType; + @ContainerType + private final int mContainerType; private final WallpaperManager mWallpaperManager; private int mCellWidth; @@ -44,7 +45,7 @@ public class ShortcutAndWidgetContainer extends ViewGroup { private int mCountX; - private ActivityContext mActivity; + private final ActivityContext mActivity; private boolean mInvertIfRtl = false; public ShortcutAndWidgetContainer(Context context, @ContainerType int containerType) { @@ -79,7 +80,7 @@ public class ShortcutAndWidgetContainer extends ViewGroup { int count = getChildCount(); int widthSpecSize = MeasureSpec.getSize(widthMeasureSpec); - int heightSpecSize = MeasureSpec.getSize(heightMeasureSpec); + int heightSpecSize = MeasureSpec.getSize(heightMeasureSpec); setMeasuredDimension(widthSpecSize, heightSpecSize); for (int i = 0; i < count; i++) { diff --git a/src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java b/src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java index 000ccbb13a..bd2f04d4ee 100644 --- a/src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java +++ b/src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java @@ -47,6 +47,7 @@ import com.android.launcher3.allapps.AllAppsStore; import com.android.launcher3.allapps.AlphabeticalAppsList; import com.android.launcher3.allapps.SearchUiManager; import com.android.launcher3.anim.PropertySetter; +import com.android.launcher3.config.FeatureFlags; import java.util.ArrayList; import java.util.List; @@ -215,7 +216,8 @@ public class AppsSearchContainerLayout extends ExtendedEditText @Override public float getScrollRangeDelta(Rect insets) { - if (mLauncher.getDeviceProfile().isVerticalBarLayout()) { + if (mLauncher.getDeviceProfile().isVerticalBarLayout() + || FeatureFlags.ENABLE_DEVICE_SEARCH.get()) { return 0; } else { return insets.bottom + insets.top;