Search in sources :

Example 16 with LauncherState

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

the class RecentsViewStateController method setStateWithAnimationInternal.

@Override
void setStateWithAnimationInternal(@NonNull LauncherState toState, @NonNull StateAnimationConfig config, @NonNull PendingAnimation builder) {
    super.setStateWithAnimationInternal(toState, config, builder);
    if (toState.overviewUi) {
        // While animating into recents, update the visible task data as needed
        builder.addOnFrameCallback(() -> mRecentsView.loadVisibleTaskData(FLAG_UPDATE_ALL));
        mRecentsView.updateEmptyMessage();
    } else {
        builder.addListener(AnimatorListeners.forSuccessCallback(mRecentsView::resetTaskVisuals));
    }
    // Create or dismiss split screen select animations
    LauncherState currentState = mLauncher.getStateManager().getState();
    if (isSplitSelectionState(toState) && !isSplitSelectionState(currentState)) {
        builder.add(mRecentsView.createSplitSelectInitAnimation().buildAnim());
    } else if (!isSplitSelectionState(toState) && isSplitSelectionState(currentState)) {
        builder.add(mRecentsView.cancelSplitSelect(true).buildAnim());
    }
    setAlphas(builder, config, toState);
    builder.setFloat(mRecentsView, FULLSCREEN_PROGRESS, toState.getOverviewFullscreenProgress(), LINEAR);
}
Also used : LauncherState(com.android.launcher3.LauncherState)

Example 17 with LauncherState

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

the class BaseRecentsViewStateController method setStateWithAnimationInternal.

/**
 * Core logic for animating the recents view UI.
 *
 * @param toState state to animate to
 * @param config current animation config
 * @param setter animator set builder
 */
void setStateWithAnimationInternal(@NonNull final LauncherState toState, @NonNull StateAnimationConfig config, @NonNull PendingAnimation setter) {
    float[] scaleAndOffset = toState.getOverviewScaleAndOffset(mLauncher);
    setter.setFloat(mRecentsView, RECENTS_SCALE_PROPERTY, scaleAndOffset[0], config.getInterpolator(ANIM_OVERVIEW_SCALE, LINEAR));
    setter.setFloat(mRecentsView, ADJACENT_PAGE_HORIZONTAL_OFFSET, scaleAndOffset[1], config.getInterpolator(ANIM_OVERVIEW_TRANSLATE_X, LINEAR));
    setter.setFloat(mRecentsView, TASK_SECONDARY_TRANSLATION, 0f, config.getInterpolator(ANIM_OVERVIEW_TRANSLATE_Y, LINEAR));
    PagedOrientationHandler orientationHandler = ((RecentsView) mLauncher.getOverviewPanel()).getPagedOrientationHandler();
    FloatProperty taskViewsFloat = orientationHandler.getSplitSelectTaskOffset(TASK_PRIMARY_SPLIT_TRANSLATION, TASK_SECONDARY_SPLIT_TRANSLATION, mLauncher.getDeviceProfile());
    setter.setFloat(mRecentsView, taskViewsFloat, toState.getSplitSelectTranslation(mLauncher), LINEAR);
    setter.setFloat(mRecentsView, getContentAlphaProperty(), toState.overviewUi ? 1 : 0, config.getInterpolator(ANIM_OVERVIEW_FADE, AGGRESSIVE_EASE_IN_OUT));
    setter.setFloat(mRecentsView, getTaskModalnessProperty(), toState.getOverviewModalness(), config.getInterpolator(ANIM_OVERVIEW_MODAL, LINEAR));
    setter.setFloat(mRecentsView, RECENTS_GRID_PROGRESS, toState.displayOverviewTasksAsGrid(mLauncher.getDeviceProfile()) ? 1f : 0f, LINEAR);
}
Also used : PagedOrientationHandler(com.android.launcher3.touch.PagedOrientationHandler) RecentsView(com.android.quickstep.views.RecentsView) FloatProperty(android.util.FloatProperty)

Example 18 with LauncherState

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

Example 19 with LauncherState

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

the class WorkspaceStateTransitionAnimation method setScrim.

public void setScrim(PropertySetter propertySetter, LauncherState state, StateAnimationConfig config) {
    Scrim workspaceDragScrim = mLauncher.getDragLayer().getWorkspaceDragScrim();
    propertySetter.setFloat(workspaceDragScrim, SCRIM_PROGRESS, state.getWorkspaceBackgroundAlpha(mLauncher), LINEAR);
    SysUiScrim sysUiScrim = mLauncher.getRootView().getSysUiScrim();
    propertySetter.setFloat(sysUiScrim, SYSUI_PROGRESS, state.hasFlag(FLAG_HAS_SYS_UI_SCRIM) ? 1 : 0, LINEAR);
    propertySetter.setViewBackgroundColor(mLauncher.getScrimView(), state.getWorkspaceScrimColor(mLauncher), config.getInterpolator(ANIM_SCRIM_FADE, ACCEL_2));
}
Also used : SysUiScrim(com.android.launcher3.graphics.SysUiScrim) Scrim(com.android.launcher3.graphics.Scrim) SysUiScrim(com.android.launcher3.graphics.SysUiScrim)

Example 20 with LauncherState

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

the class Launcher method completeAddAppWidget.

/**
 * Add a widget to the workspace.
 *
 * @param appWidgetId The app widget id
 */
@Thunk
void completeAddAppWidget(int appWidgetId, ItemInfo itemInfo, AppWidgetHostView hostView, LauncherAppWidgetProviderInfo appWidgetInfo) {
    if (appWidgetInfo == null) {
        appWidgetInfo = mAppWidgetManager.getLauncherAppWidgetInfo(appWidgetId);
    }
    if (hostView == null) {
        // Perform actual inflation because we're live
        hostView = mAppWidgetHost.createView(this, appWidgetId, appWidgetInfo);
    }
    LauncherAppWidgetInfo launcherInfo;
    launcherInfo = new LauncherAppWidgetInfo(appWidgetId, appWidgetInfo.provider, appWidgetInfo, hostView);
    launcherInfo.spanX = itemInfo.spanX;
    launcherInfo.spanY = itemInfo.spanY;
    launcherInfo.minSpanX = itemInfo.minSpanX;
    launcherInfo.minSpanY = itemInfo.minSpanY;
    launcherInfo.user = appWidgetInfo.getProfile();
    if (itemInfo instanceof PendingAddWidgetInfo) {
        launcherInfo.sourceContainer = ((PendingAddWidgetInfo) itemInfo).sourceContainer;
    } else if (itemInfo instanceof PendingRequestArgs) {
        launcherInfo.sourceContainer = ((PendingRequestArgs) itemInfo).getWidgetSourceContainer();
    }
    getModelWriter().addItemToDatabase(launcherInfo, itemInfo.container, itemInfo.screenId, itemInfo.cellX, itemInfo.cellY);
    hostView.setVisibility(View.VISIBLE);
    prepareAppWidget(hostView, launcherInfo);
    mWorkspace.addInScreen(hostView, launcherInfo);
    announceForAccessibility(R.string.item_added_to_workspace);
    // Show the widget resize frame.
    if (hostView instanceof LauncherAppWidgetHostView) {
        final LauncherAppWidgetHostView launcherHostView = (LauncherAppWidgetHostView) hostView;
        CellLayout cellLayout = getCellLayout(launcherInfo.container, launcherInfo.screenId);
        if (mStateManager.getState() == NORMAL) {
            // Show resize frame once the widget layout is drawn.
            View.OnLayoutChangeListener onLayoutChangeListener = new View.OnLayoutChangeListener() {

                @Override
                public void onLayoutChange(View view, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
                    AppWidgetResizeFrame.showForWidget(launcherHostView, cellLayout);
                    launcherHostView.removeOnLayoutChangeListener(this);
                }
            };
            launcherHostView.addOnLayoutChangeListener(onLayoutChangeListener);
            // There is a small chance that the layout was already drawn before the layout
            // change listener was registered, which means that the resize frame wouldn't be
            // shown. Directly call requestLayout to force a layout change.
            launcherHostView.requestLayout();
        } else {
            mStateManager.addStateListener(new StateManager.StateListener<LauncherState>() {

                @Override
                public void onStateTransitionComplete(LauncherState finalState) {
                    if (mPrevLauncherState == SPRING_LOADED && finalState == NORMAL) {
                        AppWidgetResizeFrame.showForWidget(launcherHostView, cellLayout);
                        mStateManager.removeStateListener(this);
                    }
                }
            });
        }
    }
}
Also used : StateManager(com.android.launcher3.statemanager.StateManager) PendingAddWidgetInfo(com.android.launcher3.widget.PendingAddWidgetInfo) LauncherAppWidgetInfo(com.android.launcher3.model.data.LauncherAppWidgetInfo) LauncherAppWidgetHostView(com.android.launcher3.widget.LauncherAppWidgetHostView) QsbContainerView(com.android.launcher3.qsb.QsbContainerView) OptionsPopupView(com.android.launcher3.views.OptionsPopupView) PendingAppWidgetHostView(com.android.launcher3.widget.PendingAppWidgetHostView) DragView(com.android.launcher3.dragndrop.DragView) ImageView(android.widget.ImageView) LauncherAppWidgetHostView(com.android.launcher3.widget.LauncherAppWidgetHostView) FloatingSurfaceView(com.android.launcher3.views.FloatingSurfaceView) AppWidgetHostView(android.appwidget.AppWidgetHostView) View(android.view.View) AllAppsContainerView(com.android.launcher3.allapps.AllAppsContainerView) ScrimView(com.android.launcher3.views.ScrimView) PendingRequestArgs(com.android.launcher3.util.PendingRequestArgs) Thunk(com.android.launcher3.util.Thunk)

Aggregations

LauncherState (com.android.launcher3.LauncherState)14 StateAnimationConfig (com.android.launcher3.states.StateAnimationConfig)8 Animator (android.animation.Animator)4 PendingAnimation (com.android.launcher3.anim.PendingAnimation)4 ValueAnimator (android.animation.ValueAnimator)3 RecentsView (com.android.quickstep.views.RecentsView)3 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)2 AnimatorSet (android.animation.AnimatorSet)2 Interpolator (android.view.animation.Interpolator)2 PendingRequestArgs (com.android.launcher3.util.PendingRequestArgs)2 AppWidgetHostView (android.appwidget.AppWidgetHostView)1 Parcelable (android.os.Parcelable)1 FloatProperty (android.util.FloatProperty)1 View (android.view.View)1 VISIBLE (android.view.View.VISIBLE)1 ImageView (android.widget.ImageView)1 Nullable (androidx.annotation.Nullable)1 BaseQuickstepLauncher (com.android.launcher3.BaseQuickstepLauncher)1 CellLayout (com.android.launcher3.CellLayout)1 DeviceProfile (com.android.launcher3.DeviceProfile)1