diff --git a/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java b/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java index d1fa2fd3ef..5b301433c3 100644 --- a/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java +++ b/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java @@ -222,7 +222,7 @@ public abstract class BaseQuickstepLauncher extends Launcher mTaskbarController.cleanup(); mTaskbarController = null; } - if (FeatureFlags.ENABLE_TASKBAR.get() && mDeviceProfile.isTablet) { + if (mDeviceProfile.isTaskbarPresent) { TaskbarActivityContext taskbarActivityContext = new TaskbarActivityContext(this); mTaskbarController = new TaskbarController(this, taskbarActivityContext.getTaskbarContainerView()); diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarController.java index ab05fbf036..d01de657d8 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarController.java @@ -89,8 +89,7 @@ public class TaskbarController { mTaskbarView = mTaskbarContainerView.findViewById(R.id.taskbar_view); mTaskbarView.construct(createTaskbarViewCallbacks()); mWindowManager = mLauncher.getWindowManager(); - mTaskbarSize = new Point(MATCH_PARENT, - mLauncher.getResources().getDimensionPixelSize(R.dimen.taskbar_size)); + mTaskbarSize = new Point(MATCH_PARENT, mLauncher.getDeviceProfile().taskbarSize); mTaskbarStateHandler = mLauncher.getTaskbarStateHandler(); mTaskbarVisibilityController = new TaskbarVisibilityController(mLauncher, createTaskbarVisibilityControllerCallbacks()); diff --git a/res/values/dimens.xml b/res/values/dimens.xml index 1ce7840ae5..beb4b7c7b0 100644 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -259,4 +259,7 @@ 16dp 4dp + + 0dp + diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java index 83a7d77601..f2b4638018 100644 --- a/src/com/android/launcher3/DeviceProfile.java +++ b/src/com/android/launcher3/DeviceProfile.java @@ -25,9 +25,12 @@ import android.graphics.Point; import android.graphics.PointF; import android.graphics.Rect; import android.view.Surface; +import android.view.WindowInsets; +import android.view.WindowManager; import com.android.launcher3.CellLayout.ContainerType; import com.android.launcher3.DevicePaddings.DevicePadding; +import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.graphics.IconShape; import com.android.launcher3.icons.DotRenderer; import com.android.launcher3.icons.IconNormalizer; @@ -149,6 +152,10 @@ public class DeviceProfile { public DotRenderer mDotRendererWorkSpace; public DotRenderer mDotRendererAllApps; + // Taskbar + public boolean isTaskbarPresent; + public int taskbarSize; + DeviceProfile(Context context, InvariantDeviceProfile inv, Info info, Point minSize, Point maxSize, int width, int height, boolean isLandscape, boolean isMultiWindowMode, boolean transposeLayoutWithOrientation, @@ -163,12 +170,13 @@ public class DeviceProfile { // Determine sizes. widthPx = width; heightPx = height; + int nonFinalAvailableHeightPx; if (isLandscape) { availableWidthPx = maxSize.x; - availableHeightPx = minSize.y; + nonFinalAvailableHeightPx = minSize.y; } else { availableWidthPx = minSize.x; - availableHeightPx = maxSize.y; + nonFinalAvailableHeightPx = maxSize.y; } mInfo = info; @@ -192,6 +200,22 @@ public class DeviceProfile { : Configuration.ORIENTATION_PORTRAIT); final Resources res = context.getResources(); + isTaskbarPresent = isTablet && FeatureFlags.ENABLE_TASKBAR.get(); + if (isTaskbarPresent) { + // Taskbar will be added later, but provides bottom insets that we should subtract + // from availableHeightPx. + taskbarSize = res.getDimensionPixelSize(R.dimen.taskbar_size); + WindowInsets windowInsets = DisplayController.INSTANCE.get(context).getHolder(mInfo.id) + .getDisplayContext().getSystemService(WindowManager.class) + .getCurrentWindowMetrics().getWindowInsets(); + int nonOverlappingTaskbarInset = + taskbarSize - windowInsets.getSystemWindowInsetBottom(); + if (nonOverlappingTaskbarInset > 0) { + nonFinalAvailableHeightPx -= nonOverlappingTaskbarInset; + } + } + availableHeightPx = nonFinalAvailableHeightPx; + edgeMarginPx = res.getDimensionPixelSize(R.dimen.dynamic_grid_edge_margin); desiredWorkspaceLeftRightMarginPx = isVerticalBarLayout() ? 0 : edgeMarginPx; diff --git a/src/com/android/launcher3/util/DisplayController.java b/src/com/android/launcher3/util/DisplayController.java index 3b7bcc285a..e787342346 100644 --- a/src/com/android/launcher3/util/DisplayController.java +++ b/src/com/android/launcher3/util/DisplayController.java @@ -193,6 +193,10 @@ public class DisplayController implements DisplayListener { : new Info(context, display); } + public Context getDisplayContext() { + return mDisplayContext; + } + protected void handleOnChange() { Info oldInfo = mInfo; Info newInfo = createInfoForContext(mDisplayContext);