Search in sources :

Example 1 with ShelfAnimState

use of com.android.quickstep.util.ShelfPeekAnim.ShelfAnimState in project Neo-Launcher by NeoApplications.

the class LauncherActivityControllerHelper method prepareRecentsUI.

@Override
public AnimationFactory prepareRecentsUI(Launcher activity, boolean activityVisible, boolean animateActivity, Consumer<AnimatorPlaybackController> callback) {
    final LauncherState startState = activity.getStateManager().getState();
    LauncherState resetState = startState;
    if (startState.disableRestore) {
        resetState = activity.getStateManager().getRestState();
    }
    activity.getStateManager().setRestState(resetState);
    final LauncherState fromState = animateActivity ? BACKGROUND_APP : OVERVIEW;
    activity.getStateManager().goToState(fromState, false);
    // Since all apps is not visible, we can safely reset the scroll position.
    // This ensures then the next swipe up to all-apps starts from scroll 0.
    activity.getAppsView().reset(false);
    return new AnimationFactory() {

        private final ShelfPeekAnim mShelfAnim = ((QuickstepAppTransitionManagerImpl) activity.getAppTransitionManager()).getShelfPeekAnim();

        private boolean mIsAttachedToWindow;

        @Override
        public void createActivityController(long transitionLength) {
            createActivityControllerInternal(activity, fromState, transitionLength, callback);
            // attached state here as well to ensure recents is shown/hidden appropriately.
            if (SysUINavigationMode.getMode(activity) == Mode.NO_BUTTON) {
                setRecentsAttachedToAppWindow(mIsAttachedToWindow, false);
            }
        }

        @Override
        public void adjustActivityControllerInterpolators() {
            if (mAdjustInterpolatorsRunnable != null) {
                mAdjustInterpolatorsRunnable.run();
            }
        }

        @Override
        public void onTransitionCancelled() {
            activity.getStateManager().goToState(startState, false);
        }

        @Override
        public void setShelfState(ShelfAnimState shelfState, Interpolator interpolator, long duration) {
            mShelfAnim.setShelfState(shelfState, interpolator, duration);
        }

        @Override
        public void setRecentsAttachedToAppWindow(boolean attached, boolean animate) {
            if (mIsAttachedToWindow == attached && animate) {
                return;
            }
            mIsAttachedToWindow = attached;
            LauncherRecentsView recentsView = activity.getOverviewPanel();
            Animator fadeAnim = activity.getStateManager().createStateElementAnimation(INDEX_RECENTS_FADE_ANIM, attached ? 1 : 0);
            int runningTaskIndex = recentsView.getRunningTaskIndex();
            if (runningTaskIndex == recentsView.getTaskViewStartIndex()) {
                // If we are on the first task (we haven't quick switched), translate recents in
                // from the side. Calculate the start translation based on current scale/scroll.
                float currScale = recentsView.getScaleX();
                float scrollOffsetX = recentsView.getScrollOffset();
                float offscreenX = recentsView.getOffscreenTranslationX(currScale);
                float fromTranslationX = attached ? offscreenX - scrollOffsetX : 0;
                float toTranslationX = attached ? 0 : offscreenX - scrollOffsetX;
                activity.getStateManager().cancelStateElementAnimation(INDEX_RECENTS_TRANSLATE_X_ANIM);
                if (!recentsView.isShown() && animate) {
                    recentsView.setTranslationX(fromTranslationX);
                } else {
                    fromTranslationX = recentsView.getTranslationX();
                }
                if (!animate) {
                    recentsView.setTranslationX(toTranslationX);
                } else {
                    activity.getStateManager().createStateElementAnimation(INDEX_RECENTS_TRANSLATE_X_ANIM, fromTranslationX, toTranslationX).start();
                }
                fadeAnim.setInterpolator(attached ? INSTANT : ACCEL_2);
            } else {
                fadeAnim.setInterpolator(ACCEL_DEACCEL);
            }
            fadeAnim.setDuration(animate ? RECENTS_ATTACH_DURATION : 0).start();
        }
    };
}
Also used : LauncherState(com.android.launcher3.LauncherState) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) ShelfPeekAnim(com.android.quickstep.util.ShelfPeekAnim) ShelfAnimState(com.android.quickstep.util.ShelfPeekAnim.ShelfAnimState) Interpolator(android.view.animation.Interpolator) TimeInterpolator(android.animation.TimeInterpolator) LauncherRecentsView(com.android.quickstep.views.LauncherRecentsView)

Example 2 with ShelfAnimState

use of com.android.quickstep.util.ShelfPeekAnim.ShelfAnimState in project Neo-Launcher by NeoApplications.

the class NoButtonQuickSwitchTouchController method onMotionPauseChanged.

@Override
public void onMotionPauseChanged(boolean isPaused) {
    ShelfAnimState shelfState = isPaused ? PEEK : HIDE;
    if (shelfState == PEEK) {
        // Some shelf elements (e.g. qsb) were hidden, but we need them visible when peeking.
        AnimatorSetBuilder builder = new AnimatorSetBuilder();
        AllAppsTransitionController allAppsController = mLauncher.getAllAppsController();
        allAppsController.setAlphas(NORMAL.getVisibleElements(mLauncher), new AnimationConfig(), builder);
        builder.build().setDuration(0).start();
        if ((OVERVIEW.getVisibleElements(mLauncher) & HOTSEAT_ICONS) != 0) {
            // Hotseat was hidden, but we need it visible when peeking.
            mLauncher.getHotseat().setAlpha(1);
        }
    }
    mShelfPeekAnim.setShelfState(shelfState, ShelfPeekAnim.INTERPOLATOR, ShelfPeekAnim.DURATION);
    VibratorWrapper.INSTANCE.get(mLauncher).vibrate(OVERVIEW_HAPTIC);
}
Also used : AnimatorSetBuilder(com.android.launcher3.anim.AnimatorSetBuilder) AllAppsTransitionController(com.android.launcher3.allapps.AllAppsTransitionController) ShelfAnimState(com.android.quickstep.util.ShelfPeekAnim.ShelfAnimState) AnimationConfig(com.android.launcher3.LauncherStateManager.AnimationConfig)

Example 3 with ShelfAnimState

use of com.android.quickstep.util.ShelfPeekAnim.ShelfAnimState in project android_packages_apps_Trebuchet by LineageOS.

the class LauncherActivityInterface method prepareRecentsUI.

@Override
public AnimationFactory prepareRecentsUI(RecentsAnimationDeviceState deviceState, boolean activityVisible, Consumer<AnimatorControllerWithResistance> callback) {
    notifyRecentsOfOrientation(deviceState.getRotationTouchHelper());
    DefaultAnimationFactory factory = new DefaultAnimationFactory(callback) {

        @Override
        public void setShelfState(ShelfAnimState shelfState, Interpolator interpolator, long duration) {
            mActivity.getShelfPeekAnim().setShelfState(shelfState, interpolator, duration);
        }

        @Override
        protected void createBackgroundToOverviewAnim(BaseQuickstepLauncher activity, PendingAnimation pa) {
            super.createBackgroundToOverviewAnim(activity, pa);
            if (!activity.getDeviceProfile().isVerticalBarLayout() && SysUINavigationMode.getMode(activity) != Mode.NO_BUTTON) {
                // Don't animate the shelf when the mode is NO_BUTTON, because we
                // update it atomically.
                pa.add(activity.getStateManager().createStateElementAnimation(INDEX_SHELF_ANIM, BACKGROUND_APP.getVerticalProgress(activity), OVERVIEW.getVerticalProgress(activity)));
            }
            // Animate the blur and wallpaper zoom
            float fromDepthRatio = BACKGROUND_APP.getDepth(activity);
            float toDepthRatio = OVERVIEW.getDepth(activity);
            pa.addFloat(getDepthController(), new ClampedDepthProperty(fromDepthRatio, toDepthRatio), fromDepthRatio, toDepthRatio, LINEAR);
        }
    };
    BaseQuickstepLauncher launcher = factory.initUI();
    // Since all apps is not visible, we can safely reset the scroll position.
    // This ensures then the next swipe up to all-apps starts from scroll 0.
    launcher.getAppsView().reset(false);
    return factory;
}
Also used : PendingAnimation(com.android.launcher3.anim.PendingAnimation) BaseQuickstepLauncher(com.android.launcher3.BaseQuickstepLauncher) ClampedDepthProperty(com.android.launcher3.statehandlers.DepthController.ClampedDepthProperty) ShelfAnimState(com.android.quickstep.util.ShelfPeekAnim.ShelfAnimState) Interpolator(android.view.animation.Interpolator)

Example 4 with ShelfAnimState

use of com.android.quickstep.util.ShelfPeekAnim.ShelfAnimState in project android_packages_apps_Trebuchet by LineageOS.

the class NoButtonQuickSwitchTouchController method onMotionPauseChanged.

@Override
public void onMotionPauseChanged(boolean isPaused) {
    VibratorWrapper.INSTANCE.get(mLauncher).vibrate(OVERVIEW_HAPTIC);
    if (FeatureFlags.ENABLE_OVERVIEW_ACTIONS.get()) {
        return;
    }
    ShelfAnimState shelfState = isPaused ? PEEK : HIDE;
    if (shelfState == PEEK) {
        // Some shelf elements (e.g. qsb) were hidden, but we need them visible when peeking.
        AllAppsTransitionController allAppsController = mLauncher.getAllAppsController();
        allAppsController.setAlphas(NORMAL, new StateAnimationConfig(), NO_ANIM_PROPERTY_SETTER);
        if ((OVERVIEW.getVisibleElements(mLauncher) & HOTSEAT_ICONS) != 0) {
            // Hotseat was hidden, but we need it visible when peeking.
            mLauncher.getHotseat().setAlpha(1);
        }
    }
    mShelfPeekAnim.setShelfState(shelfState, ShelfPeekAnim.INTERPOLATOR, ShelfPeekAnim.DURATION);
}
Also used : StateAnimationConfig(com.android.launcher3.states.StateAnimationConfig) AllAppsTransitionController(com.android.launcher3.allapps.AllAppsTransitionController) ShelfAnimState(com.android.quickstep.util.ShelfPeekAnim.ShelfAnimState)

Aggregations

ShelfAnimState (com.android.quickstep.util.ShelfPeekAnim.ShelfAnimState)4 Interpolator (android.view.animation.Interpolator)2 AllAppsTransitionController (com.android.launcher3.allapps.AllAppsTransitionController)2 Animator (android.animation.Animator)1 ObjectAnimator (android.animation.ObjectAnimator)1 TimeInterpolator (android.animation.TimeInterpolator)1 BaseQuickstepLauncher (com.android.launcher3.BaseQuickstepLauncher)1 LauncherState (com.android.launcher3.LauncherState)1 AnimationConfig (com.android.launcher3.LauncherStateManager.AnimationConfig)1 AnimatorSetBuilder (com.android.launcher3.anim.AnimatorSetBuilder)1 PendingAnimation (com.android.launcher3.anim.PendingAnimation)1 ClampedDepthProperty (com.android.launcher3.statehandlers.DepthController.ClampedDepthProperty)1 StateAnimationConfig (com.android.launcher3.states.StateAnimationConfig)1 ShelfPeekAnim (com.android.quickstep.util.ShelfPeekAnim)1 LauncherRecentsView (com.android.quickstep.views.LauncherRecentsView)1