use of com.android.launcher3.userevent.nano.LauncherLogProto.ItemType in project Neo-Launcher by NeoApplications.
the class LoaderCursor method loadIcon.
/**
* Loads the icon from the cursor and updates the {@param info} if the icon is an app resource.
*/
protected boolean loadIcon(WorkspaceItemInfo info, LauncherIcons li) {
if (itemType == LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT) {
String packageName = getString(iconPackageIndex);
String resourceName = getString(iconResourceIndex);
if (!TextUtils.isEmpty(packageName) || !TextUtils.isEmpty(resourceName)) {
info.iconResource = new ShortcutIconResource();
info.iconResource.packageName = packageName;
info.iconResource.resourceName = resourceName;
BitmapInfo iconInfo = li.createIconBitmap(info.iconResource);
if (iconInfo != null) {
info.applyFrom(iconInfo);
return true;
}
}
}
// Failed to load from resource, try loading from DB.
byte[] data = getBlob(iconIndex);
try {
info.applyFrom(li.createIconBitmap(BitmapFactory.decodeByteArray(data, 0, data.length)));
return true;
} catch (Exception e) {
Log.e(TAG, "Failed to decode byte array for info " + info, e);
return false;
}
}
use of com.android.launcher3.userevent.nano.LauncherLogProto.ItemType in project Neo-Launcher by NeoApplications.
the class LoaderCursor method loadSimpleWorkspaceItem.
public WorkspaceItemInfo loadSimpleWorkspaceItem() {
final WorkspaceItemInfo info = new WorkspaceItemInfo();
// 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.applyFrom(mIconCache.getDefaultIcon(info.user));
}
return info;
}
use of com.android.launcher3.userevent.nano.LauncherLogProto.ItemType in project Neo-Launcher by NeoApplications.
the class UserEventDispatcher method logTaskLaunchOrDismiss.
@Deprecated
public void logTaskLaunchOrDismiss(int action, int direction, int taskIndex, ComponentKey componentKey) {
LauncherEvent event = newLauncherEvent(// TAP or SWIPE or FLING
newTouchAction(action), newTarget(Target.Type.ITEM));
if (action == Action.Touch.SWIPE || action == Action.Touch.FLING) {
// Direction DOWN means the task was launched, UP means it was dismissed.
event.action.dir = direction;
}
event.srcTarget[0].itemType = LauncherLogProto.ItemType.TASK;
event.srcTarget[0].pageIndex = taskIndex;
fillComponentInfo(event.srcTarget[0], componentKey.componentName);
dispatchUserEvent(event, null);
mAppOrTaskLaunch = true;
}
use of com.android.launcher3.userevent.nano.LauncherLogProto.ItemType in project Neo-Launcher by NeoApplications.
the class FolderNameProvider method getSuggestedFolderName.
/**
* Returns suggested folder name.
*/
public CharSequence getSuggestedFolderName(Context context, ArrayList<WorkspaceItemInfo> workspaceItemInfos, CharSequence[] suggestName) {
// candidate folder name should be rewritten.
if (workspaceItemInfos.size() == 2) {
ComponentName cmp1 = workspaceItemInfos.get(0).getTargetComponent();
ComponentName cmp2 = workspaceItemInfos.get(1).getTargetComponent();
String pkgName0 = cmp1 == null ? "" : cmp1.getPackageName();
String pkgName1 = cmp2 == null ? "" : cmp2.getPackageName();
// then assign the main icon's name
if (pkgName0.equals(pkgName1)) {
WorkspaceItemInfo wInfo0 = workspaceItemInfos.get(0);
WorkspaceItemInfo wInfo1 = workspaceItemInfos.get(1);
if (workspaceItemInfos.get(0).itemType == Favorites.ITEM_TYPE_APPLICATION) {
suggestName[0] = wInfo0.title;
} else if (wInfo1.itemType == Favorites.ITEM_TYPE_APPLICATION) {
suggestName[0] = wInfo1.title;
}
return suggestName[0];
// two icons are all shortcuts. Don't assign title
}
}
return suggestName[0];
}
use of com.android.launcher3.userevent.nano.LauncherLogProto.ItemType in project android_packages_apps_Trebuchet by LineageOS.
the class PredictionUiStateManager method getAllAppsRank.
/**
* Returns ranking info for the app within all apps 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 OptionalInt getAllAppsRank(@Nullable ItemInfo itemInfo) {
if (itemInfo == null || itemInfo.getTargetComponent() == null || itemInfo.user == null) {
return OptionalInt.empty();
}
if (itemInfo.itemType == ITEM_TYPE_APPLICATION || itemInfo.itemType == ITEM_TYPE_SHORTCUT || itemInfo.itemType == ITEM_TYPE_DEEP_SHORTCUT) {
ComponentKey key = new ComponentKey(itemInfo.getTargetComponent(), itemInfo.user);
final List<ComponentKeyMapper> apps = getCurrentState().apps;
return IntStream.range(0, apps.size()).filter(index -> key.equals(apps.get(index).getComponentKey())).findFirst();
}
return OptionalInt.empty();
}
Aggregations