Merge "Remove dead taskbar code" into sc-dev

This commit is contained in:
Tony Wickham
2021-03-24 17:20:18 +00:00
committed by Android (Google) Code Review
12 changed files with 28 additions and 257 deletions

View File

@@ -338,10 +338,6 @@ public abstract class BaseQuickstepLauncher extends Launcher
@Override
public void onDragLayerHierarchyChanged() {
onLauncherStateOrFocusChanged();
if (mTaskbarController != null) {
mTaskbarController.onLauncherDragLayerHierarchyChanged();
}
}
@Override

View File

@@ -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;
}
}

View File

@@ -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;

View File

@@ -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.
*/

View File

@@ -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);
}
}

View File

@@ -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<LauncherSt
if (mTaskbarCallbacks == null) {
return;
}
if (config.hasAnimationFlag(SKIP_TASKBAR)) {
return;
}
AnimatedFloat alphaTarget = mTaskbarCallbacks.getAlphaTarget();
boolean isTaskbarVisible = (toState.getVisibleElements(mLauncher) & TASKBAR) != 0;
animation.setFloat(alphaTarget, AnimatedFloat.VALUE, isTaskbarVisible ? 1f : 0f,
config.getInterpolator(ANIM_TASKBAR_FADE, Interpolators.LINEAR));
animation.setFloat(alphaTarget, AnimatedFloat.VALUE, isTaskbarVisible ? 1f : 0f, LINEAR);
}
}

View File

@@ -31,21 +31,18 @@ import com.android.systemui.shared.system.QuickStepContract;
public class TaskbarVisibilityController {
private static final long IME_VISIBILITY_ALPHA_DURATION = 120;
private static final long FLOATING_VIEW_VISIBILITY_ALPHA_DURATION = 120;
private final BaseQuickstepLauncher mLauncher;
private final TaskbarController.TaskbarVisibilityControllerCallbacks mTaskbarCallbacks;
// Background alpha.
private AnimatedFloat mTaskbarBackgroundAlpha = new AnimatedFloat(
private final AnimatedFloat mTaskbarBackgroundAlpha = new AnimatedFloat(
this::onTaskbarBackgroundAlphaChanged);
// Overall visibility.
private AnimatedFloat mTaskbarVisibilityAlphaForLauncherState = new AnimatedFloat(
private final AnimatedFloat mTaskbarVisibilityAlphaForLauncherState = new AnimatedFloat(
this::updateVisibilityAlpha);
private AnimatedFloat mTaskbarVisibilityAlphaForIme = new AnimatedFloat(
this::updateVisibilityAlpha);
private AnimatedFloat mTaskbarVisibilityAlphaForFloatingView = new AnimatedFloat(
private final AnimatedFloat mTaskbarVisibilityAlphaForIme = new AnimatedFloat(
this::updateVisibilityAlpha);
public TaskbarVisibilityController(BaseQuickstepLauncher launcher,
@@ -62,7 +59,6 @@ public class TaskbarVisibilityController {
boolean isImeVisible = (SystemUiProxy.INSTANCE.get(mLauncher).getLastSystemUiStateFlags()
& QuickStepContract.SYSUI_STATE_IME_SHOWING) != 0;
mTaskbarVisibilityAlphaForIme.updateValue(isImeVisible ? 0f : 1f);
mTaskbarVisibilityAlphaForFloatingView.updateValue(1f);
onTaskbarBackgroundAlphaChanged();
updateVisibilityAlpha();
@@ -86,11 +82,6 @@ public class TaskbarVisibilityController {
.setDuration(IME_VISIBILITY_ALPHA_DURATION).start();
}
protected void animateToVisibilityForFloatingView(float toAlpha) {
mTaskbarVisibilityAlphaForIme.animateToValue(mTaskbarVisibilityAlphaForFloatingView.value,
toAlpha).setDuration(FLOATING_VIEW_VISIBILITY_ALPHA_DURATION).start();
}
private void onTaskbarBackgroundAlphaChanged() {
mTaskbarCallbacks.updateTaskbarBackgroundAlpha(mTaskbarBackgroundAlpha.value);
updateVisibilityAlpha();
@@ -102,8 +93,7 @@ public class TaskbarVisibilityController {
// LauncherState if Launcher is paused.
float alphaDueToLauncher = Math.max(mTaskbarBackgroundAlpha.value,
mTaskbarVisibilityAlphaForLauncherState.value);
float alphaDueToOther = mTaskbarVisibilityAlphaForIme.value
* mTaskbarVisibilityAlphaForFloatingView.value;
float alphaDueToOther = mTaskbarVisibilityAlphaForIme.value;
float taskbarAlpha = alphaDueToLauncher * alphaDueToOther;
mTaskbarCallbacks.updateTaskbarVisibilityAlpha(taskbarAlpha);

View File

@@ -18,7 +18,6 @@ package com.android.launcher3.uioverrides.states;
import static android.view.View.VISIBLE;
import static com.android.launcher3.LauncherState.HINT_STATE;
import static com.android.launcher3.LauncherState.HOTSEAT_ICONS;
import static com.android.launcher3.LauncherState.NORMAL;
import static com.android.launcher3.LauncherState.OVERVIEW;
import static com.android.launcher3.WorkspaceStateTransitionAnimation.getSpringScaleAnimator;
@@ -33,12 +32,10 @@ import static com.android.launcher3.anim.Interpolators.OVERSHOOT_1_2;
import static com.android.launcher3.anim.Interpolators.clampToProgress;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_ALL_APPS_FADE;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_DEPTH;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_HOTSEAT_FADE;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_FADE;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_SCALE;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_TRANSLATE_X;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_TRANSLATE_Y;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_TASKBAR_FADE;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_WORKSPACE_FADE;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_WORKSPACE_SCALE;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_WORKSPACE_TRANSLATE;
@@ -82,7 +79,6 @@ public class QuickstepAtomicAnimationFactory extends
if (toState == NORMAL && fromState == OVERVIEW) {
config.setInterpolator(ANIM_WORKSPACE_SCALE, DEACCEL);
config.setInterpolator(ANIM_WORKSPACE_FADE, ACCEL);
config.setInterpolator(ANIM_TASKBAR_FADE, ACCEL);
config.setInterpolator(ANIM_ALL_APPS_FADE, ACCEL);
config.setInterpolator(ANIM_OVERVIEW_SCALE, clampToProgress(ACCEL, 0, 0.9f));
config.setInterpolator(ANIM_OVERVIEW_TRANSLATE_X, ACCEL_DEACCEL);
@@ -141,7 +137,6 @@ public class QuickstepAtomicAnimationFactory extends
config.setInterpolator(ANIM_DEPTH, OVERSHOOT_1_2);
config.setInterpolator(ANIM_OVERVIEW_TRANSLATE_X, OVERSHOOT_1_2);
config.setInterpolator(ANIM_OVERVIEW_TRANSLATE_Y, OVERSHOOT_1_2);
config.setInterpolator(ANIM_TASKBAR_FADE, OVERSHOOT_1_2);
} else if (fromState == HINT_STATE && toState == NORMAL) {
config.setInterpolator(ANIM_DEPTH, DEACCEL_3);
if (mHintToNormalDuration == -1) {
@@ -150,17 +145,6 @@ public class QuickstepAtomicAnimationFactory extends
mHintToNormalDuration = (int) va.getDuration();
}
config.duration = Math.max(config.duration, mHintToNormalDuration);
} else if (mActivity.getTaskbarController() != null) {
boolean wasHotseatVisible = fromState.areElementsVisible(mActivity, HOTSEAT_ICONS);
boolean isHotseatVisible = toState.areElementsVisible(mActivity, HOTSEAT_ICONS);
if (wasHotseatVisible || isHotseatVisible) {
config.setInterpolator(ANIM_TASKBAR_FADE, INSTANT);
config.setInterpolator(ANIM_HOTSEAT_FADE, INSTANT);
if (isHotseatVisible) {
mActivity.getTaskbarController().alignRealHotseatWithTaskbar();
}
}
}
}
}

View File

@@ -24,7 +24,6 @@ import static com.android.launcher3.anim.PropertySetter.NO_ANIM_PROPERTY_SETTER;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_ALL_COMPONENTS;
import static com.android.launcher3.states.StateAnimationConfig.SKIP_DEPTH_CONTROLLER;
import static com.android.launcher3.states.StateAnimationConfig.SKIP_OVERVIEW;
import static com.android.launcher3.states.StateAnimationConfig.SKIP_TASKBAR;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
@@ -182,8 +181,7 @@ public class StaggeredWorkspaceAnim {
*/
private void prepareToAnimate(Launcher launcher, boolean animateOverviewScrim) {
StateAnimationConfig config = new StateAnimationConfig();
config.animFlags = ANIM_ALL_COMPONENTS | SKIP_OVERVIEW | SKIP_DEPTH_CONTROLLER
| SKIP_TASKBAR;
config.animFlags = ANIM_ALL_COMPONENTS | SKIP_OVERVIEW | SKIP_DEPTH_CONTROLLER;
config.duration = 0;
// setRecentsAttachedToAppWindow() will animate recents out.
launcher.getStateManager().createAtomicAnimation(BACKGROUND_APP, NORMAL, config).start();