Add checks for FeatureFlags.QSB_ON_FIRST_SCREEN
When false, it correctly does not show the QSB but leaves
a default style search bar which cannot be removed.
Add checks to control default view visibility in device
profile layout & re-layout, QSB container and in
Workspace's onMeasure
Bug: 35967694
Change-Id: I3d0f89e1022d838eeb95762fd1fb3f7257956c41
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index c9e3d4f..43f7d23 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -32,6 +32,7 @@
import com.android.launcher3.CellLayout.ContainerType;
import com.android.launcher3.badge.BadgeRenderer;
+import com.android.launcher3.config.FeatureFlags;
import java.util.ArrayList;
@@ -530,10 +531,13 @@
workspacePadding.bottom);
workspace.setPageSpacing(getWorkspacePageSpacing());
- View qsbContainer = launcher.getQsbContainer();
- lp = (FrameLayout.LayoutParams) qsbContainer.getLayoutParams();
- lp.topMargin = mInsets.top + workspacePadding.top;
- qsbContainer.setLayoutParams(lp);
+ // Only display when enabled
+ if (FeatureFlags.QSB_ON_FIRST_SCREEN) {
+ View qsbContainer = launcher.getQsbContainer();
+ lp = (FrameLayout.LayoutParams) qsbContainer.getLayoutParams();
+ lp.topMargin = mInsets.top + workspacePadding.top;
+ qsbContainer.setLayoutParams(lp);
+ }
// Layout the hotseat
Hotseat hotseat = (Hotseat) launcher.findViewById(R.id.hotseat);
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index ef00a8d..7562dd8 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -643,7 +643,8 @@
// of workspace despite that it's not a true child.
// Note that it relies on the strict ordering of measuring the workspace before the QSB
// at the dragLayer level.
- if (getChildCount() > 0) {
+ // Only measure the QSB when the view is enabled
+ if (FeatureFlags.QSB_ON_FIRST_SCREEN && getChildCount() > 0) {
CellLayout firstPage = (CellLayout) getChildAt(0);
int cellHeight = firstPage.getCellHeight();
diff --git a/src/com/android/launcher3/qsb/QsbContainerView.java b/src/com/android/launcher3/qsb/QsbContainerView.java
index 38a3e1f..4dc3c1c 100644
--- a/src/com/android/launcher3/qsb/QsbContainerView.java
+++ b/src/com/android/launcher3/qsb/QsbContainerView.java
@@ -40,6 +40,7 @@
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.compat.AppWidgetManagerCompat;
+import com.android.launcher3.config.FeatureFlags;
/**
* A frame layout which contains a QSB. This internally uses fragment to bind the view, which
@@ -89,7 +90,11 @@
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
mWrapper = new FrameLayout(getActivity());
- mWrapper.addView(createQsb(mWrapper));
+
+ // Only add the view when enabled
+ if (FeatureFlags.QSB_ON_FIRST_SCREEN) {
+ mWrapper.addView(createQsb(mWrapper));
+ }
return mWrapper;
}
@@ -197,6 +202,11 @@
}
private void rebindFragment() {
+ // Exit if the embedded qsb is disabled
+ if (!FeatureFlags.QSB_ON_FIRST_SCREEN) {
+ return;
+ }
+
if (mWrapper != null && getActivity() != null) {
mWrapper.removeAllViews();
mWrapper.addView(createQsb(mWrapper));