Search in sources :

Example 56 with OVERVIEW

use of com.android.launcher3.LauncherState.OVERVIEW in project Neo-Launcher by NeoApplications.

the class AbstractLauncherUiTest method checkLauncherIntegrity.

private static void checkLauncherIntegrity(Launcher launcher, ContainerType expectedContainerType) {
    if (launcher != null) {
        final LauncherStateManager stateManager = launcher.getStateManager();
        final LauncherState stableState = stateManager.getCurrentStableState();
        assertTrue("Stable state != state: " + stableState.getClass().getSimpleName() + ", " + stateManager.getState().getClass().getSimpleName(), stableState == stateManager.getState());
        final boolean isResumed = launcher.hasBeenResumed();
        assertTrue("hasBeenResumed() != isStarted(), hasBeenResumed(): " + isResumed, isResumed == launcher.isStarted());
        assertTrue("hasBeenResumed() != isUserActive(), hasBeenResumed(): " + isResumed, isResumed == launcher.isUserActive());
        final int ordinal = stableState.ordinal;
        switch(expectedContainerType) {
            case WORKSPACE:
            case WIDGETS:
                {
                    assertTrue("Launcher is not resumed in state: " + expectedContainerType, isResumed);
                    assertTrue(TestProtocol.stateOrdinalToString(ordinal), ordinal == TestProtocol.NORMAL_STATE_ORDINAL);
                    break;
                }
            case ALL_APPS:
                {
                    assertTrue("Launcher is not resumed in state: " + expectedContainerType, isResumed);
                    assertTrue(TestProtocol.stateOrdinalToString(ordinal), ordinal == TestProtocol.ALL_APPS_STATE_ORDINAL);
                    break;
                }
            case OVERVIEW:
                {
                    assertTrue("Launcher is not resumed in state: " + expectedContainerType, isResumed);
                    assertTrue(TestProtocol.stateOrdinalToString(ordinal), ordinal == TestProtocol.OVERVIEW_STATE_ORDINAL);
                    break;
                }
            case BACKGROUND:
                {
                    assertTrue("Launcher is resumed in state: " + expectedContainerType, !isResumed);
                    assertTrue(TestProtocol.stateOrdinalToString(ordinal), ordinal == TestProtocol.NORMAL_STATE_ORDINAL);
                    break;
                }
            default:
                throw new IllegalArgumentException("Illegal container: " + expectedContainerType);
        }
    } else {
        assertTrue("Container type is not BACKGROUND or FALLBACK_OVERVIEW: " + expectedContainerType, expectedContainerType == ContainerType.BACKGROUND || expectedContainerType == ContainerType.FALLBACK_OVERVIEW);
    }
}
Also used : LauncherState(com.android.launcher3.LauncherState) LauncherStateManager(com.android.launcher3.LauncherStateManager)

Example 57 with OVERVIEW

use of com.android.launcher3.LauncherState.OVERVIEW in project android_packages_apps_Launcher3 by ArrowOS.

the class LauncherActivityInterface method onSwipeUpToHomeComplete.

@Override
public void onSwipeUpToHomeComplete(RecentsAnimationDeviceState deviceState) {
    Launcher launcher = getCreatedActivity();
    if (launcher == null) {
        return;
    }
    // When going to home, the state animator we use has SKIP_OVERVIEW because we assume that
    // setRecentsAttachedToAppWindow() will handle animating Overview instead. Thus, at the end
    // of the animation, we should ensure recents is at the correct position for NORMAL state.
    // For example, when doing a long swipe to home, RecentsView may be scaled down. This is
    // relatively expensive, so do it on the next frame instead of critical path.
    MAIN_EXECUTOR.getHandler().post(launcher.getStateManager()::reapplyState);
    launcher.getRootView().setForceHideBackArrow(false);
    notifyRecentsOfOrientation(deviceState.getRotationTouchHelper());
}
Also used : Launcher(com.android.launcher3.Launcher) BaseQuickstepLauncher(com.android.launcher3.BaseQuickstepLauncher)

Example 58 with OVERVIEW

use of com.android.launcher3.LauncherState.OVERVIEW in project android_packages_apps_Launcher3 by ArrowOS.

the class TaskOverlayFactory method addSplitOptions.

/**
 * Does NOT add split options in the following scenarios:
 * * The taskView to add split options is already showing split screen tasks
 * * There aren't at least 2 tasks in overview to show split options for
 * * Device is in "Lock task mode"
 * * The taskView to show split options for is the focused task AND we haven't started
 *   scrolling in overview (if we haven't scrolled, there's a split overview action button so
 *   we don't need this menu option)
 */
private static void addSplitOptions(List<SystemShortcut> outShortcuts, BaseDraggingActivity activity, TaskView taskView, DeviceProfile deviceProfile) {
    RecentsView recentsView = taskView.getRecentsView();
    PagedOrientationHandler orientationHandler = recentsView.getPagedOrientationHandler();
    int[] taskViewTaskIds = taskView.getTaskIds();
    boolean taskViewHasMultipleTasks = taskViewTaskIds[0] != -1 && taskViewTaskIds[1] != -1;
    boolean notEnoughTasksToSplit = recentsView.getTaskViewCount() < 2;
    boolean isFocusedTask = deviceProfile.overviewShowAsGrid && taskView.isFocusedTask();
    boolean isTaskInExpectedScrollPosition = recentsView.isTaskInExpectedScrollPosition(recentsView.indexOfChild(taskView));
    ActivityManager activityManager = (ActivityManager) taskView.getContext().getSystemService(Context.ACTIVITY_SERVICE);
    boolean isLockTaskMode = activityManager.isInLockTaskMode();
    if (taskViewHasMultipleTasks || notEnoughTasksToSplit || isLockTaskMode || (isFocusedTask && isTaskInExpectedScrollPosition)) {
        return;
    }
    List<SplitPositionOption> positions = orientationHandler.getSplitPositionOptions(deviceProfile);
    for (SplitPositionOption option : positions) {
        outShortcuts.add(new SplitSelectSystemShortcut(activity, taskView, option));
    }
}
Also used : SplitPositionOption(com.android.launcher3.util.SplitConfigurationOptions.SplitPositionOption) PagedOrientationHandler(com.android.launcher3.touch.PagedOrientationHandler) RecentsView(com.android.quickstep.views.RecentsView) ActivityManager(android.app.ActivityManager) SplitSelectSystemShortcut(com.android.quickstep.TaskShortcutFactory.SplitSelectSystemShortcut)

Example 59 with OVERVIEW

use of com.android.launcher3.LauncherState.OVERVIEW in project android_packages_apps_Launcher3 by ArrowOS.

the class TaskOverlayFactory method getEnabledShortcuts.

public static List<SystemShortcut> getEnabledShortcuts(TaskView taskView, DeviceProfile deviceProfile, TaskIdAttributeContainer taskContainer) {
    final ArrayList<SystemShortcut> shortcuts = new ArrayList<>();
    final BaseDraggingActivity activity = BaseActivity.fromContext(taskView.getContext());
    boolean hasMultipleTasks = taskView.getTaskIds()[1] != -1;
    for (TaskShortcutFactory menuOption : MENU_OPTIONS) {
        if (hasMultipleTasks && !menuOption.showForSplitscreen()) {
            continue;
        }
        SystemShortcut shortcut = menuOption.getShortcut(activity, taskContainer);
        if (shortcut == null) {
            continue;
        }
        if (menuOption == TaskShortcutFactory.SPLIT_SCREEN && FeatureFlags.ENABLE_SPLIT_SELECT.get()) {
            addSplitOptions(shortcuts, activity, taskView, deviceProfile);
        } else {
            shortcuts.add(shortcut);
        }
    }
    RecentsOrientedState orientedState = taskView.getRecentsView().getPagedViewOrientedState();
    boolean canLauncherRotate = orientedState.isRecentsActivityRotationAllowed();
    boolean isInLandscape = orientedState.getTouchRotation() != ROTATION_0;
    // Add overview actions to the menu when in in-place rotate landscape mode.
    if (!canLauncherRotate && isInLandscape) {
        // Add screenshot action to task menu.
        SystemShortcut screenshotShortcut = TaskShortcutFactory.SCREENSHOT.getShortcut(activity, taskContainer);
        if (screenshotShortcut != null) {
            shortcuts.add(screenshotShortcut);
        }
        // Add modal action only if display orientation is the same as the device orientation.
        if (orientedState.getDisplayRotation() == ROTATION_0) {
            SystemShortcut modalShortcut = TaskShortcutFactory.MODAL.getShortcut(activity, taskContainer);
            if (modalShortcut != null) {
                shortcuts.add(modalShortcut);
            }
        }
    }
    return shortcuts;
}
Also used : BaseDraggingActivity(com.android.launcher3.BaseDraggingActivity) SystemShortcut(com.android.launcher3.popup.SystemShortcut) SplitSelectSystemShortcut(com.android.quickstep.TaskShortcutFactory.SplitSelectSystemShortcut) ArrayList(java.util.ArrayList) RecentsOrientedState(com.android.quickstep.util.RecentsOrientedState)

Example 60 with OVERVIEW

use of com.android.launcher3.LauncherState.OVERVIEW in project android_packages_apps_Launcher3 by ArrowOS.

the class ItemLongClickListener method onAllAppsItemLongClick.

private static boolean onAllAppsItemLongClick(View v) {
    TestLogging.recordEvent(TestProtocol.SEQUENCE_MAIN, "onAllAppsItemLongClick");
    v.cancelLongPress();
    Launcher launcher = Launcher.getLauncher(v.getContext());
    if (!canStartDrag(launcher))
        return false;
    // When we have exited all apps or are in transition, disregard long clicks
    if (!launcher.isInState(ALL_APPS) && !launcher.isInState(OVERVIEW))
        return false;
    if (launcher.getWorkspace().isSwitchingState())
        return false;
    StatsLogger logger = launcher.getStatsLogManager().logger();
    if (v.getTag() instanceof ItemInfo) {
        logger.withItemInfo((ItemInfo) v.getTag());
    }
    logger.log(LAUNCHER_ALLAPPS_ITEM_LONG_PRESSED);
    // Start the drag
    final DragController dragController = launcher.getDragController();
    dragController.addDragListener(new DragController.DragListener() {

        @Override
        public void onDragStart(DropTarget.DragObject dragObject, DragOptions options) {
            v.setVisibility(INVISIBLE);
        }

        @Override
        public void onDragEnd() {
            v.setVisibility(VISIBLE);
            dragController.removeDragListener(this);
        }
    });
    DeviceProfile grid = launcher.getDeviceProfile();
    DragOptions options = new DragOptions();
    options.intrinsicIconScaleFactor = (float) grid.allAppsIconSizePx / grid.iconSizePx;
    launcher.getWorkspace().beginDragShared(v, launcher.getAppsView(), options);
    return false;
}
Also used : DragOptions(com.android.launcher3.dragndrop.DragOptions) DeviceProfile(com.android.launcher3.DeviceProfile) StatsLogger(com.android.launcher3.logging.StatsLogManager.StatsLogger) ItemInfo(com.android.launcher3.model.data.ItemInfo) DragController(com.android.launcher3.dragndrop.DragController) Launcher(com.android.launcher3.Launcher) DropTarget(com.android.launcher3.DropTarget)

Aggregations

LauncherState (com.android.launcher3.LauncherState)53 Animator (android.animation.Animator)50 ValueAnimator (android.animation.ValueAnimator)42 StateAnimationConfig (com.android.launcher3.states.StateAnimationConfig)41 RecentsView (com.android.quickstep.views.RecentsView)40 AnimatorSet (android.animation.AnimatorSet)38 Launcher (com.android.launcher3.Launcher)36 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)34 ObjectAnimator (android.animation.ObjectAnimator)30 LargeTest (androidx.test.filters.LargeTest)29 Test (org.junit.Test)29 Point (android.graphics.Point)24 View (android.view.View)22 DeviceProfile (com.android.launcher3.DeviceProfile)19 PendingAnimation (com.android.launcher3.anim.PendingAnimation)19 RemoteAnimationTargetCompat (com.android.systemui.shared.system.RemoteAnimationTargetCompat)19 ItemInfo (com.android.launcher3.model.data.ItemInfo)18 DepthController (com.android.launcher3.statehandlers.DepthController)17 Task (com.android.systemui.shared.recents.model.Task)17 Rect (android.graphics.Rect)16