use of com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch in project android_packages_apps_Launcher3 by ArrowOS.
the class LauncherDragController method startDrag.
@Override
protected DragView startDrag(@Nullable Drawable drawable, @Nullable View view, DraggableView originalView, int dragLayerX, int dragLayerY, DragSource source, ItemInfo dragInfo, Point dragOffset, Rect dragRegion, float initialDragViewScale, float dragViewScaleOnDrop, DragOptions options) {
if (TestProtocol.sDebugTracing) {
Log.d(TestProtocol.NO_DROP_TARGET, "5");
}
if (PROFILE_DRAWING_DURING_DRAG) {
android.os.Debug.startMethodTracing("Launcher");
}
mActivity.hideKeyboard();
AbstractFloatingView.closeOpenViews(mActivity, false, TYPE_DISCOVERY_BOUNCE);
mOptions = options;
if (mOptions.simulatedDndStartPoint != null) {
mLastTouch.x = mMotionDown.x = mOptions.simulatedDndStartPoint.x;
mLastTouch.y = mMotionDown.y = mOptions.simulatedDndStartPoint.y;
}
final int registrationX = mMotionDown.x - dragLayerX;
final int registrationY = mMotionDown.y - dragLayerY;
final int dragRegionLeft = dragRegion == null ? 0 : dragRegion.left;
final int dragRegionTop = dragRegion == null ? 0 : dragRegion.top;
mLastDropTarget = null;
mDragObject = new DropTarget.DragObject(mActivity.getApplicationContext());
mDragObject.originalView = originalView;
mIsInPreDrag = mOptions.preDragCondition != null && !mOptions.preDragCondition.shouldStartDrag(0);
final Resources res = mActivity.getResources();
final float scaleDps = mIsInPreDrag ? res.getDimensionPixelSize(R.dimen.pre_drag_view_scale) : 0f;
final DragView dragView = mDragObject.dragView = drawable != null ? new LauncherDragView(mActivity, drawable, registrationX, registrationY, initialDragViewScale, dragViewScaleOnDrop, scaleDps) : new LauncherDragView(mActivity, view, view.getMeasuredWidth(), view.getMeasuredHeight(), registrationX, registrationY, initialDragViewScale, dragViewScaleOnDrop, scaleDps);
dragView.setItemInfo(dragInfo);
mDragObject.dragComplete = false;
mDragObject.xOffset = mMotionDown.x - (dragLayerX + dragRegionLeft);
mDragObject.yOffset = mMotionDown.y - (dragLayerY + dragRegionTop);
mDragDriver = DragDriver.create(this, mOptions, mFlingToDeleteHelper::recordMotionEvent);
if (!mOptions.isAccessibleDrag) {
mDragObject.stateAnnouncer = DragViewStateAnnouncer.createFor(dragView);
}
mDragObject.dragSource = source;
mDragObject.dragInfo = dragInfo;
mDragObject.originalDragInfo = mDragObject.dragInfo.makeShallowCopy();
if (dragOffset != null) {
dragView.setDragVisualizeOffset(new Point(dragOffset));
}
if (dragRegion != null) {
dragView.setDragRegion(new Rect(dragRegion));
}
mActivity.getDragLayer().performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
dragView.show(mLastTouch.x, mLastTouch.y);
mDistanceSinceScroll = 0;
if (!mIsInPreDrag) {
callOnDragStart();
} else if (mOptions.preDragCondition != null) {
mOptions.preDragCondition.onPreDragStart(mDragObject);
}
handleMoveEvent(mLastTouch.x, mLastTouch.y);
if (!mActivity.isTouchInProgress() && options.simulatedDndStartPoint == null) {
// If it is an internal drag and the touch is already complete, cancel immediately
MAIN_EXECUTOR.submit(this::cancelDrag);
}
return dragView;
}
use of com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch in project android_packages_apps_Launcher3 by ProtonAOSP.
the class SecondaryDisplayLauncher method onIconClicked.
private void onIconClicked(View v) {
// view has detached (it's possible for this to happen if the view is removed mid touch).
if (v.getWindowToken() == null)
return;
Object tag = v.getTag();
if (tag instanceof ItemInfo) {
ItemInfo item = (ItemInfo) tag;
Intent intent;
if (item instanceof ItemInfoWithIcon && (((ItemInfoWithIcon) item).runtimeStatusFlags & ItemInfoWithIcon.FLAG_INSTALL_SESSION_ACTIVE) != 0) {
ItemInfoWithIcon appInfo = (ItemInfoWithIcon) item;
intent = appInfo.getMarketIntent(this);
} else {
intent = item.getIntent();
}
if (intent == null) {
throw new IllegalArgumentException("Input must have a valid intent");
}
startActivitySafely(v, intent, item);
}
}
use of com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch in project android_packages_apps_Launcher3 by ProtonAOSP.
the class AddItemActivity method onLongClick.
@Override
public boolean onLongClick(View view) {
// Find the position of the preview relative to the touch location.
WidgetImageView img = mWidgetCell.getWidgetView();
NavigableAppWidgetHostView appWidgetHostView = mWidgetCell.getAppWidgetHostViewPreview();
// we abort the drag.
if (img.getDrawable() == null && appWidgetHostView == null) {
return false;
}
final Rect bounds;
// Start home and pass the draw request params
final PinItemDragListener listener;
if (appWidgetHostView != null) {
bounds = new Rect();
appWidgetHostView.getSourceVisualDragBounds(bounds);
float appWidgetHostViewScale = mWidgetCell.getAppWidgetHostViewScale();
int xOffset = appWidgetHostView.getLeft() - (int) (mLastTouchPos.x * appWidgetHostViewScale);
int yOffset = appWidgetHostView.getTop() - (int) (mLastTouchPos.y * appWidgetHostViewScale);
bounds.offset(xOffset, yOffset);
listener = new PinItemDragListener(mRequest, bounds, appWidgetHostView.getMeasuredWidth(), appWidgetHostView.getMeasuredWidth(), appWidgetHostViewScale);
} else {
bounds = img.getBitmapBounds();
bounds.offset(img.getLeft() - (int) mLastTouchPos.x, img.getTop() - (int) mLastTouchPos.y);
listener = new PinItemDragListener(mRequest, bounds, img.getDrawable().getIntrinsicWidth(), img.getWidth());
}
// Start a system drag and drop. We use a transparent bitmap as preview for system drag
// as the preview is handled internally by launcher.
ClipDescription description = new ClipDescription("", new String[] { listener.getMimeType() });
ClipData data = new ClipData(description, new ClipData.Item(""));
view.startDragAndDrop(data, new DragShadowBuilder(view) {
@Override
public void onDrawShadow(Canvas canvas) {
}
@Override
public void onProvideShadowMetrics(Point outShadowSize, Point outShadowTouchPoint) {
outShadowSize.set(SHADOW_SIZE, SHADOW_SIZE);
outShadowTouchPoint.set(SHADOW_SIZE / 2, SHADOW_SIZE / 2);
}
}, null, View.DRAG_FLAG_GLOBAL);
Intent homeIntent = new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME).setPackage(getPackageName()).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Launcher.ACTIVITY_TRACKER.registerCallback(listener);
startActivity(homeIntent, ActivityOptions.makeCustomAnimation(this, 0, android.R.anim.fade_out).toBundle());
logCommand(LAUNCHER_ADD_EXTERNAL_ITEM_DRAGGED);
mFinishOnPause = true;
return false;
}
use of com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch 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();
}
use of com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch in project android_packages_apps_Launcher3 by ProtonAOSP.
the class ItemClickHandler method onClick.
private static void onClick(View v) {
// view has detached (it's possible for this to happen if the view is removed mid touch).
if (v.getWindowToken() == null)
return;
Launcher launcher = Launcher.getLauncher(v.getContext());
if (!launcher.getWorkspace().isFinishedSwitchingState())
return;
Object tag = v.getTag();
if (tag instanceof WorkspaceItemInfo) {
onClickAppShortcut(v, (WorkspaceItemInfo) tag, launcher);
} else if (tag instanceof FolderInfo) {
if (v instanceof FolderIcon) {
onClickFolderIcon(v);
}
} else if (tag instanceof AppInfo) {
startAppShortcutOrInfoActivity(v, (AppInfo) tag, launcher);
} else if (tag instanceof LauncherAppWidgetInfo) {
if (v instanceof PendingAppWidgetHostView) {
onClickPendingWidget((PendingAppWidgetHostView) v, launcher);
}
} else if (tag instanceof SearchActionItemInfo) {
onClickSearchAction(launcher, (SearchActionItemInfo) tag);
}
}
Aggregations