Search in sources :

Example 31 with ALL_APPS

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

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 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 + velocity * getSingleFrameMs(mLauncher) * mProgressMultiplier, 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 + velocity * getSingleFrameMs(mLauncher) * mProgressMultiplier, 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.dispatchOnStartWithVelocity(endProgress, velocity);
    if (fling && targetState == LauncherState.ALL_APPS && !QUICKSTEP_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 32 with ALL_APPS

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

the class ItemLongClickListener method onAllAppsItemLongClick.

private static boolean onAllAppsItemLongClick(View v) {
    if (TestProtocol.sDebugTracing) {
        Log.d(TestProtocol.NO_CONTEXT_MENU, "onAllAppsItemLongClick1");
    }
    Launcher launcher = Launcher.getLauncher(v.getContext());
    if (!canStartDrag(launcher))
        return false;
    if (TestProtocol.sDebugTracing) {
        Log.d(TestProtocol.NO_CONTEXT_MENU, "onAllAppsItemLongClick2");
    }
    // When we have exited all apps or are in transition, disregard long clicks
    if (!launcher.isInState(ALL_APPS) && !launcher.isInState(OVERVIEW))
        return false;
    if (TestProtocol.sDebugTracing) {
        Log.d(TestProtocol.NO_CONTEXT_MENU, "onAllAppsItemLongClick3");
    }
    if (launcher.getWorkspace().isSwitchingState())
        return false;
    // 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) DragController(com.android.launcher3.dragndrop.DragController) Launcher(com.android.launcher3.Launcher) DropTarget(com.android.launcher3.DropTarget)

Example 33 with ALL_APPS

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

the class FlingAndHoldTouchController method getAnimatorSetBuilderForStates.

@Override
protected AnimatorSetBuilder getAnimatorSetBuilderForStates(LauncherState fromState, LauncherState toState) {
    if (fromState == NORMAL && toState == ALL_APPS) {
        AnimatorSetBuilder builder = new AnimatorSetBuilder();
        // Fade in prediction icons quickly, then rest of all apps after reaching overview.
        float progressToReachOverview = NORMAL.getVerticalProgress(mLauncher) - OVERVIEW.getVerticalProgress(mLauncher);
        builder.setInterpolator(ANIM_ALL_APPS_HEADER_FADE, Interpolators.clampToProgress(ACCEL, 0, ALL_APPS_CONTENT_FADE_THRESHOLD));
        builder.setInterpolator(ANIM_ALL_APPS_FADE, Interpolators.clampToProgress(ACCEL, progressToReachOverview, progressToReachOverview + ALL_APPS_CONTENT_FADE_THRESHOLD));
        // Get workspace out of the way quickly, to prepare for potential pause.
        builder.setInterpolator(ANIM_WORKSPACE_SCALE, DEACCEL_3);
        builder.setInterpolator(ANIM_WORKSPACE_TRANSLATE, DEACCEL_3);
        builder.setInterpolator(ANIM_WORKSPACE_FADE, DEACCEL_3);
        return builder;
    } else if (fromState == ALL_APPS && toState == NORMAL) {
        AnimatorSetBuilder builder = new AnimatorSetBuilder();
        // Keep all apps/predictions opaque until the very end of the transition.
        float progressToReachOverview = OVERVIEW.getVerticalProgress(mLauncher);
        builder.setInterpolator(ANIM_ALL_APPS_FADE, Interpolators.clampToProgress(DEACCEL, progressToReachOverview - ALL_APPS_CONTENT_FADE_THRESHOLD, progressToReachOverview));
        builder.setInterpolator(ANIM_ALL_APPS_HEADER_FADE, Interpolators.clampToProgress(DEACCEL, 1 - ALL_APPS_CONTENT_FADE_THRESHOLD, 1));
        return builder;
    }
    return super.getAnimatorSetBuilderForStates(fromState, toState);
}
Also used : AnimatorSetBuilder(com.android.launcher3.anim.AnimatorSetBuilder)

Example 34 with ALL_APPS

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

the class AllAppsTipView method showAllAppsTipIfNecessary.

private static boolean showAllAppsTipIfNecessary(Launcher launcher) {
    FloatingHeaderView floatingHeaderView = launcher.getAppsView().getFloatingHeaderView();
    if (!floatingHeaderView.hasVisibleContent() || AbstractFloatingView.getOpenView(launcher, TYPE_ON_BOARD_POPUP | TYPE_DISCOVERY_BOUNCE) != null || !launcher.isInState(ALL_APPS) || hasSeenAllAppsTip(launcher) || UserManagerCompat.getInstance(launcher).isDemoUser() || Utilities.IS_RUNNING_IN_TEST_HARNESS) {
        return false;
    }
    AllAppsTipView allAppsTipView = new AllAppsTipView(launcher.getAppsView().getContext(), null);
    launcher.getDragLayer().addView(allAppsTipView);
    DragLayer.LayoutParams params = (DragLayer.LayoutParams) allAppsTipView.getLayoutParams();
    params.gravity = Gravity.CENTER_HORIZONTAL;
    int top = floatingHeaderView.findFixedRowByType(PredictionRowView.class).getTop();
    allAppsTipView.setY(top - launcher.getResources().getDimensionPixelSize(R.dimen.all_apps_tip_bottom_margin));
    allAppsTipView.setAlpha(0);
    allAppsTipView.animate().alpha(1f).withLayer().setStartDelay(SHOW_DELAY_MS).setDuration(SHOW_DURATION_MS).setInterpolator(Interpolators.DEACCEL).start();
    launcher.getUserEventDispatcher().logActionTip(LauncherEventUtil.VISIBLE, ALL_APPS_PREDICTION_TIPS);
    return true;
}
Also used : DragLayer(com.android.launcher3.dragndrop.DragLayer) Paint(android.graphics.Paint) FloatingHeaderView(com.android.launcher3.allapps.FloatingHeaderView)

Example 35 with ALL_APPS

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

the class AbstractLauncherUiTest method checkLauncherIntegrity.

private static 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();
        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)

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