Snap for 7189849 from 39938cbc94 to sc-v2-release

Change-Id: Ic09b18969c9c09bb77b29e0af198a1c394521cc4
This commit is contained in:
android-build-team Robot committed 2021-03-07 00:08:46 +00:00
commit 0fea7a8ff3
11 files changed
+185 -16

No files matched your search

@@ -35,6 +35,7 @@ import android.view.View;
import androidx.annotation.Nullable;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.dragndrop.DragOptions;
import com.android.launcher3.model.WellbeingModel;
import com.android.launcher3.popup.SystemShortcut;
import com.android.launcher3.proxy.ProxyActivityStarter;
@@ -83,6 +84,8 @@ public abstract class BaseQuickstepLauncher extends Launcher
private @Nullable TaskbarController mTaskbarController;
private final TaskbarStateHandler mTaskbarStateHandler = new TaskbarStateHandler(this);
// Will be updated when dragging from taskbar.
private DragOptions mWorkspaceDragOptions = new DragOptions();
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -269,6 +272,15 @@ public abstract class BaseQuickstepLauncher extends Launcher
return mTaskbarController != null && mTaskbarController.isViewInTaskbar(v);
}
@Override
public DragOptions getDefaultWorkspaceDragOptions() {
return mWorkspaceDragOptions;
}
public void setWorkspaceDragOptions(DragOptions dragOptions) {
mWorkspaceDragOptions = dragOptions;
}
@Override
public void useFadeOutAnimationForLauncherStart(CancellationSignal signal) {
QuickstepAppTransitionManagerImpl appTransitionManager =
@@ -107,7 +107,8 @@ public class HotseatPredictionController implements DragController.DragListener,
WorkspaceItemInfo dragItem = new WorkspaceItemInfo((WorkspaceItemInfo) v.getTag());
v.setVisibility(View.INVISIBLE);
mLauncher.getWorkspace().beginDragShared(
v, null, this, dragItem, new DragPreviewProvider(v), new DragOptions());
v, null, this, dragItem, new DragPreviewProvider(v),
mLauncher.getDefaultWorkspaceDragOptions());
return true;
};
@@ -170,7 +170,14 @@ public class TaskbarController {
@Override
public View.OnLongClickListener getItemOnLongClickListener() {
return mDragController::startDragOnLongClick;
return view -> {
if (mLauncher.hasBeenResumed() && view.getTag() instanceof ItemInfo) {
alignRealHotseatWithTaskbar();
return mDragController.startWorkspaceDragOnLongClick(view);
} else {
return mDragController.startSystemDragOnLongClick(view);
}
};
}
@Override
@@ -33,6 +33,7 @@ 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;
@@ -57,7 +58,7 @@ public class TaskbarDragController {
* generate the ClipDescription and Intent.
* @return Whether {@link View#startDragAndDrop} started successfully.
*/
protected boolean startDragOnLongClick(View view) {
protected boolean startSystemDragOnLongClick(View view) {
if (!(view instanceof BubbleTextView)) {
return false;
}
@@ -124,6 +125,38 @@ 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,0 +1,99 @@
/*
* 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;
private final DragOptions mDragOptions;
// 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;
mDragOptions = new DragOptions();
mDragOptions.simulatedDndStartPoint = new Point();
mId = UUID.randomUUID().toString();
}
protected void init(DragLayer dragLayer) {
mDragLayer = dragLayer;
mDragLayer.setOnDragListener(this);
}
private void cleanup() {
mDragLayer.setOnDragListener(null);
mLauncher.setWorkspaceDragOptions(new DragOptions());
}
/**
* 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;
}
mDragOptions.simulatedDndStartPoint.set((int) dragEvent.getX(), (int) dragEvent.getY());
mLauncher.setWorkspaceDragOptions(mDragOptions);
hotseatView.performLongClick();
} else if (dragEvent.getAction() == DragEvent.ACTION_DRAG_ENDED) {
cleanup();
}
return mLauncher.getDragController().onDragEvent(dragEvent);
}
}
@@ -192,6 +192,7 @@ public class TaskbarView extends LinearLayout implements FolderIcon.FolderIconPa
} else {
hotseatView.setOnClickListener(null);
hotseatView.setOnLongClickListener(null);
hotseatView.setTag(null);
}
updateHotseatItemVisibility(hotseatView);
}
+8
View File
@@ -21,6 +21,7 @@ import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewDebug;
import android.view.ViewGroup;
import android.widget.FrameLayout;
@@ -166,4 +167,11 @@ public class Hotseat extends CellLayout implements Insettable {
protected void showInlineQsb() {
//Does nothing
}
/**
* Returns the first View for which the given itemOperator returns true, or null.
*/
public View getFirstItemMatch(Workspace.ItemOperator itemOperator) {
return mWorkspace.getFirstMatch(new CellLayout[] { this }, itemOperator);
}
}
+5
View File
@@ -121,6 +121,7 @@ import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.dot.DotInfo;
import com.android.launcher3.dragndrop.DragController;
import com.android.launcher3.dragndrop.DragLayer;
import com.android.launcher3.dragndrop.DragOptions;
import com.android.launcher3.dragndrop.DragView;
import com.android.launcher3.folder.FolderGridOrganizer;
import com.android.launcher3.folder.FolderIcon;
@@ -2863,6 +2864,10 @@ public class Launcher extends StatefulActivity<LauncherState> implements Launche
return false;
}
public DragOptions getDefaultWorkspaceDragOptions() {
return new DragOptions();
}
private static class NonConfigInstance {
public Configuration config;
public Bitmap snapshot;
+1 -1
View File
@@ -2973,7 +2973,7 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
* @param operators List of operators, in order starting from best matching operator.
* @return
*/
private View getFirstMatch(CellLayout[] cellLayouts, final ItemOperator... operators) {
View getFirstMatch(CellLayout[] cellLayouts, final ItemOperator... operators) {
// This array is filled with the first match for each operator.
final View[] matches = new View[operators.length];
// For efficiency, the outer loop should be CellLayout.
+14 -11
View File
@@ -192,6 +192,16 @@ public class LoaderTask implements Runnable {
loadWorkspace(allShortcuts);
logger.addSplit("loadWorkspace");
// Sanitize data re-syncs widgets/shortcuts based on the workspace loaded from db.
// sanitizeData should not be invoked if the workspace is loaded from a db different
// from the main db as defined in the invariant device profile.
// (e.g. both grid preview and minimal device mode uses a different db)
if (mApp.getInvariantDeviceProfile().dbFile.equals(mDbName)) {
verifyNotStopped();
sanitizeData();
logger.addSplit("sanitizeData");
}
verifyNotStopped();
mResults.bindWorkspace();
logger.addSplit("bindWorkspace");
@@ -274,14 +284,6 @@ public class LoaderTask implements Runnable {
loadFolderNames();
}
// Sanitize data re-syncs widgets/shortcuts based on the workspace loaded from db.
// sanitizeData should not be invoked if the workspace is loaded from a db different
// from the main db as defined in the invariant device profile.
// (e.g. both grid preview and minimal device mode uses a different db)
if (mApp.getInvariantDeviceProfile().dbFile.equals(mDbName)) {
sanitizeData();
}
verifyNotStopped();
updateHandler.finish();
logger.addSplit("finish icon update");
@@ -875,10 +877,11 @@ public class LoaderTask implements Runnable {
mBgDataModel.itemsIdMap.remove(folderId);
}
}
// Remove any ghost widgets
LauncherSettings.Settings.call(contentResolver,
LauncherSettings.Settings.METHOD_REMOVE_GHOST_WIDGETS);
}
// Remove any ghost widgets
LauncherSettings.Settings.call(contentResolver,
LauncherSettings.Settings.METHOD_REMOVE_GHOST_WIDGETS);
// Update pinned state of model shortcuts
mBgDataModel.updateShortcutPinnedState(context);
@@ -57,7 +57,7 @@ public class ItemLongClickListener {
if (!(v.getTag() instanceof ItemInfo)) return false;
launcher.setWaitingForResult(null);
beginDrag(v, launcher, (ItemInfo) v.getTag(), new DragOptions());
beginDrag(v, launcher, (ItemInfo) v.getTag(), launcher.getDefaultWorkspaceDragOptions());
return true;
}