Taskbar layout update
> Calculating the hotseat padding statically
> Animating taskbar views individually when animating to home
instead of a layout animation
> Moving all navbar buttons to a separate layout/controller and independent
of Launcher
> Fixing RTL layout for taskbar and nav bar
Bug: 187353581
Test: Manual
Change-Id: If21696f38beee328f553e467394776a8e8ed4c3e
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index e9245b0..2da7ac3 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -44,6 +44,7 @@
import com.android.launcher3.icons.DotRenderer;
import com.android.launcher3.icons.GraphicsUtils;
import com.android.launcher3.icons.IconNormalizer;
+import com.android.launcher3.uioverrides.ApiWrapper;
import com.android.launcher3.util.DisplayController;
import com.android.launcher3.util.DisplayController.Info;
import com.android.launcher3.util.WindowBounds;
@@ -54,6 +55,8 @@
public class DeviceProfile {
private static final int DEFAULT_DOT_SIZE = 100;
+ // Ratio of empty space, qsb should take up to appear visually centered.
+ private static final float QSB_CENTER_FACTOR = .325f;
public final InvariantDeviceProfile inv;
private final Info mInfo;
@@ -156,6 +159,7 @@
// Start is the side next to the nav bar, end is the side next to the workspace
public final int hotseatBarSidePaddingStartPx;
public final int hotseatBarSidePaddingEndPx;
+ public final int hotseatQsbHeight;
// All apps
public int allAppsOpenVerticalTranslate;
@@ -240,6 +244,7 @@
mMetrics = context.getResources().getDisplayMetrics();
final Resources res = context.getResources();
+ hotseatQsbHeight = res.getDimensionPixelSize(R.dimen.qsb_widget_height);
isTaskbarPresent = isTablet && FeatureFlags.ENABLE_TASKBAR.get();
if (isTaskbarPresent) {
// Taskbar will be added later, but provides bottom insets that we should subtract
@@ -740,7 +745,10 @@
}
}
- public Rect getHotseatLayoutPadding() {
+ /**
+ * Returns the padding for hotseat view
+ */
+ public Rect getHotseatLayoutPadding(Context context) {
if (isVerticalBarLayout()) {
if (isSeascape()) {
mHotseatPadding.set(mInsets.left + hotseatBarSidePaddingStartPx,
@@ -749,6 +757,30 @@
mHotseatPadding.set(hotseatBarSidePaddingEndPx, mInsets.top,
mInsets.right + hotseatBarSidePaddingStartPx, mInsets.bottom);
}
+ } else if (isTaskbarPresent) {
+ int hotseatHeight = workspacePadding.bottom + taskbarSize;
+ int taskbarOffset = getTaskbarOffsetY();
+ int hotseatTopDiff = hotseatHeight - taskbarSize - taskbarOffset;
+
+ int startOffset = ApiWrapper.getHotseatStartOffset(context);
+ int requiredWidth = iconSizePx * numShownHotseatIcons;
+
+ Resources res = context.getResources();
+ float taskbarIconSize = res.getDimension(R.dimen.taskbar_icon_size);
+ float taskbarIconSpacing = 2 * res.getDimension(R.dimen.taskbar_icon_spacing);
+ int maxSize = (int) (requiredWidth
+ * (taskbarIconSize + taskbarIconSpacing) / taskbarIconSize);
+ int hotseatSize = Math.min(maxSize, availableWidthPx - startOffset);
+ int sideSpacing = (availableWidthPx - hotseatSize) / 2;
+ mHotseatPadding.set(sideSpacing, hotseatTopDiff, sideSpacing, taskbarOffset);
+
+ if (startOffset > sideSpacing) {
+ int diff = Utilities.isRtl(context.getResources())
+ ? sideSpacing - startOffset
+ : startOffset - sideSpacing;
+ mHotseatPadding.left += diff;
+ mHotseatPadding.right -= diff;
+ }
} else {
// We want the edges of the hotseat to line up with the edges of the workspace, but the
// icons in the hotseat are a different size, and so don't line up perfectly. To account
@@ -769,6 +801,24 @@
}
/**
+ * Returns the number of pixels the QSB is translated from the bottom of the screen.
+ */
+ public int getQsbOffsetY() {
+ int freeSpace = isTaskbarPresent
+ ? workspacePadding.bottom
+ : hotseatBarSizePx - hotseatCellHeightPx - hotseatQsbHeight;
+ return (int) (freeSpace * QSB_CENTER_FACTOR)
+ + (isTaskbarPresent ? taskbarSize : getInsets().bottom);
+ }
+
+ /**
+ * Returns the number of pixels the taskbar is translated from the bottom of the screen.
+ */
+ public int getTaskbarOffsetY() {
+ return (getQsbOffsetY() - taskbarSize) / 2;
+ }
+
+ /**
* @return the bounds for which the open folders should be contained within
*/
public Rect getAbsoluteOpenFolderBounds() {
diff --git a/src/com/android/launcher3/Hotseat.java b/src/com/android/launcher3/Hotseat.java
index ff380ce..b3ae15e 100644
--- a/src/com/android/launcher3/Hotseat.java
+++ b/src/com/android/launcher3/Hotseat.java
@@ -49,8 +49,6 @@
private final View mQsb;
private final int mQsbHeight;
- private final int mTaskbarViewHeight;
-
public Hotseat(Context context) {
this(context, null);
}
@@ -63,10 +61,9 @@
super(context, attrs, defStyle);
mQsb = LayoutInflater.from(context).inflate(R.layout.search_container_hotseat, this, false);
- mQsbHeight = mQsb.getLayoutParams().height;
addView(mQsb);
- mTaskbarViewHeight = context.getResources().getDimensionPixelSize(R.dimen.taskbar_size);
+ mQsbHeight = getResources().getDimensionPixelSize(R.dimen.qsb_widget_height);
}
/**
@@ -114,18 +111,13 @@
lp.gravity = Gravity.BOTTOM;
lp.width = ViewGroup.LayoutParams.MATCH_PARENT;
lp.height = (grid.isTaskbarPresent
- ? grid.workspacePadding.bottom
+ ? grid.workspacePadding.bottom
: grid.hotseatBarSizePx)
+ (grid.isTaskbarPresent ? grid.taskbarSize : insets.bottom);
}
- if (!grid.isTaskbarPresent) {
- // When taskbar is present, we set the padding separately to ensure a seamless visual
- // handoff between taskbar and hotseat during drag and drop.
- Rect padding = grid.getHotseatLayoutPadding();
- setPadding(padding.left, padding.top, padding.right, padding.bottom);
- }
-
+ Rect padding = grid.getHotseatLayoutPadding(getContext());
+ setPadding(padding.left, padding.top, padding.right, padding.bottom);
setLayoutParams(lp);
InsettableFrameLayout.dispatchInsets(this, insets);
}
@@ -193,31 +185,12 @@
int left = (r - l - qsbWidth) / 2;
int right = left + qsbWidth;
- int bottom = b - t - getQsbOffsetY();
+ int bottom = b - t - mActivity.getDeviceProfile().getQsbOffsetY();
int top = bottom - mQsbHeight;
mQsb.layout(left, top, right, bottom);
}
/**
- * Returns the number of pixels the QSB is translated from the bottom of the screen.
- */
- private int getQsbOffsetY() {
- DeviceProfile dp = mActivity.getDeviceProfile();
- int freeSpace = dp.isTaskbarPresent
- ? dp.workspacePadding.bottom
- : dp.hotseatBarSizePx - dp.hotseatCellHeightPx - mQsbHeight;
- return (int) (freeSpace * QSB_CENTER_FACTOR)
- + (dp.isTaskbarPresent ? dp.taskbarSize : dp.getInsets().bottom);
- }
-
- /**
- * Returns the number of pixels the taskbar is translated from the bottom of the screen.
- */
- public int getTaskbarOffsetY() {
- return (getQsbOffsetY() - mTaskbarViewHeight) / 2;
- }
-
- /**
* Sets the alpha value of just our ShortcutAndWidgetContainer.
*/
public void setIconsAlpha(float alpha) {
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 892fb6d..fc8d65c 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -2801,13 +2801,6 @@
return new float[] {NO_SCALE, NO_OFFSET};
}
- /**
- * @see LauncherState#getTaskbarScale(Launcher)
- */
- public float getNormalTaskbarScale() {
- return 1f;
- }
-
public static Launcher getLauncher(Context context) {
return fromContext(context);
}
diff --git a/src/com/android/launcher3/LauncherState.java b/src/com/android/launcher3/LauncherState.java
index 3399ce9..7985ab5 100644
--- a/src/com/android/launcher3/LauncherState.java
+++ b/src/com/android/launcher3/LauncherState.java
@@ -181,14 +181,6 @@
return launcher.getNormalOverviewScaleAndOffset();
}
- public float getTaskbarScale(Launcher launcher) {
- return launcher.getNormalTaskbarScale();
- }
-
- public float getTaskbarTranslationY(Launcher launcher) {
- return -launcher.getHotseat().getTaskbarOffsetY();
- }
-
public float getOverviewFullscreenProgress() {
return 0;
}