Search in sources :

Example 96 with Workspace

use of com.android.launcher3.Workspace in project android_packages_apps_Trebuchet by LineageOS.

the class FocusHelper method handleNextPageFirstItem.

private static View handleNextPageFirstItem(Workspace workspace, CellLayout hotseatLayout, int pageIndex, boolean isRtl) {
    if (pageIndex + 1 >= workspace.getPageCount()) {
        return null;
    }
    CellLayout workspaceLayout = (CellLayout) workspace.getChildAt(pageIndex + 1);
    View newIcon = getFirstFocusableIconInReadingOrder(workspaceLayout, isRtl);
    if (newIcon == null) {
        // Check the hotseat if no focusable item was found on the workspace.
        newIcon = getFirstFocusableIconInReadingOrder(hotseatLayout, isRtl);
        workspace.snapToPage(pageIndex + 1);
    }
    return newIcon;
}
Also used : View(android.view.View) FolderPagedView(com.android.launcher3.folder.FolderPagedView)

Example 97 with Workspace

use of com.android.launcher3.Workspace in project android_packages_apps_Trebuchet by LineageOS.

the class QuickstepAtomicAnimationFactory method prepareForAtomicAnimation.

@Override
public void prepareForAtomicAnimation(LauncherState fromState, LauncherState toState, StateAnimationConfig config) {
    if (toState == NORMAL && fromState == OVERVIEW) {
        config.setInterpolator(ANIM_WORKSPACE_SCALE, DEACCEL);
        config.setInterpolator(ANIM_WORKSPACE_FADE, ACCEL);
        config.setInterpolator(ANIM_ALL_APPS_FADE, ACCEL);
        config.setInterpolator(ANIM_OVERVIEW_SCALE, clampToProgress(ACCEL, 0, 0.9f));
        config.setInterpolator(ANIM_OVERVIEW_TRANSLATE_X, ACCEL_DEACCEL);
        if (SysUINavigationMode.getMode(mActivity) == NO_BUTTON) {
            config.setInterpolator(ANIM_OVERVIEW_FADE, FINAL_FRAME);
        } else {
            config.setInterpolator(ANIM_OVERVIEW_FADE, DEACCEL_1_7);
        }
        Workspace workspace = mActivity.getWorkspace();
        // Start from a higher workspace scale, but only if we're invisible so we don't jump.
        boolean isWorkspaceVisible = workspace.getVisibility() == VISIBLE;
        if (isWorkspaceVisible) {
            CellLayout currentChild = (CellLayout) workspace.getChildAt(workspace.getCurrentPage());
            isWorkspaceVisible = currentChild.getVisibility() == VISIBLE && currentChild.getShortcutsAndWidgets().getAlpha() > 0;
        }
        if (!isWorkspaceVisible) {
            workspace.setScaleX(0.92f);
            workspace.setScaleY(0.92f);
        }
        Hotseat hotseat = mActivity.getHotseat();
        boolean isHotseatVisible = hotseat.getVisibility() == VISIBLE && hotseat.getAlpha() > 0;
        if (!isHotseatVisible) {
            hotseat.setScaleX(0.92f);
            hotseat.setScaleY(0.92f);
            if (ENABLE_OVERVIEW_ACTIONS.get()) {
                AllAppsContainerView qsbContainer = mActivity.getAppsView();
                View qsb = qsbContainer.getSearchView();
                boolean qsbVisible = qsb.getVisibility() == VISIBLE && qsb.getAlpha() > 0;
                if (!qsbVisible) {
                    qsbContainer.setScaleX(0.92f);
                    qsbContainer.setScaleY(0.92f);
                }
            }
        }
    } else if (toState == NORMAL && fromState == OVERVIEW_PEEK) {
        // Keep fully visible until the very end (when overview is offscreen) to make invisible.
        config.setInterpolator(ANIM_OVERVIEW_FADE, FINAL_FRAME);
    } else if (toState == OVERVIEW_PEEK && fromState == NORMAL) {
        config.setInterpolator(ANIM_OVERVIEW_FADE, INSTANT);
        config.setInterpolator(ANIM_OVERVIEW_TRANSLATE_X, OVERSHOOT_1_7);
        config.setInterpolator(ANIM_OVERVIEW_SCRIM_FADE, FAST_OUT_SLOW_IN);
    } else if ((fromState == NORMAL || fromState == HINT_STATE) && toState == OVERVIEW) {
        if (SysUINavigationMode.getMode(mActivity) == NO_BUTTON) {
            config.setInterpolator(ANIM_WORKSPACE_SCALE, fromState == NORMAL ? ACCEL : OVERSHOOT_1_2);
            config.setInterpolator(ANIM_WORKSPACE_TRANSLATE, ACCEL);
            config.setInterpolator(ANIM_OVERVIEW_FADE, INSTANT);
        } else {
            config.setInterpolator(ANIM_WORKSPACE_SCALE, OVERSHOOT_1_2);
            config.setInterpolator(ANIM_OVERVIEW_FADE, OVERSHOOT_1_2);
            // Scale up the recents, if it is not coming from the side
            RecentsView overview = mActivity.getOverviewPanel();
            if (overview.getVisibility() != VISIBLE || overview.getContentAlpha() == 0) {
                RECENTS_SCALE_PROPERTY.set(overview, RECENTS_PREPARE_SCALE);
            }
        }
        config.setInterpolator(ANIM_WORKSPACE_FADE, OVERSHOOT_1_2);
        config.setInterpolator(ANIM_ALL_APPS_FADE, OVERSHOOT_1_2);
        config.setInterpolator(ANIM_OVERVIEW_SCALE, OVERSHOOT_1_2);
        config.setInterpolator(ANIM_DEPTH, OVERSHOOT_1_2);
        Interpolator translationInterpolator = ENABLE_OVERVIEW_ACTIONS.get() && removeShelfFromOverview(mActivity) ? OVERSHOOT_1_2 : OVERSHOOT_1_7;
        config.setInterpolator(ANIM_OVERVIEW_TRANSLATE_X, translationInterpolator);
        config.setInterpolator(ANIM_OVERVIEW_TRANSLATE_Y, translationInterpolator);
    } else if (fromState == HINT_STATE && toState == NORMAL) {
        config.setInterpolator(ANIM_DEPTH, DEACCEL_3);
        if (mHintToNormalDuration == -1) {
            ValueAnimator va = getSpringScaleAnimator(mActivity, mActivity.getWorkspace(), toState.getWorkspaceScaleAndTranslation(mActivity).scale);
            mHintToNormalDuration = (int) va.getDuration();
        }
        config.duration = Math.max(config.duration, mHintToNormalDuration);
    }
}
Also used : AllAppsContainerView(com.android.launcher3.allapps.AllAppsContainerView) Hotseat(com.android.launcher3.Hotseat) CellLayout(com.android.launcher3.CellLayout) RecentsView(com.android.quickstep.views.RecentsView) Interpolator(android.view.animation.Interpolator) ValueAnimator(android.animation.ValueAnimator) View(android.view.View) AllAppsContainerView(com.android.launcher3.allapps.AllAppsContainerView) RecentsView(com.android.quickstep.views.RecentsView) Workspace(com.android.launcher3.Workspace)

Example 98 with Workspace

use of com.android.launcher3.Workspace in project android_packages_apps_Trebuchet by LineageOS.

the class NoButtonQuickSwitchTouchController method onDragEnd.

@Override
public void onDragEnd(PointF velocity) {
    boolean horizontalFling = mSwipeDetector.isFling(velocity.x);
    boolean verticalFling = mSwipeDetector.isFling(velocity.y);
    boolean noFling = !horizontalFling && !verticalFling;
    int logAction = noFling ? Touch.SWIPE : Touch.FLING;
    if (mMotionPauseDetector.isPaused() && noFling) {
        cancelAnimations();
        Animator overviewAnim = mLauncher.createAtomicAnimationFactory().createStateElementAnimation(INDEX_PAUSE_TO_OVERVIEW_ANIM);
        overviewAnim.addListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(Animator animation) {
                onAnimationToStateCompleted(OVERVIEW, logAction);
            }
        });
        overviewAnim.start();
        return;
    }
    final LauncherState targetState;
    if (horizontalFling && verticalFling) {
        if (velocity.x < 0) {
            // Flinging left and up or down both go back home.
            targetState = NORMAL;
        } else {
            if (velocity.y > 0) {
                // Flinging right and down goes to quick switch.
                targetState = QUICK_SWITCH;
            } else {
                // Flinging up and right could go either home or to quick switch.
                // Determine the target based on the higher velocity.
                targetState = Math.abs(velocity.x) > Math.abs(velocity.y) ? QUICK_SWITCH : NORMAL;
            }
        }
    } else if (horizontalFling) {
        targetState = velocity.x > 0 ? QUICK_SWITCH : NORMAL;
    } else if (verticalFling) {
        targetState = velocity.y > 0 ? QUICK_SWITCH : NORMAL;
    } else {
        // If user isn't flinging, just snap to the closest state.
        boolean passedHorizontalThreshold = mXOverviewAnim.getInterpolatedProgress() > 0.5f;
        boolean passedVerticalThreshold = mYOverviewAnim.value > 1f;
        targetState = passedHorizontalThreshold && !passedVerticalThreshold ? QUICK_SWITCH : NORMAL;
    }
    // Animate the various components to the target state.
    float xProgress = mXOverviewAnim.getProgressFraction();
    float startXProgress = Utilities.boundToRange(xProgress + velocity.x * getSingleFrameMs(mLauncher) / mXRange, 0f, 1f);
    final float endXProgress = targetState == NORMAL ? 0 : 1;
    long xDuration = BaseSwipeDetector.calculateDuration(velocity.x, Math.abs(endXProgress - startXProgress));
    ValueAnimator xOverviewAnim = mXOverviewAnim.getAnimationPlayer();
    xOverviewAnim.setFloatValues(startXProgress, endXProgress);
    xOverviewAnim.setDuration(xDuration).setInterpolator(scrollInterpolatorForVelocity(velocity.x));
    mXOverviewAnim.dispatchOnStart();
    boolean flingUpToNormal = verticalFling && velocity.y < 0 && targetState == NORMAL;
    float yProgress = mYOverviewAnim.value;
    float startYProgress = Utilities.boundToRange(yProgress - velocity.y * getSingleFrameMs(mLauncher) / mYRange, 0f, mMaxYProgress);
    final float endYProgress;
    if (flingUpToNormal) {
        endYProgress = 1;
    } else if (targetState == NORMAL) {
        // Keep overview at its current scale/translationY as it slides off the screen.
        endYProgress = startYProgress;
    } else {
        endYProgress = 0;
    }
    float yDistanceToCover = Math.abs(endYProgress - startYProgress) * mYRange;
    long yDuration = (long) (yDistanceToCover / Math.max(1f, Math.abs(velocity.y)));
    ValueAnimator yOverviewAnim = mYOverviewAnim.animateToValue(startYProgress, endYProgress);
    yOverviewAnim.setDuration(yDuration);
    mYOverviewAnim.updateValue(startYProgress);
    ValueAnimator nonOverviewAnim = mNonOverviewAnim.getAnimationPlayer();
    if (flingUpToNormal && !mIsHomeScreenVisible) {
        // We are flinging to home while workspace is invisible, run the same staggered
        // animation as from an app.
        StateAnimationConfig config = new StateAnimationConfig();
        // Update mNonOverviewAnim to do nothing so it doesn't interfere.
        config.animFlags = 0;
        updateNonOverviewAnim(targetState, config);
        nonOverviewAnim = mNonOverviewAnim.getAnimationPlayer();
        new StaggeredWorkspaceAnim(mLauncher, velocity.y, false).start();
    } else {
        boolean canceled = targetState == NORMAL;
        if (canceled) {
            // Let the state manager know that the animation didn't go to the target state,
            // but don't clean up yet (we already clean up when the animation completes).
            mNonOverviewAnim.dispatchOnCancelWithoutCancelRunnable();
        }
        float startProgress = mNonOverviewAnim.getProgressFraction();
        float endProgress = canceled ? 0 : 1;
        nonOverviewAnim.setFloatValues(startProgress, endProgress);
        mNonOverviewAnim.dispatchOnStart();
    }
    nonOverviewAnim.setDuration(Math.max(xDuration, yDuration));
    mNonOverviewAnim.setEndAction(() -> onAnimationToStateCompleted(targetState, logAction));
    cancelAnimations();
    xOverviewAnim.start();
    yOverviewAnim.start();
    nonOverviewAnim.start();
}
Also used : LauncherState(com.android.launcher3.LauncherState) Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) StateAnimationConfig(com.android.launcher3.states.StateAnimationConfig) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) StaggeredWorkspaceAnim(com.android.quickstep.util.StaggeredWorkspaceAnim) ValueAnimator(android.animation.ValueAnimator)

Example 99 with Workspace

use of com.android.launcher3.Workspace in project android_packages_apps_Trebuchet by LineageOS.

the class OverviewState method getWorkspaceScaleAndTranslation.

@Override
public ScaleAndTranslation getWorkspaceScaleAndTranslation(Launcher launcher) {
    RecentsView recentsView = launcher.getOverviewPanel();
    Workspace workspace = launcher.getWorkspace();
    View workspacePage = workspace.getPageAt(workspace.getCurrentPage());
    float workspacePageWidth = workspacePage != null && workspacePage.getWidth() != 0 ? workspacePage.getWidth() : launcher.getDeviceProfile().availableWidthPx;
    recentsView.getTaskSize(sTempRect);
    float scale = (float) sTempRect.width() / workspacePageWidth;
    float parallaxFactor = 0.5f;
    return new ScaleAndTranslation(scale, 0, -getDefaultSwipeHeight(launcher) * parallaxFactor);
}
Also used : RecentsView(com.android.quickstep.views.RecentsView) TaskView(com.android.quickstep.views.TaskView) View(android.view.View) RecentsView(com.android.quickstep.views.RecentsView) Workspace(com.android.launcher3.Workspace)

Example 100 with Workspace

use of com.android.launcher3.Workspace in project android_packages_apps_Trebuchet by LineageOS.

the class PredictionRowView method applyPredictionApps.

private void applyPredictionApps() {
    if (getChildCount() != mNumPredictedAppsPerRow) {
        while (getChildCount() > mNumPredictedAppsPerRow) {
            removeViewAt(0);
        }
        LayoutInflater inflater = mLauncher.getAppsView().getLayoutInflater();
        while (getChildCount() < mNumPredictedAppsPerRow) {
            BubbleTextView icon = (BubbleTextView) inflater.inflate(R.layout.all_apps_icon, this, false);
            icon.setOnClickListener(PREDICTION_CLICK_LISTENER);
            icon.setOnLongClickListener(ItemLongClickListener.INSTANCE_ALL_APPS);
            icon.setLongPressTimeoutFactor(1f);
            icon.setOnFocusChangeListener(mFocusHelper);
            LayoutParams lp = (LayoutParams) icon.getLayoutParams();
            // Ensure the all apps icon height matches the workspace icons in portrait mode.
            lp.height = mLauncher.getDeviceProfile().allAppsCellHeightPx;
            lp.width = 0;
            lp.weight = 1;
            addView(icon);
        }
    }
    int predictionCount = mPredictedApps.size();
    int iconColor = setColorAlphaBound(mIconTextColor, mIconCurrentTextAlpha);
    for (int i = 0; i < getChildCount(); i++) {
        BubbleTextView icon = (BubbleTextView) getChildAt(i);
        icon.reset();
        if (predictionCount > i) {
            icon.setVisibility(View.VISIBLE);
            if (mPredictedApps.get(i) instanceof AppInfo) {
                icon.applyFromApplicationInfo((AppInfo) mPredictedApps.get(i));
            } else if (mPredictedApps.get(i) instanceof WorkspaceItemInfo) {
                icon.applyFromWorkspaceItem((WorkspaceItemInfo) mPredictedApps.get(i));
            }
            icon.setTextColor(iconColor);
        } else {
            icon.setVisibility(predictionCount == 0 ? GONE : INVISIBLE);
        }
    }
    boolean predictionsEnabled = predictionCount > 0;
    if (predictionsEnabled != mPredictionsEnabled) {
        mPredictionsEnabled = predictionsEnabled;
        mLauncher.reapplyUi(false);
        updateVisibility();
    }
    mParent.onHeightUpdated();
}
Also used : LayoutInflater(android.view.LayoutInflater) BubbleTextView(com.android.launcher3.BubbleTextView) AppInfo(com.android.launcher3.model.data.AppInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Aggregations

View (android.view.View)143 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)124 Point (android.graphics.Point)115 LauncherAppWidgetHostView (com.android.launcher3.widget.LauncherAppWidgetHostView)97 Rect (android.graphics.Rect)93 ArrayList (java.util.ArrayList)91 ItemInfo (com.android.launcher3.model.data.ItemInfo)86 DragView (com.android.launcher3.dragndrop.DragView)77 PendingAppWidgetHostView (com.android.launcher3.widget.PendingAppWidgetHostView)73 AppWidgetHostView (android.appwidget.AppWidgetHostView)72 Workspace (com.android.launcher3.Workspace)63 SuppressLint (android.annotation.SuppressLint)58 DraggableView (com.android.launcher3.dragndrop.DraggableView)58 Test (org.junit.Test)57 FolderInfo (com.android.launcher3.model.data.FolderInfo)55 CellLayout (com.android.launcher3.CellLayout)51 LauncherAppWidgetInfo (com.android.launcher3.model.data.LauncherAppWidgetInfo)47 IntArray (com.android.launcher3.util.IntArray)45 Intent (android.content.Intent)43 ValueAnimator (android.animation.ValueAnimator)41