use of com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch in project Neo-Launcher by NeoApplications.
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();
// we abort the drag.
if (img.getBitmap() == null) {
return false;
}
Rect bounds = img.getBitmapBounds();
bounds.offset(img.getLeft() - (int) mLastTouchPos.x, img.getTop() - (int) mLastTouchPos.y);
// Start home and pass the draw request params
PinItemDragListener listener = new PinItemDragListener(mRequest, bounds, img.getBitmap().getWidth(), 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 = listener.addToIntent(new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME).setPackage(getPackageName()).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
listener.initWhenReady();
startActivity(homeIntent, ActivityOptions.makeCustomAnimation(this, 0, android.R.anim.fade_out).toBundle());
mFinishOnPause = true;
return false;
}
use of com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch in project Neo-Launcher by NeoApplications.
the class DragController method completeAccessibleDrag.
/**
* As above, since accessible drag and drop won't cause the same sequence of touch events,
* we manually ensure appropriate drag and drop events get emulated for accessible drag.
*/
public void completeAccessibleDrag(int[] location) {
final int[] coordinates = mCoordinatesTemp;
// We make sure that we prime the target for drop.
DropTarget dropTarget = findDropTarget(location[0], location[1], coordinates);
mDragObject.x = coordinates[0];
mDragObject.y = coordinates[1];
checkTouchMove(dropTarget);
dropTarget.prepareAccessibilityDrop();
// Perform the drop
drop(dropTarget, null);
endDrag();
}
use of com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch in project android_packages_apps_Trebuchet by LineageOS.
the class ScrimView method updateDragHandleBounds.
protected void updateDragHandleBounds() {
DeviceProfile grid = mLauncher.getDeviceProfile();
final int left;
final int width = getMeasuredWidth();
final int top = getMeasuredHeight() - mDragHandleSize.y - grid.getInsets().bottom;
final int topMargin;
if (grid.isVerticalBarLayout()) {
topMargin = grid.workspacePadding.bottom + mDragHandlePaddingInVerticalBarLayout;
if (grid.isSeascape()) {
left = width - grid.getInsets().right - mDragHandleSize.x - mDragHandlePaddingInVerticalBarLayout;
} else {
left = grid.getInsets().left + mDragHandlePaddingInVerticalBarLayout;
}
} else {
left = Math.round((width - mDragHandleSize.x) / 2f);
topMargin = grid.hotseatBarSizePx;
}
mDragHandleBounds.offsetTo(left, top - topMargin);
mHitRect.set(mDragHandleBounds);
// Inset outwards to increase touch size.
mHitRect.inset((mDragHandleSize.x - mDragHandleTouchSize) / 2f, (mDragHandleSize.y - mDragHandleTouchSize) / 2f);
if (mDragHandle != null) {
mDragHandle.setBounds(mDragHandleBounds);
}
}
use of com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch in project android_packages_apps_Trebuchet by LineageOS.
the class ItemClickHandler method onClick.
private static void onClick(View v, String sourceContainer) {
// 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, sourceContainer);
} else if (tag instanceof FolderInfo) {
if (v instanceof FolderIcon) {
onClickFolderIcon(v);
}
} else if (tag instanceof AppInfo) {
startAppShortcutOrInfoActivity(v, (AppInfo) tag, launcher, sourceContainer == null ? CONTAINER_ALL_APPS : sourceContainer);
} else if (tag instanceof LauncherAppWidgetInfo) {
if (v instanceof PendingAppWidgetHostView) {
onClickPendingWidget((PendingAppWidgetHostView) v, launcher);
}
}
}
use of com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch in project android_packages_apps_Trebuchet by LineageOS.
the class WorkspaceTouchListener method onTouch.
@Override
public boolean onTouch(View view, MotionEvent ev) {
mGestureDetector.onTouchEvent(ev);
int action = ev.getActionMasked();
if (action == ACTION_DOWN) {
// Check if we can handle long press.
boolean handleLongPress = canHandleLongPress();
if (handleLongPress) {
// Check if the event is not near the edges
DeviceProfile dp = mLauncher.getDeviceProfile();
DragLayer dl = mLauncher.getDragLayer();
Rect insets = dp.getInsets();
mTempRect.set(insets.left, insets.top, dl.getWidth() - insets.right, dl.getHeight() - insets.bottom);
mTempRect.inset(dp.edgeMarginPx, dp.edgeMarginPx);
handleLongPress = mTempRect.contains((int) ev.getX(), (int) ev.getY());
}
if (handleLongPress) {
mLongPressState = STATE_REQUESTED;
mTouchDownPoint.set(ev.getX(), ev.getY());
}
mWorkspace.onTouchEvent(ev);
// Return true to keep receiving touch events
return true;
}
if (mLongPressState == STATE_PENDING_PARENT_INFORM) {
// Inform the workspace to cancel touch handling
ev.setAction(ACTION_CANCEL);
mWorkspace.onTouchEvent(ev);
ev.setAction(action);
mLongPressState = STATE_COMPLETED;
}
final boolean result;
if (mLongPressState == STATE_COMPLETED) {
// We have handled the touch, so workspace does not need to know anything anymore.
result = true;
} else if (mLongPressState == STATE_REQUESTED) {
mWorkspace.onTouchEvent(ev);
if (mWorkspace.isHandlingTouch()) {
cancelLongPress();
} else if (action == ACTION_MOVE && PointF.length(mTouchDownPoint.x - ev.getX(), mTouchDownPoint.y - ev.getY()) > mTouchSlop) {
cancelLongPress();
}
result = true;
} else {
// We don't want to handle touch, let workspace handle it as usual.
result = false;
}
if (action == ACTION_UP || action == ACTION_POINTER_UP) {
if (!mWorkspace.isHandlingTouch()) {
final CellLayout currentPage = (CellLayout) mWorkspace.getChildAt(mWorkspace.getCurrentPage());
if (currentPage != null) {
mWorkspace.onWallpaperTap(ev);
}
}
}
if (action == ACTION_UP || action == ACTION_CANCEL) {
cancelLongPress();
}
return result;
}
Aggregations