Search in sources :

Example 6 with ALL_APPS

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

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);
        if (ENABLE_QUICKSTEP_LIVE_TILE.get()) {
            builder.addOnFrameCallback(recentsView::redrawLiveTile);
        }
        AbstractFloatingView.closeOpenContainer(mLauncher, AbstractFloatingView.TYPE_TASK_MENU);
    } 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();
    mCurrentAnimation.getTarget().addListener(newCancelListener(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 7 with ALL_APPS

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

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)

Example 8 with ALL_APPS

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

the class AllAppsEduView method playAnimation.

private void playAnimation() {
    if (mAnimation != null) {
        return;
    }
    mAnimation = new AnimatorSet();
    final Rect circleBoundsOg = new Rect(mCircle.getBounds());
    final Rect gradientBoundsOg = new Rect(mGradient.getBounds());
    final Rect temp = new Rect();
    final float transY = mMaxHeightPx - mCircleSizePx - mPaddingPx;
    // 1st: Circle alpha/scale
    int firstPart = 600;
    // 2nd: Circle animates upwards, Gradient alpha fades in, Gradient grows, All Apps hint
    int secondPart = 1200;
    int introDuration = firstPart + secondPart;
    StateAnimationConfig config = new StateAnimationConfig();
    config.setInterpolator(ANIM_ALL_APPS_FADE, Interpolators.clampToProgress(ACCEL, 0, 0.08f));
    config.duration = secondPart;
    config.userControlled = false;
    AnimatorPlaybackController stateAnimationController = mLauncher.getStateManager().createAnimationToNewWorkspace(ALL_APPS, config);
    float maxAllAppsProgress = mLauncher.getDeviceProfile().isLandscape ? 0.35f : 0.15f;
    AllAppsTransitionController allAppsController = mLauncher.getAllAppsController();
    PendingAnimation allAppsAlpha = new PendingAnimation(config.duration);
    allAppsController.setAlphas(ALL_APPS, config, allAppsAlpha);
    mAnimation.play(allAppsAlpha.buildAnim());
    ValueAnimator intro = ValueAnimator.ofFloat(0, 1f);
    intro.setInterpolator(LINEAR);
    intro.setDuration(introDuration);
    intro.addUpdateListener((new MultiValueUpdateListener() {

        FloatProp mCircleAlpha = new FloatProp(0, 255, 0, firstPart, LINEAR);

        FloatProp mCircleScale = new FloatProp(2f, 1f, 0, firstPart, OVERSHOOT_1_7);

        FloatProp mDeltaY = new FloatProp(0, transY, firstPart, secondPart, FAST_OUT_SLOW_IN);

        FloatProp mGradientAlpha = new FloatProp(0, 255, firstPart, secondPart * 0.3f, LINEAR);

        @Override
        public void onUpdate(float progress) {
            temp.set(circleBoundsOg);
            temp.offset(0, (int) -mDeltaY.value);
            Utilities.scaleRectAboutCenter(temp, mCircleScale.value);
            mCircle.setBounds(temp);
            mCircle.setAlpha((int) mCircleAlpha.value);
            mGradient.setAlpha((int) mGradientAlpha.value);
            temp.set(gradientBoundsOg);
            temp.top -= mDeltaY.value;
            mGradient.setBounds(temp);
            invalidate();
            float stateProgress = Utilities.mapToRange(mDeltaY.value, 0, transY, 0, maxAllAppsProgress, LINEAR);
            stateAnimationController.setPlayFraction(stateProgress);
        }
    }));
    intro.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            mCircle.setAlpha(0);
            mGradient.setAlpha(0);
        }
    });
    mAnimation.play(intro);
    ValueAnimator closeAllApps = ValueAnimator.ofFloat(maxAllAppsProgress, 0f);
    closeAllApps.addUpdateListener(valueAnimator -> {
        stateAnimationController.setPlayFraction((float) valueAnimator.getAnimatedValue());
    });
    closeAllApps.setInterpolator(FAST_OUT_SLOW_IN);
    closeAllApps.setStartDelay(introDuration);
    closeAllApps.setDuration(250);
    mAnimation.play(closeAllApps);
    mAnimation.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            mAnimation = null;
            // Handles cancelling the animation used to hint towards All Apps.
            mLauncher.getStateManager().goToState(NORMAL, false);
            handleClose(false);
        }
    });
    mAnimation.start();
}
Also used : PendingAnimation(com.android.launcher3.anim.PendingAnimation) Rect(android.graphics.Rect) StateAnimationConfig(com.android.launcher3.states.StateAnimationConfig) AnimatorPlaybackController(com.android.launcher3.anim.AnimatorPlaybackController) AnimatorSet(android.animation.AnimatorSet) ValueAnimator(android.animation.ValueAnimator) MultiValueUpdateListener(com.android.quickstep.util.MultiValueUpdateListener) Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) AllAppsTransitionController(com.android.launcher3.allapps.AllAppsTransitionController) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter)

Example 9 with ALL_APPS

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

the class WorkTabTest method testWorkEduFlow.

@Test
public void testWorkEduFlow() {
    mDevice.pressHome();
    waitForLauncherCondition("Launcher didn't start", Objects::nonNull);
    executeOnLauncher(launcher -> launcher.getSharedPrefs().edit().remove(WorkEduView.KEY_WORK_EDU_STEP).remove(WorkEduView.KEY_LEGACY_WORK_EDU_SEEN).commit());
    waitForLauncherCondition("Work tab not setup", launcher -> launcher.getAppsView().getContentView() instanceof AllAppsPagedView, 60000);
    executeOnLauncher(launcher -> launcher.getStateManager().goToState(ALL_APPS));
    WorkEduView workEduView = getEduView();
    // verify personal app edu is seen first and click "next"
    executeOnLauncher(l -> {
        assertEquals(((TextView) workEduView.findViewById(R.id.content_text)).getText(), l.getResources().getString(R.string.work_profile_edu_personal_apps));
        workEduView.findViewById(R.id.proceed).callOnClick();
    });
    executeOnLauncher(launcher -> Log.d(TestProtocol.WORK_PROFILE_REMOVED, "Work profile status: " + launcher.getAppsView().isPersonalTabVisible()));
    // verify work edu is seen next
    waitForLauncherCondition("Launcher did not show the next edu screen", l -> ((AllAppsPagedView) l.getAppsView().getContentView()).getCurrentPage() == WORK_PAGE && ((TextView) workEduView.findViewById(R.id.content_text)).getText().equals(l.getResources().getString(R.string.work_profile_edu_work_apps)));
}
Also used : Objects(java.util.Objects) AllAppsPagedView(com.android.launcher3.allapps.AllAppsPagedView) WorkEduView(com.android.launcher3.views.WorkEduView) Test(org.junit.Test) LargeTest(androidx.test.filters.LargeTest)

Example 10 with ALL_APPS

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

the class Launcher method onNewIntent.

@Override
protected void onNewIntent(Intent intent) {
    if (Utilities.IS_RUNNING_IN_TEST_HARNESS) {
        Log.d(TestProtocol.PERMANENT_DIAG_TAG, "Launcher.onNewIntent: " + intent);
    }
    Object traceToken = TraceHelper.INSTANCE.beginSection(ON_NEW_INTENT_EVT);
    super.onNewIntent(intent);
    boolean alreadyOnHome = hasWindowFocus() && ((intent.getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) != Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
    // Check this condition before handling isActionMain, as this will get reset.
    boolean shouldMoveToDefaultScreen = alreadyOnHome && isInState(NORMAL) && AbstractFloatingView.getTopOpenView(this) == null;
    boolean isActionMain = Intent.ACTION_MAIN.equals(intent.getAction());
    boolean internalStateHandled = ACTIVITY_TRACKER.handleNewIntent(this, intent);
    if (isActionMain) {
        if (!internalStateHandled) {
            // In all these cases, only animate if we're already on home
            closeOpenViews(isStarted());
            if (!isInState(NORMAL)) {
                // Only change state, if not already the same. This prevents cancelling any
                // animations running as part of resume
                mStateManager.goToState(NORMAL, mStateManager.shouldAnimateStateChange(), this::handlePendingActivityRequest);
            }
            // Reset the apps view
            if (!alreadyOnHome) {
                mAppsView.reset(isStarted());
            }
            if (shouldMoveToDefaultScreen && !mWorkspace.isHandlingTouch()) {
                mWorkspace.post(mWorkspace::moveToDefaultScreen);
            }
        }
        // Handle HOME_INTENT
        UserEventDispatcher ued = getUserEventDispatcher();
        Target target = newContainerTarget(mStateManager.getState().containerType);
        target.pageIndex = mWorkspace.getCurrentPage();
        ued.logActionCommand(Action.Command.HOME_INTENT, target, newContainerTarget(ContainerType.WORKSPACE));
        hideKeyboard();
        if (mLauncherCallbacks != null) {
            mLauncherCallbacks.onHomeIntent(internalStateHandled);
        }
        mOverlayManager.hideOverlay(isStarted() && !isForceInvisible());
        handleGestureContract(intent);
    } else if (Intent.ACTION_ALL_APPS.equals(intent.getAction())) {
        getStateManager().goToState(ALL_APPS, alreadyOnHome);
    }
    TraceHelper.INSTANCE.endSection(traceToken);
}
Also used : UserEventDispatcher(com.android.launcher3.logging.UserEventDispatcher) Target(com.android.launcher3.userevent.nano.LauncherLogProto.Target) LoggerUtils.newContainerTarget(com.android.launcher3.logging.LoggerUtils.newContainerTarget) DragObject(com.android.launcher3.DropTarget.DragObject)

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