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
This commit is contained in:
Louis Begin 2017-02-27 14:33:11 +08:00 committed by Sunny Goyal
parent 3ba48fa019
commit b07a355fe2
3 changed files with 21 additions and 6 deletions

View File

@ -32,6 +32,7 @@ import android.widget.FrameLayout;
import com.android.launcher3.CellLayout.ContainerType; import com.android.launcher3.CellLayout.ContainerType;
import com.android.launcher3.badge.BadgeRenderer; import com.android.launcher3.badge.BadgeRenderer;
import com.android.launcher3.config.FeatureFlags;
import java.util.ArrayList; import java.util.ArrayList;
@ -530,10 +531,13 @@ public class DeviceProfile {
workspacePadding.bottom); workspacePadding.bottom);
workspace.setPageSpacing(getWorkspacePageSpacing()); workspace.setPageSpacing(getWorkspacePageSpacing());
View qsbContainer = launcher.getQsbContainer(); // Only display when enabled
lp = (FrameLayout.LayoutParams) qsbContainer.getLayoutParams(); if (FeatureFlags.QSB_ON_FIRST_SCREEN) {
lp.topMargin = mInsets.top + workspacePadding.top; View qsbContainer = launcher.getQsbContainer();
qsbContainer.setLayoutParams(lp); lp = (FrameLayout.LayoutParams) qsbContainer.getLayoutParams();
lp.topMargin = mInsets.top + workspacePadding.top;
qsbContainer.setLayoutParams(lp);
}
// Layout the hotseat // Layout the hotseat
Hotseat hotseat = (Hotseat) launcher.findViewById(R.id.hotseat); Hotseat hotseat = (Hotseat) launcher.findViewById(R.id.hotseat);

View File

@ -643,7 +643,8 @@ public class Workspace extends PagedView
// of workspace despite that it's not a true child. // 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 // Note that it relies on the strict ordering of measuring the workspace before the QSB
// at the dragLayer level. // 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); CellLayout firstPage = (CellLayout) getChildAt(0);
int cellHeight = firstPage.getCellHeight(); int cellHeight = firstPage.getCellHeight();

View File

@ -40,6 +40,7 @@ import com.android.launcher3.LauncherAppState;
import com.android.launcher3.R; import com.android.launcher3.R;
import com.android.launcher3.Utilities; import com.android.launcher3.Utilities;
import com.android.launcher3.compat.AppWidgetManagerCompat; 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 * A frame layout which contains a QSB. This internally uses fragment to bind the view, which
@ -89,7 +90,11 @@ public class QsbContainerView extends FrameLayout {
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
mWrapper = new FrameLayout(getActivity()); 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; return mWrapper;
} }
@ -197,6 +202,11 @@ public class QsbContainerView extends FrameLayout {
} }
private void rebindFragment() { private void rebindFragment() {
// Exit if the embedded qsb is disabled
if (!FeatureFlags.QSB_ON_FIRST_SCREEN) {
return;
}
if (mWrapper != null && getActivity() != null) { if (mWrapper != null && getActivity() != null) {
mWrapper.removeAllViews(); mWrapper.removeAllViews();
mWrapper.addView(createQsb(mWrapper)); mWrapper.addView(createQsb(mWrapper));