Search in sources :

Example 1 with ALL_APPS

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

the class QuickstepTransitionManager 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 startDelay   Start delay duration.
 */
private Pair<AnimatorSet, Runnable> getLauncherContentAnimator(boolean isAppOpening, int startDelay) {
    AnimatorSet launcherAnimator = new AnimatorSet();
    Runnable endListener;
    float[] alphas = isAppOpening ? new float[] { 1, 0 } : new float[] { 0, 1 };
    float[] scales = isAppOpening ? new float[] { 1, mContentScale } : new float[] { mContentScale, 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 startScale = SCALE_PROPERTY.get(appsView);
        appsView.setAlpha(alphas[0]);
        SCALE_PROPERTY.set(appsView, scales[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 scale = ObjectAnimator.ofFloat(appsView, SCALE_PROPERTY, scales);
        scale.setInterpolator(AGGRESSIVE_EASE);
        scale.setDuration(CONTENT_SCALE_DURATION);
        launcherAnimator.play(alpha);
        launcherAnimator.play(scale);
        endListener = () -> {
            appsView.setAlpha(startAlpha);
            SCALE_PROPERTY.set(appsView, startScale);
            appsView.setLayerType(View.LAYER_TYPE_NONE, null);
        };
    } else if (mLauncher.isInState(OVERVIEW)) {
        endListener = composeViewContentAnimator(launcherAnimator, alphas, scales);
    } else {
        List<View> viewsToAnimate = new ArrayList<>();
        Workspace workspace = mLauncher.getWorkspace();
        workspace.forEachVisiblePage(view -> viewsToAnimate.add(((CellLayout) view).getShortcutsAndWidgets()));
        viewsToAnimate.add(mLauncher.getHotseat());
        viewsToAnimate.forEach(view -> {
            view.setLayerType(View.LAYER_TYPE_HARDWARE, null);
            ObjectAnimator scaleAnim = ObjectAnimator.ofFloat(view, SCALE_PROPERTY, scales).setDuration(CONTENT_SCALE_DURATION);
            scaleAnim.setInterpolator(DEACCEL_1_5);
            launcherAnimator.play(scaleAnim);
        });
        final boolean scrimEnabled = ENABLE_SCRIM_FOR_APP_LAUNCH.get();
        if (scrimEnabled) {
            int scrimColor = Themes.getAttrColor(mLauncher, R.attr.overviewScrimColor);
            int scrimColorTrans = ColorUtils.setAlphaComponent(scrimColor, 0);
            int[] colors = isAppOpening ? new int[] { scrimColorTrans, scrimColor } : new int[] { scrimColor, scrimColorTrans };
            ScrimView scrimView = mLauncher.getScrimView();
            if (scrimView.getBackground() instanceof ColorDrawable) {
                scrimView.setBackgroundColor(colors[0]);
                ObjectAnimator scrim = ObjectAnimator.ofArgb(scrimView, VIEW_BACKGROUND_COLOR, colors);
                scrim.setDuration(CONTENT_SCRIM_DURATION);
                scrim.setInterpolator(DEACCEL_1_5);
                launcherAnimator.play(scrim);
            }
        }
        // Pause page indicator animations as they lead to layer trashing.
        mLauncher.getWorkspace().getPageIndicator().pauseAnimations();
        endListener = () -> {
            viewsToAnimate.forEach(view -> {
                SCALE_PROPERTY.set(view, 1f);
                view.setLayerType(View.LAYER_TYPE_NONE, null);
            });
            if (scrimEnabled) {
                mLauncher.getScrimView().setBackgroundColor(Color.TRANSPARENT);
            }
            mLauncher.getWorkspace().getPageIndicator().skipAnimationsToEnd();
        };
    }
    launcherAnimator.setStartDelay(startDelay);
    return new Pair<>(launcherAnimator, endListener);
}
Also used : BACKGROUND_APP(com.android.launcher3.LauncherState.BACKGROUND_APP) BlurUtils(com.android.systemui.shared.system.BlurUtils) NonNull(androidx.annotation.NonNull) ColorDrawable(android.graphics.drawable.ColorDrawable) OVERVIEW(com.android.launcher3.LauncherState.OVERVIEW) Drawable(android.graphics.drawable.Drawable) KEYGUARD_ANIMATION(com.android.launcher3.config.FeatureFlags.KEYGUARD_ANIMATION) DisplayController.getSingleFrameMs(com.android.launcher3.util.DisplayController.getSingleFrameMs) Handler(android.os.Handler) Looper(android.os.Looper) AnimationSuccessListener(com.android.launcher3.anim.AnimationSuccessListener) InteractionJankMonitorWrapper(com.android.systemui.shared.system.InteractionJankMonitorWrapper) SCALE_PROPERTY(com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY) PathInterpolator(android.view.animation.PathInterpolator) MODE_CLOSING(com.android.systemui.shared.system.RemoteAnimationTargetCompat.MODE_CLOSING) Interpolator(android.view.animation.Interpolator) AGGRESSIVE_EASE(com.android.launcher3.anim.Interpolators.AGGRESSIVE_EASE) STARTING_WINDOW_TYPE_SPLASH_SCREEN(android.window.StartingWindowInfo.STARTING_WINDOW_TYPE_SPLASH_SCREEN) ViewRootImpl(android.view.ViewRootImpl) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) Nullable(androidx.annotation.Nullable) RemoteAnimationFactory(com.android.launcher3.LauncherAnimationRunner.RemoteAnimationFactory) ActivityCompat(com.android.systemui.shared.system.ActivityCompat) INVISIBLE_BY_APP_TRANSITIONS(com.android.launcher3.BaseActivity.INVISIBLE_BY_APP_TRANSITIONS) LauncherAppWidgetHostView(com.android.launcher3.widget.LauncherAppWidgetHostView) QuickStepContract.getWindowCornerRadius(com.android.systemui.shared.system.QuickStepContract.getWindowCornerRadius) RemoteAnimationDefinitionCompat(com.android.systemui.shared.system.RemoteAnimationDefinitionCompat) TaskUtils.taskIsATargetWithMode(com.android.quickstep.TaskUtils.taskIsATargetWithMode) DEACCEL_1_5(com.android.launcher3.anim.Interpolators.DEACCEL_1_5) SEPARATE_RECENTS_ACTIVITY(com.android.launcher3.config.FeatureFlags.SEPARATE_RECENTS_ACTIVITY) RemoteAnimationTargetCompat(com.android.systemui.shared.system.RemoteAnimationTargetCompat) QuickStepContract(com.android.systemui.shared.system.QuickStepContract) SystemUiProxy(com.android.quickstep.SystemUiProxy) DEACCEL_1_7(com.android.launcher3.anim.Interpolators.DEACCEL_1_7) RemoteAnimationTargets(com.android.quickstep.RemoteAnimationTargets) ArrayList(java.util.ArrayList) WorkspaceRevealAnim(com.android.quickstep.util.WorkspaceRevealAnim) LinkedHashMap(java.util.LinkedHashMap) FloatingIconView(com.android.launcher3.views.FloatingIconView) TaskViewUtils.findTaskViewToLaunch(com.android.quickstep.TaskViewUtils.findTaskViewToLaunch) RemoteAnimationProvider(com.android.quickstep.util.RemoteAnimationProvider) DEPTH(com.android.launcher3.statehandlers.DepthController.DEPTH) OnDeviceProfileChangeListener(com.android.launcher3.DeviceProfile.OnDeviceProfileChangeListener) FastBitmapDrawable(com.android.launcher3.icons.FastBitmapDrawable) VIEW_BACKGROUND_COLOR(com.android.launcher3.LauncherAnimUtils.VIEW_BACKGROUND_COLOR) DeepShortcutView(com.android.launcher3.shortcuts.DeepShortcutView) ENABLE_SCRIM_FOR_APP_LAUNCH(com.android.launcher3.config.FeatureFlags.ENABLE_SCRIM_FOR_APP_LAUNCH) STARTING_WINDOW_TYPE_NONE(android.window.StartingWindowInfo.STARTING_WINDOW_TYPE_NONE) INVISIBLE_BY_PENDING_FLAGS(com.android.launcher3.BaseActivity.INVISIBLE_BY_PENDING_FLAGS) SystemProperties(android.os.SystemProperties) LINEAR(com.android.launcher3.anim.Interpolators.LINEAR) IStartingWindowListener(com.android.wm.shell.startingsurface.IStartingWindowListener) AlphaProperty(com.android.launcher3.util.MultiValueAlpha.AlphaProperty) ColorUtils(androidx.core.graphics.ColorUtils) RunnableList(com.android.launcher3.util.RunnableList) RemoteAnimationRunnerCompat(com.android.systemui.shared.system.RemoteAnimationRunnerCompat) ValueAnimator(android.animation.ValueAnimator) Rect(android.graphics.Rect) PackageManager(android.content.pm.PackageManager) Animator(android.animation.Animator) PENDING_INVISIBLE_BY_WALLPAPER_ANIMATION(com.android.launcher3.BaseActivity.PENDING_INVISIBLE_BY_WALLPAPER_ANIMATION) RemoteAnimationAdapterCompat(com.android.systemui.shared.system.RemoteAnimationAdapterCompat) WindowManagerWrapper(com.android.systemui.shared.system.WindowManagerWrapper) TaskViewUtils(com.android.quickstep.TaskViewUtils) View(android.view.View) Matrix(android.graphics.Matrix) RectF(android.graphics.RectF) DepthController(com.android.launcher3.statehandlers.DepthController) ObjectAnimator(android.animation.ObjectAnimator) CancellationSignal(android.os.CancellationSignal) ALPHA_INDEX_TRANSITIONS(com.android.launcher3.dragndrop.DragLayer.ALPHA_INDEX_TRANSITIONS) List(java.util.List) ALL_APPS(com.android.launcher3.LauncherState.ALL_APPS) Utilities.postAsyncCallback(com.android.launcher3.Utilities.postAsyncCallback) Themes(com.android.launcher3.util.Themes) SurfaceTransactionApplier(com.android.quickstep.util.SurfaceTransactionApplier) Size(android.util.Size) ActivityOptionsCompat(com.android.systemui.shared.system.ActivityOptionsCompat) Context(android.content.Context) Pair(android.util.Pair) AnimationUtils(android.view.animation.AnimationUtils) MODE_OPENING(com.android.systemui.shared.system.RemoteAnimationTargetCompat.MODE_OPENING) AnimatorSet(android.animation.AnimatorSet) DragLayer(com.android.launcher3.dragndrop.DragLayer) ActivityOptionsWrapper(com.android.launcher3.util.ActivityOptionsWrapper) SurfaceParams(com.android.systemui.shared.system.SyncRtSurfaceTransactionApplierCompat.SurfaceParams) INVISIBLE_ALL(com.android.launcher3.BaseActivity.INVISIBLE_ALL) MultiValueUpdateListener(com.android.quickstep.util.MultiValueUpdateListener) Point(android.graphics.Point) RemoteTransitionCompat(com.android.systemui.shared.system.RemoteTransitionCompat) Color(android.graphics.Color) SurfaceControl(android.view.SurfaceControl) QuickStepContract.supportsRoundedCornersOnWindows(com.android.systemui.shared.system.QuickStepContract.supportsRoundedCornersOnWindows) ViewTreeObserver(android.view.ViewTreeObserver) ScrimView(com.android.launcher3.views.ScrimView) RecentsView(com.android.quickstep.views.RecentsView) FloatingWidgetView(com.android.quickstep.views.FloatingWidgetView) Resources(android.content.res.Resources) ObjectAnimator(android.animation.ObjectAnimator) AnimatorSet(android.animation.AnimatorSet) ScrimView(com.android.launcher3.views.ScrimView) LauncherAppWidgetHostView(com.android.launcher3.widget.LauncherAppWidgetHostView) FloatingIconView(com.android.launcher3.views.FloatingIconView) DeepShortcutView(com.android.launcher3.shortcuts.DeepShortcutView) View(android.view.View) ScrimView(com.android.launcher3.views.ScrimView) RecentsView(com.android.quickstep.views.RecentsView) FloatingWidgetView(com.android.quickstep.views.FloatingWidgetView) ValueAnimator(android.animation.ValueAnimator) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) ColorDrawable(android.graphics.drawable.ColorDrawable) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) ArrayList(java.util.ArrayList) RunnableList(com.android.launcher3.util.RunnableList) List(java.util.List) Pair(android.util.Pair)

Example 2 with ALL_APPS

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

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 3 with ALL_APPS

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

the class WorkTabTest method testWorkEduFlow.

@Ignore("b/182844465")
@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 -> {
        if (launcher.getAppsView().getContentView() instanceof AllAppsPagedView) {
            launcher.getAppsView().getAppsStore().enableDeferUpdates(DEFER_UPDATES_TEST);
            return true;
        }
        return false;
    }, LauncherInstrumentation.WAIT_TIME_MS);
    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();
    });
    AtomicInteger attempt = new AtomicInteger(0);
    // verify work edu is seen next
    waitForLauncherCondition("Launcher did not show the next edu screen", l -> {
        Log.d(TestProtocol.WORK_PROFILE_REMOVED, "running test attempt" + attempt.getAndIncrement());
        if (!(l.getAppsView().getContentView() instanceof AllAppsPagedView)) {
            Log.d(TestProtocol.WORK_PROFILE_REMOVED, "Work tab not setup. Skipping test");
            return false;
        }
        if (((AllAppsPagedView) l.getAppsView().getContentView()).getCurrentPage() != WORK_PAGE) {
            Log.d(TestProtocol.WORK_PROFILE_REMOVED, "Work page not highlighted");
        }
        return ((TextView) workEduView.findViewById(R.id.content_text)).getText().equals(l.getResources().getString(R.string.work_profile_edu_work_apps));
    });
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Objects(java.util.Objects) AllAppsPagedView(com.android.launcher3.allapps.AllAppsPagedView) WorkEduView(com.android.launcher3.views.WorkEduView) Ignore(org.junit.Ignore) LargeTest(androidx.test.filters.LargeTest) Test(org.junit.Test)

Example 4 with ALL_APPS

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

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 5 with ALL_APPS

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

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

LargeTest (androidx.test.filters.LargeTest)3 AllAppsPagedView (com.android.launcher3.allapps.AllAppsPagedView)2 RecentsView (com.android.quickstep.views.RecentsView)2 Objects (java.util.Objects)2 Ignore (org.junit.Ignore)2 Test (org.junit.Test)2 Animator (android.animation.Animator)1 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)1 AnimatorSet (android.animation.AnimatorSet)1 ObjectAnimator (android.animation.ObjectAnimator)1 ValueAnimator (android.animation.ValueAnimator)1 Context (android.content.Context)1 PackageManager (android.content.pm.PackageManager)1 Resources (android.content.res.Resources)1 Color (android.graphics.Color)1 Matrix (android.graphics.Matrix)1 Point (android.graphics.Point)1 Rect (android.graphics.Rect)1 RectF (android.graphics.RectF)1 ColorDrawable (android.graphics.drawable.ColorDrawable)1