mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-03 17:36:49 +00:00
Merge "Adding a new Edit Mode LauncherState" into udc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
afb447ee0d
@@ -19,6 +19,7 @@ package com.android.launcher3;
|
||||
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.LauncherState.ALL_APPS;
|
||||
import static com.android.launcher3.LauncherState.EDIT_MODE;
|
||||
import static com.android.launcher3.LauncherState.FLAG_MULTI_PAGE;
|
||||
import static com.android.launcher3.LauncherState.FLAG_WORKSPACE_ICONS_CAN_BE_DRAGGED;
|
||||
import static com.android.launcher3.LauncherState.FLAG_WORKSPACE_INACCESSIBLE;
|
||||
@@ -494,8 +495,9 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
|
||||
}
|
||||
}
|
||||
|
||||
// Always enter the spring loaded mode
|
||||
mLauncher.getStateManager().goToState(SPRING_LOADED);
|
||||
if (!mLauncher.isInState(EDIT_MODE)) {
|
||||
mLauncher.getStateManager().goToState(SPRING_LOADED);
|
||||
}
|
||||
mStatsLogManager.logger().withItemInfo(dragObject.dragInfo)
|
||||
.withInstanceId(dragObject.logInstanceId)
|
||||
.log(LauncherEvent.LAUNCHER_ITEM_DRAG_STARTED);
|
||||
@@ -1432,7 +1434,8 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
|
||||
}
|
||||
|
||||
private boolean workspaceInScrollableState() {
|
||||
return mLauncher.isInState(SPRING_LOADED) || !workspaceInModalState();
|
||||
return mLauncher.isInState(SPRING_LOADED) || mLauncher.isInState(EDIT_MODE)
|
||||
|| !workspaceInModalState();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1526,6 +1529,7 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
|
||||
@Override
|
||||
public void setState(LauncherState toState) {
|
||||
onStartStateTransition();
|
||||
mLauncher.getStateManager().getState().onLeavingState(mLauncher, toState);
|
||||
mStateTransitionAnimation.setState(toState);
|
||||
onEndStateTransition();
|
||||
}
|
||||
@@ -1537,6 +1541,7 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
|
||||
public void setStateWithAnimation(
|
||||
LauncherState toState, StateAnimationConfig config, PendingAnimation animation) {
|
||||
StateTransitionListener listener = new StateTransitionListener();
|
||||
mLauncher.getStateManager().getState().onLeavingState(mLauncher, toState);
|
||||
mStateTransitionAnimation.setStateWithAnimation(toState, config, animation);
|
||||
|
||||
// Invalidate the pages now, so that we have the visible pages before the
|
||||
@@ -1999,7 +2004,9 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
|
||||
distance, false, d)
|
||||
|| addToExistingFolderIfNecessary(cell, dropTargetLayout, mTargetCell,
|
||||
distance, d, false)) {
|
||||
mLauncher.getStateManager().goToState(NORMAL, SPRING_LOADED_EXIT_DELAY);
|
||||
if (!mLauncher.isInState(EDIT_MODE)) {
|
||||
mLauncher.getStateManager().goToState(NORMAL, SPRING_LOADED_EXIT_DELAY);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2128,14 +2135,19 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
|
||||
// spring-loaded mode so the page meets the icon where it was picked up.
|
||||
final RunnableList callbackList = new RunnableList();
|
||||
final Runnable onCompleteCallback = onCompleteRunnable;
|
||||
LauncherState currentState = mLauncher.getStateManager().getState();
|
||||
mLauncher.getDragController().animateDragViewToOriginalPosition(
|
||||
/* onComplete= */ callbackList::executeAllAndDestroy, cell,
|
||||
SPRING_LOADED.getTransitionDuration(mLauncher, true /* isToState */));
|
||||
mLauncher.getStateManager().goToState(NORMAL, /* delay= */ 0,
|
||||
onCompleteCallback == null
|
||||
? null
|
||||
: forSuccessCallback(
|
||||
() -> callbackList.add(onCompleteCallback)));
|
||||
currentState.getTransitionDuration(mLauncher, true /* isToState */));
|
||||
if (!mLauncher.isInState(EDIT_MODE)) {
|
||||
mLauncher.getStateManager().goToState(NORMAL, /* delay= */ 0,
|
||||
onCompleteCallback == null
|
||||
? null
|
||||
: forSuccessCallback(
|
||||
() -> callbackList.add(onCompleteCallback)));
|
||||
} else if (onCompleteCallback != null) {
|
||||
forSuccessCallback(() -> callbackList.add(onCompleteCallback));
|
||||
}
|
||||
mLauncher.getDropTargetBar().onDragEnd();
|
||||
parent.onDropChild(cell);
|
||||
return;
|
||||
@@ -2159,8 +2171,12 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
|
||||
}
|
||||
parent.onDropChild(cell);
|
||||
|
||||
mLauncher.getStateManager().goToState(NORMAL, SPRING_LOADED_EXIT_DELAY,
|
||||
onCompleteRunnable == null ? null : forSuccessCallback(onCompleteRunnable));
|
||||
if (!mLauncher.isInState(EDIT_MODE)) {
|
||||
mLauncher.getStateManager().goToState(NORMAL, SPRING_LOADED_EXIT_DELAY,
|
||||
onCompleteRunnable == null ? null : forSuccessCallback(onCompleteRunnable));
|
||||
} else if (onCompleteRunnable != null) {
|
||||
forSuccessCallback(onCompleteRunnable);
|
||||
}
|
||||
mStatsLogManager.logger().withItemInfo(d.dragInfo).withInstanceId(d.logInstanceId)
|
||||
.log(LauncherEvent.LAUNCHER_ITEM_DROP_COMPLETED);
|
||||
}
|
||||
@@ -2734,7 +2750,8 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
|
||||
final int screenId = getIdForScreen(cellLayout);
|
||||
if (!mLauncher.isHotseatLayout(cellLayout)
|
||||
&& screenId != getScreenIdForPageIndex(mCurrentPage)
|
||||
&& !mLauncher.isInState(SPRING_LOADED)) {
|
||||
&& !mLauncher.isInState(SPRING_LOADED)
|
||||
&& !mLauncher.isInState(EDIT_MODE)) {
|
||||
snapToPage(getPageIndexForScreenId(screenId));
|
||||
}
|
||||
|
||||
@@ -2812,7 +2829,6 @@ 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) {
|
||||
|
||||
Reference in New Issue
Block a user