Search in sources :

Example 76 with ItemInfo

use of com.android.launcher3.ItemInfo 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 77 with ItemInfo

use of com.android.launcher3.ItemInfo in project android_packages_apps_Launcher3 by AOSPA.

the class TaskbarDragController 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) {
    mOptions = options;
    mRegistrationX = mMotionDown.x - dragLayerX;
    mRegistrationY = 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;
    mDragObject.deferDragViewCleanupPostAnimation = false;
    mIsInPreDrag = mOptions.preDragCondition != null && !mOptions.preDragCondition.shouldStartDrag(0);
    float scalePx = mDragIconSize - dragRegion.width();
    final DragView dragView = mDragObject.dragView = new TaskbarDragView(mActivity, drawable, mRegistrationX, mRegistrationY, initialDragViewScale, dragViewScaleOnDrop, scalePx);
    dragView.setItemInfo(dragInfo);
    mDragObject.dragComplete = false;
    mDragObject.xOffset = mMotionDown.x - (dragLayerX + dragRegionLeft);
    mDragObject.yOffset = mMotionDown.y - (dragLayerY + dragRegionTop);
    mDragDriver = DragDriver.create(this, mOptions, /* secondaryEventConsumer = */
    ev -> {
    });
    if (!mOptions.isAccessibleDrag) {
        mDragObject.stateAnnouncer = DragViewStateAnnouncer.createFor(dragView);
    }
    mDragObject.dragSource = source;
    mDragObject.dragInfo = dragInfo;
    mDragObject.originalDragInfo = mDragObject.dragInfo.makeShallowCopy();
    if (dragRegion != null) {
        dragView.setDragRegion(new Rect(dragRegion));
    }
    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);
    return dragView;
}
Also used : Rect(android.graphics.Rect) InstanceIdSequence(com.android.internal.logging.InstanceIdSequence) Task(com.android.systemui.shared.recents.model.Task) LauncherAppsCompat(com.android.systemui.shared.system.LauncherAppsCompat) ItemInfo(com.android.launcher3.model.data.ItemInfo) Intent(android.content.Intent) LauncherSettings(com.android.launcher3.LauncherSettings) Drawable(android.graphics.drawable.Drawable) DraggableView(com.android.launcher3.dragndrop.DraggableView) BubbleTextView(com.android.launcher3.BubbleTextView) ClipData(android.content.ClipData) PopupContainerWithArrow(com.android.launcher3.popup.PopupContainerWithArrow) DragDriver(com.android.launcher3.dragndrop.DragDriver) MotionEvent(android.view.MotionEvent) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) UserHandle(android.os.UserHandle) DragViewStateAnnouncer(com.android.launcher3.accessibility.DragViewStateAnnouncer) View(android.view.View) Canvas(android.graphics.Canvas) DragSource(com.android.launcher3.DragSource) DragEvent(android.view.DragEvent) DropTarget(com.android.launcher3.DropTarget) DragController(com.android.launcher3.dragndrop.DragController) Point(android.graphics.Point) FeatureFlags(com.android.launcher3.config.FeatureFlags) InstanceId(com.android.internal.logging.InstanceId) ClipDescriptionCompat(com.android.systemui.shared.system.ClipDescriptionCompat) LauncherApps(android.content.pm.LauncherApps) DragOptions(com.android.launcher3.dragndrop.DragOptions) Nullable(androidx.annotation.Nullable) StatsLogManager(com.android.launcher3.logging.StatsLogManager) R(com.android.launcher3.R) ClipDescription(android.content.ClipDescription) AbstractFloatingView(com.android.launcher3.AbstractFloatingView) DragPreviewProvider(com.android.launcher3.graphics.DragPreviewProvider) DragView(com.android.launcher3.dragndrop.DragView) Resources(android.content.res.Resources) Rect(android.graphics.Rect) DragView(com.android.launcher3.dragndrop.DragView) DropTarget(com.android.launcher3.DropTarget) Point(android.graphics.Point)

Example 78 with ItemInfo

use of com.android.launcher3.ItemInfo in project android_packages_apps_Launcher3 by AOSPA.

the class TaskbarModelCallbacks method handleItemsAdded.

private boolean handleItemsAdded(List<ItemInfo> items) {
    boolean modified = false;
    for (ItemInfo item : items) {
        if (item.container == Favorites.CONTAINER_HOTSEAT) {
            mHotseatItems.put(item.screenId, item);
            modified = true;
        }
    }
    return modified;
}
Also used : ItemInfo(com.android.launcher3.model.data.ItemInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Example 79 with ItemInfo

use of com.android.launcher3.ItemInfo in project android_packages_apps_Launcher3 by AOSPA.

the class Workspace method onDragOver.

public void onDragOver(DragObject d) {
    // Skip drag over events while we are dragging over side pages
    if (!transitionStateShouldAllowDrop())
        return;
    ItemInfo item = d.dragInfo;
    if (item == null) {
        if (FeatureFlags.IS_STUDIO_BUILD) {
            throw new NullPointerException("DragObject has null info");
        }
        return;
    }
    // Ensure that we have proper spans for the item that we are dropping
    if (item.spanX < 0 || item.spanY < 0)
        throw new RuntimeException("Improper spans found");
    mDragViewVisualCenter = d.getVisualCenter(mDragViewVisualCenter);
    final View child = (mDragInfo == null) ? null : mDragInfo.cell;
    if (setDropLayoutForDragObject(d, mDragViewVisualCenter[0], mDragViewVisualCenter[1])) {
        if (mLauncher.isHotseatLayout(mDragTargetLayout)) {
            mSpringLoadedDragController.cancel();
        } else {
            mSpringLoadedDragController.setAlarm(mDragTargetLayout);
        }
    }
    // Handle the drag over
    if (mDragTargetLayout != null) {
        // We want the point to be mapped to the dragTarget.
        mapPointFromDropLayout(mDragTargetLayout, mDragViewVisualCenter);
        int minSpanX = item.spanX;
        int minSpanY = item.spanY;
        if (item.minSpanX > 0 && item.minSpanY > 0) {
            minSpanX = item.minSpanX;
            minSpanY = item.minSpanY;
        }
        mTargetCell = findNearestArea((int) mDragViewVisualCenter[0], (int) mDragViewVisualCenter[1], minSpanX, minSpanY, mDragTargetLayout, mTargetCell);
        int reorderX = mTargetCell[0];
        int reorderY = mTargetCell[1];
        setCurrentDropOverCell(mTargetCell[0], mTargetCell[1]);
        float targetCellDistance = mDragTargetLayout.getDistanceFromWorkspaceCellVisualCenter(mDragViewVisualCenter[0], mDragViewVisualCenter[1], mTargetCell);
        manageFolderFeedback(targetCellDistance, d);
        boolean nearestDropOccupied = mDragTargetLayout.isNearestDropLocationOccupied((int) mDragViewVisualCenter[0], (int) mDragViewVisualCenter[1], item.spanX, item.spanY, child, mTargetCell);
        if (!nearestDropOccupied) {
            mDragTargetLayout.visualizeDropLocation(mTargetCell[0], mTargetCell[1], item.spanX, item.spanY, d);
        } else if ((mDragMode == DRAG_MODE_NONE || mDragMode == DRAG_MODE_REORDER) && !mReorderAlarm.alarmPending() && (mLastReorderX != reorderX || mLastReorderY != reorderY) && targetCellDistance < mDragTargetLayout.getReorderRadius(mTargetCell)) {
            int[] resultSpan = new int[2];
            mDragTargetLayout.performReorder((int) mDragViewVisualCenter[0], (int) mDragViewVisualCenter[1], minSpanX, minSpanY, item.spanX, item.spanY, child, mTargetCell, resultSpan, CellLayout.MODE_SHOW_REORDER_HINT);
            // Otherwise, if we aren't adding to or creating a folder and there's no pending
            // reorder, then we schedule a reorder
            ReorderAlarmListener listener = new ReorderAlarmListener(mDragViewVisualCenter, minSpanX, minSpanY, item.spanX, item.spanY, d, child);
            mReorderAlarm.setOnAlarmListener(listener);
            mReorderAlarm.setAlarm(REORDER_TIMEOUT);
        }
        if (mDragMode == DRAG_MODE_CREATE_FOLDER || mDragMode == DRAG_MODE_ADD_TO_FOLDER || !nearestDropOccupied) {
            if (mDragTargetLayout != null) {
                mDragTargetLayout.revertTempState();
            }
        }
    }
}
Also used : WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) ItemInfo(com.android.launcher3.model.data.ItemInfo) SearchActionItemInfo(com.android.launcher3.model.data.SearchActionItemInfo) 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)

Example 80 with ItemInfo

use of com.android.launcher3.ItemInfo in project android_packages_apps_Launcher3 by AOSPA.

the class Workspace method animateWidgetDrop.

public void animateWidgetDrop(ItemInfo info, CellLayout cellLayout, final DragView dragView, final Runnable onCompleteRunnable, int animationType, final View finalView, boolean external) {
    int[] finalPos = new int[2];
    float[] scaleXY = new float[2];
    boolean scalePreview = !(info instanceof PendingAddShortcutInfo);
    getFinalPositionForDropAnimation(finalPos, scaleXY, dragView, cellLayout, info, mTargetCell, scalePreview);
    Resources res = mLauncher.getResources();
    final int duration = res.getInteger(R.integer.config_dropAnimMaxDuration) - 200;
    boolean isWidget = info.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET || info.itemType == LauncherSettings.Favorites.ITEM_TYPE_CUSTOM_APPWIDGET;
    if ((animationType == ANIMATE_INTO_POSITION_AND_RESIZE || external) && finalView != null && dragView.getContentView() != finalView) {
        Drawable crossFadeDrawable = createWidgetDrawable(info, finalView);
        dragView.crossFadeContent(crossFadeDrawable, (int) (duration * 0.8f));
    } else if (isWidget && external) {
        scaleXY[0] = scaleXY[1] = Math.min(scaleXY[0], scaleXY[1]);
    }
    DragLayer dragLayer = mLauncher.getDragLayer();
    if (animationType == CANCEL_TWO_STAGE_WIDGET_DROP_ANIMATION) {
        mLauncher.getDragLayer().animateViewIntoPosition(dragView, finalPos, 0f, 0.1f, 0.1f, DragLayer.ANIMATION_END_DISAPPEAR, onCompleteRunnable, duration);
    } else {
        int endStyle;
        if (animationType == ANIMATE_INTO_POSITION_AND_REMAIN) {
            endStyle = DragLayer.ANIMATION_END_REMAIN_VISIBLE;
        } else {
            endStyle = DragLayer.ANIMATION_END_DISAPPEAR;
        }
        Runnable onComplete = new Runnable() {

            @Override
            public void run() {
                if (finalView != null) {
                    finalView.setVisibility(VISIBLE);
                }
                if (onCompleteRunnable != null) {
                    onCompleteRunnable.run();
                }
            }
        };
        dragLayer.animateViewIntoPosition(dragView, finalPos[0], finalPos[1], 1, scaleXY[0], scaleXY[1], onComplete, endStyle, duration, this);
    }
}
Also used : DragLayer(com.android.launcher3.dragndrop.DragLayer) PendingAddShortcutInfo(com.android.launcher3.widget.PendingAddShortcutInfo) Drawable(android.graphics.drawable.Drawable) FastBitmapDrawable(com.android.launcher3.icons.FastBitmapDrawable) Resources(android.content.res.Resources) SuppressLint(android.annotation.SuppressLint) Point(android.graphics.Point)

Aggregations

ItemInfo (com.android.launcher3.model.data.ItemInfo)457 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)373 View (android.view.View)199 ArrayList (java.util.ArrayList)169 Point (android.graphics.Point)159 FolderInfo (com.android.launcher3.model.data.FolderInfo)113 SuppressLint (android.annotation.SuppressLint)110 LauncherAppWidgetInfo (com.android.launcher3.model.data.LauncherAppWidgetInfo)100 DragView (com.android.launcher3.dragndrop.DragView)98 LauncherAppWidgetHostView (com.android.launcher3.widget.LauncherAppWidgetHostView)98 AppWidgetHostView (android.appwidget.AppWidgetHostView)94 PendingAppWidgetHostView (com.android.launcher3.widget.PendingAppWidgetHostView)94 BubbleTextView (com.android.launcher3.BubbleTextView)85 Context (android.content.Context)82 List (java.util.List)80 AppInfo (com.android.launcher3.model.data.AppInfo)79 Intent (android.content.Intent)78 Rect (android.graphics.Rect)76 DraggableView (com.android.launcher3.dragndrop.DraggableView)73 ComponentName (android.content.ComponentName)72