Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 11bc3118 authored by Tony Wickham's avatar Tony Wickham Committed by Android (Google) Code Review
Browse files

Merge "Remove dead taskbar code" into sc-dev

parents a0d299f5 e63bd38a
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -338,10 +338,6 @@ public abstract class BaseQuickstepLauncher extends Launcher
    @Override
    public void onDragLayerHierarchyChanged() {
        onLauncherStateOrFocusChanged();

        if (mTaskbarController != null) {
            mTaskbarController.onLauncherDragLayerHierarchyChanged();
        }
    }

    @Override
+2 −10
Original line number Diff line number Diff line
@@ -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;
    }
}
+17 −51
Original line number Diff line number Diff line
@@ -151,33 +151,7 @@ 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);
                        }
                    } else {
                        ItemClickHandler.INSTANCE.onClick(view);
                    }

                    AbstractFloatingView.closeAllOpenViews(
                            mTaskbarContainerView.getTaskbarActivityContext());
                };
            }

            // 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);
@@ -193,18 +167,18 @@ public class TaskbarController {
                                return false;
                            });
                        });
                    } else {
                        ItemClickHandler.INSTANCE.onClick(view);
                    }

                    AbstractFloatingView.closeAllOpenViews(
                            mTaskbarContainerView.getTaskbarActivityContext());
                };
            }

            @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;
+0 −33
Original line number Diff line number Diff line
@@ -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.
     */
+0 −101
Original line number Diff line number Diff line
/*
 * 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);
    }
}
Loading