Merge "Adding a new Edit Mode LauncherState" into udc-dev am: afb447ee0d
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/22890120 Change-Id: Ie61a8ac6975d9d24c38d0a1968a5f0572efffdd4 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -19,6 +19,7 @@ import static android.app.ActivityTaskManager.INVALID_TASK_ID;
|
||||
|
||||
import static com.android.launcher3.LauncherState.ALL_APPS;
|
||||
import static com.android.launcher3.LauncherState.CLEAR_ALL_BUTTON;
|
||||
import static com.android.launcher3.LauncherState.EDIT_MODE;
|
||||
import static com.android.launcher3.LauncherState.NORMAL;
|
||||
import static com.android.launcher3.LauncherState.OVERVIEW;
|
||||
import static com.android.launcher3.LauncherState.OVERVIEW_MODAL_TASK;
|
||||
@@ -133,7 +134,8 @@ public class LauncherRecentsView extends RecentsView<QuickstepLauncher, Launcher
|
||||
|
||||
@Override
|
||||
public void onStateTransitionComplete(LauncherState finalState) {
|
||||
if (finalState == NORMAL || finalState == SPRING_LOADED || finalState == ALL_APPS) {
|
||||
if (finalState == NORMAL || finalState == SPRING_LOADED || finalState == EDIT_MODE
|
||||
|| finalState == ALL_APPS) {
|
||||
// Clean-up logic that occurs when recents is no longer in use/visible.
|
||||
reset();
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.android.launcher3;
|
||||
|
||||
import static android.animation.ValueAnimator.areAnimatorsEnabled;
|
||||
|
||||
import static com.android.launcher3.LauncherState.EDIT_MODE;
|
||||
import static com.android.launcher3.anim.Interpolators.DEACCEL_1_5;
|
||||
import static com.android.launcher3.dragndrop.DraggableView.DRAGGABLE_ICON;
|
||||
import static com.android.launcher3.icons.IconNormalizer.ICON_VISIBLE_AREA_FACTOR;
|
||||
@@ -571,7 +572,9 @@ public class CellLayout extends ViewGroup {
|
||||
}
|
||||
|
||||
protected void updateBgAlpha() {
|
||||
mBackground.setAlpha((int) (mSpringLoadedProgress * 255));
|
||||
if (!getWorkspace().mLauncher.isInState(EDIT_MODE)) {
|
||||
mBackground.setAlpha((int) (mSpringLoadedProgress * 255));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -34,6 +34,7 @@ import static com.android.launcher3.LauncherAnimUtils.WORKSPACE_SCALE_PROPERTY_F
|
||||
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_DESKTOP;
|
||||
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_NON_INTERACTIVE;
|
||||
import static com.android.launcher3.LauncherState.NORMAL;
|
||||
@@ -44,6 +45,7 @@ import static com.android.launcher3.Utilities.postAsyncCallback;
|
||||
import static com.android.launcher3.accessibility.LauncherAccessibilityDelegate.getSupportedActions;
|
||||
import static com.android.launcher3.anim.Interpolators.EMPHASIZED;
|
||||
import static com.android.launcher3.config.FeatureFlags.FOLDABLE_SINGLE_PAGE;
|
||||
import static com.android.launcher3.config.FeatureFlags.MULTI_SELECT_EDIT_MODE;
|
||||
import static com.android.launcher3.config.FeatureFlags.SHOW_DOT_PAGINATION;
|
||||
import static com.android.launcher3.logging.StatsLogManager.EventEnum;
|
||||
import static com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_BACKGROUND;
|
||||
@@ -901,12 +903,8 @@ public class Launcher extends StatefulActivity<LauncherState>
|
||||
|
||||
final int pendingAddWidgetId = requestArgs.getWidgetId();
|
||||
|
||||
Runnable exitSpringLoaded = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mStateManager.goToState(NORMAL, SPRING_LOADED_EXIT_DELAY);
|
||||
}
|
||||
};
|
||||
Runnable exitSpringLoaded = MULTI_SELECT_EDIT_MODE.get() ? null
|
||||
: () -> mStateManager.goToState(NORMAL, SPRING_LOADED_EXIT_DELAY);
|
||||
|
||||
if (requestCode == REQUEST_BIND_APPWIDGET) {
|
||||
// This is called only if the user did not previously have permissions to bind widgets
|
||||
@@ -1040,10 +1038,9 @@ public class Launcher extends StatefulActivity<LauncherState>
|
||||
final AppWidgetHostView layout = mAppWidgetHolder.createView(this, appWidgetId,
|
||||
requestArgs.getWidgetHandler().getProviderInfo(this));
|
||||
boundWidget = layout;
|
||||
onCompleteRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
completeAddAppWidget(appWidgetId, requestArgs, layout, null);
|
||||
onCompleteRunnable = () -> {
|
||||
completeAddAppWidget(appWidgetId, requestArgs, layout, null);
|
||||
if (!isInState(EDIT_MODE)) {
|
||||
mStateManager.goToState(NORMAL, SPRING_LOADED_EXIT_DELAY);
|
||||
}
|
||||
};
|
||||
@@ -1178,7 +1175,7 @@ public class Launcher extends StatefulActivity<LauncherState>
|
||||
}
|
||||
addActivityFlags(ACTIVITY_STATE_TRANSITION_ACTIVE);
|
||||
|
||||
if (state == SPRING_LOADED) {
|
||||
if (state == SPRING_LOADED || state == EDIT_MODE) {
|
||||
// Prevent any Un/InstallShortcutReceivers from updating the db while we are
|
||||
// not on homescreen
|
||||
ItemInstallQueue.INSTANCE.get(this).pauseModelPush(FLAG_DRAG_AND_DROP);
|
||||
@@ -1532,7 +1529,8 @@ public class Launcher extends StatefulActivity<LauncherState>
|
||||
mStateManager.addStateListener(new StateManager.StateListener<LauncherState>() {
|
||||
@Override
|
||||
public void onStateTransitionComplete(LauncherState finalState) {
|
||||
if (mPrevLauncherState == SPRING_LOADED && finalState == NORMAL) {
|
||||
if ((mPrevLauncherState == SPRING_LOADED || mPrevLauncherState == EDIT_MODE)
|
||||
&& finalState == NORMAL) {
|
||||
AppWidgetResizeFrame.showForWidget(launcherHostView, cellLayout);
|
||||
mStateManager.removeStateListener(this);
|
||||
}
|
||||
@@ -1900,13 +1898,9 @@ public class Launcher extends StatefulActivity<LauncherState>
|
||||
REQUEST_CREATE_APPWIDGET)) {
|
||||
// If the configuration flow was not started, add the widget
|
||||
|
||||
Runnable onComplete = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// Exit spring loaded mode if necessary after adding the widget
|
||||
mStateManager.goToState(NORMAL, SPRING_LOADED_EXIT_DELAY);
|
||||
}
|
||||
};
|
||||
// Exit spring loaded mode if necessary after adding the widget
|
||||
Runnable onComplete = MULTI_SELECT_EDIT_MODE.get() ? null
|
||||
: () -> mStateManager.goToState(NORMAL, SPRING_LOADED_EXIT_DELAY);
|
||||
completeAddAppWidget(appWidgetId, info, boundWidget,
|
||||
addFlowHandler.getProviderInfo(this));
|
||||
mWorkspace.removeExtraEmptyScreenDelayed(delay, false, onComplete);
|
||||
|
||||
@@ -21,6 +21,7 @@ import static com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_HOME;
|
||||
import static com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_OVERVIEW;
|
||||
import static com.android.launcher3.testing.shared.TestProtocol.ALL_APPS_STATE_ORDINAL;
|
||||
import static com.android.launcher3.testing.shared.TestProtocol.BACKGROUND_APP_STATE_ORDINAL;
|
||||
import static com.android.launcher3.testing.shared.TestProtocol.EDIT_MODE_STATE_ORDINAL;
|
||||
import static com.android.launcher3.testing.shared.TestProtocol.HINT_STATE_ORDINAL;
|
||||
import static com.android.launcher3.testing.shared.TestProtocol.HINT_STATE_TWO_BUTTON_ORDINAL;
|
||||
import static com.android.launcher3.testing.shared.TestProtocol.NORMAL_STATE_ORDINAL;
|
||||
@@ -38,6 +39,7 @@ import androidx.annotation.FloatRange;
|
||||
|
||||
import com.android.launcher3.statemanager.BaseState;
|
||||
import com.android.launcher3.statemanager.StateManager;
|
||||
import com.android.launcher3.states.EditModeState;
|
||||
import com.android.launcher3.states.HintState;
|
||||
import com.android.launcher3.states.SpringLoadedState;
|
||||
import com.android.launcher3.testing.shared.TestProtocol;
|
||||
@@ -103,7 +105,7 @@ public abstract class LauncherState implements BaseState<LauncherState> {
|
||||
}
|
||||
};
|
||||
|
||||
private static final LauncherState[] sAllStates = new LauncherState[10];
|
||||
private static final LauncherState[] sAllStates = new LauncherState[11];
|
||||
|
||||
/**
|
||||
* TODO: Create a separate class for NORMAL state.
|
||||
@@ -123,6 +125,7 @@ public abstract class LauncherState implements BaseState<LauncherState> {
|
||||
*/
|
||||
public static final LauncherState SPRING_LOADED = new SpringLoadedState(
|
||||
SPRING_LOADED_STATE_ORDINAL);
|
||||
public static final LauncherState EDIT_MODE = new EditModeState(EDIT_MODE_STATE_ORDINAL);
|
||||
public static final LauncherState ALL_APPS = new AllAppsState(ALL_APPS_STATE_ORDINAL);
|
||||
public static final LauncherState HINT_STATE = new HintState(HINT_STATE_ORDINAL);
|
||||
public static final LauncherState HINT_STATE_TWO_BUTTON = new HintState(
|
||||
@@ -328,7 +331,9 @@ public abstract class LauncherState implements BaseState<LauncherState> {
|
||||
* Gets the translation provider for workspace pages.
|
||||
*/
|
||||
public PageTranslationProvider getWorkspacePageTranslationProvider(Launcher launcher) {
|
||||
if (this != SPRING_LOADED || !launcher.getDeviceProfile().isTwoPanels) {
|
||||
if (this != SPRING_LOADED
|
||||
|| this != EDIT_MODE
|
||||
|| !launcher.getDeviceProfile().isTwoPanels) {
|
||||
return DEFAULT_PAGE_TRANSLATION_PROVIDER;
|
||||
}
|
||||
final float quarterPageSpacing = launcher.getWorkspace().getPageSpacing() / 4f;
|
||||
@@ -343,6 +348,16 @@ public abstract class LauncherState implements BaseState<LauncherState> {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when leaving this LauncherState
|
||||
* @param launcher - Launcher instance
|
||||
* @param toState - New LauncherState that is being entered
|
||||
*/
|
||||
public void onLeavingState(Launcher launcher, LauncherState toState) {
|
||||
// no-op
|
||||
// override to handle when leaving current LauncherState
|
||||
}
|
||||
|
||||
@Override
|
||||
public LauncherState getHistoryForState(LauncherState previousState) {
|
||||
// No history is supported
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -59,6 +59,7 @@ import com.android.launcher3.anim.PropertySetter;
|
||||
import com.android.launcher3.anim.SpringAnimationBuilder;
|
||||
import com.android.launcher3.graphics.Scrim;
|
||||
import com.android.launcher3.graphics.SysUiScrim;
|
||||
import com.android.launcher3.states.EditModeState;
|
||||
import com.android.launcher3.states.SpringLoadedState;
|
||||
import com.android.launcher3.states.StateAnimationConfig;
|
||||
import com.android.launcher3.util.DynamicResource;
|
||||
@@ -212,8 +213,8 @@ public class WorkspaceStateTransitionAnimation {
|
||||
PageAlphaProvider pageAlphaProvider, PropertySetter propertySetter,
|
||||
StateAnimationConfig config) {
|
||||
float pageAlpha = pageAlphaProvider.getPageAlpha(childIndex);
|
||||
float springLoadedProgress = (state instanceof SpringLoadedState) ? 1.0f : 0f;
|
||||
|
||||
float springLoadedProgress =
|
||||
(state instanceof SpringLoadedState || state instanceof EditModeState) ? 1f : 0f;
|
||||
propertySetter.setFloat(cl,
|
||||
CellLayout.SPRING_LOADED_PROGRESS, springLoadedProgress, ZOOM_OUT);
|
||||
Interpolator fadeInterpolator = config.getInterpolator(ANIM_WORKSPACE_FADE,
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.android.launcher3.dragndrop;
|
||||
|
||||
import static com.android.launcher3.AbstractFloatingView.TYPE_DISCOVERY_BOUNCE;
|
||||
import static com.android.launcher3.LauncherAnimUtils.SPRING_LOADED_EXIT_DELAY;
|
||||
import static com.android.launcher3.LauncherState.EDIT_MODE;
|
||||
import static com.android.launcher3.LauncherState.NORMAL;
|
||||
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
|
||||
|
||||
@@ -157,7 +158,9 @@ public class LauncherDragController extends DragController<Launcher> {
|
||||
|
||||
@Override
|
||||
protected void exitDrag() {
|
||||
mActivity.getStateManager().goToState(NORMAL, SPRING_LOADED_EXIT_DELAY);
|
||||
if (!mActivity.isInState(EDIT_MODE)) {
|
||||
mActivity.getStateManager().goToState(NORMAL, SPRING_LOADED_EXIT_DELAY);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -57,7 +57,8 @@ public class LauncherDragView extends DragView<Launcher>
|
||||
@Override
|
||||
public void onStateTransitionComplete(LauncherState finalState) {
|
||||
setVisibility((finalState == LauncherState.NORMAL
|
||||
|| finalState == LauncherState.SPRING_LOADED) ? VISIBLE : INVISIBLE);
|
||||
|| finalState == LauncherState.SPRING_LOADED
|
||||
|| finalState == LauncherState.EDIT_MODE) ? VISIBLE : INVISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -16,6 +16,11 @@
|
||||
|
||||
package com.android.launcher3.dragndrop;
|
||||
|
||||
import static com.android.launcher3.LauncherAnimUtils.SPRING_LOADED_EXIT_DELAY;
|
||||
import static com.android.launcher3.LauncherState.EDIT_MODE;
|
||||
import static com.android.launcher3.LauncherState.SPRING_LOADED;
|
||||
import static com.android.launcher3.config.FeatureFlags.MULTI_SELECT_EDIT_MODE;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
import android.content.ComponentName;
|
||||
@@ -29,10 +34,8 @@ import android.os.Build;
|
||||
import android.os.Process;
|
||||
|
||||
import com.android.launcher3.Launcher;
|
||||
import com.android.launcher3.LauncherAnimUtils;
|
||||
import com.android.launcher3.LauncherAppState;
|
||||
import com.android.launcher3.LauncherSettings;
|
||||
import com.android.launcher3.LauncherState;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.icons.IconCache;
|
||||
import com.android.launcher3.model.data.WorkspaceItemInfo;
|
||||
@@ -90,11 +93,11 @@ public class PinShortcutRequestActivityInfo extends ShortcutConfigActivityInfo {
|
||||
|
||||
@Override
|
||||
public WorkspaceItemInfo createWorkspaceItemInfo() {
|
||||
long transitionDuration = (MULTI_SELECT_EDIT_MODE.get() ? EDIT_MODE : SPRING_LOADED)
|
||||
.getTransitionDuration(Launcher.getLauncher(mContext), true /* isToState */);
|
||||
// Total duration for the drop animation to complete.
|
||||
long duration = mContext.getResources().getInteger(R.integer.config_dropAnimMaxDuration) +
|
||||
LauncherAnimUtils.SPRING_LOADED_EXIT_DELAY +
|
||||
LauncherState.SPRING_LOADED.getTransitionDuration(Launcher.getLauncher(mContext),
|
||||
true /* isToState */);
|
||||
SPRING_LOADED_EXIT_DELAY + transitionDuration;
|
||||
// Delay the actual accept() call until the drop animation is complete.
|
||||
return PinRequestHelper.createWorkspaceItemFromPinItemRequest(
|
||||
mContext, mRequestSupplier.get(), duration);
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.android.launcher3.folder;
|
||||
import static android.text.TextUtils.isEmpty;
|
||||
|
||||
import static com.android.launcher3.LauncherAnimUtils.SPRING_LOADED_EXIT_DELAY;
|
||||
import static com.android.launcher3.LauncherState.EDIT_MODE;
|
||||
import static com.android.launcher3.LauncherState.NORMAL;
|
||||
import static com.android.launcher3.compat.AccessibilityManagerCompat.sendCustomAccessibilityEvent;
|
||||
import static com.android.launcher3.config.FeatureFlags.ALWAYS_USE_HARDWARE_OPTIMIZATION_FOR_FOLDER_ANIMATIONS;
|
||||
@@ -1339,7 +1340,10 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
|
||||
mLauncherDelegate.getModelWriter());
|
||||
}
|
||||
|
||||
launcher.getStateManager().goToState(NORMAL, SPRING_LOADED_EXIT_DELAY);
|
||||
if (!launcher.isInState(EDIT_MODE)) {
|
||||
launcher.getStateManager().goToState(NORMAL, SPRING_LOADED_EXIT_DELAY);
|
||||
}
|
||||
|
||||
if (d.stateAnnouncer != null) {
|
||||
d.stateAnnouncer.completeAction(R.string.item_moved);
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.android.launcher3.keyboard;
|
||||
|
||||
import static android.app.Activity.DEFAULT_KEYS_SEARCH_LOCAL;
|
||||
|
||||
import static com.android.launcher3.LauncherState.EDIT_MODE;
|
||||
import static com.android.launcher3.LauncherState.SPRING_LOADED;
|
||||
|
||||
import android.app.Activity;
|
||||
@@ -114,7 +115,7 @@ public class KeyboardDragAndDropView extends AbstractFloatingView
|
||||
|
||||
@Override
|
||||
public void onStateTransitionStart(LauncherState toState) {
|
||||
if (toState != SPRING_LOADED) {
|
||||
if (toState != SPRING_LOADED && toState != EDIT_MODE) {
|
||||
close(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (C) 2023 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.states
|
||||
|
||||
import android.content.Context
|
||||
import com.android.launcher3.Launcher
|
||||
import com.android.launcher3.LauncherState
|
||||
import com.android.launcher3.logging.StatsLogManager
|
||||
import com.android.launcher3.views.ActivityContext
|
||||
|
||||
/** Definition for Edit Mode state used for home gardening multi-select */
|
||||
class EditModeState(id: Int) : LauncherState(id, StatsLogManager.LAUNCHER_STATE_HOME, STATE_FLAGS) {
|
||||
|
||||
companion object {
|
||||
private val STATE_FLAGS =
|
||||
(FLAG_MULTI_PAGE or
|
||||
FLAG_WORKSPACE_INACCESSIBLE or
|
||||
FLAG_DISABLE_RESTORE or
|
||||
FLAG_WORKSPACE_ICONS_CAN_BE_DRAGGED or
|
||||
FLAG_WORKSPACE_HAS_BACKGROUNDS)
|
||||
}
|
||||
|
||||
override fun <T> getTransitionDuration(context: T, isToState: Boolean): Int where
|
||||
T : Context?,
|
||||
T : ActivityContext? {
|
||||
return 150
|
||||
}
|
||||
|
||||
override fun <T> getDepthUnchecked(context: T): Float where T : Context?, T : ActivityContext? {
|
||||
return 0.5f
|
||||
}
|
||||
|
||||
override fun getWorkspaceScaleAndTranslation(launcher: Launcher): ScaleAndTranslation {
|
||||
val scale = launcher.deviceProfile.getWorkspaceSpringLoadScale(launcher)
|
||||
return ScaleAndTranslation(scale, 0f, 0f)
|
||||
}
|
||||
|
||||
override fun getHotseatScaleAndTranslation(launcher: Launcher): ScaleAndTranslation {
|
||||
val scale = launcher.deviceProfile.getWorkspaceSpringLoadScale(launcher)
|
||||
return ScaleAndTranslation(scale, 0f, 0f)
|
||||
}
|
||||
|
||||
override fun getWorkspaceBackgroundAlpha(launcher: Launcher): Float {
|
||||
return 0.2f
|
||||
}
|
||||
|
||||
override fun onLeavingState(launcher: Launcher?, toState: LauncherState?) {
|
||||
// cleanup any changes to workspace
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@ import static android.view.View.INVISIBLE;
|
||||
import static android.view.View.VISIBLE;
|
||||
|
||||
import static com.android.launcher3.LauncherState.ALL_APPS;
|
||||
import static com.android.launcher3.LauncherState.EDIT_MODE;
|
||||
import static com.android.launcher3.LauncherState.NORMAL;
|
||||
import static com.android.launcher3.LauncherState.OVERVIEW;
|
||||
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_ITEM_LONG_PRESSED;
|
||||
@@ -58,7 +59,11 @@ public class ItemLongClickListener {
|
||||
}
|
||||
Launcher launcher = Launcher.getLauncher(v.getContext());
|
||||
if (!canStartDrag(launcher)) return false;
|
||||
if (!launcher.isInState(NORMAL) && !launcher.isInState(OVERVIEW)) return false;
|
||||
if (!launcher.isInState(NORMAL)
|
||||
&& !launcher.isInState(OVERVIEW)
|
||||
&& !launcher.isInState(EDIT_MODE)) {
|
||||
return false;
|
||||
}
|
||||
if (!(v.getTag() instanceof ItemInfo)) return false;
|
||||
|
||||
launcher.setWaitingForResult(null);
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.android.launcher3.views;
|
||||
|
||||
import static androidx.core.content.ContextCompat.getColorStateList;
|
||||
|
||||
import static com.android.launcher3.LauncherState.EDIT_MODE;
|
||||
import static com.android.launcher3.config.FeatureFlags.ENABLE_MATERIAL_U_POPUP;
|
||||
import static com.android.launcher3.config.FeatureFlags.MULTI_SELECT_EDIT_MODE;
|
||||
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.IGNORE;
|
||||
@@ -222,6 +223,8 @@ public class OptionsPopupView extends ArrowPopup<Launcher>
|
||||
}
|
||||
|
||||
private static boolean enterHomeGardening(View view) {
|
||||
Launcher launcher = Launcher.getLauncher(view.getContext());
|
||||
launcher.getStateManager().goToState(EDIT_MODE);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ public final class TestProtocol {
|
||||
public static final int HINT_STATE_ORDINAL = 7;
|
||||
public static final int HINT_STATE_TWO_BUTTON_ORDINAL = 8;
|
||||
public static final int OVERVIEW_SPLIT_SELECT_ORDINAL = 9;
|
||||
public static final int EDIT_MODE_STATE_ORDINAL = 10;
|
||||
public static final String TAPL_EVENTS_TAG = "TaplEvents";
|
||||
public static final String SEQUENCE_MAIN = "Main";
|
||||
public static final String SEQUENCE_TIS = "TIS";
|
||||
@@ -63,6 +64,8 @@ public final class TestProtocol {
|
||||
return "Hint2Button";
|
||||
case OVERVIEW_SPLIT_SELECT_ORDINAL:
|
||||
return "OverviewSplitSelect";
|
||||
case EDIT_MODE_STATE_ORDINAL:
|
||||
return "EditMode";
|
||||
default:
|
||||
return "Unknown";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user