use of com.android.launcher3.userevent.nano.LauncherLogProto.ItemType in project android_packages_apps_Launcher3 by ProtonAOSP.
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;
}
use of com.android.launcher3.userevent.nano.LauncherLogProto.ItemType in project android_packages_apps_Launcher3 by ProtonAOSP.
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_404Launcher by P-404.
the class LauncherProvider method initializeExternalAdd.
private boolean initializeExternalAdd(ContentValues values) {
// 1. Ensure that externally added items have a valid item id
int id = mOpenHelper.generateNewItemId();
values.put(LauncherSettings.Favorites._ID, id);
// 2. In the case of an app widget, and if no app widget id is specified, we
// attempt allocate and bind the widget.
Integer itemType = values.getAsInteger(LauncherSettings.Favorites.ITEM_TYPE);
if (itemType != null && itemType.intValue() == LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET && !values.containsKey(LauncherSettings.Favorites.APPWIDGET_ID)) {
final AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(getContext());
ComponentName cn = ComponentName.unflattenFromString(values.getAsString(Favorites.APPWIDGET_PROVIDER));
if (cn != null) {
try {
AppWidgetHost widgetHost = mOpenHelper.newLauncherWidgetHost();
int appWidgetId = widgetHost.allocateAppWidgetId();
values.put(LauncherSettings.Favorites.APPWIDGET_ID, appWidgetId);
if (!appWidgetManager.bindAppWidgetIdIfAllowed(appWidgetId, cn)) {
widgetHost.deleteAppWidgetId(appWidgetId);
return false;
}
} catch (RuntimeException e) {
Log.e(TAG, "Failed to initialize external widget", e);
return false;
}
} else {
return false;
}
}
return true;
}
use of com.android.launcher3.userevent.nano.LauncherLogProto.ItemType in project android_packages_apps_404Launcher by P-404.
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_404Launcher by P-404.
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;
}
Aggregations