Search in sources :

Example 41 with PagedOrientationHandler

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

the class TaskMenuView method orientAroundTaskView.

private void orientAroundTaskView(TaskIdAttributeContainer taskContainer) {
    RecentsView recentsView = mActivity.getOverviewPanel();
    PagedOrientationHandler orientationHandler = recentsView.getPagedOrientationHandler();
    measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);
    orientationHandler.setTaskMenuAroundTaskView(this, mTaskInsetMargin);
    // Get Position
    DeviceProfile deviceProfile = mActivity.getDeviceProfile();
    mActivity.getDragLayer().getDescendantRectRelativeToSelf(mTaskView, sTempRect);
    Rect insets = mActivity.getDragLayer().getInsets();
    BaseDragLayer.LayoutParams params = (BaseDragLayer.LayoutParams) getLayoutParams();
    int padding = getResources().getDimensionPixelSize(R.dimen.task_menu_vertical_padding);
    params.width = orientationHandler.getTaskMenuWidth(taskContainer.getThumbnailView(), deviceProfile) - (2 * padding);
    // Gravity set to Left instead of Start as sTempRect.left measures Left distance not Start
    params.gravity = Gravity.LEFT;
    setLayoutParams(params);
    setScaleX(mTaskView.getScaleX());
    setScaleY(mTaskView.getScaleY());
    // Set divider spacing
    ShapeDrawable divider = new ShapeDrawable(new RectShape());
    divider.getPaint().setColor(getResources().getColor(android.R.color.transparent));
    int dividerSpacing = (int) getResources().getDimension(R.dimen.task_menu_spacing);
    mOptionLayout.setShowDividers(SHOW_DIVIDER_MIDDLE);
    orientationHandler.setTaskOptionsMenuLayoutOrientation(deviceProfile, mOptionLayout, dividerSpacing, divider);
    setPosition(sTempRect.left - insets.left, sTempRect.top - insets.top, 0);
}
Also used : DeviceProfile(com.android.launcher3.DeviceProfile) BaseDragLayer(com.android.launcher3.views.BaseDragLayer) Rect(android.graphics.Rect) RectShape(android.graphics.drawable.shapes.RectShape) PagedOrientationHandler(com.android.launcher3.touch.PagedOrientationHandler) ShapeDrawable(android.graphics.drawable.ShapeDrawable)

Example 42 with PagedOrientationHandler

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

the class ClearAllButton method applySecondaryTranslation.

private void applySecondaryTranslation() {
    RecentsView recentsView = getRecentsView();
    if (recentsView == null) {
        return;
    }
    PagedOrientationHandler orientationHandler = recentsView.getPagedOrientationHandler();
    orientationHandler.getSecondaryViewTranslate().set(this, orientationHandler.getSecondaryValue(0f, getOriginalTranslationY()));
}
Also used : PagedOrientationHandler(com.android.launcher3.touch.PagedOrientationHandler)

Example 43 with PagedOrientationHandler

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

the class ClearAllButton method applyPrimaryTranslation.

private void applyPrimaryTranslation() {
    RecentsView recentsView = getRecentsView();
    if (recentsView == null) {
        return;
    }
    PagedOrientationHandler orientationHandler = recentsView.getPagedOrientationHandler();
    orientationHandler.getPrimaryViewTranslate().set(this, orientationHandler.getPrimaryValue(0f, getOriginalTranslationY()) + mNormalTranslationPrimary + getFullscreenTrans(mFullscreenTranslationPrimary) + getGridTrans(mGridTranslationPrimary));
}
Also used : PagedOrientationHandler(com.android.launcher3.touch.PagedOrientationHandler)

Example 44 with PagedOrientationHandler

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

the class ClearAllButton method onRecentsViewScroll.

public void onRecentsViewScroll(int scroll, boolean gridEnabled) {
    RecentsView recentsView = getRecentsView();
    if (recentsView == null) {
        return;
    }
    PagedOrientationHandler orientationHandler = recentsView.getPagedOrientationHandler();
    float orientationSize = orientationHandler.getPrimaryValue(getWidth(), getHeight());
    if (orientationSize == 0) {
        return;
    }
    int clearAllScroll = recentsView.getClearAllScroll();
    int adjustedScrollFromEdge = Math.abs(scroll - clearAllScroll);
    float shift = Math.min(adjustedScrollFromEdge, orientationSize);
    mNormalTranslationPrimary = mIsRtl ? -shift : shift;
    if (!gridEnabled) {
        mNormalTranslationPrimary += mSidePadding;
    }
    applyPrimaryTranslation();
    applySecondaryTranslation();
    mScrollAlpha = 1 - shift / orientationSize;
    updateAlpha();
}
Also used : PagedOrientationHandler(com.android.launcher3.touch.PagedOrientationHandler)

Example 45 with PagedOrientationHandler

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

the class AnimatorControllerWithResistance method createRecentsResistanceAnim.

/**
 * Creates the resistance animation for {@link #createForRecents}, or can be used separately
 * when starting from recents, i.e. {@link #createRecentsResistanceFromOverviewAnim}.
 */
public static <SCALE, TRANSLATION> PendingAnimation createRecentsResistanceAnim(RecentsParams<SCALE, TRANSLATION> params) {
    Rect startRect = new Rect();
    PagedOrientationHandler orientationHandler = params.recentsOrientedState.getOrientationHandler();
    LauncherActivityInterface.INSTANCE.calculateTaskSize(params.context, params.dp, startRect);
    long distanceToCover = startRect.bottom;
    PendingAnimation resistAnim = params.resistAnim != null ? params.resistAnim : new PendingAnimation(distanceToCover * 2);
    PointF pivot = new PointF();
    float fullscreenScale = params.recentsOrientedState.getFullScreenScaleAndPivot(startRect, params.dp, pivot);
    // Compute where the task view would be based on the end scale.
    RectF endRectF = new RectF(startRect);
    Matrix temp = new Matrix();
    temp.setScale(params.resistanceParams.scaleMaxResist, params.resistanceParams.scaleMaxResist, pivot.x, pivot.y);
    temp.mapRect(endRectF);
    // Translate such that the task view touches the top of the screen when drag does.
    float endTranslation = endRectF.top * orientationHandler.getSecondaryTranslationDirectionFactor() * params.resistanceParams.translationFactor;
    resistAnim.addFloat(params.translationTarget, params.translationProperty, params.startTranslation, endTranslation, RECENTS_TRANSLATE_RESIST_INTERPOLATOR);
    float prevScaleRate = (fullscreenScale - params.startScale) / (params.dp.heightPx - startRect.bottom);
    // This is what the scale would be at the end of the drag if we didn't apply resistance.
    float endScale = params.startScale - prevScaleRate * distanceToCover;
    // Create an interpolator that resists the scale so the scale doesn't get smaller than
    // RECENTS_SCALE_MAX_RESIST.
    float startResist = Utilities.getProgress(params.resistanceParams.scaleStartResist, params.startScale, endScale);
    float maxResist = Utilities.getProgress(params.resistanceParams.scaleMaxResist, params.startScale, endScale);
    float stopResist = params.resistanceParams.stopScalingAtTop ? 1f - startRect.top / endRectF.top : 1f;
    final TimeInterpolator scaleInterpolator = t -> {
        if (t < startResist) {
            return t;
        }
        if (t > stopResist) {
            return maxResist;
        }
        float resistProgress = Utilities.getProgress(t, startResist, stopResist);
        resistProgress = RECENTS_SCALE_RESIST_INTERPOLATOR.getInterpolation(resistProgress);
        return startResist + resistProgress * (maxResist - startResist);
    };
    resistAnim.addFloat(params.scaleTarget, params.scaleProperty, params.startScale, endScale, scaleInterpolator);
    return resistAnim;
}
Also used : RectF(android.graphics.RectF) RectF(android.graphics.RectF) Utilities(com.android.launcher3.Utilities) Context(android.content.Context) Rect(android.graphics.Rect) TimeInterpolator(android.animation.TimeInterpolator) PointF(android.graphics.PointF) Launcher(com.android.launcher3.Launcher) DEACCEL(com.android.launcher3.anim.Interpolators.DEACCEL) FloatProperty(android.util.FloatProperty) AnimatorPlaybackController(com.android.launcher3.anim.AnimatorPlaybackController) DeviceProfile(com.android.launcher3.DeviceProfile) LINEAR(com.android.launcher3.anim.Interpolators.LINEAR) RECENTS_SCALE_PROPERTY(com.android.quickstep.views.RecentsView.RECENTS_SCALE_PROPERTY) Nullable(androidx.annotation.Nullable) LauncherActivityInterface(com.android.quickstep.LauncherActivityInterface) RecentsView(com.android.quickstep.views.RecentsView) TASK_SECONDARY_TRANSLATION(com.android.quickstep.views.RecentsView.TASK_SECONDARY_TRANSLATION) Matrix(android.graphics.Matrix) PagedOrientationHandler(com.android.launcher3.touch.PagedOrientationHandler) PendingAnimation(com.android.launcher3.anim.PendingAnimation) PendingAnimation(com.android.launcher3.anim.PendingAnimation) Rect(android.graphics.Rect) Matrix(android.graphics.Matrix) PagedOrientationHandler(com.android.launcher3.touch.PagedOrientationHandler) PointF(android.graphics.PointF) TimeInterpolator(android.animation.TimeInterpolator)

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