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();
}
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;
}
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);
}
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;
}
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();
}
Aggregations