Search in sources :

Example 1 with InstanceId

use of com.android.internal.logging.InstanceId in project android_packages_apps_Launcher3 by AOSPA.

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 2 with InstanceId

use of com.android.internal.logging.InstanceId in project android_packages_apps_404Launcher by P-404.

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 3 with InstanceId

use of com.android.internal.logging.InstanceId 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 4 with InstanceId

use of com.android.internal.logging.InstanceId 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)

Aggregations

ClipData (android.content.ClipData)4 ClipDescription (android.content.ClipDescription)4 Intent (android.content.Intent)4 LauncherApps (android.content.pm.LauncherApps)4 Canvas (android.graphics.Canvas)4 Point (android.graphics.Point)4 View (android.view.View)4 InstanceId (com.android.internal.logging.InstanceId)4 InstanceIdSequence (com.android.internal.logging.InstanceIdSequence)4 AbstractFloatingView (com.android.launcher3.AbstractFloatingView)4 BubbleTextView (com.android.launcher3.BubbleTextView)4 DragView (com.android.launcher3.dragndrop.DragView)4 DraggableView (com.android.launcher3.dragndrop.DraggableView)4 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)4 Task (com.android.systemui.shared.recents.model.Task)4