Merge "Adjust height of tablet AllApps base on row height" 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/QuickstepTransitionManager.java b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java
index 5eb0e39..c089d1b 100644
--- a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java
+++ b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java
@@ -444,7 +444,7 @@
4 - rotationChange);
}
}
- if (mDeviceProfile.isTaskbarPresentInApps) {
+ if (mDeviceProfile.isTaskbarPresentInApps && !target.willShowImeOnTarget) {
// Animate to above the taskbar.
bounds.bottom -= target.contentInsets.bottom;
}
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 f38cdc8..0d41230 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -23,23 +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.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;
@@ -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();
@@ -479,10 +481,18 @@
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;
}
/**
@@ -576,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);
}
@@ -1484,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;
@@ -1500,6 +1518,10 @@
return this;
}
+ public Builder setDotRendererCache(SparseArray<DotRenderer> dotRendererCache) {
+ mDotRendererCache = dotRendererCache;
+ return this;
+ }
public Builder setWindowBounds(WindowBounds bounds) {
mWindowBounds = bounds;
@@ -1526,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/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/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,