Merge branch 'android15-release' into merge-aosp15
This commit is contained in:
@@ -18,8 +18,10 @@
|
||||
|
||||
package com.android.launcher3;
|
||||
|
||||
import static com.android.launcher3.BubbleTextView.DISPLAY_FOLDER;
|
||||
import static com.android.launcher3.Flags.enableSmartspaceRemovalToggle;
|
||||
import static com.android.launcher3.LauncherAnimUtils.SPRING_LOADED_EXIT_DELAY;
|
||||
import static com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_APPLICATION;
|
||||
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_HOTSEAT_PREDICTION;
|
||||
import static com.android.launcher3.LauncherState.ALL_APPS;
|
||||
import static com.android.launcher3.LauncherState.EDIT_MODE;
|
||||
import static com.android.launcher3.LauncherState.FLAG_MULTI_PAGE;
|
||||
@@ -29,6 +31,7 @@ import static com.android.launcher3.LauncherState.HINT_STATE;
|
||||
import static com.android.launcher3.LauncherState.NORMAL;
|
||||
import static com.android.launcher3.LauncherState.SPRING_LOADED;
|
||||
import static com.android.launcher3.MotionEventsUtils.isTrackpadMultiFingerSwipe;
|
||||
import static com.android.launcher3.Utilities.SHOULD_SHOW_FIRST_PAGE_WIDGET;
|
||||
import static com.android.launcher3.anim.AnimatorListeners.forSuccessCallback;
|
||||
import static com.android.launcher3.config.FeatureFlags.FOLDABLE_SINGLE_PAGE;
|
||||
import static com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_HOME;
|
||||
@@ -79,6 +82,8 @@ import com.android.app.animation.Interpolators;
|
||||
import com.android.launcher3.accessibility.AccessibleDragListenerAdapter;
|
||||
import com.android.launcher3.accessibility.WorkspaceAccessibilityHelper;
|
||||
import com.android.launcher3.anim.PendingAnimation;
|
||||
import com.android.launcher3.apppairs.AppPairIcon;
|
||||
import com.android.launcher3.celllayout.CellInfo;
|
||||
import com.android.launcher3.celllayout.CellLayoutLayoutParams;
|
||||
import com.android.launcher3.celllayout.CellPosMapper;
|
||||
import com.android.launcher3.celllayout.CellPosMapper.CellPos;
|
||||
@@ -100,10 +105,10 @@ import com.android.launcher3.logger.LauncherAtom;
|
||||
import com.android.launcher3.logging.InstanceId;
|
||||
import com.android.launcher3.logging.StatsLogManager;
|
||||
import com.android.launcher3.logging.StatsLogManager.LauncherEvent;
|
||||
import com.android.launcher3.model.data.AppPairInfo;
|
||||
import com.android.launcher3.model.data.FolderInfo;
|
||||
import com.android.launcher3.model.data.ItemInfo;
|
||||
import com.android.launcher3.model.data.LauncherAppWidgetInfo;
|
||||
import com.android.launcher3.model.data.WorkspaceItemFactory;
|
||||
import com.android.launcher3.model.data.WorkspaceItemInfo;
|
||||
import com.android.launcher3.pageindicators.PageIndicator;
|
||||
import com.android.launcher3.statemanager.StateManager;
|
||||
@@ -129,12 +134,12 @@ import com.android.launcher3.widget.PendingAddShortcutInfo;
|
||||
import com.android.launcher3.widget.PendingAddWidgetInfo;
|
||||
import com.android.launcher3.widget.PendingAppWidgetHostView;
|
||||
import com.android.launcher3.widget.WidgetManagerHelper;
|
||||
import com.android.launcher3.widget.dragndrop.AppWidgetHostViewDragListener;
|
||||
import com.android.launcher3.widget.util.WidgetSizes;
|
||||
import com.android.systemui.plugins.shared.LauncherOverlayManager.LauncherOverlay;
|
||||
import com.google.android.renderscript.Toolkit;
|
||||
import com.patrykmichalik.opto.core.PreferenceExtensionsKt;
|
||||
import com.android.systemui.plugins.shared.LauncherOverlayManager.LauncherOverlayCallbacks;
|
||||
import com.android.systemui.plugins.shared.LauncherOverlayManager.LauncherOverlayTouchProxy;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
@@ -158,7 +163,7 @@ import app.lawnchair.util.LawnchairUtilsKt;
|
||||
* @param <T> Class that extends View and PageIndicator
|
||||
*/
|
||||
public class Workspace<T extends View & PageIndicator> extends PagedView<T>
|
||||
implements DropTarget, DragSource, View.OnTouchListener,
|
||||
implements DropTarget, DragSource, View.OnTouchListener, CellLayoutContainer,
|
||||
DragController.DragListener, Insettable, StateHandler<LauncherState>,
|
||||
WorkspaceLayoutManager, LauncherBindableItemsContainer, LauncherOverlayCallbacks {
|
||||
|
||||
@@ -203,7 +208,7 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
|
||||
/**
|
||||
* CellInfo for the cell that is currently being dragged
|
||||
*/
|
||||
protected CellLayout.CellInfo mDragInfo;
|
||||
protected CellInfo mDragInfo;
|
||||
|
||||
/**
|
||||
* Target drop area calculated during last acceptDrop call.
|
||||
@@ -255,6 +260,8 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
|
||||
public static final int REORDER_TIMEOUT = 650;
|
||||
protected final Alarm mReorderAlarm = new Alarm();
|
||||
private PreviewBackground mFolderCreateBg;
|
||||
/** The underlying view that we are dragging something over. */
|
||||
private View mDragOverView = null;
|
||||
private FolderIcon mDragOverFolderIcon = null;
|
||||
private boolean mCreateUserFolderOnDrop = false;
|
||||
private boolean mAddToExistingFolderOnDrop = false;
|
||||
@@ -354,7 +361,9 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
|
||||
var blurThreshold = mPreferenceManger.getWallpaperBlurFactorThreshold().get();
|
||||
var wallpaperBitmap = mWallpaperManager.getDrawable();
|
||||
try {
|
||||
mWallpaperManager.setBitmap(LawnchairUtilsKt.blurBitmap(toBitmap(wallpaperBitmap),blurWallpaper, blurThreshold), null, true, WallpaperManager.FLAG_SYSTEM);
|
||||
mWallpaperManager.setBitmap(
|
||||
LawnchairUtilsKt.blurBitmap(toBitmap(wallpaperBitmap), blurWallpaper, blurThreshold), null,
|
||||
true, WallpaperManager.FLAG_SYSTEM);
|
||||
mWallpaperManager.forgetLoadedWallpaper();
|
||||
} catch (Exception ex) {
|
||||
Log.e(TAG, "error failed bluring wallpaper");
|
||||
@@ -384,7 +393,7 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
|
||||
setPageSpacing(Math.max(maxInsets, maxPadding));
|
||||
}
|
||||
|
||||
updateCellLayoutPadding();
|
||||
updateCellLayoutMeasures();
|
||||
updateWorkspaceWidgetsSizes();
|
||||
setPageIndicatorInset();
|
||||
updateWorkspaceScreensPadding();
|
||||
@@ -438,10 +447,12 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
|
||||
mPageIndicator.setLayoutParams(lp);
|
||||
}
|
||||
|
||||
private void updateCellLayoutPadding() {
|
||||
private void updateCellLayoutMeasures() {
|
||||
Rect padding = mLauncher.getDeviceProfile().cellLayoutPaddingPx;
|
||||
mWorkspaceScreens.forEach(
|
||||
s -> s.setPadding(padding.left, padding.top, padding.right, padding.bottom));
|
||||
mWorkspaceScreens.forEach(cellLayout -> {
|
||||
cellLayout.setPadding(padding.left, padding.top, padding.right, padding.bottom);
|
||||
cellLayout.setSpaceBetweenCellLayoutsPx(getPageSpacing() / 4);
|
||||
});
|
||||
}
|
||||
|
||||
private void updateWorkspaceWidgetsSizes() {
|
||||
@@ -515,7 +526,8 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
|
||||
|
||||
public Rect estimateItemPosition(CellLayout cl, int hCell, int vCell, int hSpan, int vSpan) {
|
||||
Rect r = new Rect();
|
||||
if (cl == null) return r;
|
||||
if (cl == null)
|
||||
return r;
|
||||
cl.cellToRect(hCell, vCell, hSpan, vSpan, r);
|
||||
return r;
|
||||
}
|
||||
@@ -582,11 +594,6 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
|
||||
return !FOLDABLE_SINGLE_PAGE.get() && mLauncher.mDeviceProfile.isTwoPanels;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPanelCount() {
|
||||
return isTwoPanelEnabled() ? 2 : super.getPanelCount();
|
||||
}
|
||||
|
||||
public void deferRemoveExtraEmptyScreen() {
|
||||
mDeferRemoveExtraEmptyScreen = true;
|
||||
}
|
||||
@@ -598,7 +605,7 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
|
||||
}
|
||||
|
||||
updateChildrenLayersEnabled();
|
||||
StateManager<LauncherState> stateManager = mLauncher.getStateManager();
|
||||
StateManager<LauncherState, Launcher> stateManager = mLauncher.getStateManager();
|
||||
stateManager.addStateListener(new StateManager.StateListener<LauncherState>() {
|
||||
@Override
|
||||
public void onStateTransitionComplete(LauncherState finalState) {
|
||||
@@ -708,7 +715,7 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
|
||||
// transition animations competing with us changing the scroll when we add pages
|
||||
disableLayoutTransitions();
|
||||
|
||||
// Recycle the QSB widget
|
||||
// Recycle the first page pinned item
|
||||
if (mFirstPagePinnedItem != null) {
|
||||
ViewGroup viewGroup = (ViewGroup) mFirstPagePinnedItem.getParent();
|
||||
if (viewGroup != null) {
|
||||
@@ -722,12 +729,14 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
|
||||
mScreenOrder.clear();
|
||||
mWorkspaceScreens.clear();
|
||||
|
||||
// Ensure that the first page is always present
|
||||
if (!enableSmartspaceRemovalToggle()) {
|
||||
bindAndInitFirstWorkspaceScreen();
|
||||
}
|
||||
|
||||
// Remove any deferred refresh callbacks
|
||||
mLauncher.mHandler.removeCallbacksAndMessages(DeferredWidgetRefresh.class);
|
||||
|
||||
// Ensure that the first page is always present
|
||||
bindAndInitFirstWorkspaceScreen();
|
||||
|
||||
// Re-enable the layout transitions
|
||||
enableLayoutTransitions();
|
||||
}
|
||||
@@ -763,6 +772,7 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
|
||||
newScreen = (CellLayout) LayoutInflater.from(getContext()).inflate(
|
||||
R.layout.workspace_screen, this, false /* attachToRoot */);
|
||||
}
|
||||
newScreen.setCellLayoutContainer(this);
|
||||
|
||||
mWorkspaceScreens.put(screenId, newScreen);
|
||||
mScreenOrder.add(insertIndex, screenId);
|
||||
@@ -771,7 +781,7 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
|
||||
mLauncher.getStateManager().getState(), newScreen, insertIndex);
|
||||
|
||||
updatePageScrollValues();
|
||||
updateCellLayoutPadding();
|
||||
updateCellLayoutMeasures();
|
||||
return newScreen;
|
||||
}
|
||||
|
||||
@@ -892,6 +902,14 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
|
||||
// and we store them as extra empty screens.
|
||||
for (int i = 0; i < finalScreens.size(); i++) {
|
||||
int screenId = finalScreens.keyAt(i);
|
||||
|
||||
// We don't want to remove the first screen even if it's empty because that's
|
||||
// where
|
||||
// first page pinned item would go if it gets turned back on.
|
||||
if (enableSmartspaceRemovalToggle() && screenId == FIRST_SCREEN_ID) {
|
||||
continue;
|
||||
}
|
||||
|
||||
CellLayout screen = finalScreens.get(screenId);
|
||||
|
||||
mWorkspaceScreens.remove(screenId);
|
||||
@@ -1037,7 +1055,8 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
|
||||
return mWorkspaceScreens.get(screenId);
|
||||
}
|
||||
|
||||
public int getIdForScreen(CellLayout layout) {
|
||||
@Override
|
||||
public int getCellLayoutId(CellLayout layout) {
|
||||
int index = mWorkspaceScreens.indexOfValue(layout);
|
||||
if (index != -1) {
|
||||
return mWorkspaceScreens.keyAt(index);
|
||||
@@ -1049,6 +1068,16 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
|
||||
return indexOfChild(mWorkspaceScreens.get(screenId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCellLayoutIndex(CellLayout cellLayout) {
|
||||
return indexOfChild(mWorkspaceScreens.get(getCellLayoutId(cellLayout)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPanelCount() {
|
||||
return isTwoPanelEnabled() ? 2 : super.getPanelCount();
|
||||
}
|
||||
|
||||
public IntSet getCurrentPageScreenIds() {
|
||||
return IntSet.wrap(getScreenIdForPageIndex(getCurrentPage()));
|
||||
}
|
||||
@@ -1091,7 +1120,7 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
|
||||
if (!isTwoPanelEnabled()) {
|
||||
return null;
|
||||
}
|
||||
int screenId = getIdForScreen(cellLayout);
|
||||
int screenId = getCellLayoutId(cellLayout);
|
||||
if (screenId == -1) {
|
||||
return null;
|
||||
}
|
||||
@@ -1270,7 +1299,8 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
|
||||
|
||||
private boolean isEventOverQsb(float x, float y) {
|
||||
CellLayout target = (CellLayout) getChildAt(mCurrentPage);
|
||||
if (target.getShortcutsAndWidgets() == null) return false;
|
||||
if (target.getShortcutsAndWidgets() == null)
|
||||
return false;
|
||||
ShortcutAndWidgetContainer container = target.getShortcutsAndWidgets();
|
||||
mTempFXY[0] = x;
|
||||
mTempFXY[1] = y;
|
||||
@@ -1359,7 +1389,7 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
|
||||
mLauncher.onPageEndTransition();
|
||||
}
|
||||
|
||||
public void setLauncherOverlay(LauncherOverlay overlay) {
|
||||
public void setLauncherOverlay(LauncherOverlayTouchProxy overlay) {
|
||||
final EdgeEffectCompat newEffect;
|
||||
if (overlay == null) {
|
||||
newEffect = new EdgeEffectCompat(getContext());
|
||||
@@ -1762,7 +1792,7 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
|
||||
page.setAccessibilityDelegate(null);
|
||||
}
|
||||
|
||||
public void startDrag(CellLayout.CellInfo cellInfo, DragOptions options) {
|
||||
public void startDrag(CellInfo cellInfo, DragOptions options) {
|
||||
View child = cellInfo.cell;
|
||||
|
||||
mDragInfo = cellInfo;
|
||||
@@ -1772,9 +1802,15 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
|
||||
mDragController.addDragListener(
|
||||
new AccessibleDragListenerAdapter(this, WorkspaceAccessibilityHelper::new) {
|
||||
@Override
|
||||
protected void enableAccessibleDrag(boolean enable) {
|
||||
super.enableAccessibleDrag(enable);
|
||||
protected void enableAccessibleDrag(boolean enable,
|
||||
@Nullable DragObject dragObject) {
|
||||
super.enableAccessibleDrag(enable, dragObject);
|
||||
setEnableForLayout(mLauncher.getHotseat(), enable);
|
||||
if (enable && dragObject != null
|
||||
&& dragObject.dragInfo instanceof LauncherAppWidgetInfo) {
|
||||
mLauncher.getHotseat().setImportantForAccessibility(
|
||||
IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1878,9 +1914,6 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
|
||||
|
||||
final DragView dv;
|
||||
if (contentView instanceof View) {
|
||||
if (contentView instanceof LauncherAppWidgetHostView) {
|
||||
mDragController.addDragListener(new AppWidgetHostViewDragListener(mLauncher));
|
||||
}
|
||||
dv = mDragController.startDrag(
|
||||
contentView,
|
||||
draggableView,
|
||||
@@ -1936,7 +1969,7 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
|
||||
int spanX;
|
||||
int spanY;
|
||||
if (mDragInfo != null) {
|
||||
final CellLayout.CellInfo dragCellInfo = mDragInfo;
|
||||
final CellInfo dragCellInfo = mDragInfo;
|
||||
spanX = dragCellInfo.spanX;
|
||||
spanY = dragCellInfo.spanY;
|
||||
} else {
|
||||
@@ -1979,7 +2012,7 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
|
||||
}
|
||||
}
|
||||
|
||||
int screenId = getIdForScreen(dropTargetLayout);
|
||||
int screenId = getCellLayoutId(dropTargetLayout);
|
||||
if (Workspace.EXTRA_EMPTY_SCREEN_IDS.contains(screenId)) {
|
||||
commitExtraEmptyScreens();
|
||||
}
|
||||
@@ -2013,11 +2046,9 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean aboveShortcut = (dropOverView.getTag() instanceof WorkspaceItemInfo
|
||||
&& ((WorkspaceItemInfo) dropOverView
|
||||
.getTag()).container != LauncherSettings.Favorites.CONTAINER_HOTSEAT_PREDICTION);
|
||||
boolean willBecomeShortcut = (info.itemType == ITEM_TYPE_APPLICATION ||
|
||||
info.itemType == LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT);
|
||||
boolean aboveShortcut = Folder.willAccept(dropOverView.getTag())
|
||||
&& ((ItemInfo) dropOverView.getTag()).container != CONTAINER_HOTSEAT_PREDICTION;
|
||||
boolean willBecomeShortcut = Folder.willAcceptItemType(info.itemType);
|
||||
|
||||
return (aboveShortcut && willBecomeShortcut);
|
||||
}
|
||||
@@ -2065,14 +2096,14 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
|
||||
if (v == null || hasntMoved || !mCreateUserFolderOnDrop)
|
||||
return false;
|
||||
mCreateUserFolderOnDrop = false;
|
||||
final int screenId = getIdForScreen(target);
|
||||
final int screenId = getCellLayoutId(target);
|
||||
|
||||
boolean aboveShortcut = (v.getTag() instanceof WorkspaceItemInfo);
|
||||
boolean willBecomeShortcut = (newView.getTag() instanceof WorkspaceItemInfo);
|
||||
boolean aboveShortcut = Folder.willAccept(v.getTag());
|
||||
boolean willBecomeShortcut = Folder.willAccept(newView.getTag());
|
||||
|
||||
if (aboveShortcut && willBecomeShortcut) {
|
||||
WorkspaceItemInfo sourceInfo = (WorkspaceItemInfo) newView.getTag();
|
||||
WorkspaceItemInfo destInfo = (WorkspaceItemInfo) v.getTag();
|
||||
ItemInfo sourceInfo = (ItemInfo) newView.getTag();
|
||||
ItemInfo destInfo = (ItemInfo) v.getTag();
|
||||
// if the drag started here, we need to remove it from the workspace
|
||||
if (!external) {
|
||||
getParentCellLayoutForView(mDragInfo.cell).removeView(mDragInfo.cell);
|
||||
@@ -2096,7 +2127,7 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
|
||||
// In order to keep everything continuous, we hand off the currently rendered
|
||||
// folder background to the newly created icon. This preserves animation state.
|
||||
fi.setFolderBackground(mFolderCreateBg);
|
||||
mFolderCreateBg = new PreviewBackground();
|
||||
mFolderCreateBg = new PreviewBackground(getContext());
|
||||
fi.performCreateAnimation(destInfo, v, sourceInfo, d, folderLocation, scale);
|
||||
} else {
|
||||
fi.prepareCreateAnimation(v);
|
||||
@@ -2168,7 +2199,7 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
|
||||
boolean hasMovedIntoHotseat = mLauncher.isHotseatLayout(dropTargetLayout);
|
||||
int container = hasMovedIntoHotseat ? LauncherSettings.Favorites.CONTAINER_HOTSEAT
|
||||
: LauncherSettings.Favorites.CONTAINER_DESKTOP;
|
||||
int screenId = (mTargetCell[0] < 0) ? mDragInfo.screenId : getIdForScreen(dropTargetLayout);
|
||||
int screenId = (mTargetCell[0] < 0) ? mDragInfo.screenId : getCellLayoutId(dropTargetLayout);
|
||||
int spanX = mDragInfo != null ? mDragInfo.spanX : 1;
|
||||
int spanY = mDragInfo != null ? mDragInfo.spanY : 1;
|
||||
// First we find the cell nearest to point at which the item is
|
||||
@@ -2499,10 +2530,6 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
|
||||
}
|
||||
}
|
||||
|
||||
public CellLayout getCurrentDragOverlappingLayout() {
|
||||
return mDragOverlappingLayout;
|
||||
}
|
||||
|
||||
void setCurrentDropOverCell(int x, int y) {
|
||||
if (x != mDragOverX || y != mDragOverY) {
|
||||
mDragOverX = x;
|
||||
@@ -2537,6 +2564,11 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
|
||||
if (mFolderCreateBg != null) {
|
||||
mFolderCreateBg.animateToRest();
|
||||
}
|
||||
|
||||
if (mDragOverView instanceof AppPairIcon api) {
|
||||
api.getIconDrawableArea().onTemporaryContainerChange(null);
|
||||
mDragOverView = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void cleanupAddToFolder() {
|
||||
@@ -2822,32 +2854,36 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
|
||||
return;
|
||||
}
|
||||
|
||||
final View dragOverView = mDragTargetLayout.getChildAt(mTargetCell[0], mTargetCell[1]);
|
||||
mDragOverView = mDragTargetLayout.getChildAt(mTargetCell[0], mTargetCell[1]);
|
||||
ItemInfo info = dragObject.dragInfo;
|
||||
boolean userFolderPending = willCreateUserFolder(info, dragOverView, false);
|
||||
boolean userFolderPending = willCreateUserFolder(info, mDragOverView, false);
|
||||
if (mDragMode == DRAG_MODE_NONE && userFolderPending) {
|
||||
|
||||
mFolderCreateBg = new PreviewBackground();
|
||||
mFolderCreateBg = new PreviewBackground(getContext());
|
||||
mFolderCreateBg.setup(mLauncher, mLauncher, null,
|
||||
dragOverView.getMeasuredWidth(), dragOverView.getPaddingTop());
|
||||
mDragOverView.getMeasuredWidth(), mDragOverView.getPaddingTop());
|
||||
|
||||
// The full preview background should appear behind the icon
|
||||
mFolderCreateBg.isClipping = false;
|
||||
|
||||
if (mDragOverView instanceof AppPairIcon api) {
|
||||
api.getIconDrawableArea().onTemporaryContainerChange(DISPLAY_FOLDER);
|
||||
}
|
||||
|
||||
mFolderCreateBg.animateToAccept(mDragTargetLayout, mTargetCell[0], mTargetCell[1]);
|
||||
mDragTargetLayout.clearDragOutlines();
|
||||
setDragMode(DRAG_MODE_CREATE_FOLDER);
|
||||
|
||||
if (dragObject.stateAnnouncer != null) {
|
||||
dragObject.stateAnnouncer.announce(WorkspaceAccessibilityHelper
|
||||
.getDescriptionForDropOver(dragOverView, getContext()));
|
||||
.getDescriptionForDropOver(mDragOverView, getContext()));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
boolean willAddToFolder = willAddToExistingUserFolder(info, dragOverView);
|
||||
boolean willAddToFolder = willAddToExistingUserFolder(info, mDragOverView);
|
||||
if (willAddToFolder && mDragMode == DRAG_MODE_NONE) {
|
||||
mDragOverFolderIcon = ((FolderIcon) dragOverView);
|
||||
mDragOverFolderIcon = ((FolderIcon) mDragOverView);
|
||||
mDragOverFolderIcon.onDragEnter(info);
|
||||
if (mDragTargetLayout != null) {
|
||||
mDragTargetLayout.clearDragOutlines();
|
||||
@@ -2856,7 +2892,7 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
|
||||
|
||||
if (dragObject.stateAnnouncer != null) {
|
||||
dragObject.stateAnnouncer.announce(WorkspaceAccessibilityHelper
|
||||
.getDescriptionForDropOver(dragOverView, getContext()));
|
||||
.getDescriptionForDropOver(mDragOverView, getContext()));
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -2945,7 +2981,7 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
|
||||
final int container = mLauncher.isHotseatLayout(cellLayout)
|
||||
? LauncherSettings.Favorites.CONTAINER_HOTSEAT
|
||||
: LauncherSettings.Favorites.CONTAINER_DESKTOP;
|
||||
final int screenId = getIdForScreen(cellLayout);
|
||||
final int screenId = getCellLayoutId(cellLayout);
|
||||
if (!mLauncher.isHotseatLayout(cellLayout)
|
||||
&& screenId != getScreenIdForPageIndex(mCurrentPage)
|
||||
&& !mLauncher.isInState(SPRING_LOADED)
|
||||
@@ -3026,32 +3062,9 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
|
||||
} else {
|
||||
// This is for other drag/drop cases, like dragging from All Apps
|
||||
mLauncher.getStateManager().goToState(NORMAL, SPRING_LOADED_EXIT_DELAY);
|
||||
View view;
|
||||
|
||||
switch (info.itemType) {
|
||||
case LauncherSettings.Favorites.ITEM_TYPE_APPLICATION:
|
||||
case LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT:
|
||||
case LauncherSettings.Favorites.ITEM_TYPE_SEARCH_ACTION:
|
||||
if (info instanceof WorkspaceItemFactory) {
|
||||
// Came from all apps -- make a copy
|
||||
info = ((WorkspaceItemFactory) info).makeWorkspaceItem(mLauncher);
|
||||
d.dragInfo = info;
|
||||
}
|
||||
if (info instanceof WorkspaceItemInfo
|
||||
&& info.container == LauncherSettings.Favorites.CONTAINER_PREDICTION) {
|
||||
// Came from all apps prediction row -- make a copy
|
||||
info = new WorkspaceItemInfo((WorkspaceItemInfo) info);
|
||||
d.dragInfo = info;
|
||||
}
|
||||
view = mLauncher.createShortcut(cellLayout, (WorkspaceItemInfo) info);
|
||||
break;
|
||||
case LauncherSettings.Favorites.ITEM_TYPE_FOLDER:
|
||||
view = FolderIcon.inflateFolderAndIcon(R.layout.folder_icon, mLauncher, cellLayout,
|
||||
(FolderInfo) info);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException("Unknown item type: " + info.itemType);
|
||||
}
|
||||
View view = mLauncher.getItemInflater()
|
||||
.inflateItem(info, mLauncher.getModelWriter(), cellLayout);
|
||||
d.dragInfo = info = (ItemInfo) view.getTag();
|
||||
|
||||
// First we find the cell nearest to point at which the item is
|
||||
// dropped, without any consideration to whether there is an item there.
|
||||
@@ -3178,7 +3191,7 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
|
||||
}
|
||||
|
||||
public void animateWidgetDrop(ItemInfo info, CellLayout cellLayout, final DragView dragView,
|
||||
final Runnable onCompleteRunnable, int animationType, final View finalView,
|
||||
final Runnable onCompleteRunnable, int animationType, @Nullable final View finalView,
|
||||
boolean external) {
|
||||
int[] finalPos = new int[2];
|
||||
float scaleXY[] = new float[2];
|
||||
@@ -3250,7 +3263,7 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
|
||||
* is created/
|
||||
* destroyed
|
||||
*/
|
||||
public CellLayout.CellInfo getDragInfo() {
|
||||
public CellInfo getDragInfo() {
|
||||
return mDragInfo;
|
||||
}
|
||||
|
||||
@@ -3509,7 +3522,7 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
|
||||
}
|
||||
} else if (child instanceof FolderIcon) {
|
||||
FolderInfo folderInfo = (FolderInfo) info;
|
||||
List<WorkspaceItemInfo> matches = folderInfo.contents.stream()
|
||||
List<ItemInfo> matches = folderInfo.getContents().stream()
|
||||
.filter(matcher)
|
||||
.collect(Collectors.toList());
|
||||
if (!matches.isEmpty()) {
|
||||
@@ -3518,6 +3531,11 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
|
||||
((FolderIcon) child).getFolder().close(false /* animate */);
|
||||
}
|
||||
}
|
||||
} else if (info instanceof AppPairInfo api) {
|
||||
// If an app pair's member apps are being removed, delete the whole app pair.
|
||||
if (api.anyMatch(matcher)) {
|
||||
mLauncher.removeItem(child, info, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3569,9 +3587,9 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
|
||||
}
|
||||
} else if (info instanceof FolderInfo && v instanceof FolderIcon) {
|
||||
FolderInfo fi = (FolderInfo) info;
|
||||
if (fi.contents.stream().anyMatch(matcher)) {
|
||||
if (fi.anyMatch(matcher)) {
|
||||
FolderDotInfo folderDotInfo = new FolderDotInfo();
|
||||
for (WorkspaceItemInfo si : fi.contents) {
|
||||
for (ItemInfo si : fi.getContents()) {
|
||||
folderDotInfo.addDotInfo(mLauncher.getDotInfoForItem(si));
|
||||
}
|
||||
((FolderIcon) v).setDotInfo(folderDotInfo);
|
||||
@@ -3611,7 +3629,8 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
|
||||
if (item.hasRestoreFlag(LauncherAppWidgetInfo.FLAG_ID_NOT_VALID)) {
|
||||
widgetInfo = widgetHelper.findProvider(item.providerName, item.user);
|
||||
} else {
|
||||
widgetInfo = widgetHelper.getLauncherAppWidgetInfo(item.appWidgetId);
|
||||
widgetInfo = widgetHelper.getLauncherAppWidgetInfo(item.appWidgetId,
|
||||
item.getTargetComponent());
|
||||
}
|
||||
|
||||
if (widgetInfo != null) {
|
||||
@@ -3693,14 +3712,15 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
|
||||
|
||||
@Override
|
||||
protected String getCurrentPageDescription() {
|
||||
int page = (mNextPage != INVALID_PAGE) ? mNextPage : mCurrentPage;
|
||||
return getPageDescription(page);
|
||||
int pageIndex = (mNextPage != INVALID_PAGE) ? mNextPage : mCurrentPage;
|
||||
return getPageDescription(pageIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param page page index.
|
||||
* @return Description of the page at the given page index.
|
||||
*/
|
||||
@Override
|
||||
public String getPageDescription(int page) {
|
||||
int nScreens = getChildCount();
|
||||
int extraScreenId = mScreenOrder.indexOf(EXTRA_EMPTY_SCREEN_ID);
|
||||
|
||||
Reference in New Issue
Block a user