Search in sources :

Example 11 with ALL_APPS

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

the class NavBarToHomeTouchController method initCurrentAnimation.

private void initCurrentAnimation() {
    long accuracy = (long) (getShiftRange() * 2);
    final PendingAnimation builder = new PendingAnimation(accuracy);
    if (mStartState.overviewUi) {
        RecentsView recentsView = mLauncher.getOverviewPanel();
        AnimatorControllerWithResistance.createRecentsResistanceFromOverviewAnim(mLauncher, builder);
        builder.setFloat(mLauncher.getDragLayer().getOverviewScrim(), OverviewScrim.SCRIM_MULTIPLIER, OVERVIEW_TO_HOME_SCRIM_MULTIPLIER, PULLBACK_INTERPOLATOR);
        if (ENABLE_QUICKSTEP_LIVE_TILE.get()) {
            builder.addOnFrameCallback(() -> recentsView.redrawLiveTile(false));
        }
    } else if (mStartState == ALL_APPS) {
        AllAppsTransitionController allAppsController = mLauncher.getAllAppsController();
        builder.setFloat(allAppsController, ALL_APPS_PROGRESS, -mPullbackDistance / allAppsController.getShiftRange(), PULLBACK_INTERPOLATOR);
        // Slightly fade out all apps content to further distinguish from scrolling.
        StateAnimationConfig config = new StateAnimationConfig();
        config.duration = accuracy;
        config.setInterpolator(StateAnimationConfig.ANIM_ALL_APPS_FADE, Interpolators.mapToProgress(PULLBACK_INTERPOLATOR, 0, 0.5f));
        allAppsController.setAlphas(mEndState, config, builder);
    }
    AbstractFloatingView topView = AbstractFloatingView.getTopOpenView(mLauncher);
    if (topView != null) {
        topView.addHintCloseAnim(mPullbackDistance, PULLBACK_INTERPOLATOR, builder);
    }
    mCurrentAnimation = builder.createPlaybackController().setOnCancelRunnable(this::clearState);
}
Also used : PendingAnimation(com.android.launcher3.anim.PendingAnimation) StateAnimationConfig(com.android.launcher3.states.StateAnimationConfig) AllAppsTransitionController(com.android.launcher3.allapps.AllAppsTransitionController) RecentsView(com.android.quickstep.views.RecentsView) AbstractFloatingView(com.android.launcher3.AbstractFloatingView)

Example 12 with ALL_APPS

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

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) || launcher.getSystemService(UserManager.class).isDemoUser() || Utilities.IS_RUNNING_IN_TEST_HARNESS) {
        return false;
    }
    int[] coords = new int[2];
    floatingHeaderView.findFixedRowByType(PredictionRowView.class).getLocationOnScreen(coords);
    ArrowTipView arrowTipView = new ArrowTipView(launcher).setOnClosedCallback(() -> {
        launcher.getSharedPrefs().edit().putBoolean(ALL_APPS_TIP_SEEN, true).apply();
        launcher.getUserEventDispatcher().logActionTip(LauncherEventUtil.DISMISS, ALL_APPS_PREDICTION_TIPS);
    });
    arrowTipView.show(launcher.getString(R.string.all_apps_prediction_tip), coords[1]);
    return true;
}
Also used : UserManager(android.os.UserManager) ArrowTipView(com.android.launcher3.views.ArrowTipView) FloatingHeaderView(com.android.launcher3.allapps.FloatingHeaderView)

Example 13 with ALL_APPS

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

the class NavBarToHomeTouchController method initCurrentAnimation.

private void initCurrentAnimation() {
    long accuracy = (long) (getShiftRange() * 2);
    final AnimatorSet anim = new AnimatorSet();
    if (mStartState == OVERVIEW) {
        RecentsView recentsView = mLauncher.getOverviewPanel();
        float pullbackDist = mPullbackDistance;
        if (!recentsView.isRtl()) {
            pullbackDist = -pullbackDist;
        }
        Animator pullback = ObjectAnimator.ofFloat(recentsView, TRANSLATION_X, pullbackDist);
        pullback.setInterpolator(PULLBACK_INTERPOLATOR);
        anim.play(pullback);
    } else if (mStartState == ALL_APPS) {
        AnimatorSetBuilder builder = new AnimatorSetBuilder();
        AllAppsTransitionController allAppsController = mLauncher.getAllAppsController();
        Animator allAppsProgress = ObjectAnimator.ofFloat(allAppsController, ALL_APPS_PROGRESS, -mPullbackDistance / allAppsController.getShiftRange());
        allAppsProgress.setInterpolator(PULLBACK_INTERPOLATOR);
        builder.play(allAppsProgress);
        // Slightly fade out all apps content to further distinguish from scrolling.
        builder.setInterpolator(AnimatorSetBuilder.ANIM_ALL_APPS_FADE, Interpolators.mapToProgress(PULLBACK_INTERPOLATOR, 0, 0.5f));
        AnimationConfig config = new AnimationConfig();
        config.duration = accuracy;
        allAppsController.setAlphas(mEndState.getVisibleElements(mLauncher), config, builder);
        anim.play(builder.build());
    }
    AbstractFloatingView topView = AbstractFloatingView.getTopOpenView(mLauncher);
    if (topView != null) {
        Animator hintCloseAnim = topView.createHintCloseAnim(mPullbackDistance);
        if (hintCloseAnim != null) {
            hintCloseAnim.setInterpolator(PULLBACK_INTERPOLATOR);
            anim.play(hintCloseAnim);
        }
    }
    anim.setDuration(accuracy);
    mCurrentAnimation = AnimatorPlaybackController.wrap(anim, accuracy, this::clearState);
}
Also used : Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) ValueAnimator(android.animation.ValueAnimator) AnimatorSetBuilder(com.android.launcher3.anim.AnimatorSetBuilder) AllAppsTransitionController(com.android.launcher3.allapps.AllAppsTransitionController) RecentsView(com.android.quickstep.views.RecentsView) AnimatorSet(android.animation.AnimatorSet) AnimationConfig(com.android.launcher3.LauncherStateManager.AnimationConfig) AbstractFloatingView(com.android.launcher3.AbstractFloatingView)

Example 14 with ALL_APPS

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

the class QuickstepAppTransitionManagerImpl method getLauncherContentAnimator.

/**
 * Content is everything on screen except the background and the floating view (if any).
 *
 * @param isAppOpening True when this is called when an app is opening.
 *                     False when this is called when an app is closing.
 * @param trans        Array that contains the start and end translation values for the content.
 */
protected Pair<AnimatorSet, Runnable> getLauncherContentAnimator(boolean isAppOpening, float[] trans) {
    AnimatorSet launcherAnimator = new AnimatorSet();
    Runnable endListener;
    float[] alphas = isAppOpening ? new float[] { 1, 0 } : new float[] { 0, 1 };
    if (mLauncher.isInState(ALL_APPS)) {
        // All Apps in portrait mode is full screen, so we only animate AllAppsContainerView.
        final View appsView = mLauncher.getAppsView();
        final float startAlpha = appsView.getAlpha();
        final float startY = appsView.getTranslationY();
        appsView.setAlpha(alphas[0]);
        appsView.setTranslationY(trans[0]);
        ObjectAnimator alpha = ObjectAnimator.ofFloat(appsView, View.ALPHA, alphas);
        alpha.setDuration(CONTENT_ALPHA_DURATION);
        alpha.setInterpolator(LINEAR);
        appsView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
        alpha.addListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(Animator animation) {
                appsView.setLayerType(View.LAYER_TYPE_NONE, null);
            }
        });
        ObjectAnimator transY = ObjectAnimator.ofFloat(appsView, View.TRANSLATION_Y, trans);
        transY.setInterpolator(AGGRESSIVE_EASE);
        transY.setDuration(CONTENT_TRANSLATION_DURATION);
        launcherAnimator.play(alpha);
        launcherAnimator.play(transY);
        endListener = () -> {
            appsView.setAlpha(startAlpha);
            appsView.setTranslationY(startY);
            appsView.setLayerType(View.LAYER_TYPE_NONE, null);
        };
    } else if (mLauncher.isInState(OVERVIEW)) {
        AllAppsTransitionController allAppsController = mLauncher.getAllAppsController();
        launcherAnimator.play(ObjectAnimator.ofFloat(allAppsController, ALL_APPS_PROGRESS, allAppsController.getProgress(), ALL_APPS_PROGRESS_OFF_SCREEN));
        endListener = composeViewContentAnimator(launcherAnimator, alphas, trans);
    } else {
        mDragLayerAlpha.setValue(alphas[0]);
        ObjectAnimator alpha = ObjectAnimator.ofFloat(mDragLayerAlpha, MultiValueAlpha.VALUE, alphas);
        alpha.setDuration(CONTENT_ALPHA_DURATION);
        alpha.setInterpolator(LINEAR);
        launcherAnimator.play(alpha);
        mDragLayer.setTranslationY(trans[0]);
        ObjectAnimator transY = ObjectAnimator.ofFloat(mDragLayer, View.TRANSLATION_Y, trans);
        transY.setInterpolator(AGGRESSIVE_EASE);
        transY.setDuration(CONTENT_TRANSLATION_DURATION);
        launcherAnimator.play(transY);
        mDragLayer.getScrim().hideSysUiScrim(true);
        // Pause page indicator animations as they lead to layer trashing.
        mLauncher.getWorkspace().getPageIndicator().pauseAnimations();
        mDragLayer.setLayerType(View.LAYER_TYPE_HARDWARE, null);
        endListener = this::resetContentView;
    }
    return new Pair<>(launcherAnimator, endListener);
}
Also used : Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) ValueAnimator(android.animation.ValueAnimator) AllAppsTransitionController(com.android.launcher3.allapps.AllAppsTransitionController) ObjectAnimator(android.animation.ObjectAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) AnimatorSet(android.animation.AnimatorSet) View(android.view.View) FloatingIconView(com.android.launcher3.views.FloatingIconView) DeepShortcutView(com.android.launcher3.shortcuts.DeepShortcutView) Pair(android.util.Pair)

Example 15 with ALL_APPS

use of com.android.launcher3.LauncherState.ALL_APPS 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)

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