Search in sources :

Example 1 with RotationMode

use of com.android.launcher3.graphics.RotationMode in project Neo-Launcher by NeoApplications.

the class RecentsView method getEventDispatcher.

public Consumer<MotionEvent> getEventDispatcher(RotationMode rotationMode) {
    if (rotationMode.isTransposed) {
        Matrix transform = new Matrix();
        transform.setRotate(-rotationMode.surfaceRotation);
        if (getWidth() > 0 && getHeight() > 0) {
            float scale = ((float) getWidth()) / getHeight();
            transform.postScale(scale, 1 / scale);
        }
        Matrix inverse = new Matrix();
        transform.invert(inverse);
        return e -> {
            e.transform(transform);
            super.onTouchEvent(e);
            e.transform(inverse);
        };
    } else {
        return super::onTouchEvent;
    }
}
Also used : SyncRtSurfaceTransactionApplierCompat(com.android.systemui.shared.system.SyncRtSurfaceTransactionApplierCompat) Drawable(android.graphics.drawable.Drawable) LayoutTransition(android.animation.LayoutTransition) Handler(android.os.Handler) TAP(com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch.TAP) Canvas(android.graphics.Canvas) AccessibilityEvent(android.view.accessibility.AccessibilityEvent) PendingAnimation(com.android.launcher3.util.PendingAnimation) SCALE_PROPERTY(com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY) RotationMode(com.android.launcher3.graphics.RotationMode) TargetApi(android.annotation.TargetApi) CLEAR_ALL_BUTTON(com.android.launcher3.userevent.nano.LauncherLogProto.ControlType.CLEAR_ALL_BUTTON) RecentsAnimationWrapper(com.android.quickstep.RecentsAnimationWrapper) DeviceProfile(com.android.launcher3.DeviceProfile) HapticFeedbackConstants(android.view.HapticFeedbackConstants) Nullable(androidx.annotation.Nullable) Layout(android.text.Layout) TextPaint(android.text.TextPaint) LauncherLogProto(com.android.launcher3.userevent.nano.LauncherLogProto) TimeInterpolator(android.animation.TimeInterpolator) Insettable(com.android.launcher3.Insettable) Utilities.squaredTouchSlop(com.android.launcher3.Utilities.squaredTouchSlop) ArrayList(java.util.ArrayList) TaskUtils.checkCurrentOrManagedUserId(com.android.quickstep.TaskUtils.checkCurrentOrManagedUserId) ComponentName(android.content.ComponentName) ViewPool(com.android.launcher3.util.ViewPool) ViewDebug(android.view.ViewDebug) FeatureFlags(com.android.launcher3.config.FeatureFlags) Direction(com.android.launcher3.userevent.nano.LauncherLogProto.Action.Direction) LINEAR(com.android.launcher3.anim.Interpolators.LINEAR) SparseBooleanArray(android.util.SparseBooleanArray) R(com.android.launcher3.R) ComponentKey(com.android.launcher3.util.ComponentKey) MIN_VISIBLE_CHANGE_PIXELS(androidx.dynamicanimation.animation.DynamicAnimation.MIN_VISIBLE_CHANGE_PIXELS) ValueAnimator(android.animation.ValueAnimator) ACCEL(com.android.launcher3.anim.Interpolators.ACCEL) UI_STATE_OVERVIEW(com.android.launcher3.util.SystemUiController.UI_STATE_OVERVIEW) Rect(android.graphics.Rect) PackageManagerWrapper(com.android.systemui.shared.system.PackageManagerWrapper) Task(com.android.systemui.shared.recents.model.Task) Animator(android.animation.Animator) FloatProperty(android.util.FloatProperty) QUICKSTEP_SPRINGS(com.android.launcher3.config.FeatureFlags.QUICKSTEP_SPRINGS) AttributeSet(android.util.AttributeSet) ActivityManagerWrapper(com.android.systemui.shared.system.ActivityManagerWrapper) View(android.view.View) Matrix(android.graphics.Matrix) LauncherEventUtil(com.android.systemui.shared.system.LauncherEventUtil) RectF(android.graphics.RectF) Utilities(com.android.launcher3.Utilities) SpringForce(androidx.dynamicanimation.animation.SpringForce) TransitionListener(android.animation.LayoutTransition.TransitionListener) UI_HELPER_EXECUTOR(com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR) ObjectAnimator(android.animation.ObjectAnimator) EDGE_NAV_BAR(com.android.launcher3.Utilities.EDGE_NAV_BAR) TaskUtils(com.android.quickstep.TaskUtils) TaskStackChangeListener(com.android.systemui.shared.system.TaskStackChangeListener) ViewGroup(android.view.ViewGroup) WindowInsets(android.view.WindowInsets) ThumbnailData(com.android.systemui.shared.recents.model.ThumbnailData) TaskThumbnailChangeListener(com.android.quickstep.RecentsModel.TaskThumbnailChangeListener) ListView(android.widget.ListView) Themes(com.android.launcher3.util.Themes) SUCCESS_TRANSITION_PROGRESS(com.android.launcher3.uioverrides.touchcontrollers.TaskViewTouchController.SUCCESS_TRANSITION_PROGRESS) Typeface(android.graphics.Typeface) ActivityManager(android.app.ActivityManager) Context(android.content.Context) StaticLayout(android.text.StaticLayout) AccessibilityNodeInfo(android.view.accessibility.AccessibilityNodeInfo) TaskThumbnailCache(com.android.quickstep.TaskThumbnailCache) CHANGE_FLAG_ICON_PARAMS(com.android.launcher3.InvariantDeviceProfile.CHANGE_FLAG_ICON_PARAMS) KeyEvent(android.view.KeyEvent) Touch(com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch) STATE_HANDLER_INVISIBILITY_FLAGS(com.android.launcher3.BaseActivity.STATE_HANDLER_INVISIBILITY_FLAGS) Intent(android.content.Intent) AnimatorPlaybackController(com.android.launcher3.anim.AnimatorPlaybackController) SpringObjectAnimator(com.android.launcher3.anim.SpringObjectAnimator) FAST_OUT_SLOW_IN(com.android.launcher3.anim.Interpolators.FAST_OUT_SLOW_IN) Utilities.squaredHypot(com.android.launcher3.Utilities.squaredHypot) MotionEvent(android.view.MotionEvent) BaseActivity(com.android.launcher3.BaseActivity) ENABLE_QUICKSTEP_LIVE_TILE(com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE) AnimatorSet(android.animation.AnimatorSet) Build(android.os.Build) OverScroller(com.android.launcher3.util.OverScroller) LayoutInflater(android.view.LayoutInflater) VIEW_TRANSLATE_Y(com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_Y) VIEW_TRANSLATE_X(com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_X) ClipAnimationHelper(com.android.quickstep.util.ClipAnimationHelper) Point(android.graphics.Point) ACCEL_2(com.android.launcher3.anim.Interpolators.ACCEL_2) LauncherState(com.android.launcher3.LauncherState) Consumer(java.util.function.Consumer) InvariantDeviceProfile(com.android.launcher3.InvariantDeviceProfile) PropertyListBuilder(com.android.launcher3.anim.PropertyListBuilder) RecentsModel(com.android.quickstep.RecentsModel) PagedView(com.android.launcher3.PagedView) Matrix(android.graphics.Matrix)

Example 2 with RotationMode

use of com.android.launcher3.graphics.RotationMode in project Neo-Launcher by NeoApplications.

the class DragLayer method onLayout.

@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
    RotationMode rotation = mActivity.getRotationMode();
    if (!rotation.isTransposed) {
        super.onLayout(changed, left, top, right, bottom);
        return;
    }
    final int count = getChildCount();
    final int parentWidth = right - left;
    final int parentHeight = bottom - top;
    for (int i = 0; i < count; i++) {
        final View child = getChildAt(i);
        if (child.getVisibility() == GONE) {
            continue;
        }
        final FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) child.getLayoutParams();
        if (lp instanceof LayoutParams) {
            final LayoutParams dlp = (LayoutParams) lp;
            if (dlp.customPosition) {
                child.layout(dlp.x, dlp.y, dlp.x + dlp.width, dlp.y + dlp.height);
                continue;
            }
        }
        final int width = child.getMeasuredWidth();
        final int height = child.getMeasuredHeight();
        int childLeft;
        int childTop;
        int gravity = lp.gravity;
        if (gravity == -1) {
            gravity = Gravity.TOP | Gravity.START;
        }
        final int layoutDirection = getLayoutDirection();
        int absoluteGravity = Gravity.getAbsoluteGravity(gravity, layoutDirection);
        if (child instanceof Transposable) {
            absoluteGravity = rotation.toNaturalGravity(absoluteGravity);
            switch(absoluteGravity & Gravity.HORIZONTAL_GRAVITY_MASK) {
                case Gravity.CENTER_HORIZONTAL:
                    childTop = (parentHeight - height) / 2 + lp.topMargin - lp.bottomMargin;
                    break;
                case Gravity.RIGHT:
                    childTop = width / 2 + lp.rightMargin - height / 2;
                    break;
                case Gravity.LEFT:
                default:
                    childTop = parentHeight - lp.leftMargin - width / 2 - height / 2;
            }
            switch(absoluteGravity & Gravity.VERTICAL_GRAVITY_MASK) {
                case Gravity.CENTER_VERTICAL:
                    childLeft = (parentWidth - width) / 2 + lp.leftMargin - lp.rightMargin;
                    break;
                case Gravity.BOTTOM:
                    childLeft = parentWidth - width / 2 - height / 2 - lp.bottomMargin;
                    break;
                case Gravity.TOP:
                default:
                    childLeft = height / 2 - width / 2 + lp.topMargin;
            }
        } else {
            switch(absoluteGravity & Gravity.HORIZONTAL_GRAVITY_MASK) {
                case Gravity.CENTER_HORIZONTAL:
                    childLeft = (parentWidth - width) / 2 + lp.leftMargin - lp.rightMargin;
                    break;
                case Gravity.RIGHT:
                    childLeft = parentWidth - width - lp.rightMargin;
                    break;
                case Gravity.LEFT:
                default:
                    childLeft = lp.leftMargin;
            }
            switch(absoluteGravity & Gravity.VERTICAL_GRAVITY_MASK) {
                case Gravity.TOP:
                    childTop = lp.topMargin;
                    break;
                case Gravity.CENTER_VERTICAL:
                    childTop = (parentHeight - height) / 2 + lp.topMargin - lp.bottomMargin;
                    break;
                case Gravity.BOTTOM:
                    childTop = parentHeight - height - lp.bottomMargin;
                    break;
                default:
                    childTop = lp.topMargin;
            }
        }
        child.layout(childLeft, childTop, childLeft + width, childTop + height);
    }
}
Also used : FrameLayout(android.widget.FrameLayout) RotationMode(com.android.launcher3.graphics.RotationMode) Transposable(com.android.launcher3.views.Transposable) View(android.view.View) TextView(android.widget.TextView) AbstractFloatingView(com.android.launcher3.AbstractFloatingView)

Example 3 with RotationMode

use of com.android.launcher3.graphics.RotationMode in project Neo-Launcher by NeoApplications.

the class Workspace method setInsets.

@Override
public void setInsets(Rect insets) {
    DeviceProfile grid = mLauncher.getDeviceProfile();
    DeviceProfile stableGrid = mLauncher.getWallpaperDeviceProfile();
    mMaxDistanceForFolderCreation = stableGrid.isTablet ? 0.75f * stableGrid.iconSizePx : 0.55f * stableGrid.iconSizePx;
    mWorkspaceFadeInAdjacentScreens = grid.shouldFadeAdjacentWorkspaceScreens();
    Rect padding = stableGrid.workspacePadding;
    RotationMode rotationMode = mLauncher.getRotationMode();
    rotationMode.mapRect(padding, mTempRect);
    setPadding(mTempRect.left, mTempRect.top, mTempRect.right, mTempRect.bottom);
    rotationMode.mapRect(stableGrid.getInsets(), mInsets);
    if (mWorkspaceFadeInAdjacentScreens) {
        // In landscape mode the page spacing is set to the default.
        setPageSpacing(grid.edgeMarginPx);
    } else {
        // In portrait, we want the pages spaced such that there is no
        // overhang of the previous / next page into the current page viewport.
        // We assume symmetrical padding in portrait mode.
        setPageSpacing(Math.max(grid.edgeMarginPx, padding.left + 1));
    }
    int paddingLeftRight = stableGrid.cellLayoutPaddingLeftRightPx;
    int paddingBottom = stableGrid.cellLayoutBottomPaddingPx;
    for (int i = mWorkspaceScreens.size() - 1; i >= 0; i--) {
        CellLayout page = mWorkspaceScreens.valueAt(i);
        page.setRotationMode(rotationMode);
        page.setPadding(paddingLeftRight, 0, paddingLeftRight, paddingBottom);
    }
}
Also used : Rect(android.graphics.Rect) RotationMode(com.android.launcher3.graphics.RotationMode) SuppressLint(android.annotation.SuppressLint) Point(android.graphics.Point)

Example 4 with RotationMode

use of com.android.launcher3.graphics.RotationMode in project Neo-Launcher by NeoApplications.

the class DragLayer method onMeasure.

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    RotationMode rotation = mActivity.getRotationMode();
    int count = getChildCount();
    if (!rotation.isTransposed || getMode(widthMeasureSpec) != EXACTLY || getMode(heightMeasureSpec) != EXACTLY) {
        for (int i = 0; i < count; i++) {
            final View child = getChildAt(i);
            child.setRotation(rotation.surfaceRotation);
        }
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    } else {
        for (int i = 0; i < count; i++) {
            final View child = getChildAt(i);
            if (child.getVisibility() == GONE) {
                continue;
            }
            if (!(child instanceof Transposable)) {
                measureChildWithMargins(child, widthMeasureSpec, 0, heightMeasureSpec, 0);
            } else {
                measureChildWithMargins(child, heightMeasureSpec, 0, widthMeasureSpec, 0);
                child.setPivotX(child.getMeasuredWidth() / 2);
                child.setPivotY(child.getMeasuredHeight() / 2);
                child.setRotation(rotation.surfaceRotation);
            }
        }
        setMeasuredDimension(getSize(widthMeasureSpec), getSize(heightMeasureSpec));
    }
}
Also used : RotationMode(com.android.launcher3.graphics.RotationMode) Transposable(com.android.launcher3.views.Transposable) View(android.view.View) TextView(android.widget.TextView) AbstractFloatingView(com.android.launcher3.AbstractFloatingView)

Example 5 with RotationMode

use of com.android.launcher3.graphics.RotationMode in project Neo-Launcher by NeoApplications.

the class Utilities method getDescendantCoordRelativeToAncestor.

/**
 * Given a coordinate relative to the descendant, find the coordinate in a parent view's
 * coordinates.
 *
 * @param descendant The descendant to which the passed coordinate is relative.
 * @param ancestor The root view to make the coordinates relative to.
 * @param coord The coordinate that we want mapped.
 * @param includeRootScroll Whether or not to account for the scroll of the descendant:
 *          sometimes this is relevant as in a child's coordinates within the descendant.
 * @param ignoreTransform If true, view transform is ignored
 * @param outRotation If not null, and {@param ignoreTransform} is true, this is set to the
 *                   overall rotation of the view in degrees.
 * @return The factor by which this descendant is scaled relative to this DragLayer. Caution
 *         this scale factor is assumed to be equal in X and Y, and so if at any point this
 *         assumption fails, we will need to return a pair of scale factors.
 */
public static float getDescendantCoordRelativeToAncestor(View descendant, View ancestor, float[] coord, boolean includeRootScroll, boolean ignoreTransform, float[] outRotation) {
    float scale = 1.0f;
    View v = descendant;
    while (v != ancestor && v != null) {
        // which is very strange... ignore the scroll.
        if (v != descendant || includeRootScroll) {
            offsetPoints(coord, -v.getScrollX(), -v.getScrollY());
        }
        if (ignoreTransform) {
            if (v instanceof Transposable) {
                RotationMode m = ((Transposable) v).getRotationMode();
                if (m.isTransposed) {
                    sMatrix.setRotate(m.surfaceRotation, v.getPivotX(), v.getPivotY());
                    sMatrix.mapPoints(coord);
                    if (outRotation != null) {
                        outRotation[0] += m.surfaceRotation;
                    }
                }
            }
        } else {
            v.getMatrix().mapPoints(coord);
        }
        offsetPoints(coord, v.getLeft(), v.getTop());
        scale *= v.getScaleX();
        v = (View) v.getParent();
    }
    return scale;
}
Also used : RotationMode(com.android.launcher3.graphics.RotationMode) Transposable(com.android.launcher3.views.Transposable) View(android.view.View)

Aggregations

RotationMode (com.android.launcher3.graphics.RotationMode)5 View (android.view.View)4 Point (android.graphics.Point)2 Rect (android.graphics.Rect)2 Transposable (com.android.launcher3.views.Transposable)2 Animator (android.animation.Animator)1 AnimatorSet (android.animation.AnimatorSet)1 LayoutTransition (android.animation.LayoutTransition)1 TransitionListener (android.animation.LayoutTransition.TransitionListener)1 ObjectAnimator (android.animation.ObjectAnimator)1 TimeInterpolator (android.animation.TimeInterpolator)1 ValueAnimator (android.animation.ValueAnimator)1 SuppressLint (android.annotation.SuppressLint)1 TargetApi (android.annotation.TargetApi)1 ActivityManager (android.app.ActivityManager)1 ComponentName (android.content.ComponentName)1 Context (android.content.Context)1 Intent (android.content.Intent)1 Canvas (android.graphics.Canvas)1 Matrix (android.graphics.Matrix)1