Search in sources :

Example 66 with Touch

use of com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch in project android_packages_apps_Launcher3 by ArrowOS.

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);
    }
}
Also used : FolderIcon(com.android.launcher3.folder.FolderIcon) Launcher(com.android.launcher3.Launcher) LauncherAppWidgetInfo(com.android.launcher3.model.data.LauncherAppWidgetInfo) SearchActionItemInfo(com.android.launcher3.model.data.SearchActionItemInfo) PendingAppWidgetHostView(com.android.launcher3.widget.PendingAppWidgetHostView) FolderInfo(com.android.launcher3.model.data.FolderInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) AppInfo(com.android.launcher3.model.data.AppInfo)

Example 67 with Touch

use of com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch in project android_packages_apps_Launcher3 by ArrowOS.

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);
    }
}
Also used : ItemInfo(com.android.launcher3.model.data.ItemInfo) Intent(android.content.Intent) ItemInfoWithIcon(com.android.launcher3.model.data.ItemInfoWithIcon)

Example 68 with Touch

use of com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch in project android_packages_apps_Launcher3 by ArrowOS.

the class TaskbarDragController method startSystemDrag.

private void startSystemDrag(BubbleTextView btv) {
    View.DragShadowBuilder shadowBuilder = new View.DragShadowBuilder(btv) {

        @Override
        public void onProvideShadowMetrics(Point shadowSize, Point shadowTouchPoint) {
            shadowSize.set(mDragIconSize, mDragIconSize);
            // The registration point was taken before the icon scaled to mDragIconSize, so
            // offset the registration to where the touch is on the new size.
            int offsetX = (mDragIconSize - mDragObject.dragView.getDragRegionWidth()) / 2;
            int offsetY = (mDragIconSize - mDragObject.dragView.getDragRegionHeight()) / 2;
            shadowTouchPoint.set(mRegistrationX + offsetX, mRegistrationY + offsetY);
        }

        @Override
        public void onDrawShadow(Canvas canvas) {
            canvas.save();
            float scale = mDragObject.dragView.getScaleX();
            canvas.scale(scale, scale);
            mDragObject.dragView.draw(canvas);
            canvas.restore();
        }
    };
    Object tag = btv.getTag();
    ClipDescription clipDescription = null;
    Intent intent = null;
    if (tag instanceof WorkspaceItemInfo) {
        WorkspaceItemInfo item = (WorkspaceItemInfo) tag;
        LauncherApps launcherApps = mActivity.getSystemService(LauncherApps.class);
        clipDescription = new ClipDescription(item.title, new String[] { item.itemType == LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT ? ClipDescriptionCompat.MIMETYPE_APPLICATION_SHORTCUT : ClipDescriptionCompat.MIMETYPE_APPLICATION_ACTIVITY });
        intent = new Intent();
        if (item.itemType == LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT) {
            intent.putExtra(Intent.EXTRA_PACKAGE_NAME, item.getIntent().getPackage());
            intent.putExtra(Intent.EXTRA_SHORTCUT_ID, item.getDeepShortcutId());
        } else {
            intent.putExtra(ClipDescriptionCompat.EXTRA_PENDING_INTENT, LauncherAppsCompat.getMainActivityLaunchIntent(launcherApps, item.getIntent().getComponent(), null, item.user));
        }
        intent.putExtra(Intent.EXTRA_USER, item.user);
    } else if (tag instanceof Task) {
        Task task = (Task) tag;
        clipDescription = new ClipDescription(task.titleDescription, new String[] { ClipDescriptionCompat.MIMETYPE_APPLICATION_TASK });
        intent = new Intent();
        intent.putExtra(ClipDescriptionCompat.EXTRA_TASK_ID, task.key.id);
        intent.putExtra(Intent.EXTRA_USER, UserHandle.of(task.key.userId));
    }
    if (clipDescription != null && intent != null) {
        // Need to share the same InstanceId between launcher3 and WM Shell (internal).
        InstanceId internalInstanceId = new InstanceIdSequence(com.android.launcher3.logging.InstanceId.INSTANCE_ID_MAX).newInstanceId();
        com.android.launcher3.logging.InstanceId launcherInstanceId = new com.android.launcher3.logging.InstanceId(internalInstanceId.getId());
        intent.putExtra(ClipDescription.EXTRA_LOGGING_INSTANCE_ID, internalInstanceId);
        ClipData clipData = new ClipData(clipDescription, new ClipData.Item(intent));
        if (btv.startDragAndDrop(clipData, shadowBuilder, null, /* localState */
        View.DRAG_FLAG_GLOBAL | View.DRAG_FLAG_OPAQUE)) {
            onSystemDragStarted();
            mActivity.getStatsLogManager().logger().withItemInfo(mDragObject.dragInfo).withInstanceId(launcherInstanceId).log(StatsLogManager.LauncherEvent.LAUNCHER_ITEM_DRAG_STARTED);
        }
    }
}
Also used : Task(com.android.systemui.shared.recents.model.Task) InstanceId(com.android.internal.logging.InstanceId) Canvas(android.graphics.Canvas) Intent(android.content.Intent) LauncherApps(android.content.pm.LauncherApps) Point(android.graphics.Point) DraggableView(com.android.launcher3.dragndrop.DraggableView) BubbleTextView(com.android.launcher3.BubbleTextView) View(android.view.View) AbstractFloatingView(com.android.launcher3.AbstractFloatingView) DragView(com.android.launcher3.dragndrop.DragView) Point(android.graphics.Point) InstanceIdSequence(com.android.internal.logging.InstanceIdSequence) ClipData(android.content.ClipData) ClipDescription(android.content.ClipDescription) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Example 69 with Touch

use of com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch in project android_packages_apps_Launcher3 by ProtonAOSP.

the class TaskbarDragController method startSystemDrag.

private void startSystemDrag(BubbleTextView btv) {
    View.DragShadowBuilder shadowBuilder = new View.DragShadowBuilder(btv) {

        @Override
        public void onProvideShadowMetrics(Point shadowSize, Point shadowTouchPoint) {
            shadowSize.set(mDragIconSize, mDragIconSize);
            // The registration point was taken before the icon scaled to mDragIconSize, so
            // offset the registration to where the touch is on the new size.
            int offsetX = (mDragIconSize - mDragObject.dragView.getDragRegionWidth()) / 2;
            int offsetY = (mDragIconSize - mDragObject.dragView.getDragRegionHeight()) / 2;
            shadowTouchPoint.set(mRegistrationX + offsetX, mRegistrationY + offsetY);
        }

        @Override
        public void onDrawShadow(Canvas canvas) {
            canvas.save();
            float scale = mDragObject.dragView.getScaleX();
            canvas.scale(scale, scale);
            mDragObject.dragView.draw(canvas);
            canvas.restore();
        }
    };
    Object tag = btv.getTag();
    ClipDescription clipDescription = null;
    Intent intent = null;
    if (tag instanceof WorkspaceItemInfo) {
        WorkspaceItemInfo item = (WorkspaceItemInfo) tag;
        LauncherApps launcherApps = mActivity.getSystemService(LauncherApps.class);
        clipDescription = new ClipDescription(item.title, new String[] { item.itemType == LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT ? ClipDescriptionCompat.MIMETYPE_APPLICATION_SHORTCUT : ClipDescriptionCompat.MIMETYPE_APPLICATION_ACTIVITY });
        intent = new Intent();
        if (item.itemType == LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT) {
            intent.putExtra(Intent.EXTRA_PACKAGE_NAME, item.getIntent().getPackage());
            intent.putExtra(Intent.EXTRA_SHORTCUT_ID, item.getDeepShortcutId());
        } else {
            intent.putExtra(ClipDescriptionCompat.EXTRA_PENDING_INTENT, LauncherAppsCompat.getMainActivityLaunchIntent(launcherApps, item.getIntent().getComponent(), null, item.user));
        }
        intent.putExtra(Intent.EXTRA_USER, item.user);
    } else if (tag instanceof Task) {
        Task task = (Task) tag;
        clipDescription = new ClipDescription(task.titleDescription, new String[] { ClipDescriptionCompat.MIMETYPE_APPLICATION_TASK });
        intent = new Intent();
        intent.putExtra(ClipDescriptionCompat.EXTRA_TASK_ID, task.key.id);
        intent.putExtra(Intent.EXTRA_USER, UserHandle.of(task.key.userId));
    }
    if (clipDescription != null && intent != null) {
        // Need to share the same InstanceId between launcher3 and WM Shell (internal).
        InstanceId internalInstanceId = new InstanceIdSequence(com.android.launcher3.logging.InstanceId.INSTANCE_ID_MAX).newInstanceId();
        com.android.launcher3.logging.InstanceId launcherInstanceId = new com.android.launcher3.logging.InstanceId(internalInstanceId.getId());
        intent.putExtra(ClipDescription.EXTRA_LOGGING_INSTANCE_ID, internalInstanceId);
        ClipData clipData = new ClipData(clipDescription, new ClipData.Item(intent));
        if (btv.startDragAndDrop(clipData, shadowBuilder, null, /* localState */
        View.DRAG_FLAG_GLOBAL | View.DRAG_FLAG_OPAQUE)) {
            onSystemDragStarted();
            mActivity.getStatsLogManager().logger().withItemInfo(mDragObject.dragInfo).withInstanceId(launcherInstanceId).log(StatsLogManager.LauncherEvent.LAUNCHER_ITEM_DRAG_STARTED);
        }
    }
}
Also used : Task(com.android.systemui.shared.recents.model.Task) InstanceId(com.android.internal.logging.InstanceId) Canvas(android.graphics.Canvas) Intent(android.content.Intent) LauncherApps(android.content.pm.LauncherApps) Point(android.graphics.Point) DraggableView(com.android.launcher3.dragndrop.DraggableView) BubbleTextView(com.android.launcher3.BubbleTextView) View(android.view.View) AbstractFloatingView(com.android.launcher3.AbstractFloatingView) DragView(com.android.launcher3.dragndrop.DragView) Point(android.graphics.Point) InstanceIdSequence(com.android.internal.logging.InstanceIdSequence) ClipData(android.content.ClipData) ClipDescription(android.content.ClipDescription) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Example 70 with Touch

use of com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch in project android_packages_apps_Launcher3 by ProtonAOSP.

the class Workspace method beginDragShared.

/**
 * Core functionality for beginning a drag operation for an item that will be dropped within
 * the workspace
 */
public DragView beginDragShared(View child, DraggableView draggableView, DragSource source, ItemInfo dragObject, DragPreviewProvider previewProvider, DragOptions dragOptions) {
    float iconScale = 1f;
    if (child instanceof BubbleTextView) {
        Drawable icon = ((BubbleTextView) child).getIcon();
        if (icon instanceof FastBitmapDrawable) {
            iconScale = ((FastBitmapDrawable) icon).getAnimatedScale();
        }
    }
    // Clear the pressed state if necessary
    child.clearFocus();
    child.setPressed(false);
    if (child instanceof BubbleTextView) {
        BubbleTextView icon = (BubbleTextView) child;
        icon.clearPressedBackground();
    }
    if (draggableView == null && child instanceof DraggableView) {
        draggableView = (DraggableView) child;
    }
    final View contentView = previewProvider.getContentView();
    final float scale;
    // The draggable drawable follows the touch point around on the screen
    final Drawable drawable;
    if (contentView == null) {
        drawable = previewProvider.createDrawable();
        scale = previewProvider.getScaleAndPosition(drawable, mTempXY);
    } else {
        drawable = null;
        scale = previewProvider.getScaleAndPosition(contentView, mTempXY);
    }
    int halfPadding = previewProvider.previewPadding / 2;
    int dragLayerX = mTempXY[0];
    int dragLayerY = mTempXY[1];
    Point dragVisualizeOffset = null;
    Rect dragRect = new Rect();
    if (draggableView != null) {
        draggableView.getSourceVisualDragBounds(dragRect);
        dragLayerY += dragRect.top;
        dragVisualizeOffset = new Point(-halfPadding, halfPadding);
    }
    if (child.getParent() instanceof ShortcutAndWidgetContainer) {
        mDragSourceInternal = (ShortcutAndWidgetContainer) child.getParent();
    }
    if (child instanceof BubbleTextView && !dragOptions.isAccessibleDrag) {
        PopupContainerWithArrow<Launcher> popupContainer = PopupContainerWithArrow.showForIcon((BubbleTextView) child);
        if (popupContainer != null) {
            dragOptions.preDragCondition = popupContainer.createPreDragCondition();
        }
    }
    final DragView dv;
    if (contentView instanceof View) {
        if (contentView instanceof LauncherAppWidgetHostView) {
            mDragController.addDragListener(new AppWidgetHostViewDragListener(mLauncher));
        }
        dv = mDragController.startDrag(contentView, draggableView, dragLayerX, dragLayerY, source, dragObject, dragVisualizeOffset, dragRect, scale * iconScale, scale, dragOptions);
    } else {
        dv = mDragController.startDrag(drawable, draggableView, dragLayerX, dragLayerY, source, dragObject, dragVisualizeOffset, dragRect, scale * iconScale, scale, dragOptions);
    }
    return dv;
}
Also used : Rect(android.graphics.Rect) Drawable(android.graphics.drawable.Drawable) FastBitmapDrawable(com.android.launcher3.icons.FastBitmapDrawable) DragView(com.android.launcher3.dragndrop.DragView) Point(android.graphics.Point) DraggableView(com.android.launcher3.dragndrop.DraggableView) DraggableView(com.android.launcher3.dragndrop.DraggableView) LauncherAppWidgetHostView(com.android.launcher3.widget.LauncherAppWidgetHostView) AppWidgetHostView(android.appwidget.AppWidgetHostView) View(android.view.View) PendingAppWidgetHostView(com.android.launcher3.widget.PendingAppWidgetHostView) DragView(com.android.launcher3.dragndrop.DragView) SuppressLint(android.annotation.SuppressLint) Point(android.graphics.Point) FastBitmapDrawable(com.android.launcher3.icons.FastBitmapDrawable) AppWidgetHostViewDragListener(com.android.launcher3.widget.dragndrop.AppWidgetHostViewDragListener) LauncherAppWidgetHostView(com.android.launcher3.widget.LauncherAppWidgetHostView)

Aggregations

Point (android.graphics.Point)32 Rect (android.graphics.Rect)28 Intent (android.content.Intent)20 View (android.view.View)17 DragLayer (com.android.launcher3.dragndrop.DragLayer)14 DropTarget (com.android.launcher3.DropTarget)13 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)13 ClipData (android.content.ClipData)12 ClipDescription (android.content.ClipDescription)12 Canvas (android.graphics.Canvas)12 DragView (com.android.launcher3.dragndrop.DragView)12 PendingAppWidgetHostView (com.android.launcher3.widget.PendingAppWidgetHostView)12 DraggableView (com.android.launcher3.dragndrop.DraggableView)10 DeviceProfile (com.android.launcher3.DeviceProfile)8 FolderIcon (com.android.launcher3.folder.FolderIcon)8 AnimatorSet (android.animation.AnimatorSet)7 ObjectAnimator (android.animation.ObjectAnimator)7 SuppressLint (android.annotation.SuppressLint)7 Drawable (android.graphics.drawable.Drawable)7 DragShadowBuilder (android.view.View.DragShadowBuilder)7