Merge "Remove scaling from spring loaded y translation." into tm-qpr-dev
diff --git a/proguard.flags b/proguard.flags
index a450183..53a68de 100644
--- a/proguard.flags
+++ b/proguard.flags
@@ -2,10 +2,6 @@
*;
}
--keep class com.android.launcher3.graphics.ShadowDrawable {
- public <init>(...);
-}
-
# The support library contains references to newer platform versions.
# Don't warn about those in case this app is linking against an older
# platform version. We know about them, and they are safe.
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java
index ea15acb..dbf9759 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java
@@ -314,10 +314,10 @@
int qsbEnd;
if (layoutRtl) {
qsbStart = iconEnd + mItemMarginLeftRight;
- qsbEnd = qsbStart + deviceProfile.qsbWidth;
+ qsbEnd = qsbStart + deviceProfile.hotseatQsbWidth;
} else {
qsbEnd = iconEnd - mItemMarginLeftRight;
- qsbStart = qsbEnd - deviceProfile.qsbWidth;
+ qsbStart = qsbEnd - deviceProfile.hotseatQsbWidth;
}
int qsbTop = (bottom - top - deviceProfile.hotseatQsbHeight) / 2;
int qsbBottom = qsbTop + deviceProfile.hotseatQsbHeight;
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java
index 0f6de73..929dc20 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java
@@ -295,10 +295,11 @@
boolean isRtl = Utilities.isRtl(child.getResources());
float hotseatIconCenter = isRtl
? launcherDp.widthPx - hotseatPadding.right + borderSpacing
- + launcherDp.qsbWidth / 2f
- : hotseatPadding.left - borderSpacing - launcherDp.qsbWidth / 2f;
+ + launcherDp.hotseatQsbWidth / 2f
+ : hotseatPadding.left - borderSpacing - launcherDp.hotseatQsbWidth / 2f;
float childCenter = (child.getLeft() + child.getRight()) / 2f;
- float halfQsbIconWidthDiff = (launcherDp.qsbWidth - taskbarDp.iconSizePx) / 2f;
+ float halfQsbIconWidthDiff =
+ (launcherDp.hotseatQsbWidth - taskbarDp.iconSizePx) / 2f;
setter.addFloat(child, ICON_TRANSLATE_X,
isRtl ? -halfQsbIconWidthDiff : halfQsbIconWidthDiff,
hotseatIconCenter - childCenter, LINEAR);
@@ -312,7 +313,7 @@
: Interpolators.clampToProgress(LINEAR, 0.84f, 1f));
setter.addOnFrameListener(animator -> AlphaUpdateListener.updateVisibility(child));
- float qsbInsetFraction = halfQsbIconWidthDiff / launcherDp.qsbWidth;
+ float qsbInsetFraction = halfQsbIconWidthDiff / launcherDp.hotseatQsbWidth;
if (child instanceof HorizontalInsettableView) {
setter.addFloat((HorizontalInsettableView) child,
HorizontalInsettableView.HORIZONTAL_INSETS, qsbInsetFraction, 0,
diff --git a/quickstep/tests/src/com/android/quickstep/DeviceProfileTest.kt b/quickstep/tests/src/com/android/quickstep/DeviceProfileTest.kt
index 1208a2a..b50d3ee 100644
--- a/quickstep/tests/src/com/android/quickstep/DeviceProfileTest.kt
+++ b/quickstep/tests/src/com/android/quickstep/DeviceProfileTest.kt
@@ -110,7 +110,7 @@
"\tnumShownHotseatIcons: 4\n" +
"\thotseatBorderSpace: 95.0px (36.190475dp)\n" +
"\tisQsbInline: false\n" +
- "\tqsbWidth: 913.0px (347.8095dp)\n" +
+ "\thotseatQsbWidth: 913.0px (347.8095dp)\n" +
"\tisTaskbarPresent:false\n" +
"\tisTaskbarPresentInApps:false\n" +
"\ttaskbarSize: 0.0px (0.0dp)\n" +
@@ -229,7 +229,7 @@
"\tnumShownHotseatIcons: 4\n" +
"\thotseatBorderSpace: 95.0px (36.190475dp)\n" +
"\tisQsbInline: false\n" +
- "\tqsbWidth: 913.0px (347.8095dp)\n" +
+ "\thotseatQsbWidth: 913.0px (347.8095dp)\n" +
"\tisTaskbarPresent:false\n" +
"\tisTaskbarPresentInApps:false\n" +
"\ttaskbarSize: 0.0px (0.0dp)\n" +
@@ -349,7 +349,7 @@
"\tnumShownHotseatIcons: 5\n" +
"\thotseatBorderSpace: 101.0px (50.5dp)\n" +
"\tisQsbInline: true\n" +
- "\tqsbWidth: 855.0px (427.5dp)\n" +
+ "\thotseatQsbWidth: 855.0px (427.5dp)\n" +
"\tisTaskbarPresent:true\n" +
"\tisTaskbarPresentInApps:true\n" +
"\ttaskbarSize: 120.0px (60.0dp)\n" +
@@ -469,7 +469,7 @@
"\tnumShownHotseatIcons: 6\n" +
"\thotseatBorderSpace: 100.0px (50.0dp)\n" +
"\tisQsbInline: true\n" +
- "\tqsbWidth: 640.0px (320.0dp)\n" +
+ "\thotseatQsbWidth: 640.0px (320.0dp)\n" +
"\tisTaskbarPresent:true\n" +
"\tisTaskbarPresentInApps:true\n" +
"\ttaskbarSize: 120.0px (60.0dp)\n" +
@@ -560,8 +560,8 @@
"\tfolderCellLayoutBorderSpacePx Horizontal: 0.0px (0.0dp)\n" +
"\tfolderCellLayoutBorderSpacePx Vertical: 0.0px (0.0dp)\n" +
"\tbottomSheetTopPadding: 704.0px (352.0dp)\n" +
- "\tallAppsShiftRange: 1856.0px (928.0dp)\n" +
- "\tallAppsTopPadding: 704.0px (352.0dp)\n" +
+ "\tallAppsShiftRange: 1936.0px (968.0dp)\n" +
+ "\tallAppsTopPadding: 624.0px (312.0dp)\n" +
"\tallAppsIconSizePx: 120.0px (60.0dp)\n" +
"\tallAppsIconTextSizePx: 28.0px (14.0dp)\n" +
"\tallAppsIconDrawablePaddingPx: 14.0px (7.0dp)\n" +
@@ -589,7 +589,7 @@
"\tnumShownHotseatIcons: 5\n" +
"\thotseatBorderSpace: 116.0px (58.0dp)\n" +
"\tisQsbInline: false\n" +
- "\tqsbWidth: 1300.0px (650.0dp)\n" +
+ "\thotseatQsbWidth: 1300.0px (650.0dp)\n" +
"\tisTaskbarPresent:true\n" +
"\tisTaskbarPresentInApps:true\n" +
"\ttaskbarSize: 120.0px (60.0dp)\n" +
@@ -680,8 +680,8 @@
"\tfolderCellLayoutBorderSpacePx Horizontal: 0.0px (0.0dp)\n" +
"\tfolderCellLayoutBorderSpacePx Vertical: 0.0px (0.0dp)\n" +
"\tbottomSheetTopPadding: 704.0px (352.0dp)\n" +
- "\tallAppsShiftRange: 1856.0px (928.0dp)\n" +
- "\tallAppsTopPadding: 704.0px (352.0dp)\n" +
+ "\tallAppsShiftRange: 1936.0px (968.0dp)\n" +
+ "\tallAppsTopPadding: 624.0px (312.0dp)\n" +
"\tallAppsIconSizePx: 120.0px (60.0dp)\n" +
"\tallAppsIconTextSizePx: 28.0px (14.0dp)\n" +
"\tallAppsIconDrawablePaddingPx: 14.0px (7.0dp)\n" +
@@ -709,7 +709,7 @@
"\tnumShownHotseatIcons: 6\n" +
"\thotseatBorderSpace: 116.0px (58.0dp)\n" +
"\tisQsbInline: false\n" +
- "\tqsbWidth: 1300.0px (650.0dp)\n" +
+ "\thotseatQsbWidth: 1300.0px (650.0dp)\n" +
"\tisTaskbarPresent:true\n" +
"\tisTaskbarPresentInApps:true\n" +
"\ttaskbarSize: 120.0px (60.0dp)\n" +
@@ -829,7 +829,7 @@
"\tnumShownHotseatIcons: 6\n" +
"\thotseatBorderSpace: 61.0px (23.238094dp)\n" +
"\tisQsbInline: false\n" +
- "\tqsbWidth: 1467.0px (558.8571dp)\n" +
+ "\thotseatQsbWidth: 1467.0px (558.8571dp)\n" +
"\tisTaskbarPresent:true\n" +
"\tisTaskbarPresentInApps:true\n" +
"\ttaskbarSize: 158.0px (60.190475dp)\n" +
@@ -949,7 +949,7 @@
"\tnumShownHotseatIcons: 6\n" +
"\thotseatBorderSpace: 105.0px (40.0dp)\n" +
"\tisQsbInline: false\n" +
- "\tqsbWidth: 1467.0px (558.8571dp)\n" +
+ "\thotseatQsbWidth: 1467.0px (558.8571dp)\n" +
"\tisTaskbarPresent:true\n" +
"\tisTaskbarPresentInApps:true\n" +
"\ttaskbarSize: 158.0px (60.190475dp)\n" +
@@ -1069,7 +1069,7 @@
"\tnumShownHotseatIcons: 6\n" +
"\thotseatBorderSpace: 47.0px (17.904762dp)\n" +
"\tisQsbInline: false\n" +
- "\tqsbWidth: 1236.0px (470.85715dp)\n" +
+ "\thotseatQsbWidth: 1236.0px (470.85715dp)\n" +
"\tisTaskbarPresent:true\n" +
"\tisTaskbarPresentInApps:true\n" +
"\ttaskbarSize: 158.0px (60.190475dp)\n" +
@@ -1189,7 +1189,7 @@
"\tnumShownHotseatIcons: 6\n" +
"\thotseatBorderSpace: 84.0px (32.0dp)\n" +
"\tisQsbInline: false\n" +
- "\tqsbWidth: 1236.0px (470.85715dp)\n" +
+ "\thotseatQsbWidth: 1236.0px (470.85715dp)\n" +
"\tisTaskbarPresent:true\n" +
"\tisTaskbarPresentInApps:true\n" +
"\ttaskbarSize: 158.0px (60.190475dp)\n" +
@@ -1308,7 +1308,7 @@
"\tnumShownHotseatIcons: 4\n" +
"\thotseatBorderSpace: 0.0px (0.0dp)\n" +
"\tisQsbInline: false\n" +
- "\tqsbWidth: 1525.0px (580.9524dp)\n" +
+ "\thotseatQsbWidth: 1525.0px (580.9524dp)\n" +
"\tisTaskbarPresent:false\n" +
"\tisTaskbarPresentInApps:false\n" +
"\ttaskbarSize: 0.0px (0.0dp)\n" +
@@ -1427,7 +1427,7 @@
"\tnumShownHotseatIcons: 4\n" +
"\thotseatBorderSpace: 0.0px (0.0dp)\n" +
"\tisQsbInline: false\n" +
- "\tqsbWidth: 1621.0px (617.5238dp)\n" +
+ "\thotseatQsbWidth: 1621.0px (617.5238dp)\n" +
"\tisTaskbarPresent:false\n" +
"\tisTaskbarPresentInApps:false\n" +
"\ttaskbarSize: 0.0px (0.0dp)\n" +
diff --git a/res/drawable/ic_block_shadow.xml b/res/drawable/ic_block_shadow.xml
deleted file mode 100644
index 045fe8d..0000000
--- a/res/drawable/ic_block_shadow.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2020 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<com.android.launcher3.graphics.ShadowDrawable
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:src="@drawable/ic_block_no_shadow"
- android:elevation="@dimen/drop_target_shadow_elevation" />
diff --git a/res/drawable/ic_remove_shadow.xml b/res/drawable/ic_remove_shadow.xml
deleted file mode 100644
index 48abc10..0000000
--- a/res/drawable/ic_remove_shadow.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2017 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<com.android.launcher3.graphics.ShadowDrawable
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:src="@drawable/ic_remove_no_shadow"
- android:elevation="@dimen/drop_target_shadow_elevation" />
diff --git a/res/drawable/ic_setup_shadow.xml b/res/drawable/ic_setup_shadow.xml
deleted file mode 100644
index 10aeee6..0000000
--- a/res/drawable/ic_setup_shadow.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2017 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<com.android.launcher3.graphics.ShadowDrawable
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:src="@drawable/ic_setting"
- android:elevation="@dimen/drop_target_shadow_elevation" />
diff --git a/res/drawable/ic_uninstall_shadow.xml b/res/drawable/ic_uninstall_shadow.xml
deleted file mode 100644
index b441b0e..0000000
--- a/res/drawable/ic_uninstall_shadow.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2017 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<com.android.launcher3.graphics.ShadowDrawable
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:src="@drawable/ic_uninstall_no_shadow"
- android:elevation="@dimen/drop_target_shadow_elevation" />
diff --git a/src/com/android/launcher3/CellLayout.java b/src/com/android/launcher3/CellLayout.java
index 52960a9..9f3e1fa 100644
--- a/src/com/android/launcher3/CellLayout.java
+++ b/src/com/android/launcher3/CellLayout.java
@@ -496,8 +496,8 @@
// Draw reorder drag target.
debugPaint.setColor(Color.RED);
- canvas.drawCircle(cellCenter[0], cellCenter[1], getReorderRadius(targetCell),
- debugPaint);
+ canvas.drawCircle(cellCenter[0], cellCenter[1],
+ getReorderRadius(targetCell, 1, 1), debugPaint);
// Draw folder creation drag target.
if (canCreateFolder) {
@@ -912,18 +912,18 @@
DeviceProfile grid = mActivity.getDeviceProfile();
float iconVisibleRadius = ICON_VISIBLE_AREA_FACTOR * grid.iconSizePx / 2;
// Halfway between reorder radius and icon.
- return (getReorderRadius(targetCell) + iconVisibleRadius) / 2;
+ return (getReorderRadius(targetCell, 1, 1) + iconVisibleRadius) / 2;
}
/**
* Returns the max distance from the center of a cell that will start to reorder on drag over.
*/
- public float getReorderRadius(int[] targetCell) {
+ public float getReorderRadius(int[] targetCell, int spanX, int spanY) {
int[] centerPoint = mTmpPoint;
getWorkspaceCellVisualCenter(targetCell[0], targetCell[1], centerPoint);
Rect cellBoundsWithSpacing = mTempRect;
- cellToRect(targetCell[0], targetCell[1], 1, 1, cellBoundsWithSpacing);
+ cellToRect(targetCell[0], targetCell[1], spanX, spanY, cellBoundsWithSpacing);
cellBoundsWithSpacing.inset(-mBorderSpace.x / 2, -mBorderSpace.y / 2);
if (canCreateFolder(getChildAt(targetCell[0], targetCell[1]))) {
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index 366d372..0d41230 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -23,24 +23,25 @@
import static com.android.launcher3.Utilities.dpiFromPx;
import static com.android.launcher3.Utilities.pxFromSp;
import static com.android.launcher3.folder.ClippedFolderIconLayoutRule.ICON_OVERLAP_FACTOR;
+import static com.android.launcher3.icons.GraphicsUtils.getShapePath;
import static com.android.launcher3.testing.shared.ResourceUtils.pxFromDp;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
-import android.graphics.Path;
import android.graphics.Point;
import android.graphics.PointF;
import android.graphics.Rect;
import android.util.DisplayMetrics;
+import android.util.SparseArray;
import android.view.Surface;
+import androidx.annotation.NonNull;
+
import com.android.launcher3.CellLayout.ContainerType;
import com.android.launcher3.DevicePaddings.DevicePadding;
-import com.android.launcher3.config.FeatureFlags;
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;
@@ -54,6 +55,8 @@
public class DeviceProfile {
private static final int DEFAULT_DOT_SIZE = 100;
+ private static final float ALL_APPS_TABLET_MAX_ROWS = 5.5f;
+
// Ratio of empty space, qsb should take up to appear visually centered.
private final float mQsbCenterFactor;
@@ -167,13 +170,12 @@
// 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 int hotseatQsbWidth; // only used when isQsbInline
public final int hotseatQsbHeight;
public final int hotseatQsbVisualHeight;
private final int hotseatQsbShadowHeight;
public int hotseatBorderSpace;
- public int qsbWidth; // only used when isQsbInline
-
// All apps
public Point allAppsBorderSpacePx;
public int allAppsShiftRange;
@@ -222,8 +224,8 @@
private boolean mIsSeascape;
// Notification dots
- public DotRenderer mDotRendererWorkSpace;
- public DotRenderer mDotRendererAllApps;
+ public final DotRenderer mDotRendererWorkSpace;
+ public final DotRenderer mDotRendererAllApps;
// Taskbar
public boolean isTaskbarPresent;
@@ -237,8 +239,8 @@
/** TODO: Once we fully migrate to staged split, remove "isMultiWindowMode" */
DeviceProfile(Context context, InvariantDeviceProfile inv, Info info, WindowBounds windowBounds,
- boolean isMultiWindowMode, boolean transposeLayoutWithOrientation,
- boolean useTwoPanels, boolean isGestureMode) {
+ SparseArray<DotRenderer> dotRendererCache, boolean isMultiWindowMode,
+ boolean transposeLayoutWithOrientation, boolean useTwoPanels, boolean isGestureMode) {
this.inv = inv;
this.isLandscape = windowBounds.isLandscape();
@@ -309,10 +311,6 @@
+ res.getDimensionPixelSize(R.dimen.bottom_sheet_extra_top_padding)
+ (isTablet ? 0 : edgeMarginPx); // phones need edgeMarginPx additional padding
- allAppsTopPadding = isTablet ? bottomSheetTopPadding : 0;
- allAppsShiftRange = isTablet
- ? heightPx - allAppsTopPadding
- : res.getDimensionPixelSize(R.dimen.all_apps_starting_vertical_translate);
folderLabelTextScale = res.getFloat(R.dimen.folder_label_text_scale);
folderContentPaddingLeftRight =
res.getDimensionPixelSize(R.dimen.folder_content_padding_left_right);
@@ -463,16 +461,38 @@
// Hotseat and QSB width depends on updated cellSize and workspace padding
hotseatBorderSpace = calculateHotseatBorderSpace();
- qsbWidth = calculateQsbWidth();
+ hotseatQsbWidth = calculateQsbWidth();
+
+ // AllApps height calculation depends on updated cellSize
+ if (isTablet) {
+ int collapseHandleHeight =
+ res.getDimensionPixelOffset(R.dimen.bottom_sheet_handle_area_height);
+ int contentHeight = heightPx - collapseHandleHeight - hotseatQsbHeight;
+ int targetContentHeight = (int) (allAppsCellHeightPx * ALL_APPS_TABLET_MAX_ROWS);
+ allAppsTopPadding = Math.max(mInsets.top, contentHeight - targetContentHeight);
+ allAppsShiftRange = heightPx - allAppsTopPadding;
+ } else {
+ allAppsTopPadding = 0;
+ allAppsShiftRange =
+ res.getDimensionPixelSize(R.dimen.all_apps_starting_vertical_translate);
+ }
flingToDeleteThresholdVelocity = res.getDimensionPixelSize(
R.dimen.drag_flingToDeleteMinVelocity);
// This is done last, after iconSizePx is calculated above.
- Path dotPath = GraphicsUtils.getShapePath(DEFAULT_DOT_SIZE);
- mDotRendererWorkSpace = new DotRenderer(iconSizePx, dotPath, DEFAULT_DOT_SIZE);
- mDotRendererAllApps = iconSizePx == allAppsIconSizePx ? mDotRendererWorkSpace :
- new DotRenderer(allAppsIconSizePx, dotPath, DEFAULT_DOT_SIZE);
+ mDotRendererWorkSpace = createDotRenderer(iconSizePx, dotRendererCache);
+ mDotRendererAllApps = createDotRenderer(allAppsIconSizePx, dotRendererCache);
+ }
+
+ private static DotRenderer createDotRenderer(
+ int size, @NonNull SparseArray<DotRenderer> cache) {
+ DotRenderer renderer = cache.get(size);
+ if (renderer == null) {
+ renderer = new DotRenderer(size, getShapePath(DEFAULT_DOT_SIZE), DEFAULT_DOT_SIZE);
+ cache.put(size, renderer);
+ }
+ return renderer;
}
/**
@@ -566,10 +586,16 @@
widthPx, heightPx, availableWidthPx, availableHeightPx, rotationHint);
bounds.bounds.offsetTo(windowX, windowY);
bounds.insets.set(mInsets);
+
+ SparseArray<DotRenderer> dotRendererCache = new SparseArray<>();
+ dotRendererCache.put(iconSizePx, mDotRendererWorkSpace);
+ dotRendererCache.put(allAppsIconSizePx, mDotRendererAllApps);
+
return new Builder(context, inv, mInfo)
.setWindowBounds(bounds)
.setUseTwoPanels(isTwoPanels)
.setMultiWindowMode(isMultiWindowMode)
+ .setDotRendererCache(dotRendererCache)
.setGestureMode(isGestureMode);
}
@@ -1052,7 +1078,7 @@
hotseatBarSizePx - hotseatBarBottomPadding - hotseatCellHeightPx;
// Push icons to the side
- int additionalQsbSpace = isQsbInline ? qsbWidth + hotseatBorderSpace : 0;
+ int additionalQsbSpace = isQsbInline ? hotseatQsbWidth + hotseatBorderSpace : 0;
int requiredWidth = iconSizePx * numShownHotseatIcons
+ hotseatBorderSpace * (numShownHotseatIcons - 1)
+ additionalQsbSpace;
@@ -1077,7 +1103,7 @@
hotseatBarPadding.right += diff;
}
} else if (isScalableGrid) {
- int sideSpacing = (availableWidthPx - qsbWidth) / 2;
+ int sideSpacing = (availableWidthPx - hotseatQsbWidth) / 2;
hotseatBarPadding.set(sideSpacing,
0,
sideSpacing,
@@ -1350,7 +1376,7 @@
writer.println(prefix + "\tnumShownHotseatIcons: " + numShownHotseatIcons);
writer.println(prefix + pxToDpStr("hotseatBorderSpace", hotseatBorderSpace));
writer.println(prefix + "\tisQsbInline: " + isQsbInline);
- writer.println(prefix + pxToDpStr("qsbWidth", qsbWidth));
+ writer.println(prefix + pxToDpStr("hotseatQsbWidth", hotseatQsbWidth));
writer.println(prefix + "\tisTaskbarPresent:" + isTaskbarPresent);
writer.println(prefix + "\tisTaskbarPresentInApps:" + isTaskbarPresentInApps);
@@ -1474,6 +1500,8 @@
private Boolean mTransposeLayoutWithOrientation;
private Boolean mIsGestureMode;
+ private SparseArray<DotRenderer> mDotRendererCache;
+
public Builder(Context context, InvariantDeviceProfile inv, Info info) {
mContext = context;
mInv = inv;
@@ -1490,6 +1518,10 @@
return this;
}
+ public Builder setDotRendererCache(SparseArray<DotRenderer> dotRendererCache) {
+ mDotRendererCache = dotRendererCache;
+ return this;
+ }
public Builder setWindowBounds(WindowBounds bounds) {
mWindowBounds = bounds;
@@ -1516,8 +1548,12 @@
if (mIsGestureMode == null) {
mIsGestureMode = DisplayController.getNavigationMode(mContext).hasGestures;
}
- return new DeviceProfile(mContext, mInv, mInfo, mWindowBounds, mIsMultiWindowMode,
- mTransposeLayoutWithOrientation, mUseTwoPanels, mIsGestureMode);
+ if (mDotRendererCache == null) {
+ mDotRendererCache = new SparseArray<>();
+ }
+ return new DeviceProfile(mContext, mInv, mInfo, mWindowBounds, mDotRendererCache,
+ mIsMultiWindowMode, mTransposeLayoutWithOrientation, mUseTwoPanels,
+ mIsGestureMode);
}
}
diff --git a/src/com/android/launcher3/Hotseat.java b/src/com/android/launcher3/Hotseat.java
index 05ed319..bf492a9 100644
--- a/src/com/android/launcher3/Hotseat.java
+++ b/src/com/android/launcher3/Hotseat.java
@@ -47,7 +47,6 @@
private Consumer<Boolean> mOnVisibilityAggregatedCallback;
private final View mQsb;
- private final int mQsbHeight;
public Hotseat(Context context) {
this(context, null);
@@ -62,8 +61,6 @@
mQsb = LayoutInflater.from(context).inflate(R.layout.search_container_hotseat, this, false);
addView(mQsb);
-
- mQsbHeight = getResources().getDimensionPixelSize(R.dimen.qsb_widget_height);
}
/**
@@ -171,29 +168,29 @@
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
- int qsbWidth = mActivity.getDeviceProfile().qsbWidth;
-
- mQsb.measure(MeasureSpec.makeMeasureSpec(qsbWidth, MeasureSpec.EXACTLY),
- MeasureSpec.makeMeasureSpec(mQsbHeight, MeasureSpec.EXACTLY));
+ DeviceProfile dp = mActivity.getDeviceProfile();
+ mQsb.measure(MeasureSpec.makeMeasureSpec(dp.hotseatQsbWidth, MeasureSpec.EXACTLY),
+ MeasureSpec.makeMeasureSpec(dp.hotseatQsbHeight, MeasureSpec.EXACTLY));
}
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
super.onLayout(changed, l, t, r, b);
- int qsbWidth = mQsb.getMeasuredWidth();
+ int qsbMeasuredWidth = mQsb.getMeasuredWidth();
int left;
- if (mActivity.getDeviceProfile().isQsbInline) {
- int qsbSpace = mActivity.getDeviceProfile().hotseatBorderSpace;
+ DeviceProfile dp = mActivity.getDeviceProfile();
+ if (dp.isQsbInline) {
+ int qsbSpace = dp.hotseatBorderSpace;
left = Utilities.isRtl(getResources()) ? r - getPaddingRight() + qsbSpace
- : l + getPaddingLeft() - qsbWidth - qsbSpace;
+ : l + getPaddingLeft() - qsbMeasuredWidth - qsbSpace;
} else {
- left = (r - l - qsbWidth) / 2;
+ left = (r - l - qsbMeasuredWidth) / 2;
}
- int right = left + qsbWidth;
+ int right = left + qsbMeasuredWidth;
- int bottom = b - t - mActivity.getDeviceProfile().getQsbOffsetY();
- int top = bottom - mQsbHeight;
+ int bottom = b - t - dp.getQsbOffsetY();
+ int top = bottom - dp.hotseatQsbHeight;
mQsb.layout(left, top, right, bottom);
}
diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java
index 9b01734..67620e3 100644
--- a/src/com/android/launcher3/InvariantDeviceProfile.java
+++ b/src/com/android/launcher3/InvariantDeviceProfile.java
@@ -48,6 +48,7 @@
import androidx.annotation.VisibleForTesting;
import androidx.core.content.res.ResourcesCompat;
+import com.android.launcher3.icons.DotRenderer;
import com.android.launcher3.model.DeviceGridState;
import com.android.launcher3.provider.RestoreDbTask;
import com.android.launcher3.testing.shared.ResourceUtils;
@@ -396,10 +397,12 @@
final List<DeviceProfile> localSupportedProfiles = new ArrayList<>();
defaultWallpaperSize = new Point(displayInfo.currentSize);
+ SparseArray<DotRenderer> dotRendererCache = new SparseArray<>();
for (WindowBounds bounds : displayInfo.supportedBounds) {
localSupportedProfiles.add(new DeviceProfile.Builder(context, this, displayInfo)
.setUseTwoPanels(deviceType == TYPE_MULTI_DISPLAY)
.setWindowBounds(bounds)
+ .setDotRendererCache(dotRendererCache)
.build());
// Wallpaper size should be the maximum of the all possible sizes Launcher expects
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index 83d0752..2bc5e64 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -2424,7 +2424,8 @@
} else if ((mDragMode == DRAG_MODE_NONE || mDragMode == DRAG_MODE_REORDER)
&& !mReorderAlarm.alarmPending()
&& (mLastReorderX != reorderX || mLastReorderY != reorderY)
- && targetCellDistance < mDragTargetLayout.getReorderRadius(mTargetCell)) {
+ && targetCellDistance < mDragTargetLayout.getReorderRadius(mTargetCell, item.spanX,
+ item.spanY)) {
int[] resultSpan = new int[2];
mDragTargetLayout.performReorder((int) mDragViewVisualCenter[0],
diff --git a/src/com/android/launcher3/allapps/WorkModeSwitch.java b/src/com/android/launcher3/allapps/WorkModeSwitch.java
index aee7c4c..fedc91f 100644
--- a/src/com/android/launcher3/allapps/WorkModeSwitch.java
+++ b/src/com/android/launcher3/allapps/WorkModeSwitch.java
@@ -91,12 +91,12 @@
MarginLayoutParams lp = (MarginLayoutParams) getLayoutParams();
if (lp != null) {
int bottomMargin = getResources().getDimensionPixelSize(R.dimen.work_fab_margin_bottom);
+ DeviceProfile dp = ActivityContext.lookupContext(getContext()).getDeviceProfile();
if (FeatureFlags.ENABLE_FLOATING_SEARCH_BAR.get()) {
bottomMargin <<= 1; // Double margin to add space above search bar.
- bottomMargin += getResources().getDimensionPixelSize(R.dimen.qsb_widget_height);
+ bottomMargin += dp.hotseatQsbHeight;
}
- DeviceProfile dp = ActivityContext.lookupContext(getContext()).getDeviceProfile();
if (!dp.isGestureMode) {
if (dp.isTaskbarPresent) {
bottomMargin += dp.taskbarSize;
diff --git a/src/com/android/launcher3/graphics/ShadowDrawable.java b/src/com/android/launcher3/graphics/ShadowDrawable.java
deleted file mode 100644
index d8a7070..0000000
--- a/src/com/android/launcher3/graphics/ShadowDrawable.java
+++ /dev/null
@@ -1,213 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.launcher3.graphics;
-
-import android.annotation.TargetApi;
-import android.content.res.Resources;
-import android.content.res.TypedArray;
-import android.graphics.Bitmap;
-import android.graphics.BlurMaskFilter;
-import android.graphics.Canvas;
-import android.graphics.Color;
-import android.graphics.ColorFilter;
-import android.graphics.Paint;
-import android.graphics.PixelFormat;
-import android.graphics.Rect;
-import android.graphics.drawable.Drawable;
-import android.os.Build;
-import android.util.AttributeSet;
-
-import com.android.launcher3.R;
-import com.android.launcher3.icons.BitmapRenderer;
-
-import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserException;
-
-import java.io.IOException;
-
-/**
- * A drawable which adds shadow around a child drawable.
- */
-@TargetApi(Build.VERSION_CODES.O)
-public class ShadowDrawable extends Drawable {
-
- private final Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);
-
- private final ShadowDrawableState mState;
-
- @SuppressWarnings("unused")
- public ShadowDrawable() {
- this(new ShadowDrawableState());
- }
-
- private ShadowDrawable(ShadowDrawableState state) {
- mState = state;
- }
-
- @Override
- public void draw(Canvas canvas) {
- Rect bounds = getBounds();
- if (bounds.isEmpty()) {
- return;
- }
- if (mState.mLastDrawnBitmap == null) {
- regenerateBitmapCache();
- }
- canvas.drawBitmap(mState.mLastDrawnBitmap, null, bounds, mPaint);
- }
-
- @Override
- public void setAlpha(int alpha) {
- mPaint.setAlpha(alpha);
- invalidateSelf();
- }
-
- @Override
- public void setColorFilter(ColorFilter colorFilter) {
- mPaint.setColorFilter(colorFilter);
- invalidateSelf();
- }
-
- @Override
- public ConstantState getConstantState() {
- return mState;
- }
-
- @Override
- public int getOpacity() {
- return PixelFormat.TRANSLUCENT;
- }
-
- @Override
- public int getIntrinsicHeight() {
- return mState.mIntrinsicHeight;
- }
-
- @Override
- public int getIntrinsicWidth() {
- return mState.mIntrinsicWidth;
- }
-
- @Override
- public boolean canApplyTheme() {
- return mState.canApplyTheme();
- }
-
- @Override
- public void applyTheme(Resources.Theme t) {
- TypedArray ta = t.obtainStyledAttributes(new int[] {R.attr.isWorkspaceDarkText});
- boolean isDark = ta.getBoolean(0, false);
- ta.recycle();
- if (mState.mIsDark != isDark) {
- mState.mIsDark = isDark;
- mState.mLastDrawnBitmap = null;
- invalidateSelf();
- }
- }
-
- private void regenerateBitmapCache() {
- // Call mutate, so that the pixel allocation by the underlying vector drawable is cleared.
- Drawable d = mState.mChildState.newDrawable().mutate();
- d.setBounds(mState.mShadowSize, mState.mShadowSize,
- mState.mIntrinsicWidth - mState.mShadowSize,
- mState.mIntrinsicHeight - mState.mShadowSize);
- d.setTint(mState.mIsDark ? mState.mDarkTintColor : Color.WHITE);
-
- if (mState.mIsDark) {
- // Dark text do not have any shadow, but just the bitmap
- mState.mLastDrawnBitmap = BitmapRenderer.createHardwareBitmap(
- mState.mIntrinsicWidth, mState.mIntrinsicHeight, d::draw);
- } else {
- Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);
- paint.setMaskFilter(new BlurMaskFilter(mState.mShadowSize, BlurMaskFilter.Blur.NORMAL));
-
- // Generate the shadow bitmap
- int[] offset = new int[2];
- Bitmap shadow = BitmapRenderer.createSoftwareBitmap(
- mState.mIntrinsicWidth, mState.mIntrinsicHeight, d::draw)
- .extractAlpha(paint, offset);
-
- paint.setMaskFilter(null);
- paint.setColor(mState.mShadowColor);
- mState.mLastDrawnBitmap = BitmapRenderer.createHardwareBitmap(
- mState.mIntrinsicWidth, mState.mIntrinsicHeight, c -> {
- c.drawBitmap(shadow, offset[0], offset[1], paint);
- d.draw(c);
- });
- }
- }
-
- @Override
- public void inflate(Resources r, XmlPullParser parser, AttributeSet attrs,
- Resources.Theme theme) throws XmlPullParserException, IOException {
- super.inflate(r, parser, attrs, theme);
-
- final TypedArray a = theme == null
- ? r.obtainAttributes(attrs, R.styleable.ShadowDrawable)
- : theme.obtainStyledAttributes(attrs, R.styleable.ShadowDrawable, 0, 0);
- try {
- Drawable d = a.getDrawable(R.styleable.ShadowDrawable_android_src);
- if (d == null) {
- throw new XmlPullParserException("missing src attribute");
- }
- mState.mShadowColor = a.getColor(
- R.styleable.ShadowDrawable_android_shadowColor, Color.BLACK);
- mState.mShadowSize = a.getDimensionPixelSize(
- R.styleable.ShadowDrawable_android_elevation, 0);
- mState.mDarkTintColor = a.getColor(
- R.styleable.ShadowDrawable_darkTintColor, Color.BLACK);
-
- mState.mIntrinsicHeight = d.getIntrinsicHeight() + 2 * mState.mShadowSize;
- mState.mIntrinsicWidth = d.getIntrinsicWidth() + 2 * mState.mShadowSize;
- mState.mChangingConfigurations = d.getChangingConfigurations();
-
- mState.mChildState = d.getConstantState();
- } finally {
- a.recycle();
- }
- }
-
- private static class ShadowDrawableState extends ConstantState {
-
- int mChangingConfigurations;
- int mIntrinsicWidth;
- int mIntrinsicHeight;
-
- int mShadowColor;
- int mShadowSize;
- int mDarkTintColor;
-
- boolean mIsDark;
- Bitmap mLastDrawnBitmap;
- ConstantState mChildState;
-
- @Override
- public Drawable newDrawable() {
- return new ShadowDrawable(this);
- }
-
- @Override
- public int getChangingConfigurations() {
- return mChangingConfigurations;
- }
-
- @Override
- public boolean canApplyTheme() {
- return true;
- }
- }
-}
diff --git a/tests/src/com/android/launcher3/DeviceProfileBaseTest.kt b/tests/src/com/android/launcher3/DeviceProfileBaseTest.kt
index 4732fc1..7046782 100644
--- a/tests/src/com/android/launcher3/DeviceProfileBaseTest.kt
+++ b/tests/src/com/android/launcher3/DeviceProfileBaseTest.kt
@@ -18,6 +18,7 @@
import android.content.Context
import android.graphics.PointF
import android.graphics.Rect
+import android.util.SparseArray
import androidx.test.core.app.ApplicationProvider
import com.android.launcher3.util.DisplayController.Info
import com.android.launcher3.util.WindowBounds
@@ -56,6 +57,7 @@
inv,
info,
windowBounds,
+ SparseArray(),
isMultiWindowMode,
transposeLayoutWithOrientation,
useTwoPanels,