Search in sources :

Example 41 with WorkspaceItemInfo

use of com.android.launcher3.model.data.WorkspaceItemInfo in project android_packages_apps_Launcher3 by AOSPA.

the class HotseatEduDialog method populatePreview.

private void populatePreview(List<WorkspaceItemInfo> predictions) {
    for (int i = 0; i < mActivityContext.getDeviceProfile().numShownHotseatIcons; i++) {
        WorkspaceItemInfo info = predictions.get(i);
        PredictedAppIcon icon = PredictedAppIcon.createIcon(mSampleHotseat, info);
        icon.setEnabled(false);
        icon.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
        icon.verifyHighRes();
        CellLayout.LayoutParams lp = new CellLayout.LayoutParams(i, 0, 1, 1);
        mSampleHotseat.addViewToCellLayout(icon, i, info.getViewId(), lp, true);
    }
}
Also used : CellLayout(com.android.launcher3.CellLayout) PredictedAppIcon(com.android.launcher3.uioverrides.PredictedAppIcon) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Example 42 with WorkspaceItemInfo

use of com.android.launcher3.model.data.WorkspaceItemInfo in project android_packages_apps_Launcher3 by AOSPA.

the class HotseatPredictionController method removePredictedApps.

private void removePredictedApps(List<PredictedAppIcon.PredictedIconOutlineDrawing> outlines, DropTarget.DragObject dragObject) {
    if (mIconRemoveAnimators != null) {
        mIconRemoveAnimators.end();
    }
    mIconRemoveAnimators = new AnimatorSet();
    removeOutlineDrawings();
    for (PredictedAppIcon icon : getPredictedIcons()) {
        if (!icon.isEnabled()) {
            continue;
        }
        if (dragObject.dragSource == this && icon.equals(dragObject.originalView)) {
            removeIconWithoutNotify(icon);
            continue;
        }
        int rank = ((WorkspaceItemInfo) icon.getTag()).rank;
        outlines.add(new PredictedAppIcon.PredictedIconOutlineDrawing(mHotseat.getCellXFromOrder(rank), mHotseat.getCellYFromOrder(rank), icon));
        icon.setEnabled(false);
        ObjectAnimator animator = ObjectAnimator.ofFloat(icon, SCALE_PROPERTY, 0);
        animator.addListener(new AnimationSuccessListener() {

            @Override
            public void onAnimationSuccess(Animator animator) {
                if (icon.getParent() != null) {
                    removeIconWithoutNotify(icon);
                }
            }
        });
        mIconRemoveAnimators.play(animator);
    }
    mIconRemoveAnimators.start();
}
Also used : Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) ObjectAnimator(android.animation.ObjectAnimator) PredictedAppIcon(com.android.launcher3.uioverrides.PredictedAppIcon) AnimatorSet(android.animation.AnimatorSet) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) AnimationSuccessListener(com.android.launcher3.anim.AnimationSuccessListener)

Example 43 with WorkspaceItemInfo

use of com.android.launcher3.model.data.WorkspaceItemInfo in project android_packages_apps_Launcher3 by AOSPA.

the class LauncherTaskbarUIController method onTaskbarIconLaunched.

@Override
public void onTaskbarIconLaunched(WorkspaceItemInfo item) {
    InstanceId instanceId = new InstanceIdSequence().newInstanceId();
    mLauncher.logAppLaunch(mControllers.taskbarActivityContext.getStatsLogManager(), item, instanceId);
}
Also used : InstanceId(com.android.launcher3.logging.InstanceId) InstanceIdSequence(com.android.launcher3.logging.InstanceIdSequence)

Example 44 with WorkspaceItemInfo

use of com.android.launcher3.model.data.WorkspaceItemInfo in project android_packages_apps_Launcher3 by AOSPA.

the class TaskbarActivityContext method onTaskbarIconClicked.

protected void onTaskbarIconClicked(View view) {
    Object tag = view.getTag();
    if (tag instanceof Task) {
        Task task = (Task) tag;
        ActivityManagerWrapper.getInstance().startActivityFromRecents(task.key, ActivityOptions.makeBasic());
    } else if (tag instanceof FolderInfo) {
        FolderIcon folderIcon = (FolderIcon) view;
        Folder folder = folderIcon.getFolder();
        setTaskbarWindowFullscreen(true);
        getDragLayer().post(() -> {
            folder.animateOpen();
            getStatsLogManager().logger().withItemInfo(folder.mInfo).log(LAUNCHER_FOLDER_OPEN);
            folder.iterateOverItems((itemInfo, itemView) -> {
                mControllers.taskbarViewController.setClickAndLongClickListenersForIcon(itemView);
                // To play haptic when dragging, like other Taskbar items do.
                itemView.setHapticFeedbackEnabled(true);
                return false;
            });
        });
    } else if (tag instanceof WorkspaceItemInfo) {
        WorkspaceItemInfo info = (WorkspaceItemInfo) tag;
        if (info.isDisabled()) {
            ItemClickHandler.handleDisabledItemClicked(info, this);
        } else {
            Intent intent = new Intent(info.getIntent()).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            try {
                if (mIsSafeModeEnabled && !PackageManagerHelper.isSystemApp(this, intent)) {
                    Toast.makeText(this, R.string.safemode_shortcut_error, Toast.LENGTH_SHORT).show();
                } else if (info.isPromise()) {
                    intent = new PackageManagerHelper(this).getMarketIntent(info.getTargetPackage()).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    startActivity(intent);
                } else if (info.itemType == Favorites.ITEM_TYPE_DEEP_SHORTCUT) {
                    String id = info.getDeepShortcutId();
                    String packageName = intent.getPackage();
                    getSystemService(LauncherApps.class).startShortcut(packageName, id, null, null, info.user);
                } else if (info.user.equals(Process.myUserHandle())) {
                    startActivity(intent);
                } else {
                    getSystemService(LauncherApps.class).startMainActivity(intent.getComponent(), info.user, intent.getSourceBounds(), null);
                }
                mControllers.uiController.onTaskbarIconLaunched(info);
            } catch (NullPointerException | ActivityNotFoundException | SecurityException e) {
                Toast.makeText(this, R.string.activity_not_found, Toast.LENGTH_SHORT).show();
                Log.e(TAG, "Unable to launch. tag=" + info + " intent=" + intent, e);
            }
        }
    } else {
        Log.e(TAG, "Unknown type clicked: " + tag);
    }
    AbstractFloatingView.closeAllOpenViews(this);
}
Also used : Rect(android.graphics.Rect) Task(com.android.systemui.shared.recents.model.Task) Config(android.content.pm.ActivityInfo.Config) NonNull(androidx.annotation.NonNull) WindowManager(android.view.WindowManager) FrameLayout(android.widget.FrameLayout) Process(android.os.Process) ITYPE_BOTTOM_TAPPABLE_ELEMENT(com.android.systemui.shared.system.WindowManagerWrapper.ITYPE_BOTTOM_TAPPABLE_ELEMENT) ActivityOptions(android.app.ActivityOptions) ActivityManagerWrapper(com.android.systemui.shared.system.ActivityManagerWrapper) WindowManagerWrapper(com.android.systemui.shared.system.WindowManagerWrapper) LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS(android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS) LauncherAtom(com.android.launcher3.logger.LauncherAtom) ContextThemeWrapper(android.view.ContextThemeWrapper) FolderInfo(com.android.launcher3.model.data.FolderInfo) Display(android.view.Display) View(android.view.View) RotationButtonController(com.android.systemui.shared.rotation.RotationButtonController) Log(android.util.Log) SysUINavigationMode(com.android.quickstep.SysUINavigationMode) Favorites(com.android.launcher3.LauncherSettings.Favorites) Mode(com.android.quickstep.SysUINavigationMode.Mode) TYPE_NAVIGATION_BAR_PANEL(android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR_PANEL) LauncherApps(android.content.pm.LauncherApps) DeviceProfile(com.android.launcher3.DeviceProfile) Nullable(androidx.annotation.Nullable) ActivityNotFoundException(android.content.ActivityNotFoundException) ITYPE_EXTRA_NAVIGATION_BAR(com.android.systemui.shared.system.WindowManagerWrapper.ITYPE_EXTRA_NAVIGATION_BAR) LAUNCHER_FOLDER_OPEN(com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_FOLDER_OPEN) Themes(com.android.launcher3.util.Themes) PackageManagerHelper(com.android.launcher3.util.PackageManagerHelper) Folder(com.android.launcher3.folder.Folder) Context(android.content.Context) SettingsCache(com.android.launcher3.util.SettingsCache) Insets(android.graphics.Insets) FolderIcon(com.android.launcher3.folder.FolderIcon) ScopedUnfoldTransitionProgressProvider(com.android.systemui.unfold.util.ScopedUnfoldTransitionProgressProvider) Intent(android.content.Intent) PixelFormat(android.graphics.PixelFormat) SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED(com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED) ViewCache(com.android.launcher3.util.ViewCache) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) Toast(android.widget.Toast) AnimatorSet(android.animation.AnimatorSet) Settings(android.provider.Settings) SYSUI_STATE_QUICK_SETTINGS_EXPANDED(com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_QUICK_SETTINGS_EXPANDED) ActivityContext(com.android.launcher3.views.ActivityContext) LayoutInflater(android.view.LayoutInflater) MATCH_PARENT(android.view.ViewGroup.LayoutParams.MATCH_PARENT) ItemClickHandler(com.android.launcher3.touch.ItemClickHandler) SystemProperties(android.os.SystemProperties) Gravity(android.view.Gravity) R(com.android.launcher3.R) RoundedCorner(android.view.RoundedCorner) AbstractFloatingView(com.android.launcher3.AbstractFloatingView) TraceHelper(com.android.launcher3.util.TraceHelper) Resources(android.content.res.Resources) Task(com.android.systemui.shared.recents.model.Task) Intent(android.content.Intent) LauncherApps(android.content.pm.LauncherApps) Folder(com.android.launcher3.folder.Folder) FolderInfo(com.android.launcher3.model.data.FolderInfo) ActivityNotFoundException(android.content.ActivityNotFoundException) FolderIcon(com.android.launcher3.folder.FolderIcon) PackageManagerHelper(com.android.launcher3.util.PackageManagerHelper) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Example 45 with WorkspaceItemInfo

use of com.android.launcher3.model.data.WorkspaceItemInfo 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)

Aggregations

WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)418 View (android.view.View)168 ArrayList (java.util.ArrayList)145 ItemInfo (com.android.launcher3.model.data.ItemInfo)125 Intent (android.content.Intent)119 FolderInfo (com.android.launcher3.model.data.FolderInfo)100 AppInfo (com.android.launcher3.model.data.AppInfo)94 BubbleTextView (com.android.launcher3.BubbleTextView)87 AppWidgetHostView (android.appwidget.AppWidgetHostView)84 SuppressLint (android.annotation.SuppressLint)78 DragView (com.android.launcher3.dragndrop.DragView)78 ComponentName (android.content.ComponentName)76 LauncherAppWidgetInfo (com.android.launcher3.model.data.LauncherAppWidgetInfo)73 PendingAppWidgetHostView (com.android.launcher3.widget.PendingAppWidgetHostView)72 Rect (android.graphics.Rect)68 FolderIcon (com.android.launcher3.folder.FolderIcon)68 Context (android.content.Context)62 HashSet (java.util.HashSet)62 Point (android.graphics.Point)59 LauncherAppWidgetHostView (com.android.launcher3.widget.LauncherAppWidgetHostView)57