Search in sources :

Example 41 with ALL_APPS

use of com.android.launcher3.LauncherState.ALL_APPS in project android_packages_apps_Trebuchet by LineageOS.

the class AbstractStateChangeTouchController method onDragEnd.

@Override
public void onDragEnd(float velocity) {
    boolean fling = mDetector.isFling(velocity);
    final int logAction = fling ? Touch.FLING : Touch.SWIPE;
    boolean blockedFling = fling && mFlingBlockCheck.isBlocked();
    if (blockedFling) {
        fling = false;
    }
    final LauncherState targetState;
    final float progress = mCurrentAnimation.getProgressFraction();
    final float progressVelocity = velocity * mProgressMultiplier;
    final float interpolatedProgress = mCurrentAnimation.getInterpolatedProgress();
    if (fling) {
        targetState = Float.compare(Math.signum(velocity), Math.signum(mProgressMultiplier)) == 0 ? mToState : mFromState;
    // snap to top or bottom using the release velocity
    } else {
        float successProgress = mToState == ALL_APPS ? MIN_PROGRESS_TO_ALL_APPS : SUCCESS_TRANSITION_PROGRESS;
        targetState = (interpolatedProgress > successProgress) ? mToState : mFromState;
    }
    final float endProgress;
    final float startProgress;
    final long duration;
    // Increase the duration if we prevented the fling, as we are going against a high velocity.
    final int durationMultiplier = blockedFling && targetState == mFromState ? LauncherAnimUtils.blockedFlingDurationFactor(velocity) : 1;
    if (targetState == mToState) {
        endProgress = 1;
        if (progress >= 1) {
            duration = 0;
            startProgress = 1;
        } else {
            startProgress = Utilities.boundToRange(progress + progressVelocity * getSingleFrameMs(mLauncher), 0f, 1f);
            duration = BaseSwipeDetector.calculateDuration(velocity, endProgress - Math.max(progress, 0)) * durationMultiplier;
        }
    } else {
        // Let the state manager know that the animation didn't go to the target state,
        // but don't cancel ourselves (we already clean up when the animation completes).
        mCurrentAnimation.dispatchOnCancelWithoutCancelRunnable();
        endProgress = 0;
        if (progress <= 0) {
            duration = 0;
            startProgress = 0;
        } else {
            startProgress = Utilities.boundToRange(progress + progressVelocity * getSingleFrameMs(mLauncher), 0f, 1f);
            duration = BaseSwipeDetector.calculateDuration(velocity, Math.min(progress, 1) - endProgress) * durationMultiplier;
        }
    }
    mCurrentAnimation.setEndAction(() -> onSwipeInteractionCompleted(targetState, logAction));
    ValueAnimator anim = mCurrentAnimation.getAnimationPlayer();
    anim.setFloatValues(startProgress, endProgress);
    maybeUpdateAtomicAnim(mFromState, targetState, targetState == mToState ? 1f : 0f);
    updateSwipeCompleteAnimation(anim, Math.max(duration, getRemainingAtomicDuration()), targetState, velocity, fling);
    mCurrentAnimation.dispatchOnStart();
    if (fling && targetState == LauncherState.ALL_APPS && !UNSTABLE_SPRINGS.get()) {
        mLauncher.getAppsView().addSpringFromFlingUpdateListener(anim, velocity);
    }
    anim.start();
    mAtomicAnimAutoPlayInfo = new AutoPlayAtomicAnimationInfo(endProgress, anim.getDuration());
    maybeAutoPlayAtomicComponentsAnim();
}
Also used : LauncherState(com.android.launcher3.LauncherState) ValueAnimator(android.animation.ValueAnimator)

Example 42 with ALL_APPS

use of com.android.launcher3.LauncherState.ALL_APPS in project android_packages_apps_Launcher3 by AOSPA.

the class Launcher method onInitialBindComplete.

@Override
@TargetApi(Build.VERSION_CODES.S)
public void onInitialBindComplete(IntSet boundPages, RunnableList pendingTasks) {
    mSynchronouslyBoundPages = boundPages;
    mPagesToBindSynchronously = new IntSet();
    clearPendingBinds();
    ViewOnDrawExecutor executor = new ViewOnDrawExecutor(pendingTasks);
    mPendingExecutor = executor;
    if (!isInState(ALL_APPS)) {
        mAppsView.getAppsStore().enableDeferUpdates(AllAppsStore.DEFER_UPDATES_NEXT_DRAW);
        pendingTasks.add(() -> mAppsView.getAppsStore().disableDeferUpdates(AllAppsStore.DEFER_UPDATES_NEXT_DRAW));
    }
    AlphaProperty property = mDragLayer.getAlphaProperty(ALPHA_INDEX_LAUNCHER_LOAD);
    if (property.getValue() < 1) {
        ObjectAnimator anim = ObjectAnimator.ofFloat(property, MultiValueAlpha.VALUE, 1);
        anim.addListener(AnimatorListeners.forEndCallback(executor::onLoadAnimationCompleted));
        anim.start();
    } else {
        executor.onLoadAnimationCompleted();
    }
    executor.attachTo(this);
    if (Utilities.ATLEAST_S) {
        Trace.endAsyncSection(DISPLAY_WORKSPACE_TRACE_METHOD_NAME, DISPLAY_WORKSPACE_TRACE_COOKIE);
    }
}
Also used : AlphaProperty(com.android.launcher3.util.MultiValueAlpha.AlphaProperty) IntSet(com.android.launcher3.util.IntSet) ObjectAnimator(android.animation.ObjectAnimator) ViewOnDrawExecutor(com.android.launcher3.util.ViewOnDrawExecutor) TargetApi(android.annotation.TargetApi)

Example 43 with ALL_APPS

use of com.android.launcher3.LauncherState.ALL_APPS in project android_packages_apps_Launcher3 by AOSPA.

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)

Example 44 with ALL_APPS

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

the class Launcher method onInitialBindComplete.

@Override
@TargetApi(Build.VERSION_CODES.S)
public void onInitialBindComplete(IntSet boundPages, RunnableList pendingTasks) {
    mSynchronouslyBoundPages = boundPages;
    mPagesToBindSynchronously = new IntSet();
    clearPendingBinds();
    ViewOnDrawExecutor executor = new ViewOnDrawExecutor(pendingTasks);
    mPendingExecutor = executor;
    if (!isInState(ALL_APPS)) {
        mAppsView.getAppsStore().enableDeferUpdates(AllAppsStore.DEFER_UPDATES_NEXT_DRAW);
        pendingTasks.add(() -> mAppsView.getAppsStore().disableDeferUpdates(AllAppsStore.DEFER_UPDATES_NEXT_DRAW));
    }
    AlphaProperty property = mDragLayer.getAlphaProperty(ALPHA_INDEX_LAUNCHER_LOAD);
    if (property.getValue() < 1) {
        ObjectAnimator anim = ObjectAnimator.ofFloat(property, MultiValueAlpha.VALUE, 1);
        anim.addListener(AnimatorListeners.forEndCallback(executor::onLoadAnimationCompleted));
        anim.start();
    } else {
        executor.onLoadAnimationCompleted();
    }
    executor.attachTo(this);
    if (Utilities.ATLEAST_S) {
        Trace.endAsyncSection(DISPLAY_WORKSPACE_TRACE_METHOD_NAME, DISPLAY_WORKSPACE_TRACE_COOKIE);
    }
}
Also used : AlphaProperty(com.android.launcher3.util.MultiValueAlpha.AlphaProperty) IntSet(com.android.launcher3.util.IntSet) ObjectAnimator(android.animation.ObjectAnimator) ViewOnDrawExecutor(com.android.launcher3.util.ViewOnDrawExecutor) TargetApi(android.annotation.TargetApi)

Example 45 with ALL_APPS

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

the class AbstractLauncherUiTest method checkLauncherIntegrity.

private void checkLauncherIntegrity(Launcher launcher, ContainerType expectedContainerType) {
    if (launcher != null) {
        final StateManager<LauncherState> 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();
        final boolean isStarted = launcher.isStarted();
        checkLauncherState(launcher, expectedContainerType, isResumed, isStarted);
        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:
                {
                    checkLauncherStateInOverview(launcher, expectedContainerType, isStarted, 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)

Aggregations

RecentsView (com.android.quickstep.views.RecentsView)16 ValueAnimator (android.animation.ValueAnimator)15 LauncherState (com.android.launcher3.LauncherState)13 ObjectAnimator (android.animation.ObjectAnimator)12 StateAnimationConfig (com.android.launcher3.states.StateAnimationConfig)12 AllAppsTransitionController (com.android.launcher3.allapps.AllAppsTransitionController)11 Animator (android.animation.Animator)9 AnimatorSet (android.animation.AnimatorSet)9 ALL_APPS (com.android.launcher3.LauncherState.ALL_APPS)9 OVERVIEW (com.android.launcher3.LauncherState.OVERVIEW)9 DEACCEL_1_7 (com.android.launcher3.anim.Interpolators.DEACCEL_1_7)9 LINEAR (com.android.launcher3.anim.Interpolators.LINEAR)9 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)8 Pair (android.util.Pair)7 View (android.view.View)7 DeviceProfile (com.android.launcher3.DeviceProfile)7 DropTarget (com.android.launcher3.DropTarget)7 Launcher (com.android.launcher3.Launcher)7 DragController (com.android.launcher3.dragndrop.DragController)7 AlphaProperty (com.android.launcher3.util.MultiValueAlpha.AlphaProperty)7