Search in sources :

Example 1 with SplitSelectStateController

use of com.android.quickstep.util.SplitSelectStateController in project android_packages_apps_Launcher3 by crdroidandroid.

the class RecentsActivity method setupViews.

/**
 * Init drag layer and overview panel views.
 */
protected void setupViews() {
    inflateRootView(R.layout.fallback_recents_activity);
    setContentView(getRootView());
    mDragLayer = findViewById(R.id.drag_layer);
    mScrimView = findViewById(R.id.scrim_view);
    mFallbackRecentsView = findViewById(R.id.overview_panel);
    mActionsView = findViewById(R.id.overview_actions_view);
    SYSUI_PROGRESS.set(getRootView().getSysUiScrim(), 0f);
    SplitPlaceholderView splitPlaceholderView = findViewById(R.id.split_placeholder);
    splitPlaceholderView.init(new SplitSelectStateController(mUiHandler, SystemUiProxy.INSTANCE.get(this)));
    mDragLayer.recreateControllers();
    mFallbackRecentsView.init(mActionsView, splitPlaceholderView);
}
Also used : SplitSelectStateController(com.android.quickstep.util.SplitSelectStateController) SplitPlaceholderView(com.android.quickstep.views.SplitPlaceholderView)

Example 2 with SplitSelectStateController

use of com.android.quickstep.util.SplitSelectStateController in project android_packages_apps_Launcher3 by crdroidandroid.

the class RecentsView method cancelSplitSelect.

public PendingAnimation cancelSplitSelect(boolean animate) {
    SplitSelectStateController splitController = mSplitPlaceholderView.getSplitController();
    SplitPositionOption splitOption = splitController.getActiveSplitPositionOption();
    Rect initialBounds = splitController.getInitialBounds();
    splitController.resetState();
    int duration = mActivity.getStateManager().getState().getTransitionDuration(getContext());
    PendingAnimation pendingAnim = new PendingAnimation(duration);
    if (!animate) {
        resetFromSplitSelectionState();
        return pendingAnim;
    }
    addViewInLayout(mSplitHiddenTaskView, mSplitHiddenTaskViewIndex, mSplitHiddenTaskView.getLayoutParams());
    mSplitHiddenTaskView.setAlpha(0);
    int[] oldScroll = new int[getChildCount()];
    getPageScrolls(oldScroll, false, view -> view.getVisibility() != GONE && view != mSplitHiddenTaskView);
    int[] newScroll = new int[getChildCount()];
    getPageScrolls(newScroll, false, SIMPLE_SCROLL_LOGIC);
    boolean needsCurveUpdates = false;
    for (int i = mSplitHiddenTaskViewIndex; i >= 0; i--) {
        View child = getChildAt(i);
        if (child == mSplitHiddenTaskView) {
            TaskView taskView = (TaskView) child;
            int dir = mOrientationHandler.getSplitTaskViewDismissDirection(splitOption, mActivity.getDeviceProfile());
            FloatProperty<TaskView> dismissingTaskViewTranslate;
            Rect hiddenBounds = new Rect(taskView.getLeft(), taskView.getTop(), taskView.getRight(), taskView.getBottom());
            int distanceDelta = 0;
            if (dir == PagedOrientationHandler.SPLIT_TRANSLATE_SECONDARY_NEGATIVE) {
                dismissingTaskViewTranslate = taskView.getSecondaryDissmissTranslationProperty();
                distanceDelta = initialBounds.top - hiddenBounds.top;
                taskView.layout(initialBounds.left, hiddenBounds.top, initialBounds.right, hiddenBounds.bottom);
            } else {
                dismissingTaskViewTranslate = taskView.getPrimaryDismissTranslationProperty();
                distanceDelta = initialBounds.left - hiddenBounds.left;
                taskView.layout(hiddenBounds.left, initialBounds.top, hiddenBounds.right, initialBounds.bottom);
                if (dir == PagedOrientationHandler.SPLIT_TRANSLATE_PRIMARY_POSITIVE) {
                    distanceDelta *= -1;
                }
            }
            pendingAnim.add(ObjectAnimator.ofFloat(mSplitHiddenTaskView, dismissingTaskViewTranslate, distanceDelta));
            pendingAnim.add(ObjectAnimator.ofFloat(mSplitHiddenTaskView, ALPHA, 1));
        } else {
            // ignore views to left
            if (showAsGrid()) {
                // TODO(b/186800707) handle more elegantly for grid
                continue;
            }
            int scrollDiff = newScroll[i] - oldScroll[i];
            if (scrollDiff != 0) {
                FloatProperty translationProperty = child instanceof TaskView ? ((TaskView) child).getPrimaryDismissTranslationProperty() : mOrientationHandler.getPrimaryViewTranslate();
                ResourceProvider rp = DynamicResource.provider(mActivity);
                SpringProperty sp = new SpringProperty(SpringProperty.FLAG_CAN_SPRING_ON_END).setDampingRatio(rp.getFloat(R.dimen.dismiss_task_trans_x_damping_ratio)).setStiffness(rp.getFloat(R.dimen.dismiss_task_trans_x_stiffness));
                pendingAnim.add(ObjectAnimator.ofFloat(child, translationProperty, scrollDiff).setDuration(duration), ACCEL, sp);
                needsCurveUpdates = true;
            }
        }
    }
    if (needsCurveUpdates) {
        pendingAnim.addOnFrameCallback(this::updateCurveProperties);
    }
    pendingAnim.addListener(new AnimationSuccessListener() {

        @Override
        public void onAnimationSuccess(Animator animator) {
            // TODO(b/186800707) Figure out how to undo for grid view
            // Need to handle cases where dismissed task is
            // * Top Row
            // * Bottom Row
            // * Focused Task
            updateGridProperties();
            resetFromSplitSelectionState();
        }
    });
    return pendingAnim;
}
Also used : PendingAnimation(com.android.launcher3.anim.PendingAnimation) SpringProperty(com.android.launcher3.anim.SpringProperty) Rect(android.graphics.Rect) ImageView(android.widget.ImageView) View(android.view.View) ListView(android.widget.ListView) PagedView(com.android.launcher3.PagedView) TextPaint(android.text.TextPaint) Point(android.graphics.Point) ValueAnimator(android.animation.ValueAnimator) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) SplitPositionOption(com.android.launcher3.util.SplitConfigurationOptions.SplitPositionOption) ResourceProvider(com.android.systemui.plugins.ResourceProvider) SplitSelectStateController(com.android.quickstep.util.SplitSelectStateController) FloatProperty(android.util.FloatProperty) AnimationSuccessListener(com.android.launcher3.anim.AnimationSuccessListener)

Example 3 with SplitSelectStateController

use of com.android.quickstep.util.SplitSelectStateController in project android_packages_apps_Launcher3 by crdroidandroid.

the class RecentsView method initiateSplitSelect.

public void initiateSplitSelect(TaskView taskView, SplitPositionOption splitPositionOption) {
    mSplitHiddenTaskView = taskView;
    SplitSelectStateController splitController = mSplitPlaceholderView.getSplitController();
    Rect initialBounds = new Rect(taskView.getLeft(), taskView.getTop(), taskView.getRight(), taskView.getBottom());
    splitController.setInitialTaskSelect(taskView, splitPositionOption, initialBounds);
    mSplitHiddenTaskViewIndex = indexOfChild(taskView);
    mSplitPlaceholderView.setLayoutParams(splitController.getLayoutParamsForActivePosition(getResources(), mActivity.getDeviceProfile()));
    mSplitPlaceholderView.setIcon(taskView.getIconView());
}
Also used : Rect(android.graphics.Rect) SplitSelectStateController(com.android.quickstep.util.SplitSelectStateController)

Example 4 with SplitSelectStateController

use of com.android.quickstep.util.SplitSelectStateController in project android_packages_apps_Launcher3 by crdroidandroid.

the class BaseQuickstepLauncher method setupViews.

@Override
protected void setupViews() {
    super.setupViews();
    SysUINavigationMode.INSTANCE.get(this).updateMode();
    mActionsView = findViewById(R.id.overview_actions_view);
    mSplitPlaceholderView = findViewById(R.id.split_placeholder);
    RecentsView overviewPanel = (RecentsView) getOverviewPanel();
    mSplitPlaceholderView.init(new SplitSelectStateController(mHandler, SystemUiProxy.INSTANCE.get(this)));
    overviewPanel.init(mActionsView, mSplitPlaceholderView);
    mActionsView.setDp(getDeviceProfile());
    mActionsView.updateVerticalMargin(SysUINavigationMode.getMode(this));
    mAppTransitionManager = new QuickstepTransitionManager(this);
    mAppTransitionManager.registerRemoteAnimations();
    bindService(new Intent(this, TouchInteractionService.class), mTisBinderConnection, 0);
}
Also used : RecentsView(com.android.quickstep.views.RecentsView) Intent(android.content.Intent) SplitSelectStateController(com.android.quickstep.util.SplitSelectStateController) TouchInteractionService(com.android.quickstep.TouchInteractionService)

Example 5 with SplitSelectStateController

use of com.android.quickstep.util.SplitSelectStateController in project android_packages_apps_Launcher3 by crdroidandroid.

the class RecentsView method addDismissedTaskAnimations.

private void addDismissedTaskAnimations(TaskView taskView, long duration, PendingAnimation anim) {
    // Use setFloat instead of setViewAlpha as we want to keep the view visible even when it's
    // alpha is set to 0 so that it can be recycled in the view pool properly
    anim.setFloat(taskView, VIEW_ALPHA, 0, clampToProgress(ACCEL, 0, 0.5f));
    SplitSelectStateController splitController = mSplitPlaceholderView.getSplitController();
    ResourceProvider rp = DynamicResource.provider(mActivity);
    SpringProperty sp = new SpringProperty(SpringProperty.FLAG_CAN_SPRING_ON_START).setDampingRatio(rp.getFloat(R.dimen.dismiss_task_trans_y_damping_ratio)).setStiffness(rp.getFloat(R.dimen.dismiss_task_trans_y_stiffness));
    FloatProperty<TaskView> dismissingTaskViewTranslate = taskView.getSecondaryDissmissTranslationProperty();
    // TODO(b/186800707) translate entire grid size distance
    int translateDistance = mOrientationHandler.getSecondaryDimension(taskView);
    int positiveNegativeFactor = mOrientationHandler.getSecondaryTranslationDirectionFactor();
    if (splitController.isSplitSelectActive()) {
        // Have the task translate towards whatever side was just pinned
        int dir = mOrientationHandler.getSplitTaskViewDismissDirection(splitController.getActiveSplitPositionOption(), mActivity.getDeviceProfile());
        switch(dir) {
            case PagedOrientationHandler.SPLIT_TRANSLATE_SECONDARY_NEGATIVE:
                dismissingTaskViewTranslate = taskView.getSecondaryDissmissTranslationProperty();
                positiveNegativeFactor = -1;
                break;
            case PagedOrientationHandler.SPLIT_TRANSLATE_PRIMARY_POSITIVE:
                dismissingTaskViewTranslate = taskView.getPrimaryDismissTranslationProperty();
                positiveNegativeFactor = 1;
                break;
            case PagedOrientationHandler.SPLIT_TRANSLATE_PRIMARY_NEGATIVE:
                dismissingTaskViewTranslate = taskView.getPrimaryDismissTranslationProperty();
                positiveNegativeFactor = -1;
                break;
            default:
                throw new IllegalStateException("Invalid split task translation: " + dir);
        }
    }
    // Double translation distance so dismissal drag is the full height, as we only animate
    // the drag for the first half of the progress.
    anim.add(ObjectAnimator.ofFloat(taskView, dismissingTaskViewTranslate, positiveNegativeFactor * translateDistance * 2).setDuration(duration), LINEAR, sp);
    if (ENABLE_QUICKSTEP_LIVE_TILE.get() && mEnableDrawingLiveTile && taskView.isRunningTask()) {
        anim.addOnFrameCallback(() -> {
            mLiveTileTaskViewSimulator.taskSecondaryTranslation.value = mOrientationHandler.getSecondaryValue(taskView.getTranslationX(), taskView.getTranslationY());
            redrawLiveTile();
        });
    }
}
Also used : SpringProperty(com.android.launcher3.anim.SpringProperty) ResourceProvider(com.android.systemui.plugins.ResourceProvider) SplitSelectStateController(com.android.quickstep.util.SplitSelectStateController) TextPaint(android.text.TextPaint) Point(android.graphics.Point)

Aggregations

SplitSelectStateController (com.android.quickstep.util.SplitSelectStateController)5 Point (android.graphics.Point)2 Rect (android.graphics.Rect)2 TextPaint (android.text.TextPaint)2 SpringProperty (com.android.launcher3.anim.SpringProperty)2 ResourceProvider (com.android.systemui.plugins.ResourceProvider)2 Animator (android.animation.Animator)1 ObjectAnimator (android.animation.ObjectAnimator)1 ValueAnimator (android.animation.ValueAnimator)1 Intent (android.content.Intent)1 FloatProperty (android.util.FloatProperty)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 ListView (android.widget.ListView)1 PagedView (com.android.launcher3.PagedView)1 AnimationSuccessListener (com.android.launcher3.anim.AnimationSuccessListener)1 PendingAnimation (com.android.launcher3.anim.PendingAnimation)1 SplitPositionOption (com.android.launcher3.util.SplitConfigurationOptions.SplitPositionOption)1 TouchInteractionService (com.android.quickstep.TouchInteractionService)1 RecentsView (com.android.quickstep.views.RecentsView)1