Search in sources :

Example 66 with DragLayer

use of com.android.launcher3.dragndrop.DragLayer in project android_packages_apps_Launcher3 by ProtonAOSP.

the class LauncherAppWidgetHostView method onInterceptTouchEvent.

public boolean onInterceptTouchEvent(MotionEvent ev) {
    if (ev.getAction() == MotionEvent.ACTION_DOWN) {
        DragLayer dragLayer = mLauncher.getDragLayer();
        if (mIsScrollable) {
            dragLayer.requestDisallowInterceptTouchEvent(true);
        }
        dragLayer.setTouchCompleteListener(this);
    }
    mLongPressHelper.onTouchEvent(ev);
    return mLongPressHelper.hasPerformedLongPress();
}
Also used : DragLayer(com.android.launcher3.dragndrop.DragLayer)

Example 67 with DragLayer

use of com.android.launcher3.dragndrop.DragLayer in project android_packages_apps_Launcher3 by ProtonAOSP.

the class LauncherAppWidgetHostView method onLongClick.

@Override
public boolean onLongClick(View view) {
    if (mIsScrollable) {
        DragLayer dragLayer = mLauncher.getDragLayer();
        dragLayer.requestDisallowInterceptTouchEvent(false);
    }
    view.performLongClick();
    return true;
}
Also used : DragLayer(com.android.launcher3.dragndrop.DragLayer)

Example 68 with DragLayer

use of com.android.launcher3.dragndrop.DragLayer in project android_packages_apps_Launcher3 by ProtonAOSP.

the class ButtonDropTarget method onDrop.

/**
 * On drop animate the dropView to the icon.
 */
@Override
public void onDrop(final DragObject d, final DragOptions options) {
    if (options.isFlingToDelete) {
        // FlingAnimation handles the animation and then calls completeDrop().
        return;
    }
    final DragLayer dragLayer = mLauncher.getDragLayer();
    final DragView dragView = d.dragView;
    final Rect to = getIconRect(d);
    final float scale = (float) to.width() / dragView.getMeasuredWidth();
    dragView.detachContentView(/* reattachToPreviousParent= */
    true);
    mDropTargetBar.deferOnDragEnd();
    Runnable onAnimationEndRunnable = () -> {
        completeDrop(d);
        mDropTargetBar.onDragEnd();
        mLauncher.getStateManager().goToState(NORMAL);
    };
    dragLayer.animateView(d.dragView, to, scale, 0.1f, 0.1f, DRAG_VIEW_DROP_DURATION, Interpolators.DEACCEL_2, onAnimationEndRunnable, DragLayer.ANIMATION_END_DISAPPEAR, null);
}
Also used : DragLayer(com.android.launcher3.dragndrop.DragLayer) Rect(android.graphics.Rect) DragView(com.android.launcher3.dragndrop.DragView)

Example 69 with DragLayer

use of com.android.launcher3.dragndrop.DragLayer in project android_packages_apps_Launcher3 by ProtonAOSP.

the class ButtonDropTarget method getIconRect.

public Rect getIconRect(DragObject dragObject) {
    int viewWidth = dragObject.dragView.getMeasuredWidth();
    int viewHeight = dragObject.dragView.getMeasuredHeight();
    int drawableWidth = mDrawable.getIntrinsicWidth();
    int drawableHeight = mDrawable.getIntrinsicHeight();
    DragLayer dragLayer = mLauncher.getDragLayer();
    // Find the rect to animate to (the view is center aligned)
    Rect to = new Rect();
    dragLayer.getViewRectRelativeToSelf(this, to);
    final int width = drawableWidth;
    final int height = drawableHeight;
    final int left;
    final int right;
    if (Utilities.isRtl(getResources())) {
        right = to.right - getPaddingRight();
        left = right - width;
    } else {
        left = to.left + getPaddingLeft();
        right = left + width;
    }
    final int top = to.top + (getMeasuredHeight() - height) / 2;
    final int bottom = top + height;
    to.set(left, top, right, bottom);
    // Center the destination rect about the trash icon
    final int xOffset = -(viewWidth - width) / 2;
    final int yOffset = -(viewHeight - height) / 2;
    to.offset(xOffset, yOffset);
    return to;
}
Also used : DragLayer(com.android.launcher3.dragndrop.DragLayer) Rect(android.graphics.Rect)

Example 70 with DragLayer

use of com.android.launcher3.dragndrop.DragLayer in project android_packages_apps_Launcher3 by ProtonAOSP.

the class AppWidgetResizeFrame method snapToWidget.

private void snapToWidget(boolean animate) {
    getSnappedRectRelativeToDragLayer(sTmpRect);
    int newWidth = sTmpRect.width();
    int newHeight = sTmpRect.height();
    int newX = sTmpRect.left;
    int newY = sTmpRect.top;
    // down accordingly to provide a proper touch target.
    if (newY < 0) {
        // In this case we shift the touch region down to start at the top of the DragLayer
        mTopTouchRegionAdjustment = -newY;
    } else {
        mTopTouchRegionAdjustment = 0;
    }
    if (newY + newHeight > mDragLayer.getHeight()) {
        // In this case we shift the touch region up to end at the bottom of the DragLayer
        mBottomTouchRegionAdjustment = -(newY + newHeight - mDragLayer.getHeight());
    } else {
        mBottomTouchRegionAdjustment = 0;
    }
    final DragLayer.LayoutParams lp = (DragLayer.LayoutParams) getLayoutParams();
    final CellLayout pairedCellLayout;
    if (mCellLayout.getParent() instanceof Workspace) {
        Workspace workspace = (Workspace) mCellLayout.getParent();
        pairedCellLayout = workspace.getScreenPair(mCellLayout);
    } else {
        pairedCellLayout = null;
    }
    if (!animate) {
        lp.width = newWidth;
        lp.height = newHeight;
        lp.x = newX;
        lp.y = newY;
        for (int i = 0; i < HANDLE_COUNT; i++) {
            mDragHandles[i].setAlpha(1f);
        }
        if (pairedCellLayout != null) {
            updateInvalidResizeEffect(mCellLayout, pairedCellLayout, /* alpha= */
            1f, /* springLoadedProgress= */
            0f);
        }
        requestLayout();
    } else {
        ObjectAnimator oa = ObjectAnimator.ofPropertyValuesHolder(lp, PropertyValuesHolder.ofInt(LAYOUT_WIDTH, lp.width, newWidth), PropertyValuesHolder.ofInt(LAYOUT_HEIGHT, lp.height, newHeight), PropertyValuesHolder.ofInt(LAYOUT_X, lp.x, newX), PropertyValuesHolder.ofInt(LAYOUT_Y, lp.y, newY));
        mFirstFrameAnimatorHelper.addTo(oa).addUpdateListener(a -> requestLayout());
        AnimatorSet set = new AnimatorSet();
        set.play(oa);
        for (int i = 0; i < HANDLE_COUNT; i++) {
            set.play(mFirstFrameAnimatorHelper.addTo(ObjectAnimator.ofFloat(mDragHandles[i], ALPHA, 1f)));
        }
        if (pairedCellLayout != null) {
            updateInvalidResizeEffect(mCellLayout, pairedCellLayout, /* alpha= */
            1f, /* springLoadedProgress= */
            0f, /* animatorSet= */
            set);
        }
        set.setDuration(SNAP_DURATION);
        set.start();
    }
    setFocusableInTouchMode(true);
    requestFocus();
}
Also used : DragLayer(com.android.launcher3.dragndrop.DragLayer) ObjectAnimator(android.animation.ObjectAnimator) AnimatorSet(android.animation.AnimatorSet)

Aggregations

DragLayer (com.android.launcher3.dragndrop.DragLayer)100 Rect (android.graphics.Rect)67 BaseDragLayer (com.android.launcher3.views.BaseDragLayer)33 ViewGroup (android.view.ViewGroup)23 Resources (android.content.res.Resources)22 AnimatorSet (android.animation.AnimatorSet)20 View (android.view.View)18 SuppressLint (android.annotation.SuppressLint)16 AbstractFloatingView (com.android.launcher3.AbstractFloatingView)15 DeviceProfile (com.android.launcher3.DeviceProfile)15 Workspace (com.android.launcher3.Workspace)15 Animator (android.animation.Animator)14 ObjectAnimator (android.animation.ObjectAnimator)14 Point (android.graphics.Point)12 ItemInfo (com.android.launcher3.model.data.ItemInfo)12 CellLayout (com.android.launcher3.CellLayout)11 DragView (com.android.launcher3.dragndrop.DragView)11 ArrayList (java.util.ArrayList)11 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)10 Drawable (android.graphics.drawable.Drawable)10