Search in sources :

Example 11 with ItemType

use of com.android.launcher3.userevent.nano.LauncherLogProto.ItemType in project android_packages_apps_Trebuchet by LineageOS.

the class UserEventDispatcher method logActionOnItem.

/**
 * Creates new {@link LauncherEvent} of ITEM target type with input arguments and dispatches it.
 *
 * @param touchAction ENUM value of {@link LauncherLogProto.Action.Touch} Action
 * @param dir         ENUM value of {@link LauncherLogProto.Action.Direction} Action
 * @param itemType    ENUM value of {@link LauncherLogProto.ItemType}
 * @param gridX       Nullable X coordinate of item's position on the workspace grid
 * @param gridY       Nullable Y coordinate of item's position on the workspace grid
 */
public void logActionOnItem(int touchAction, int dir, int itemType, @Nullable Integer gridX, @Nullable Integer gridY) {
    Target itemTarget = newTarget(Target.Type.ITEM);
    itemTarget.itemType = itemType;
    ofNullable(gridX).ifPresent(value -> itemTarget.gridX = value);
    ofNullable(gridY).ifPresent(value -> itemTarget.gridY = value);
    LauncherEvent event = newLauncherEvent(newTouchAction(touchAction), itemTarget);
    event.action.dir = dir;
    dispatchUserEvent(event, null);
}
Also used : LoggerUtils.newTarget(com.android.launcher3.logging.LoggerUtils.newTarget) Target(com.android.launcher3.userevent.nano.LauncherLogProto.Target) LoggerUtils.newControlTarget(com.android.launcher3.logging.LoggerUtils.newControlTarget) LoggerUtils.newItemTarget(com.android.launcher3.logging.LoggerUtils.newItemTarget) DropTarget(com.android.launcher3.DropTarget) LoggerUtils.newContainerTarget(com.android.launcher3.logging.LoggerUtils.newContainerTarget) LoggerUtils.newDropTarget(com.android.launcher3.logging.LoggerUtils.newDropTarget) LauncherEvent(com.android.launcher3.userevent.nano.LauncherLogProto.LauncherEvent) LoggerUtils.newLauncherEvent(com.android.launcher3.logging.LoggerUtils.newLauncherEvent)

Example 12 with ItemType

use of com.android.launcher3.userevent.nano.LauncherLogProto.ItemType in project Neo-Launcher by NeoApplications.

the class PredictionUiStateManager method fillInPredictedRank.

/**
 * Fill in predicted_rank field based on app prediction.
 * Only applicable when {@link ItemInfo#itemType} is one of the followings:
 * {@link LauncherSettings.Favorites#ITEM_TYPE_APPLICATION},
 * {@link LauncherSettings.Favorites#ITEM_TYPE_SHORTCUT},
 * {@link LauncherSettings.Favorites#ITEM_TYPE_DEEP_SHORTCUT}
 */
public static void fillInPredictedRank(@NonNull ItemInfo itemInfo, @NonNull LauncherLogProto.Target target) {
    final PredictionUiStateManager manager = PredictionUiStateManager.INSTANCE.getNoCreate();
    if (manager == null || itemInfo.getTargetComponent() == null || itemInfo.user == null || (itemInfo.itemType != LauncherSettings.Favorites.ITEM_TYPE_APPLICATION && itemInfo.itemType != LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT && itemInfo.itemType != LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT)) {
        return;
    }
    final ComponentKey k = new ComponentKey(itemInfo.getTargetComponent(), itemInfo.user);
    final List<ComponentKeyMapper> predictedApps = manager.getCurrentState().apps;
    IntStream.range(0, predictedApps.size()).filter((i) -> k.equals(predictedApps.get(i).getComponentKey())).findFirst().ifPresent((rank) -> target.predictedRank = rank);
}
Also used : ComponentKey(com.android.launcher3.util.ComponentKey)

Example 13 with ItemType

use of com.android.launcher3.userevent.nano.LauncherLogProto.ItemType in project Neo-Launcher by NeoApplications.

the class Folder method acceptDrop.

@Override
public boolean acceptDrop(DragObject d) {
    final ItemInfo item = d.dragInfo;
    final int itemType = item.itemType;
    return ((itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION || itemType == LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT || itemType == LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT));
}
Also used : WorkspaceItemInfo(com.android.launcher3.WorkspaceItemInfo) ItemInfo(com.android.launcher3.ItemInfo) SuppressLint(android.annotation.SuppressLint)

Example 14 with ItemType

use of com.android.launcher3.userevent.nano.LauncherLogProto.ItemType in project Neo-Launcher by NeoApplications.

the class UserEventDispatcher method logActionOnItem.

/**
 * Creates new {@link LauncherEvent} of ITEM target type with input arguments and dispatches it.
 *
 * @param touchAction ENUM value of {@link LauncherLogProto.Action.Touch} Action
 * @param dir         ENUM value of {@link LauncherLogProto.Action.Direction} Action
 * @param itemType    ENUM value of {@link LauncherLogProto.ItemType}
 * @param gridX       Nullable X coordinate of item's position on the workspace grid
 * @param gridY       Nullable Y coordinate of item's position on the workspace grid
 */
public void logActionOnItem(int touchAction, int dir, int itemType, @Nullable Integer gridX, @Nullable Integer gridY) {
    Target itemTarget = newTarget(Target.Type.ITEM);
    itemTarget.itemType = itemType;
    ofNullable(gridX).ifPresent(value -> itemTarget.gridX = value);
    ofNullable(gridY).ifPresent(value -> itemTarget.gridY = value);
    LauncherEvent event = newLauncherEvent(newTouchAction(touchAction), itemTarget);
    event.action.dir = dir;
    dispatchUserEvent(event, null);
}
Also used : LoggerUtils.newTarget(com.android.launcher3.logging.LoggerUtils.newTarget) Target(com.android.launcher3.userevent.nano.LauncherLogProto.Target) LoggerUtils.newControlTarget(com.android.launcher3.logging.LoggerUtils.newControlTarget) LoggerUtils.newItemTarget(com.android.launcher3.logging.LoggerUtils.newItemTarget) DropTarget(com.android.launcher3.DropTarget) LoggerUtils.newContainerTarget(com.android.launcher3.logging.LoggerUtils.newContainerTarget) LoggerUtils.newDropTarget(com.android.launcher3.logging.LoggerUtils.newDropTarget) LauncherEvent(com.android.launcher3.userevent.nano.LauncherLogProto.LauncherEvent) LoggerUtils.newLauncherEvent(com.android.launcher3.logging.LoggerUtils.newLauncherEvent)

Example 15 with ItemType

use of com.android.launcher3.userevent.nano.LauncherLogProto.ItemType in project Neo-Launcher by NeoApplications.

the class LoaderCursor method getRestoredItemInfo.

/**
 * Make an WorkspaceItemInfo object for a restored application or shortcut item that points
 * to a package that is not yet installed on the system.
 */
public WorkspaceItemInfo getRestoredItemInfo(Intent intent) {
    final WorkspaceItemInfo info = new WorkspaceItemInfo();
    info.user = user;
    info.intent = intent;
    // the fallback icon
    if (!loadIcon(info)) {
        mIconCache.getTitleAndIcon(info, false);
    }
    if (hasRestoreFlag(WorkspaceItemInfo.FLAG_RESTORED_ICON)) {
        String title = getTitle();
        if (!TextUtils.isEmpty(title)) {
            info.title = Utilities.trim(title);
        }
    } else if (hasRestoreFlag(WorkspaceItemInfo.FLAG_AUTOINSTALL_ICON)) {
        if (TextUtils.isEmpty(info.title)) {
            info.title = getTitle();
        }
    } else {
        throw new InvalidParameterException("Invalid restoreType " + restoreFlag);
    }
    info.contentDescription = mPM.getUserBadgedLabel(info.title, info.user);
    info.itemType = itemType;
    info.status = restoreFlag;
    return info;
}
Also used : InvalidParameterException(java.security.InvalidParameterException) WorkspaceItemInfo(com.android.launcher3.WorkspaceItemInfo)

Aggregations

WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)19 ComponentName (android.content.ComponentName)14 Intent (android.content.Intent)11 InvalidParameterException (java.security.InvalidParameterException)10 Nullable (androidx.annotation.Nullable)7 LauncherSettings (com.android.launcher3.LauncherSettings)7 ContainerInfo (com.android.launcher3.logger.LauncherAtom.ContainerInfo)7 SuppressLint (android.annotation.SuppressLint)6 Process (android.os.Process)6 ITEM_TYPE_APPLICATION (com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_APPLICATION)6 ITEM_TYPE_DEEP_SHORTCUT (com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT)6 ITEM_TYPE_SHORTCUT (com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT)6 ItemInfo (com.android.launcher3.model.data.ItemInfo)6 AppWidgetHost (android.appwidget.AppWidgetHost)5 AppWidgetManager (android.appwidget.AppWidgetManager)5 ContentValues (android.content.ContentValues)5 UserHandle (android.os.UserHandle)5 Favorites (com.android.launcher3.LauncherSettings.Favorites)5 CONTAINER_ALL_APPS (com.android.launcher3.LauncherSettings.Favorites.CONTAINER_ALL_APPS)5 CONTAINER_DESKTOP (com.android.launcher3.LauncherSettings.Favorites.CONTAINER_DESKTOP)5