Search in sources :

Example 36 with ALL_APPS

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

the class WorkTabTest method toggleWorks.

@Test
public void toggleWorks() {
    mDevice.pressHome();
    waitForLauncherCondition("Launcher didn't start", Objects::nonNull);
    executeOnLauncher(launcher -> launcher.getStateManager().goToState(ALL_APPS));
    waitForState("Launcher internal state didn't switch to All Apps", () -> ALL_APPS);
    getOnceNotNull("Apps view did not bind", launcher -> launcher.getAppsView().getWorkModeSwitch(), 60000);
    UserManager userManager = getFromLauncher(l -> l.getSystemService(UserManager.class));
    assertEquals(2, userManager.getUserProfiles().size());
    UserHandle workProfile = getFromLauncher(l -> {
        UserHandle myHandle = Process.myUserHandle();
        List<UserHandle> userProfiles = userManager.getUserProfiles();
        return userProfiles.get(0) == myHandle ? userProfiles.get(1) : userProfiles.get(0);
    });
    waitForLauncherCondition("work profile can't be turned off", l -> userManager.requestQuietModeEnabled(true, workProfile));
    assertTrue(userManager.isQuietModeEnabled(workProfile));
    executeOnLauncher(launcher -> {
        WorkModeSwitch wf = launcher.getAppsView().getWorkModeSwitch();
        ((AllAppsPagedView) launcher.getAppsView().getContentView()).snapToPageImmediately(AllAppsContainerView.AdapterHolder.WORK);
        wf.toggle();
    });
    waitForLauncherCondition("Work toggle did not work", l -> l.getSystemService(UserManager.class).isQuietModeEnabled(workProfile));
}
Also used : UserManager(android.os.UserManager) UserHandle(android.os.UserHandle) Objects(java.util.Objects) WorkModeSwitch(com.android.launcher3.allapps.WorkModeSwitch) AllAppsPagedView(com.android.launcher3.allapps.AllAppsPagedView) Test(org.junit.Test) LargeTest(androidx.test.filters.LargeTest)

Example 37 with ALL_APPS

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

the class WorkTabTest method testWorkEduIntermittent.

@Test
public void testWorkEduIntermittent() {
    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));
    // verify personal app edu is seen
    getEduView();
    // dismiss personal edu
    mDevice.pressHome();
    waitForState("Launcher did not go home", () -> NORMAL);
    // open work tab
    executeOnLauncher(launcher -> launcher.getStateManager().goToState(ALL_APPS));
    waitForState("Launcher did not switch to all apps", () -> ALL_APPS);
    executeOnLauncher(launcher -> {
        AllAppsPagedView pagedView = (AllAppsPagedView) launcher.getAppsView().getContentView();
        pagedView.setCurrentPage(WORK_PAGE);
    });
    WorkEduView workEduView = getEduView();
    // verify work tab edu is shown
    waitForLauncherCondition("Launcher did not show the next edu screen", l -> ((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) TextView(android.widget.TextView) Test(org.junit.Test) LargeTest(androidx.test.filters.LargeTest)

Example 38 with ALL_APPS

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

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;
    // 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 39 with ALL_APPS

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

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.
 */
private 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);
        Workspace workspace = mLauncher.getWorkspace();
        View currentPage = ((CellLayout) workspace.getChildAt(workspace.getCurrentPage())).getShortcutsAndWidgets();
        View hotseat = mLauncher.getHotseat();
        View qsb = mLauncher.findViewById(R.id.search_container_all_apps);
        currentPage.setLayerType(View.LAYER_TYPE_HARDWARE, null);
        hotseat.setLayerType(View.LAYER_TYPE_HARDWARE, null);
        qsb.setLayerType(View.LAYER_TYPE_HARDWARE, null);
        launcherAnimator.play(ObjectAnimator.ofFloat(currentPage, View.TRANSLATION_Y, trans));
        launcherAnimator.play(ObjectAnimator.ofFloat(hotseat, View.TRANSLATION_Y, trans));
        launcherAnimator.play(ObjectAnimator.ofFloat(qsb, View.TRANSLATION_Y, trans));
        // Pause page indicator animations as they lead to layer trashing.
        mLauncher.getWorkspace().getPageIndicator().pauseAnimations();
        endListener = () -> {
            currentPage.setTranslationY(0);
            hotseat.setTranslationY(0);
            qsb.setTranslationY(0);
            currentPage.setLayerType(View.LAYER_TYPE_NONE, null);
            hotseat.setLayerType(View.LAYER_TYPE_NONE, null);
            qsb.setLayerType(View.LAYER_TYPE_NONE, null);
            mDragLayerAlpha.setValue(1f);
            mLauncher.getWorkspace().getPageIndicator().skipAnimationsToEnd();
        };
    }
    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 40 with ALL_APPS

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

the class FlingAndHoldTouchController method getConfigForStates.

@Override
protected StateAnimationConfig getConfigForStates(LauncherState fromState, LauncherState toState) {
    if (fromState == NORMAL && toState == ALL_APPS) {
        StateAnimationConfig builder = new StateAnimationConfig();
        // 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) {
        StateAnimationConfig builder = new StateAnimationConfig();
        // 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.getConfigForStates(fromState, toState);
}
Also used : StateAnimationConfig(com.android.launcher3.states.StateAnimationConfig)

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