Search in sources :

Example 91 with PagedOrientationHandler

use of com.android.launcher3.touch.PagedOrientationHandler in project android_packages_apps_Launcher3 by ProtonAOSP.

the class TaskMenuView method setPosition.

private void setPosition(float x, float y, int overscrollShift) {
    PagedOrientationHandler pagedOrientationHandler = mTaskView.getPagedOrientationHandler();
    // Inset due to margin
    PointF additionalInset = pagedOrientationHandler.getAdditionalInsetForTaskMenu(mTaskInsetMargin);
    DeviceProfile deviceProfile = mActivity.getDeviceProfile();
    int taskTopMargin = deviceProfile.overviewTaskThumbnailTopMarginPx;
    float adjustedY = y + taskTopMargin - additionalInset.y;
    float adjustedX = x - additionalInset.x;
    // Changing pivot to make computations easier
    // NOTE: Changing the pivots means the rotated view gets rotated about the new pivots set,
    // which would render the X and Y position set here incorrect
    setPivotX(0);
    if (deviceProfile.overviewShowAsGrid) {
        // In tablet, set pivotY to original position without mThumbnailTopMargin adjustment.
        setPivotY(-taskTopMargin);
    } else {
        setPivotY(0);
    }
    setRotation(pagedOrientationHandler.getDegreesRotated());
    setX(pagedOrientationHandler.getTaskMenuX(adjustedX, mTaskContainer.getThumbnailView(), overscrollShift, deviceProfile));
    setY(pagedOrientationHandler.getTaskMenuY(adjustedY, mTaskContainer.getThumbnailView(), overscrollShift));
    // TODO(b/193432925) temporary menu placement for split screen task menus
    TaskIdAttributeContainer[] taskIdAttributeContainers = mTaskView.getTaskIdAttributeContainers();
    if (taskIdAttributeContainers[0].getStagePosition() != STAGE_POSITION_UNDEFINED) {
        if (mTaskContainer.getStagePosition() != STAGE_POSITION_BOTTOM_OR_RIGHT) {
            return;
        }
        Rect r = new Rect();
        mTaskContainer.getThumbnailView().getBoundsOnScreen(r);
        if (deviceProfile.isLandscape) {
            setX(r.left);
        } else {
            setY(r.top);
        }
    }
}
Also used : DeviceProfile(com.android.launcher3.DeviceProfile) Rect(android.graphics.Rect) PagedOrientationHandler(com.android.launcher3.touch.PagedOrientationHandler) TaskIdAttributeContainer(com.android.quickstep.views.TaskView.TaskIdAttributeContainer) PointF(android.graphics.PointF)

Example 92 with PagedOrientationHandler

use of com.android.launcher3.touch.PagedOrientationHandler in project android_packages_apps_Launcher3 by ProtonAOSP.

the class RecentsView method updateOrientationHandler.

private void updateOrientationHandler(boolean forceRecreateDragLayerControllers) {
    // Handle orientation changes.
    PagedOrientationHandler oldOrientationHandler = mOrientationHandler;
    mOrientationHandler = mOrientationState.getOrientationHandler();
    mIsRtl = mOrientationHandler.getRecentsRtlSetting(getResources());
    setLayoutDirection(mIsRtl ? View.LAYOUT_DIRECTION_RTL : View.LAYOUT_DIRECTION_LTR);
    mClearAllButton.setLayoutDirection(mIsRtl ? View.LAYOUT_DIRECTION_LTR : View.LAYOUT_DIRECTION_RTL);
    mClearAllButton.setRotation(mOrientationHandler.getDegreesRotated());
    if (forceRecreateDragLayerControllers || !mOrientationHandler.equals(oldOrientationHandler)) {
        // Changed orientations, update controllers so they intercept accordingly.
        mActivity.getDragLayer().recreateControllers();
        onOrientationChanged();
    }
    boolean isInLandscape = mOrientationState.getTouchRotation() != ROTATION_0 || mOrientationState.getRecentsActivityRotation() != ROTATION_0;
    mActionsView.updateHiddenFlags(HIDDEN_NON_ZERO_ROTATION, !mOrientationState.isRecentsActivityRotationAllowed() && isInLandscape);
    // Update TaskView's DeviceProfile dependent layout.
    updateChildTaskOrientations();
    // Recalculate DeviceProfile dependent layout.
    updateSizeAndPadding();
    requestLayout();
    // Reapply the current page to update page scrolls.
    setCurrentPage(mCurrentPage);
}
Also used : PagedOrientationHandler(com.android.launcher3.touch.PagedOrientationHandler)

Example 93 with PagedOrientationHandler

use of com.android.launcher3.touch.PagedOrientationHandler in project android_packages_apps_Launcher3 by ProtonAOSP.

the class TaskViewTouchController method reInitAnimationController.

private void reInitAnimationController(boolean goingUp) {
    if (mCurrentAnimation != null && mCurrentAnimationIsGoingUp == goingUp) {
        // No need to init
        return;
    }
    if ((goingUp && !mAllowGoingUp) || (!goingUp && !mAllowGoingDown)) {
        // Trying to re-init in an unsupported direction.
        return;
    }
    if (mCurrentAnimation != null) {
        mCurrentAnimation.setPlayFraction(0);
        mCurrentAnimation.getTarget().removeListener(this);
        mCurrentAnimation.dispatchOnCancel();
    }
    PagedOrientationHandler orientationHandler = mRecentsView.getPagedOrientationHandler();
    mCurrentAnimationIsGoingUp = goingUp;
    BaseDragLayer dl = mActivity.getDragLayer();
    final int secondaryLayerDimension = orientationHandler.getSecondaryDimension(dl);
    long maxDuration = 2 * secondaryLayerDimension;
    int verticalFactor = orientationHandler.getTaskDragDisplacementFactor(mIsRtl);
    int secondaryTaskDimension = orientationHandler.getSecondaryDimension(mTaskBeingDragged);
    // The interpolator controlling the most prominent visual movement. We use this to determine
    // whether we passed SUCCESS_TRANSITION_PROGRESS.
    final Interpolator currentInterpolator;
    PendingAnimation pa;
    if (goingUp) {
        currentInterpolator = Interpolators.LINEAR;
        pa = mRecentsView.createTaskDismissAnimation(mTaskBeingDragged, true, /* animateTaskView */
        true, /* removeTask */
        maxDuration, false);
        mEndDisplacement = -secondaryTaskDimension;
    } else {
        currentInterpolator = Interpolators.ZOOM_IN;
        pa = mRecentsView.createTaskLaunchAnimation(mTaskBeingDragged, maxDuration, currentInterpolator);
        // Since the thumbnail is what is filling the screen, based the end displacement on it.
        View thumbnailView = mTaskBeingDragged.getThumbnail();
        mTempCords[1] = orientationHandler.getSecondaryDimension(thumbnailView);
        dl.getDescendantCoordRelativeToSelf(thumbnailView, mTempCords);
        mEndDisplacement = secondaryLayerDimension - mTempCords[1];
    }
    mEndDisplacement *= verticalFactor;
    mCurrentAnimation = pa.createPlaybackController();
    // Setting this interpolator doesn't affect the visual motion, but is used to determine
    // whether we successfully reached the target state in onDragEnd().
    mCurrentAnimation.getTarget().setInterpolator(currentInterpolator);
    onUserControlledAnimationCreated(mCurrentAnimation);
    mCurrentAnimation.getTarget().addListener(this);
    mCurrentAnimation.dispatchOnStart();
    mProgressMultiplier = 1 / mEndDisplacement;
}
Also used : BaseDragLayer(com.android.launcher3.views.BaseDragLayer) PendingAnimation(com.android.launcher3.anim.PendingAnimation) PagedOrientationHandler(com.android.launcher3.touch.PagedOrientationHandler) Interpolator(android.view.animation.Interpolator) TaskView(com.android.quickstep.views.TaskView) View(android.view.View) RecentsView(com.android.quickstep.views.RecentsView) AbstractFloatingView(com.android.launcher3.AbstractFloatingView)

Example 94 with PagedOrientationHandler

use of com.android.launcher3.touch.PagedOrientationHandler in project android_packages_apps_Launcher3 by ProtonAOSP.

the class TaskOverlayFactory method addSplitOptions.

/**
 * Does NOT add split options in the following scenarios:
 * * The taskView to add split options is already showing split screen tasks
 * * There aren't at least 2 tasks in overview to show split options for
 * * Device is in "Lock task mode"
 * * The taskView to show split options for is the focused task AND we haven't started
 *   scrolling in overview (if we haven't scrolled, there's a split overview action button so
 *   we don't need this menu option)
 */
private static void addSplitOptions(List<SystemShortcut> outShortcuts, BaseDraggingActivity activity, TaskView taskView, DeviceProfile deviceProfile) {
    RecentsView recentsView = taskView.getRecentsView();
    PagedOrientationHandler orientationHandler = recentsView.getPagedOrientationHandler();
    int[] taskViewTaskIds = taskView.getTaskIds();
    boolean taskViewHasMultipleTasks = taskViewTaskIds[0] != -1 && taskViewTaskIds[1] != -1;
    boolean notEnoughTasksToSplit = recentsView.getTaskViewCount() < 2;
    boolean isFocusedTask = deviceProfile.overviewShowAsGrid && taskView.isFocusedTask();
    boolean isTaskInExpectedScrollPosition = recentsView.isTaskInExpectedScrollPosition(recentsView.indexOfChild(taskView));
    ActivityManager activityManager = (ActivityManager) taskView.getContext().getSystemService(Context.ACTIVITY_SERVICE);
    boolean isLockTaskMode = activityManager.isInLockTaskMode();
    if (taskViewHasMultipleTasks || notEnoughTasksToSplit || isLockTaskMode || (isFocusedTask && isTaskInExpectedScrollPosition)) {
        return;
    }
    List<SplitPositionOption> positions = orientationHandler.getSplitPositionOptions(deviceProfile);
    for (SplitPositionOption option : positions) {
        outShortcuts.add(new SplitSelectSystemShortcut(activity, taskView, option));
    }
}
Also used : SplitPositionOption(com.android.launcher3.util.SplitConfigurationOptions.SplitPositionOption) PagedOrientationHandler(com.android.launcher3.touch.PagedOrientationHandler) RecentsView(com.android.quickstep.views.RecentsView) ActivityManager(android.app.ActivityManager) SplitSelectSystemShortcut(com.android.quickstep.TaskShortcutFactory.SplitSelectSystemShortcut)

Example 95 with PagedOrientationHandler

use of com.android.launcher3.touch.PagedOrientationHandler in project android_packages_apps_Launcher3 by ProtonAOSP.

the class ClearAllButton method onLayout.

@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
    super.onLayout(changed, left, top, right, bottom);
    PagedOrientationHandler orientationHandler = getRecentsView().getPagedOrientationHandler();
    mSidePadding = orientationHandler.getClearAllSidePadding(getRecentsView(), mIsRtl);
}
Also used : PagedOrientationHandler(com.android.launcher3.touch.PagedOrientationHandler)

Aggregations

PagedOrientationHandler (com.android.launcher3.touch.PagedOrientationHandler)101 RecentsView (com.android.quickstep.views.RecentsView)25 DeviceProfile (com.android.launcher3.DeviceProfile)22 Rect (android.graphics.Rect)16 PendingAnimation (com.android.launcher3.anim.PendingAnimation)15 FloatProperty (android.util.FloatProperty)14 BaseDragLayer (com.android.launcher3.views.BaseDragLayer)12 PointF (android.graphics.PointF)11 RectF (android.graphics.RectF)11 Point (android.graphics.Point)9 TimeInterpolator (android.animation.TimeInterpolator)6 Matrix (android.graphics.Matrix)6 View (android.view.View)6 Interpolator (android.view.animation.Interpolator)6 AbstractFloatingView (com.android.launcher3.AbstractFloatingView)6 TaskView (com.android.quickstep.views.TaskView)6 Context (android.content.Context)5 ShapeDrawable (android.graphics.drawable.ShapeDrawable)5 RectShape (android.graphics.drawable.shapes.RectShape)5 MotionEvent (android.view.MotionEvent)5