Search in sources :

Example 91 with Target

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

the class HotseatEduController method showHotseatArrowTip.

/**
 * Finds a child suitable child in hotseat and shows arrow tip pointing at it.
 *
 * @param usePinned used to determine target view. If true, will use the first matching pinned
 *                  item. Otherwise, will use the first predicted child
 * @param message   String to be shown inside the arrowView
 * @return whether suitable child was found and tip was shown
 */
private boolean showHotseatArrowTip(boolean usePinned, String message) {
    int childCount = mHotseat.getShortcutsAndWidgets().getChildCount();
    boolean isPortrait = !mLauncher.getDeviceProfile().isVerticalBarLayout();
    BubbleTextView tipTargetView = null;
    for (int i = childCount - 1; i > -1; i--) {
        int x = isPortrait ? i : 0;
        int y = isPortrait ? 0 : i;
        View v = mHotseat.getShortcutsAndWidgets().getChildAt(x, y);
        if (v instanceof BubbleTextView && v.getTag() instanceof WorkspaceItemInfo) {
            ItemInfo info = (ItemInfo) v.getTag();
            boolean isPinned = info.container == LauncherSettings.Favorites.CONTAINER_HOTSEAT;
            if (isPinned == usePinned) {
                tipTargetView = (BubbleTextView) v;
                break;
            }
        }
    }
    if (tipTargetView == null) {
        Log.e(TAG, "Unable to find suitable view for ArrowTip");
        return false;
    }
    Rect bounds = Utilities.getViewBounds(tipTargetView);
    new ArrowTipView(mLauncher).show(message, Gravity.END, bounds.centerX(), bounds.top);
    return true;
}
Also used : Rect(android.graphics.Rect) ItemInfo(com.android.launcher3.model.data.ItemInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) BubbleTextView(com.android.launcher3.BubbleTextView) BubbleTextView(com.android.launcher3.BubbleTextView) View(android.view.View) ArrowTipView(com.android.launcher3.views.ArrowTipView) ArrowTipView(com.android.launcher3.views.ArrowTipView) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Example 92 with Target

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

the class HotseatPredictionModel method convertDataModelToAppTargetBundle.

/**
 * Creates and returns bundle using workspace items
 */
public static Bundle convertDataModelToAppTargetBundle(Context context, BgDataModel dataModel) {
    Bundle bundle = new Bundle();
    ArrayList<AppTargetEvent> events = new ArrayList<>();
    ArrayList<ItemInfo> workspaceItems = dataModel.getAllWorkspaceItems();
    for (ItemInfo item : workspaceItems) {
        AppTarget target = getAppTargetFromItemInfo(context, item);
        if (target != null && !isTrackedForHotseatPrediction(item))
            continue;
        events.add(wrapAppTargetWithItemLocation(target, AppTargetEvent.ACTION_PIN, item));
    }
    ArrayList<AppTarget> currentTargets = new ArrayList<>();
    FixedContainerItems hotseatItems = dataModel.extraItems.get(CONTAINER_HOTSEAT_PREDICTION);
    if (hotseatItems != null) {
        for (ItemInfo itemInfo : hotseatItems.items) {
            AppTarget target = getAppTargetFromItemInfo(context, itemInfo);
            if (target != null)
                currentTargets.add(target);
        }
    }
    bundle.putParcelableArrayList(BUNDLE_KEY_PIN_EVENTS, events);
    bundle.putParcelableArrayList(BUNDLE_KEY_CURRENT_ITEMS, currentTargets);
    return bundle;
}
Also used : AppTarget(android.app.prediction.AppTarget) PredictionHelper.getAppTargetFromItemInfo(com.android.launcher3.model.PredictionHelper.getAppTargetFromItemInfo) ItemInfo(com.android.launcher3.model.data.ItemInfo) Bundle(android.os.Bundle) ArrayList(java.util.ArrayList) FixedContainerItems(com.android.launcher3.model.BgDataModel.FixedContainerItems) AppTargetEvent(android.app.prediction.AppTargetEvent)

Example 93 with Target

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

the class QuickstepModelDelegate method getBundleForWidgetsOnWorkspace.

private Bundle getBundleForWidgetsOnWorkspace(Context context, BgDataModel dataModel) {
    Bundle bundle = new Bundle();
    ArrayList<AppTargetEvent> widgetEvents = dataModel.getAllWorkspaceItems().stream().filter(PredictionHelper::isTrackedForWidgetPrediction).map(item -> {
        AppTarget target = getAppTargetFromItemInfo(context, item);
        if (target == null)
            return null;
        return wrapAppTargetWithItemLocation(target, AppTargetEvent.ACTION_PIN, item);
    }).filter(Objects::nonNull).collect(toCollection(ArrayList::new));
    bundle.putParcelableArrayList(BUNDLE_KEY_ADDED_APP_WIDGETS, widgetEvents);
    return bundle;
}
Also used : AppTarget(android.app.prediction.AppTarget) Bundle(android.os.Bundle) HotseatPredictionModel.convertDataModelToAppTargetBundle(com.android.launcher3.hybridhotseat.HotseatPredictionModel.convertDataModelToAppTargetBundle) AppTargetEvent(android.app.prediction.AppTargetEvent)

Example 94 with Target

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

the class Workspace method addToExistingFolderIfNecessary.

boolean addToExistingFolderIfNecessary(View newView, CellLayout target, int[] targetCell, float distance, DragObject d, boolean external) {
    if (distance > target.getFolderCreationRadius(targetCell))
        return false;
    View dropOverView = target.getChildAt(targetCell[0], targetCell[1]);
    if (!mAddToExistingFolderOnDrop)
        return false;
    mAddToExistingFolderOnDrop = false;
    if (dropOverView instanceof FolderIcon) {
        FolderIcon fi = (FolderIcon) dropOverView;
        if (fi.acceptDrop(d.dragInfo)) {
            mStatsLogManager.logger().withItemInfo(fi.mInfo).withInstanceId(d.logInstanceId).log(LauncherEvent.LAUNCHER_ITEM_DROP_COMPLETED_ON_FOLDER_ICON);
            fi.onDrop(d, false);
            // if the drag started here, we need to remove it from the workspace
            if (!external) {
                getParentCellLayoutForView(mDragInfo.cell).removeView(mDragInfo.cell);
            }
            return true;
        }
    }
    return false;
}
Also used : FolderIcon(com.android.launcher3.folder.FolderIcon) 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)

Example 95 with Target

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

the class Workspace method onDropCompleted.

/**
 * Called at the end of a drag which originated on the workspace.
 */
public void onDropCompleted(final View target, final DragObject d, final boolean success) {
    if (success) {
        if (target != this && mDragInfo != null) {
            removeWorkspaceItem(mDragInfo.cell);
        }
    } else if (mDragInfo != null) {
        // When drag is cancelled, reattach content view back to its original parent.
        if (mDragInfo.cell instanceof LauncherAppWidgetHostView && d.dragView != null) {
            d.dragView.detachContentView(/* reattachToPreviousParent= */
            true);
        }
        final CellLayout cellLayout = mLauncher.getCellLayout(mDragInfo.container, mDragInfo.screenId);
        if (cellLayout != null) {
            cellLayout.onDropChild(mDragInfo.cell);
        } else if (FeatureFlags.IS_STUDIO_BUILD) {
            throw new RuntimeException("Invalid state: cellLayout == null in " + "Workspace#onDropCompleted. Please file a bug. ");
        }
    }
    View cell = getHomescreenIconByItemId(d.originalDragInfo.id);
    if (d.cancelled && cell != null) {
        cell.setVisibility(VISIBLE);
    }
    mDragInfo = null;
}
Also used : LauncherAppWidgetHostView(com.android.launcher3.widget.LauncherAppWidgetHostView) 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)

Aggregations

View (android.view.View)85 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)59 Point (android.graphics.Point)42 Rect (android.graphics.Rect)41 AppWidgetHostView (android.appwidget.AppWidgetHostView)40 AbstractFloatingView (com.android.launcher3.AbstractFloatingView)38 ItemInfo (com.android.launcher3.model.data.ItemInfo)37 Animator (android.animation.Animator)35 ValueAnimator (android.animation.ValueAnimator)35 Target (com.android.launcher3.userevent.nano.LauncherLogProto.Target)35 BubbleTextView (com.android.launcher3.BubbleTextView)34 DropTarget (com.android.launcher3.DropTarget)32 DragView (com.android.launcher3.dragndrop.DragView)30 LauncherAppWidgetHostView (com.android.launcher3.widget.LauncherAppWidgetHostView)30 AnimatorSet (android.animation.AnimatorSet)29 RemoteAnimationTargetCompat (com.android.systemui.shared.system.RemoteAnimationTargetCompat)29 ComponentName (android.content.ComponentName)28 ObjectAnimator (android.animation.ObjectAnimator)27 DraggableView (com.android.launcher3.dragndrop.DraggableView)26 AppInfo (com.android.launcher3.model.data.AppInfo)26