Fix taskbar icon flicker and jump when transforming to hotseat
- Apply additional translation on TaskbarView to account for difference between taskbar icon to bottom spacing compared to hotseat icon to bottom spacing
- Call updateIconAlignment outside of synchronizeNextDraw's then block, which get run after the synchronization
Bug: 204850744
Test: manual
Change-Id: Id65842f506eb342105082649446eb694cd5c33a4
(cherry picked from commit 51da219869)
Merged-In: Id65842f506eb342105082649446eb694cd5c33a4
This commit is contained in:
1 parent
748195421c
commit
e2e1509d55
4 files changed
+34
-42
No files matched your search
@@ -30,7 +30,6 @@ import androidx.annotation.Nullable;
|
|||||||
|
|
||||||
import com.android.launcher3.AbstractFloatingView;
|
import com.android.launcher3.AbstractFloatingView;
|
||||||
import com.android.launcher3.BaseQuickstepLauncher;
|
import com.android.launcher3.BaseQuickstepLauncher;
|
||||||
import com.android.launcher3.DeviceProfile;
|
|
||||||
import com.android.launcher3.LauncherState;
|
import com.android.launcher3.LauncherState;
|
||||||
import com.android.launcher3.Utilities;
|
import com.android.launcher3.Utilities;
|
||||||
import com.android.launcher3.statemanager.StateManager;
|
import com.android.launcher3.statemanager.StateManager;
|
||||||
@@ -407,18 +406,13 @@ import java.util.function.Supplier;
|
|||||||
boolean firstFrameVisChanged = (taskbarWillBeVisible && Float.compare(currentValue, 1) != 0)
|
boolean firstFrameVisChanged = (taskbarWillBeVisible && Float.compare(currentValue, 1) != 0)
|
||||||
|| (!taskbarWillBeVisible && Float.compare(currentValue, 0) != 0);
|
|| (!taskbarWillBeVisible && Float.compare(currentValue, 0) != 0);
|
||||||
|
|
||||||
|
updateIconAlignment(alignment);
|
||||||
|
|
||||||
// Sync the first frame where we swap taskbar and hotseat.
|
// Sync the first frame where we swap taskbar and hotseat.
|
||||||
if (firstFrameVisChanged && mCanSyncViews && !Utilities.IS_RUNNING_IN_TEST_HARNESS) {
|
if (firstFrameVisChanged && mCanSyncViews && !Utilities.IS_RUNNING_IN_TEST_HARNESS) {
|
||||||
DeviceProfile dp = mLauncher.getDeviceProfile();
|
|
||||||
|
|
||||||
// Do all the heavy work before the sync.
|
|
||||||
mControllers.taskbarViewController.createIconAlignmentControllerIfNotExists(dp);
|
|
||||||
|
|
||||||
ViewRootSync.synchronizeNextDraw(mLauncher.getHotseat(),
|
ViewRootSync.synchronizeNextDraw(mLauncher.getHotseat(),
|
||||||
mControllers.taskbarActivityContext.getDragLayer(),
|
mControllers.taskbarActivityContext.getDragLayer(),
|
||||||
() -> updateIconAlignment(alignment));
|
() -> {});
|
||||||
} else {
|
|
||||||
updateIconAlignment(alignment);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -204,16 +204,6 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates the icon alignment controller if it does not already exist.
|
|
||||||
* @param launcherDp Launcher device profile.
|
|
||||||
*/
|
|
||||||
public void createIconAlignmentControllerIfNotExists(DeviceProfile launcherDp) {
|
|
||||||
if (mIconAlignControllerLazy == null) {
|
|
||||||
mIconAlignControllerLazy = createIconAlignmentController(launcherDp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the taskbar icon alignment relative to Launcher hotseat icons
|
* Sets the taskbar icon alignment relative to Launcher hotseat icons
|
||||||
* @param alignmentRatio [0, 1]
|
* @param alignmentRatio [0, 1]
|
||||||
@@ -221,7 +211,9 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar
|
|||||||
* 1 => fully aligned
|
* 1 => fully aligned
|
||||||
*/
|
*/
|
||||||
public void setLauncherIconAlignment(float alignmentRatio, DeviceProfile launcherDp) {
|
public void setLauncherIconAlignment(float alignmentRatio, DeviceProfile launcherDp) {
|
||||||
createIconAlignmentControllerIfNotExists(launcherDp);
|
if (mIconAlignControllerLazy == null) {
|
||||||
|
mIconAlignControllerLazy = createIconAlignmentController(launcherDp);
|
||||||
|
}
|
||||||
mIconAlignControllerLazy.setPlayFraction(alignmentRatio);
|
mIconAlignControllerLazy.setPlayFraction(alignmentRatio);
|
||||||
if (alignmentRatio <= 0 || alignmentRatio >= 1) {
|
if (alignmentRatio <= 0 || alignmentRatio >= 1) {
|
||||||
// Cleanup lazy controller so that it is created again in next animation
|
// Cleanup lazy controller so that it is created again in next animation
|
||||||
|
|||||||
@@ -149,8 +149,6 @@ public class CellLayout extends ViewGroup {
|
|||||||
private boolean mVisualizeDropLocation = true;
|
private boolean mVisualizeDropLocation = true;
|
||||||
private RectF mVisualizeGridRect = new RectF();
|
private RectF mVisualizeGridRect = new RectF();
|
||||||
private Paint mVisualizeGridPaint = new Paint();
|
private Paint mVisualizeGridPaint = new Paint();
|
||||||
private int mGridVisualizationPaddingX;
|
|
||||||
private int mGridVisualizationPaddingY;
|
|
||||||
private int mGridVisualizationRoundingRadius;
|
private int mGridVisualizationRoundingRadius;
|
||||||
private float mGridAlpha = 0f;
|
private float mGridAlpha = 0f;
|
||||||
private int mGridColor = 0;
|
private int mGridColor = 0;
|
||||||
@@ -262,10 +260,6 @@ public class CellLayout extends ViewGroup {
|
|||||||
mBackground.setAlpha(0);
|
mBackground.setAlpha(0);
|
||||||
|
|
||||||
mGridColor = Themes.getAttrColor(getContext(), R.attr.workspaceAccentColor);
|
mGridColor = Themes.getAttrColor(getContext(), R.attr.workspaceAccentColor);
|
||||||
mGridVisualizationPaddingX = res.getDimensionPixelSize(
|
|
||||||
R.dimen.grid_visualization_horizontal_cell_spacing);
|
|
||||||
mGridVisualizationPaddingY = res.getDimensionPixelSize(
|
|
||||||
R.dimen.grid_visualization_vertical_cell_spacing);
|
|
||||||
mGridVisualizationRoundingRadius =
|
mGridVisualizationRoundingRadius =
|
||||||
res.getDimensionPixelSize(R.dimen.grid_visualization_rounding_radius);
|
res.getDimensionPixelSize(R.dimen.grid_visualization_rounding_radius);
|
||||||
mReorderPreviewAnimationMagnitude = (REORDER_PREVIEW_MAGNITUDE * deviceProfile.iconSizePx);
|
mReorderPreviewAnimationMagnitude = (REORDER_PREVIEW_MAGNITUDE * deviceProfile.iconSizePx);
|
||||||
@@ -595,8 +589,8 @@ public class CellLayout extends ViewGroup {
|
|||||||
|
|
||||||
protected void visualizeGrid(Canvas canvas) {
|
protected void visualizeGrid(Canvas canvas) {
|
||||||
DeviceProfile dp = mActivity.getDeviceProfile();
|
DeviceProfile dp = mActivity.getDeviceProfile();
|
||||||
int paddingX = Math.min((mCellWidth - dp.iconSizePx) / 2, mGridVisualizationPaddingX);
|
int paddingX = Math.min((mCellWidth - dp.iconSizePx) / 2, dp.gridVisualizationPaddingX);
|
||||||
int paddingY = Math.min((mCellHeight - dp.iconSizePx) / 2, mGridVisualizationPaddingY);
|
int paddingY = Math.min((mCellHeight - dp.iconSizePx) / 2, dp.gridVisualizationPaddingY);
|
||||||
mVisualizeGridRect.set(paddingX, paddingY,
|
mVisualizeGridRect.set(paddingX, paddingY,
|
||||||
mCellWidth - paddingX,
|
mCellWidth - paddingX,
|
||||||
mCellHeight - paddingY);
|
mCellHeight - paddingY);
|
||||||
|
|||||||
@@ -100,6 +100,8 @@ public class DeviceProfile {
|
|||||||
// Workspace
|
// Workspace
|
||||||
public final int desiredWorkspaceHorizontalMarginOriginalPx;
|
public final int desiredWorkspaceHorizontalMarginOriginalPx;
|
||||||
public int desiredWorkspaceHorizontalMarginPx;
|
public int desiredWorkspaceHorizontalMarginPx;
|
||||||
|
public int gridVisualizationPaddingX;
|
||||||
|
public int gridVisualizationPaddingY;
|
||||||
public Point cellLayoutBorderSpaceOriginalPx;
|
public Point cellLayoutBorderSpaceOriginalPx;
|
||||||
public Point cellLayoutBorderSpacePx;
|
public Point cellLayoutBorderSpacePx;
|
||||||
public Rect cellLayoutPaddingPx = new Rect();
|
public Rect cellLayoutPaddingPx = new Rect();
|
||||||
@@ -301,6 +303,10 @@ public class DeviceProfile {
|
|||||||
|
|
||||||
desiredWorkspaceHorizontalMarginPx = getHorizontalMarginPx(inv, res);
|
desiredWorkspaceHorizontalMarginPx = getHorizontalMarginPx(inv, res);
|
||||||
desiredWorkspaceHorizontalMarginOriginalPx = desiredWorkspaceHorizontalMarginPx;
|
desiredWorkspaceHorizontalMarginOriginalPx = desiredWorkspaceHorizontalMarginPx;
|
||||||
|
gridVisualizationPaddingX = res.getDimensionPixelSize(
|
||||||
|
R.dimen.grid_visualization_horizontal_cell_spacing);
|
||||||
|
gridVisualizationPaddingY = res.getDimensionPixelSize(
|
||||||
|
R.dimen.grid_visualization_vertical_cell_spacing);
|
||||||
|
|
||||||
bottomSheetTopPadding = mInsets.top // statusbar height
|
bottomSheetTopPadding = mInsets.top // statusbar height
|
||||||
+ res.getDimensionPixelSize(R.dimen.bottom_sheet_extra_top_padding)
|
+ res.getDimensionPixelSize(R.dimen.bottom_sheet_extra_top_padding)
|
||||||
@@ -1063,24 +1069,23 @@ public class DeviceProfile {
|
|||||||
mInsets.right + hotseatBarSidePaddingStartPx, paddingBottom);
|
mInsets.right + hotseatBarSidePaddingStartPx, paddingBottom);
|
||||||
}
|
}
|
||||||
} else if (isTaskbarPresent) {
|
} else if (isTaskbarPresent) {
|
||||||
boolean isRtl = Utilities.isRtl(context.getResources());
|
// Center the QSB vertically with hotseat
|
||||||
int hotseatHeight = workspacePadding.bottom;
|
int hotseatBottomPadding = getHotseatBottomPadding();
|
||||||
int taskbarOffset = getTaskbarOffsetY();
|
int hotseatTopPadding =
|
||||||
|
workspacePadding.bottom - hotseatBottomPadding - hotseatCellHeightPx;
|
||||||
|
|
||||||
// Push icons to the side
|
// Push icons to the side
|
||||||
int additionalQsbSpace = isQsbInline ? qsbWidth + hotseatBorderSpace : 0;
|
int additionalQsbSpace = isQsbInline ? qsbWidth + hotseatBorderSpace : 0;
|
||||||
|
|
||||||
// Center the QSB vertically with hotseat
|
|
||||||
int hotseatTopPadding = hotseatHeight - taskbarOffset - hotseatCellHeightPx;
|
|
||||||
|
|
||||||
int endOffset = ApiWrapper.getHotseatEndOffset(context);
|
|
||||||
int requiredWidth = iconSizePx * numShownHotseatIcons
|
int requiredWidth = iconSizePx * numShownHotseatIcons
|
||||||
+ hotseatBorderSpace * (numShownHotseatIcons - 1)
|
+ hotseatBorderSpace * (numShownHotseatIcons - 1)
|
||||||
+ additionalQsbSpace;
|
+ additionalQsbSpace;
|
||||||
|
int endOffset = ApiWrapper.getHotseatEndOffset(context);
|
||||||
int hotseatWidth = Math.min(requiredWidth, availableWidthPx - endOffset);
|
int hotseatWidth = Math.min(requiredWidth, availableWidthPx - endOffset);
|
||||||
int sideSpacing = (availableWidthPx - hotseatWidth) / 2;
|
int sideSpacing = (availableWidthPx - hotseatWidth) / 2;
|
||||||
mHotseatPadding.set(sideSpacing, hotseatTopPadding, sideSpacing, taskbarOffset);
|
|
||||||
|
|
||||||
|
mHotseatPadding.set(sideSpacing, hotseatTopPadding, sideSpacing, hotseatBottomPadding);
|
||||||
|
|
||||||
|
boolean isRtl = Utilities.isRtl(context.getResources());
|
||||||
if (isRtl) {
|
if (isRtl) {
|
||||||
mHotseatPadding.right += additionalQsbSpace;
|
mHotseatPadding.right += additionalQsbSpace;
|
||||||
} else {
|
} else {
|
||||||
@@ -1140,10 +1145,7 @@ public class DeviceProfile {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private int getHotseatBottomPadding() {
|
||||||
* Returns the number of pixels the taskbar is translated from the bottom of the screen.
|
|
||||||
*/
|
|
||||||
public int getTaskbarOffsetY() {
|
|
||||||
if (isQsbInline) {
|
if (isQsbInline) {
|
||||||
return getQsbOffsetY() - (Math.abs(hotseatQsbHeight - hotseatCellHeightPx) / 2);
|
return getQsbOffsetY() - (Math.abs(hotseatQsbHeight - hotseatCellHeightPx) / 2);
|
||||||
} else {
|
} else {
|
||||||
@@ -1151,6 +1153,16 @@ public class DeviceProfile {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the number of pixels the taskbar is translated from the bottom of the screen.
|
||||||
|
*/
|
||||||
|
public int getTaskbarOffsetY() {
|
||||||
|
int taskbarIconBottomSpace = (taskbarSize - iconSizePx) / 2;
|
||||||
|
int launcherIconBottomSpace =
|
||||||
|
Math.min((hotseatCellHeightPx - iconSizePx) / 2, gridVisualizationPaddingY);
|
||||||
|
return getHotseatBottomPadding() + launcherIconBottomSpace - taskbarIconBottomSpace;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of pixels required below OverviewActions excluding insets.
|
* Returns the number of pixels required below OverviewActions excluding insets.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in new issue
Block a user