Loading src/com/android/launcher3/ButtonDropTarget.java +0 −4 Original line number Diff line number Diff line Loading @@ -217,7 +217,6 @@ public abstract class ButtonDropTarget extends TextView final DragView dragView = d.dragView; final Rect to = getIconRect(d); final float scale = (float) to.width() / dragView.getMeasuredWidth(); dragView.disableColorExtraction(); dragView.detachContentView(/* reattachToPreviousParent= */ true); mDropTargetBar.deferOnDragEnd(); Loading @@ -225,9 +224,6 @@ public abstract class ButtonDropTarget extends TextView completeDrop(d); mDropTargetBar.onDragEnd(); mLauncher.getStateManager().goToState(NORMAL); // Only re-enable updates once the workspace is back to normal, which will be after the // current frame. post(dragView::resumeColorExtraction); }; dragLayer.animateView(d.dragView, to, scale, 0.1f, 0.1f, Loading src/com/android/launcher3/CellLayout.java +2 −9 Original line number Diff line number Diff line Loading @@ -18,7 +18,6 @@ package com.android.launcher3; import static android.animation.ValueAnimator.areAnimatorsEnabled; import static com.android.launcher3.Utilities.getBoundsForViewInDragLayer; import static com.android.launcher3.anim.Interpolators.DEACCEL_1_5; import android.animation.Animator; Loading Loading @@ -1071,18 +1070,12 @@ public class CellLayout extends ViewGroup { // Apply local extracted color if the DragView is an AppWidgetHostViewDrawable. View view = dragObject.dragView.getContentView(); if (view instanceof LauncherAppWidgetHostView) { Launcher launcher = Launcher.getLauncher(dragObject.dragView.getContext()); Launcher launcher = Launcher.getLauncher(getContext()); Workspace workspace = launcher.getWorkspace(); int screenId = workspace.getIdForScreen(this); int pageId = workspace.getPageIndexForScreenId(screenId); cellToRect(targetCell[0], targetCell[1], spanX, spanY, mTempRect); // Now get the rect in drag layer coordinates. getBoundsForViewInDragLayer(launcher.getDragLayer(), this, mTempRect, true, mTmpFloatArray, mTempRectF); Utilities.setRect(mTempRectF, mTempRect); ((LauncherAppWidgetHostView) view).handleDrag(mTempRect, pageId); ((LauncherAppWidgetHostView) view).handleDrag(mTempRect, this, screenId); } } Loading src/com/android/launcher3/DeviceProfile.java +4 −0 Original line number Diff line number Diff line Loading @@ -458,6 +458,10 @@ public class DeviceProfile { cellLayoutBorderSpacingPx = isScalableGrid ? borderSpacing : 0; } public Info getDisplayInfo() { return mInfo; } /** * We inset the widget padding added by the system and instead rely on the border spacing * between cells to create reliable consistency between widgets Loading src/com/android/launcher3/Workspace.java +12 −43 Original line number Diff line number Diff line Loading @@ -198,7 +198,6 @@ public class Workspace extends PagedView<WorkspacePageIndicator> private final int[] mTempXY = new int[2]; private final float[] mTempFXY = new float[2]; @Thunk float[] mDragViewVisualCenter = new float[2]; private final float[] mTempTouchCoordinates = new float[2]; private SpringLoadedDragController mSpringLoadedDragController; Loading @@ -208,8 +207,6 @@ public class Workspace extends PagedView<WorkspacePageIndicator> private boolean mStripScreensOnPageStopMoving = false; private DragPreviewProvider mOutlineProvider = null; private boolean mWorkspaceFadeInAdjacentScreens; final WallpaperOffsetInterpolator mWallpaperOffset; Loading Loading @@ -494,7 +491,6 @@ public class Workspace extends PagedView<WorkspacePageIndicator> }); mDragInfo = null; mOutlineProvider = null; mDragSourceInternal = null; } Loading Loading @@ -1333,11 +1329,7 @@ public class Workspace extends PagedView<WorkspacePageIndicator> position[0], position[1], 0, null); } public void prepareDragWithProvider(DragPreviewProvider outlineProvider) { mOutlineProvider = outlineProvider; } private void onStartStateTransition(LauncherState state) { private void onStartStateTransition() { mIsSwitchingState = true; mTransitionProgress = 0; Loading @@ -1358,7 +1350,7 @@ public class Workspace extends PagedView<WorkspacePageIndicator> */ @Override public void setState(LauncherState toState) { onStartStateTransition(toState); onStartStateTransition(); mStateTransitionAnimation.setState(toState); onEndStateTransition(); } Loading @@ -1369,7 +1361,7 @@ public class Workspace extends PagedView<WorkspacePageIndicator> @Override public void setStateWithAnimation( LauncherState toState, StateAnimationConfig config, PendingAnimation animation) { StateTransitionListener listener = new StateTransitionListener(toState); StateTransitionListener listener = new StateTransitionListener(); mStateTransitionAnimation.setStateWithAnimation(toState, config, animation); // Invalidate the pages now, so that we have the visible pages before the Loading Loading @@ -1478,8 +1470,6 @@ public class Workspace extends PagedView<WorkspacePageIndicator> icon.clearPressedBackground(); } mOutlineProvider = previewProvider; if (draggableView == null && child instanceof DraggableView) { draggableView = (DraggableView) child; } Loading Loading @@ -1791,17 +1781,14 @@ public class Workspace extends PagedView<WorkspacePageIndicator> int snapScreen = -1; boolean resizeOnDrop = false; Runnable onCompleteRunnable = null; if (d.dragSource != this || mDragInfo == null) { final int[] touchXY = new int[] { (int) mDragViewVisualCenter[0], (int) mDragViewVisualCenter[1] }; onDropExternal(touchXY, dropTargetLayout, d); } else { final View cell = mDragInfo.cell; final DragView dragView = d.dragView; boolean droppedOnOriginalCellDuringTransition = false; Runnable onCompleteRunnable = dragView::resumeColorExtraction; dragView.disableColorExtraction(); if (dropTargetLayout != null && !d.cancelled) { // Move internally Loading Loading @@ -1912,9 +1899,7 @@ public class Workspace extends PagedView<WorkspacePageIndicator> AppWidgetProviderInfo pInfo = hostView.getAppWidgetInfo(); if (pInfo != null && pInfo.resizeMode != AppWidgetProviderInfo.RESIZE_NONE && !options.isAccessibleDrag) { final Runnable previousRunnable = onCompleteRunnable; onCompleteRunnable = () -> { previousRunnable.run(); if (!isPageInTransition()) { AppWidgetResizeFrame.showForWidget(hostView, cellLayout); } Loading Loading @@ -1983,7 +1968,7 @@ public class Workspace extends PagedView<WorkspacePageIndicator> parent.onDropChild(cell); mLauncher.getStateManager().goToState(NORMAL, SPRING_LOADED_EXIT_DELAY, forSuccessCallback(onCompleteRunnable)); onCompleteRunnable == null ? null : forSuccessCallback(onCompleteRunnable)); mStatsLogManager.logger().withItemInfo(d.dragInfo).withInstanceId(d.logInstanceId) .log(LauncherEvent.LAUNCHER_ITEM_DROP_COMPLETED); } Loading Loading @@ -2301,25 +2286,16 @@ public class Workspace extends PagedView<WorkspacePageIndicator> int nextPage = getNextPage(); if (layout == null && !isPageInTransition()) { // Check if the item is dragged over currentPage - 1 page mTempTouchCoordinates[0] = Math.min(centerX, d.x); mTempTouchCoordinates[1] = d.y; layout = verifyInsidePage(nextPage + (mIsRtl ? 1 : -1), mTempTouchCoordinates); layout = verifyInsidePage(nextPage + (mIsRtl ? 1 : -1), Math.min(centerX, d.x), d.y); } if (layout == null && !isPageInTransition()) { // Check if the item is dragged over currentPage + 1 page mTempTouchCoordinates[0] = Math.max(centerX, d.x); mTempTouchCoordinates[1] = d.y; layout = verifyInsidePage(nextPage + (mIsRtl ? -1 : 1), mTempTouchCoordinates); layout = verifyInsidePage(nextPage + (mIsRtl ? -1 : 1), Math.max(centerX, d.x), d.y); } // If two panel is enabled, users can also drag items to currentPage + 2 if (isTwoPanelEnabled() && layout == null && !isPageInTransition()) { // Check if the item is dragged over currentPage + 2 page mTempTouchCoordinates[0] = Math.max(centerX, d.x); mTempTouchCoordinates[1] = d.y; layout = verifyInsidePage(nextPage + (mIsRtl ? -2 : 2), mTempTouchCoordinates); layout = verifyInsidePage(nextPage + (mIsRtl ? -2 : 2), Math.max(centerX, d.x), d.y); } // Always pick the current page. Loading @@ -2337,12 +2313,11 @@ public class Workspace extends PagedView<WorkspacePageIndicator> /** * Returns the child CellLayout if the point is inside the page coordinates, null otherwise. */ private CellLayout verifyInsidePage(int pageNo, float[] touchXy) { private CellLayout verifyInsidePage(int pageNo, float x, float y) { if (pageNo >= 0 && pageNo < getPageCount()) { CellLayout cl = (CellLayout) getChildAt(pageNo); mapPointFromSelfToChild(cl, touchXy); if (touchXy[0] >= 0 && touchXy[0] <= cl.getWidth() && touchXy[1] >= 0 && touchXy[1] <= cl.getHeight()) { if (x >= cl.getLeft() && x <= cl.getRight() && y >= cl.getTop() && y <= cl.getBottom()) { // This point is inside the cell layout return cl; } Loading Loading @@ -3341,12 +3316,6 @@ public class Workspace extends PagedView<WorkspacePageIndicator> private class StateTransitionListener extends AnimatorListenerAdapter implements AnimatorUpdateListener { private final LauncherState mToState; StateTransitionListener(LauncherState toState) { mToState = toState; } @Override public void onAnimationUpdate(ValueAnimator anim) { mTransitionProgress = anim.getAnimatedFraction(); Loading @@ -3354,7 +3323,7 @@ public class Workspace extends PagedView<WorkspacePageIndicator> @Override public void onAnimationStart(Animator animation) { onStartStateTransition(mToState); onStartStateTransition(); } @Override Loading src/com/android/launcher3/dragndrop/DragView.java +0 −29 Original line number Diff line number Diff line Loading @@ -65,7 +65,6 @@ import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.util.RunnableList; import com.android.launcher3.views.ActivityContext; import com.android.launcher3.views.BaseDragLayer; import com.android.launcher3.widget.LauncherAppWidgetHostView; /** A custom view for rendering an icon, folder, shortcut or widget during drag-n-drop. */ public abstract class DragView<T extends Context & ActivityContext> extends FrameLayout { Loading Loading @@ -299,16 +298,6 @@ public abstract class DragView<T extends Context & ActivityContext> extends Fram mOnDragStartCallback.executeAllAndDestroy(); } // TODO(b/183609936): This is only for LauncherAppWidgetHostView that is rendered in a drawable. // Once LauncherAppWidgetHostView is directly rendered in this view, removes this method. @Override public void invalidate() { super.invalidate(); if (mContent instanceof ImageView) { mContent.invalidate(); } } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(makeMeasureSpec(mWidth, EXACTLY), makeMeasureSpec(mHeight, EXACTLY)); Loading Loading @@ -487,24 +476,6 @@ public abstract class DragView<T extends Context & ActivityContext> extends Fram } } /** * If the drag view uses color extraction, block it. */ public void disableColorExtraction() { if (mContent instanceof LauncherAppWidgetHostView) { ((LauncherAppWidgetHostView) mContent).disableColorExtraction(); } } /** * If the drag view uses color extraction, restores it. */ public void resumeColorExtraction() { if (mContent instanceof LauncherAppWidgetHostView) { ((LauncherAppWidgetHostView) mContent).enableColorExtraction(/* updateColors= */ false); } } /** * Removes this view from the {@link DragLayer}. * Loading Loading
src/com/android/launcher3/ButtonDropTarget.java +0 −4 Original line number Diff line number Diff line Loading @@ -217,7 +217,6 @@ public abstract class ButtonDropTarget extends TextView final DragView dragView = d.dragView; final Rect to = getIconRect(d); final float scale = (float) to.width() / dragView.getMeasuredWidth(); dragView.disableColorExtraction(); dragView.detachContentView(/* reattachToPreviousParent= */ true); mDropTargetBar.deferOnDragEnd(); Loading @@ -225,9 +224,6 @@ public abstract class ButtonDropTarget extends TextView completeDrop(d); mDropTargetBar.onDragEnd(); mLauncher.getStateManager().goToState(NORMAL); // Only re-enable updates once the workspace is back to normal, which will be after the // current frame. post(dragView::resumeColorExtraction); }; dragLayer.animateView(d.dragView, to, scale, 0.1f, 0.1f, Loading
src/com/android/launcher3/CellLayout.java +2 −9 Original line number Diff line number Diff line Loading @@ -18,7 +18,6 @@ package com.android.launcher3; import static android.animation.ValueAnimator.areAnimatorsEnabled; import static com.android.launcher3.Utilities.getBoundsForViewInDragLayer; import static com.android.launcher3.anim.Interpolators.DEACCEL_1_5; import android.animation.Animator; Loading Loading @@ -1071,18 +1070,12 @@ public class CellLayout extends ViewGroup { // Apply local extracted color if the DragView is an AppWidgetHostViewDrawable. View view = dragObject.dragView.getContentView(); if (view instanceof LauncherAppWidgetHostView) { Launcher launcher = Launcher.getLauncher(dragObject.dragView.getContext()); Launcher launcher = Launcher.getLauncher(getContext()); Workspace workspace = launcher.getWorkspace(); int screenId = workspace.getIdForScreen(this); int pageId = workspace.getPageIndexForScreenId(screenId); cellToRect(targetCell[0], targetCell[1], spanX, spanY, mTempRect); // Now get the rect in drag layer coordinates. getBoundsForViewInDragLayer(launcher.getDragLayer(), this, mTempRect, true, mTmpFloatArray, mTempRectF); Utilities.setRect(mTempRectF, mTempRect); ((LauncherAppWidgetHostView) view).handleDrag(mTempRect, pageId); ((LauncherAppWidgetHostView) view).handleDrag(mTempRect, this, screenId); } } Loading
src/com/android/launcher3/DeviceProfile.java +4 −0 Original line number Diff line number Diff line Loading @@ -458,6 +458,10 @@ public class DeviceProfile { cellLayoutBorderSpacingPx = isScalableGrid ? borderSpacing : 0; } public Info getDisplayInfo() { return mInfo; } /** * We inset the widget padding added by the system and instead rely on the border spacing * between cells to create reliable consistency between widgets Loading
src/com/android/launcher3/Workspace.java +12 −43 Original line number Diff line number Diff line Loading @@ -198,7 +198,6 @@ public class Workspace extends PagedView<WorkspacePageIndicator> private final int[] mTempXY = new int[2]; private final float[] mTempFXY = new float[2]; @Thunk float[] mDragViewVisualCenter = new float[2]; private final float[] mTempTouchCoordinates = new float[2]; private SpringLoadedDragController mSpringLoadedDragController; Loading @@ -208,8 +207,6 @@ public class Workspace extends PagedView<WorkspacePageIndicator> private boolean mStripScreensOnPageStopMoving = false; private DragPreviewProvider mOutlineProvider = null; private boolean mWorkspaceFadeInAdjacentScreens; final WallpaperOffsetInterpolator mWallpaperOffset; Loading Loading @@ -494,7 +491,6 @@ public class Workspace extends PagedView<WorkspacePageIndicator> }); mDragInfo = null; mOutlineProvider = null; mDragSourceInternal = null; } Loading Loading @@ -1333,11 +1329,7 @@ public class Workspace extends PagedView<WorkspacePageIndicator> position[0], position[1], 0, null); } public void prepareDragWithProvider(DragPreviewProvider outlineProvider) { mOutlineProvider = outlineProvider; } private void onStartStateTransition(LauncherState state) { private void onStartStateTransition() { mIsSwitchingState = true; mTransitionProgress = 0; Loading @@ -1358,7 +1350,7 @@ public class Workspace extends PagedView<WorkspacePageIndicator> */ @Override public void setState(LauncherState toState) { onStartStateTransition(toState); onStartStateTransition(); mStateTransitionAnimation.setState(toState); onEndStateTransition(); } Loading @@ -1369,7 +1361,7 @@ public class Workspace extends PagedView<WorkspacePageIndicator> @Override public void setStateWithAnimation( LauncherState toState, StateAnimationConfig config, PendingAnimation animation) { StateTransitionListener listener = new StateTransitionListener(toState); StateTransitionListener listener = new StateTransitionListener(); mStateTransitionAnimation.setStateWithAnimation(toState, config, animation); // Invalidate the pages now, so that we have the visible pages before the Loading Loading @@ -1478,8 +1470,6 @@ public class Workspace extends PagedView<WorkspacePageIndicator> icon.clearPressedBackground(); } mOutlineProvider = previewProvider; if (draggableView == null && child instanceof DraggableView) { draggableView = (DraggableView) child; } Loading Loading @@ -1791,17 +1781,14 @@ public class Workspace extends PagedView<WorkspacePageIndicator> int snapScreen = -1; boolean resizeOnDrop = false; Runnable onCompleteRunnable = null; if (d.dragSource != this || mDragInfo == null) { final int[] touchXY = new int[] { (int) mDragViewVisualCenter[0], (int) mDragViewVisualCenter[1] }; onDropExternal(touchXY, dropTargetLayout, d); } else { final View cell = mDragInfo.cell; final DragView dragView = d.dragView; boolean droppedOnOriginalCellDuringTransition = false; Runnable onCompleteRunnable = dragView::resumeColorExtraction; dragView.disableColorExtraction(); if (dropTargetLayout != null && !d.cancelled) { // Move internally Loading Loading @@ -1912,9 +1899,7 @@ public class Workspace extends PagedView<WorkspacePageIndicator> AppWidgetProviderInfo pInfo = hostView.getAppWidgetInfo(); if (pInfo != null && pInfo.resizeMode != AppWidgetProviderInfo.RESIZE_NONE && !options.isAccessibleDrag) { final Runnable previousRunnable = onCompleteRunnable; onCompleteRunnable = () -> { previousRunnable.run(); if (!isPageInTransition()) { AppWidgetResizeFrame.showForWidget(hostView, cellLayout); } Loading Loading @@ -1983,7 +1968,7 @@ public class Workspace extends PagedView<WorkspacePageIndicator> parent.onDropChild(cell); mLauncher.getStateManager().goToState(NORMAL, SPRING_LOADED_EXIT_DELAY, forSuccessCallback(onCompleteRunnable)); onCompleteRunnable == null ? null : forSuccessCallback(onCompleteRunnable)); mStatsLogManager.logger().withItemInfo(d.dragInfo).withInstanceId(d.logInstanceId) .log(LauncherEvent.LAUNCHER_ITEM_DROP_COMPLETED); } Loading Loading @@ -2301,25 +2286,16 @@ public class Workspace extends PagedView<WorkspacePageIndicator> int nextPage = getNextPage(); if (layout == null && !isPageInTransition()) { // Check if the item is dragged over currentPage - 1 page mTempTouchCoordinates[0] = Math.min(centerX, d.x); mTempTouchCoordinates[1] = d.y; layout = verifyInsidePage(nextPage + (mIsRtl ? 1 : -1), mTempTouchCoordinates); layout = verifyInsidePage(nextPage + (mIsRtl ? 1 : -1), Math.min(centerX, d.x), d.y); } if (layout == null && !isPageInTransition()) { // Check if the item is dragged over currentPage + 1 page mTempTouchCoordinates[0] = Math.max(centerX, d.x); mTempTouchCoordinates[1] = d.y; layout = verifyInsidePage(nextPage + (mIsRtl ? -1 : 1), mTempTouchCoordinates); layout = verifyInsidePage(nextPage + (mIsRtl ? -1 : 1), Math.max(centerX, d.x), d.y); } // If two panel is enabled, users can also drag items to currentPage + 2 if (isTwoPanelEnabled() && layout == null && !isPageInTransition()) { // Check if the item is dragged over currentPage + 2 page mTempTouchCoordinates[0] = Math.max(centerX, d.x); mTempTouchCoordinates[1] = d.y; layout = verifyInsidePage(nextPage + (mIsRtl ? -2 : 2), mTempTouchCoordinates); layout = verifyInsidePage(nextPage + (mIsRtl ? -2 : 2), Math.max(centerX, d.x), d.y); } // Always pick the current page. Loading @@ -2337,12 +2313,11 @@ public class Workspace extends PagedView<WorkspacePageIndicator> /** * Returns the child CellLayout if the point is inside the page coordinates, null otherwise. */ private CellLayout verifyInsidePage(int pageNo, float[] touchXy) { private CellLayout verifyInsidePage(int pageNo, float x, float y) { if (pageNo >= 0 && pageNo < getPageCount()) { CellLayout cl = (CellLayout) getChildAt(pageNo); mapPointFromSelfToChild(cl, touchXy); if (touchXy[0] >= 0 && touchXy[0] <= cl.getWidth() && touchXy[1] >= 0 && touchXy[1] <= cl.getHeight()) { if (x >= cl.getLeft() && x <= cl.getRight() && y >= cl.getTop() && y <= cl.getBottom()) { // This point is inside the cell layout return cl; } Loading Loading @@ -3341,12 +3316,6 @@ public class Workspace extends PagedView<WorkspacePageIndicator> private class StateTransitionListener extends AnimatorListenerAdapter implements AnimatorUpdateListener { private final LauncherState mToState; StateTransitionListener(LauncherState toState) { mToState = toState; } @Override public void onAnimationUpdate(ValueAnimator anim) { mTransitionProgress = anim.getAnimatedFraction(); Loading @@ -3354,7 +3323,7 @@ public class Workspace extends PagedView<WorkspacePageIndicator> @Override public void onAnimationStart(Animator animation) { onStartStateTransition(mToState); onStartStateTransition(); } @Override Loading
src/com/android/launcher3/dragndrop/DragView.java +0 −29 Original line number Diff line number Diff line Loading @@ -65,7 +65,6 @@ import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.util.RunnableList; import com.android.launcher3.views.ActivityContext; import com.android.launcher3.views.BaseDragLayer; import com.android.launcher3.widget.LauncherAppWidgetHostView; /** A custom view for rendering an icon, folder, shortcut or widget during drag-n-drop. */ public abstract class DragView<T extends Context & ActivityContext> extends FrameLayout { Loading Loading @@ -299,16 +298,6 @@ public abstract class DragView<T extends Context & ActivityContext> extends Fram mOnDragStartCallback.executeAllAndDestroy(); } // TODO(b/183609936): This is only for LauncherAppWidgetHostView that is rendered in a drawable. // Once LauncherAppWidgetHostView is directly rendered in this view, removes this method. @Override public void invalidate() { super.invalidate(); if (mContent instanceof ImageView) { mContent.invalidate(); } } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(makeMeasureSpec(mWidth, EXACTLY), makeMeasureSpec(mHeight, EXACTLY)); Loading Loading @@ -487,24 +476,6 @@ public abstract class DragView<T extends Context & ActivityContext> extends Fram } } /** * If the drag view uses color extraction, block it. */ public void disableColorExtraction() { if (mContent instanceof LauncherAppWidgetHostView) { ((LauncherAppWidgetHostView) mContent).disableColorExtraction(); } } /** * If the drag view uses color extraction, restores it. */ public void resumeColorExtraction() { if (mContent instanceof LauncherAppWidgetHostView) { ((LauncherAppWidgetHostView) mContent).enableColorExtraction(/* updateColors= */ false); } } /** * Removes this view from the {@link DragLayer}. * Loading