From e63bd38a55e262ea98d2bbcea45ecef0fbd3e931 Mon Sep 17 00:00:00 2001 From: Tony Wickham Date: Mon, 22 Mar 2021 17:19:41 -0700 Subject: [PATCH] Remove dead taskbar code Test: Works as before Bug: 182512211 Change-Id: Id4c979f2924f9ae6881a9bed18bcc52fbd80c05b --- .../launcher3/BaseQuickstepLauncher.java | 4 - .../taskbar/TaskbarActivityContext.java | 12 +-- .../launcher3/taskbar/TaskbarController.java | 68 +++--------- .../taskbar/TaskbarDragController.java | 33 ------ .../taskbar/TaskbarDragListener.java | 101 ------------------ .../taskbar/TaskbarStateHandler.java | 10 +- .../taskbar/TaskbarVisibilityController.java | 18 +--- .../QuickstepAtomicAnimationFactory.java | 16 --- .../util/StaggeredWorkspaceAnim.java | 4 +- .../launcher3/AbstractFloatingView.java | 7 -- .../WorkspaceStateTransitionAnimation.java | 4 +- .../states/StateAnimationConfig.java | 8 +- 12 files changed, 28 insertions(+), 257 deletions(-) delete mode 100644 quickstep/src/com/android/launcher3/taskbar/TaskbarDragListener.java diff --git a/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java b/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java index 9ab49cebfa..6ba74145b2 100644 --- a/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java +++ b/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java @@ -338,10 +338,6 @@ public abstract class BaseQuickstepLauncher extends Launcher @Override public void onDragLayerHierarchyChanged() { onLauncherStateOrFocusChanged(); - - if (mTaskbarController != null) { - mTaskbarController.onLauncherDragLayerHierarchyChanged(); - } } @Override diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java index fc5e2c1740..5513c1658c 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java @@ -35,14 +35,13 @@ public class TaskbarActivityContext extends ContextWrapper implements ActivityCo private final DeviceProfile mDeviceProfile; private final LayoutInflater mLayoutInflater; private final TaskbarContainerView mTaskbarContainerView; - private final float mIconScale; public TaskbarActivityContext(BaseQuickstepLauncher launcher) { super(launcher); mDeviceProfile = launcher.getDeviceProfile().copy(this); float taskbarIconSize = getResources().getDimension(R.dimen.taskbar_icon_size); - mIconScale = taskbarIconSize / mDeviceProfile.iconSizePx; - mDeviceProfile.updateIconSize(mIconScale, getResources()); + float iconScale = taskbarIconSize / mDeviceProfile.iconSizePx; + mDeviceProfile.updateIconSize(iconScale, getResources()); mLayoutInflater = LayoutInflater.from(this).cloneInContext(this); @@ -73,11 +72,4 @@ public class TaskbarActivityContext extends ContextWrapper implements ActivityCo public Rect getFolderBoundingBox() { return mTaskbarContainerView.getFolderBoundingBox(); } - - /** - * @return The ratio of taskbar icon size vs normal workspace/hotseat icon size. - */ - public float getTaskbarIconScale() { - return mIconScale; - } } diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarController.java index abf6d54146..eccc41bfe2 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarController.java @@ -151,13 +151,22 @@ public class TaskbarController { ActivityManagerWrapper.getInstance().startActivityFromRecents(task.key, ActivityOptions.makeBasic()); } else if (tag instanceof FolderInfo) { - if (mLauncher.hasBeenResumed()) { - FolderInfo folderInfo = (FolderInfo) tag; - onClickedOnFolderFromHome(folderInfo); - } else { - FolderIcon folderIcon = (FolderIcon) view; - onClickedOnFolderInApp(folderIcon); - } + FolderIcon folderIcon = (FolderIcon) view; + Folder folder = folderIcon.getFolder(); + + setTaskbarWindowFullscreen(true); + + mTaskbarContainerView.post(() -> { + folder.animateOpen(); + + folder.iterateOverItems((itemInfo, itemView) -> { + itemView.setOnClickListener(getItemOnClickListener()); + itemView.setOnLongClickListener(getItemOnLongClickListener()); + // To play haptic when dragging, like other Taskbar items do. + itemView.setHapticFeedbackEnabled(true); + return false; + }); + }); } else { ItemClickHandler.INSTANCE.onClick(view); } @@ -167,44 +176,9 @@ public class TaskbarController { }; } - // Open the real folder in Launcher. - private void onClickedOnFolderFromHome(FolderInfo folderInfo) { - alignRealHotseatWithTaskbar(); - - FolderIcon folderIcon = (FolderIcon) mLauncher.getHotseat() - .getFirstItemMatch((info, v) -> info == folderInfo); - folderIcon.post(folderIcon::performClick); - } - - // Open the Taskbar folder, and handle clicks on folder items. - private void onClickedOnFolderInApp(FolderIcon folderIcon) { - Folder folder = folderIcon.getFolder(); - - setTaskbarWindowFullscreen(true); - - mTaskbarContainerView.post(() -> { - folder.animateOpen(); - - folder.iterateOverItems((itemInfo, itemView) -> { - itemView.setOnClickListener(getItemOnClickListener()); - itemView.setOnLongClickListener(getItemOnLongClickListener()); - // To play haptic when dragging, like other Taskbar items do. - itemView.setHapticFeedbackEnabled(true); - return false; - }); - }); - } - @Override public View.OnLongClickListener getItemOnLongClickListener() { - return view -> { - if (mLauncher.hasBeenResumed() && view.getTag() instanceof ItemInfo) { - // TODO: remove this path - return mDragController.startWorkspaceDragOnLongClick(view); - } else { - return mDragController.startSystemDragOnLongClick(view); - } - }; + return mDragController::startSystemDragOnLongClick; } @Override @@ -509,14 +483,6 @@ public class TaskbarController { mTaskbarViewOnHome.getHeight() - hotseatBounds.bottom); } - /** - * A view was added or removed from DragLayer, check if we need to hide our hotseat copy and - * show the real one instead. - */ - public void onLauncherDragLayerHierarchyChanged() { - // TODO: remove, as this is a no-op now - } - private void updateWhichTaskbarViewIsVisible() { boolean isInApp = !mLauncher.hasBeenResumed() || mIsAnimatingToLauncher || mIsAnimatingToApp; diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java index f51e49837d..5eb34cb360 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java @@ -33,7 +33,6 @@ import com.android.launcher3.BaseQuickstepLauncher; import com.android.launcher3.BubbleTextView; import com.android.launcher3.LauncherSettings; import com.android.launcher3.R; -import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.model.data.WorkspaceItemInfo; import com.android.systemui.shared.recents.model.Task; import com.android.systemui.shared.system.ClipDescriptionCompat; @@ -125,38 +124,6 @@ public class TaskbarDragController { return false; } - /** - * Starts a drag and drop operation that controls a real Workspace (Hotseat) view. - * @param view The Taskbar item that was long clicked. - * @return Whether {@link View#startDragAndDrop} started successfully. - */ - protected boolean startWorkspaceDragOnLongClick(View view) { - View.DragShadowBuilder transparentShadowBuilder = new View.DragShadowBuilder(view) { - private static final int ARBITRARY_SHADOW_SIZE = 10; - - @Override - public void onDrawShadow(Canvas canvas) { - } - - @Override - public void onProvideShadowMetrics(Point outShadowSize, Point outShadowTouchPoint) { - outShadowSize.set(ARBITRARY_SHADOW_SIZE, ARBITRARY_SHADOW_SIZE); - outShadowTouchPoint.set(ARBITRARY_SHADOW_SIZE / 2, ARBITRARY_SHADOW_SIZE / 2); - } - }; - - TaskbarDragListener taskbarDragListener = new TaskbarDragListener(mLauncher, - (ItemInfo) view.getTag()); - if (view.startDragAndDrop(new ClipData("", new String[] {taskbarDragListener.getMimeType()}, - new ClipData.Item("")), - transparentShadowBuilder, null /* localState */, View.DRAG_FLAG_GLOBAL)) { - view.setOnDragListener(getDraggedViewDragListener()); - taskbarDragListener.init(mLauncher.getDragLayer()); - return true; - } - return false; - } - /** * Hide the original Taskbar item while it is being dragged. */ diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarDragListener.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarDragListener.java deleted file mode 100644 index dc27df1909..0000000000 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarDragListener.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (C) 2021 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.taskbar; - -import android.content.ClipDescription; -import android.graphics.Point; -import android.view.DragEvent; -import android.view.View; - -import com.android.launcher3.BaseQuickstepLauncher; -import com.android.launcher3.dragndrop.DragLayer; -import com.android.launcher3.dragndrop.DragOptions; -import com.android.launcher3.model.data.ItemInfo; - -import java.util.UUID; - -/** - * Listens to system drag and drop events initated by the Taskbar, and forwards them to Launcher's - * internal DragController to move Hotseat items. - */ -public class TaskbarDragListener implements View.OnDragListener { - - private static final String MIME_TYPE_PREFIX = "com.android.launcher3.taskbar.drag_and_drop/"; - - private final BaseQuickstepLauncher mLauncher; - private final ItemInfo mDraggedItem; - // Randomly generated id used to verify the drag event. - private final String mId; - - // Initialized in init(). - DragLayer mDragLayer; - - /** - * @param draggedItem The info of the item that was long clicked, which we will use to find - * the equivalent match on Hotseat to drag internally. - */ - public TaskbarDragListener(BaseQuickstepLauncher launcher, ItemInfo draggedItem) { - mLauncher = launcher; - mDraggedItem = draggedItem; - mId = UUID.randomUUID().toString(); - } - - protected void init(DragLayer dragLayer) { - mDragLayer = dragLayer; - mDragLayer.setOnDragListener(this); - // Temporarily disable haptics, as system will already play one when drag and drop starts. - mDragLayer.setHapticFeedbackEnabled(false); - } - - private void cleanup() { - mDragLayer.setOnDragListener(null); - mLauncher.setNextWorkspaceDragOptions(null); - mDragLayer.setHapticFeedbackEnabled(true); - } - - /** - * Returns a randomly generated id used to verify the drag event. - */ - protected String getMimeType() { - return MIME_TYPE_PREFIX + mId; - } - - @Override - public boolean onDrag(View dragLayer, DragEvent dragEvent) { - ClipDescription clipDescription = dragEvent.getClipDescription(); - if (dragEvent.getAction() == DragEvent.ACTION_DRAG_STARTED) { - if (clipDescription == null || !clipDescription.hasMimeType(getMimeType())) { - // We didn't initiate this drag, ignore. - cleanup(); - return false; - } - View hotseatView = mLauncher.getHotseat().getFirstItemMatch( - (info, view) -> info == mDraggedItem); - if (hotseatView == null) { - cleanup(); - return false; - } - DragOptions dragOptions = new DragOptions(); - dragOptions.simulatedDndStartPoint = new Point((int) dragEvent.getX(), - (int) dragEvent.getY()); - mLauncher.setNextWorkspaceDragOptions(dragOptions); - hotseatView.performLongClick(); - } else if (dragEvent.getAction() == DragEvent.ACTION_DRAG_ENDED) { - cleanup(); - } - return mLauncher.getDragController().onDragEvent(dragEvent); - } -} diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarStateHandler.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarStateHandler.java index b4b5d8b3fe..0a3819dad5 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarStateHandler.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarStateHandler.java @@ -16,14 +16,12 @@ package com.android.launcher3.taskbar; import static com.android.launcher3.LauncherState.TASKBAR; -import static com.android.launcher3.states.StateAnimationConfig.ANIM_TASKBAR_FADE; -import static com.android.launcher3.states.StateAnimationConfig.SKIP_TASKBAR; +import static com.android.launcher3.anim.Interpolators.LINEAR; import androidx.annotation.Nullable; import com.android.launcher3.BaseQuickstepLauncher; import com.android.launcher3.LauncherState; -import com.android.launcher3.anim.Interpolators; import com.android.launcher3.anim.PendingAnimation; import com.android.launcher3.statemanager.StateManager; import com.android.launcher3.states.StateAnimationConfig; @@ -65,13 +63,9 @@ public class TaskbarStateHandler implements StateManager.StateHandler