Search in sources :

Example 6 with ItemType

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

the class HotseatPredictionController method encodeHotseatLayoutIntoPredictionRank.

/**
 * Fill in predicted_rank field based on app prediction.
 * Only applicable when {@link ItemInfo#itemType} is PREDICTED_HOTSEAT
 */
public static void encodeHotseatLayoutIntoPredictionRank(@NonNull ItemInfo itemInfo, @NonNull LauncherLogProto.Target target) {
    QuickstepLauncher launcher = QuickstepLauncher.ACTIVITY_TRACKER.getCreatedActivity();
    if (launcher == null || launcher.getHotseatPredictionController() == null || itemInfo.getTargetComponent() == null) {
        return;
    }
    HotseatPredictionController controller = launcher.getHotseatPredictionController();
    final ComponentKey k = new ComponentKey(itemInfo.getTargetComponent(), itemInfo.user);
    final List<ComponentKeyMapper> predictedApps = controller.mComponentKeyMappers;
    OptionalInt rank = IntStream.range(0, predictedApps.size()).filter((i) -> k.equals(predictedApps.get(i).getComponentKey())).findFirst();
    target.predictedRank = 10000 + (controller.mPredictedSpotsCount * 100) + (rank.isPresent() ? rank.getAsInt() + 1 : 0);
}
Also used : ComponentKeyMapper(com.android.launcher3.appprediction.ComponentKeyMapper) NonNull(androidx.annotation.NonNull) Animator(android.animation.Animator) LauncherSettings(com.android.launcher3.LauncherSettings) DynamicItemCache(com.android.launcher3.appprediction.DynamicItemCache) IconCache(com.android.launcher3.icons.IconCache) AppTarget(android.app.prediction.AppTarget) Process(android.os.Process) ShortcutKey(com.android.launcher3.shortcuts.ShortcutKey) LAUNCHER_HOTSEAT_RANKED(com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_HOTSEAT_RANKED) HotseatEduController.getSettingsIntent(com.android.launcher3.hybridhotseat.HotseatEduController.getSettingsIntent) FolderInfo(com.android.launcher3.model.data.FolderInfo) View(android.view.View) AnimationSuccessListener(com.android.launcher3.anim.AnimationSuccessListener) SCALE_PROPERTY(com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY) Log(android.util.Log) Utilities(com.android.launcher3.Utilities) AppPredictor(android.app.prediction.AppPredictor) QuickstepLauncher(com.android.launcher3.uioverrides.QuickstepLauncher) Launcher(com.android.launcher3.Launcher) ObjectAnimator(android.animation.ObjectAnimator) AppPredictionManager(android.app.prediction.AppPredictionManager) AllAppsStore(com.android.launcher3.allapps.AllAppsStore) PredictedAppIcon(com.android.launcher3.uioverrides.PredictedAppIcon) ViewGroup(android.view.ViewGroup) DragOptions(com.android.launcher3.dragndrop.DragOptions) HapticFeedbackConstants(android.view.HapticFeedbackConstants) List(java.util.List) Nullable(androidx.annotation.Nullable) AppPredictionContext(android.app.prediction.AppPredictionContext) NORMAL(com.android.launcher3.LauncherState.NORMAL) LauncherLogProto(com.android.launcher3.userevent.nano.LauncherLogProto) IntStream(java.util.stream.IntStream) AppInfo(com.android.launcher3.model.data.AppInfo) ContainerInfo(com.android.launcher3.logger.LauncherAtom.ContainerInfo) ItemInfo(com.android.launcher3.model.data.ItemInfo) Snackbar(com.android.launcher3.views.Snackbar) OptionalInt(java.util.OptionalInt) ArrayList(java.util.ArrayList) ItemLongClickListener(com.android.launcher3.touch.ItemLongClickListener) PredictedHotseatContainer(com.android.launcher3.logger.LauncherAtom.PredictedHotseatContainer) AppTargetEvent(android.app.prediction.AppTargetEvent) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) AnimatorSet(android.animation.AnimatorSet) DragSource(com.android.launcher3.DragSource) WeakReference(java.lang.ref.WeakReference) SystemShortcut(com.android.launcher3.popup.SystemShortcut) CHANGE_FLAG_GRID(com.android.launcher3.InvariantDeviceProfile.CHANGE_FLAG_GRID) IntArray(com.android.launcher3.util.IntArray) InstanceId(com.android.launcher3.logging.InstanceId) ArrowTipView(com.android.launcher3.views.ArrowTipView) ComponentName(android.content.ComponentName) DropTarget(com.android.launcher3.DropTarget) LauncherAppState(com.android.launcher3.LauncherAppState) DragController(com.android.launcher3.dragndrop.DragController) OnboardingPrefs(com.android.launcher3.util.OnboardingPrefs) Hotseat(com.android.launcher3.Hotseat) InvariantDeviceProfile(com.android.launcher3.InvariantDeviceProfile) R(com.android.launcher3.R) ComponentKey(com.android.launcher3.util.ComponentKey) Collections(java.util.Collections) ItemInfoWithIcon(com.android.launcher3.model.data.ItemInfoWithIcon) ComponentKey(com.android.launcher3.util.ComponentKey) QuickstepLauncher(com.android.launcher3.uioverrides.QuickstepLauncher) OptionalInt(java.util.OptionalInt) ComponentKeyMapper(com.android.launcher3.appprediction.ComponentKeyMapper)

Example 7 with ItemType

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

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;
    }
    if (itemInfo.container != LauncherSettings.Favorites.CONTAINER_PREDICTION) {
        HotseatPredictionController.encodeHotseatLayoutIntoPredictionRank(itemInfo, target);
        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 = 0 - rank);
}
Also used : ComponentKey(com.android.launcher3.util.ComponentKey)

Example 8 with ItemType

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

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 : ItemInfo(com.android.launcher3.model.data.ItemInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) SuppressLint(android.annotation.SuppressLint)

Example 9 with ItemType

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

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.model.data.WorkspaceItemInfo)

Example 10 with ItemType

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

the class LoaderCursor method loadSimpleWorkspaceItem.

@VisibleForTesting
public WorkspaceItemInfo loadSimpleWorkspaceItem() {
    final WorkspaceItemInfo info = new WorkspaceItemInfo();
    info.intent = new Intent();
    // Non-app shortcuts are only supported for current user.
    info.user = user;
    info.itemType = itemType;
    info.title = getTitle();
    // the fallback icon
    if (!loadIcon(info)) {
        info.bitmap = mIconCache.getDefaultIcon(info.user);
    }
    return info;
}
Also used : Intent(android.content.Intent) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) VisibleForTesting(androidx.annotation.VisibleForTesting)

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