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);
}
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);
}
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));
}
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;
}
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;
}
Aggregations