use of com.android.launcher3.WorkspaceItemInfo in project android_packages_apps_Trebuchet by LineageOS.
the class FolderNameProviderTest method setUp.
@Before
public void setUp() {
mContext = RuntimeEnvironment.application;
mItem1 = new WorkspaceItemInfo(new AppInfo(new ComponentName("a.b.c", "a.b.c/a.b.c.d"), "title1", UserHandle.of(10), new Intent().setComponent(new ComponentName("a.b.c", "a.b.c/a.b.c.d"))));
mItem2 = new WorkspaceItemInfo(new AppInfo(new ComponentName("a.b.c", "a.b.c/a.b.c.d"), "title2", UserHandle.of(10), new Intent().setComponent(new ComponentName("a.b.c", "a.b.c/a.b.c.d"))));
}
use of com.android.launcher3.WorkspaceItemInfo in project android_packages_apps_Trebuchet by LineageOS.
the class LoaderCursorTest method loadSimpleShortcut.
@Test
public void loadSimpleShortcut() {
initCursor(ITEM_TYPE_SHORTCUT, "my-shortcut");
assertTrue(mLoaderCursor.moveToNext());
WorkspaceItemInfo info = mLoaderCursor.loadSimpleWorkspaceItem();
assertTrue(mApp.getIconCache().isDefaultIcon(info.bitmap, info.user));
assertEquals("my-shortcut", info.title);
assertEquals(ITEM_TYPE_SHORTCUT, info.itemType);
}
use of com.android.launcher3.WorkspaceItemInfo in project android_packages_apps_Trebuchet by LineageOS.
the class LoaderCursorTest method getAppShortcutInfo_dontAllowMissing_validComponent.
@Test
public void getAppShortcutInfo_dontAllowMissing_validComponent() throws Exception {
ComponentName cn = new ComponentName(TEST_PACKAGE, TEST_PACKAGE);
shadowOf(mContext.getPackageManager()).addActivityIfNotPresent(cn);
initCursor(ITEM_TYPE_APPLICATION, "");
assertTrue(mLoaderCursor.moveToNext());
WorkspaceItemInfo info = Executors.MODEL_EXECUTOR.submit(() -> mLoaderCursor.getAppShortcutInfo(new Intent().setComponent(cn), false, /* allowMissingTarget */
true)).get();
assertNotNull(info);
assertTrue(PackageManagerHelper.isLauncherAppTarget(info.getIntent()));
}
use of com.android.launcher3.WorkspaceItemInfo in project android_packages_apps_Trebuchet by LineageOS.
the class LoaderCursorTest method getAppShortcutInfo_allowMissing_invalidComponent.
@Test
public void getAppShortcutInfo_allowMissing_invalidComponent() throws Exception {
initCursor(ITEM_TYPE_APPLICATION, "");
assertTrue(mLoaderCursor.moveToNext());
ComponentName cn = new ComponentName(mContext.getPackageName(), "dummy-do");
WorkspaceItemInfo info = Executors.MODEL_EXECUTOR.submit(() -> mLoaderCursor.getAppShortcutInfo(new Intent().setComponent(cn), true, /* allowMissingTarget */
true)).get();
assertNotNull(info);
assertTrue(PackageManagerHelper.isLauncherAppTarget(info.getIntent()));
}
use of com.android.launcher3.WorkspaceItemInfo in project android_packages_apps_Trebuchet by LineageOS.
the class LoaderCursor method getAppShortcutInfo.
/**
* Make an WorkspaceItemInfo object for a shortcut that is an application.
*/
public WorkspaceItemInfo getAppShortcutInfo(Intent intent, boolean allowMissingTarget, boolean useLowResIcon) {
if (user == null) {
Log.d(TAG, "Null user found in getShortcutInfo");
return null;
}
ComponentName componentName = intent.getComponent();
if (componentName == null) {
Log.d(TAG, "Missing component found in getShortcutInfo");
return null;
}
Intent newIntent = new Intent(Intent.ACTION_MAIN, null);
newIntent.addCategory(Intent.CATEGORY_LAUNCHER);
newIntent.setComponent(componentName);
LauncherActivityInfo lai = mContext.getSystemService(LauncherApps.class).resolveActivity(newIntent, user);
if ((lai == null) && !allowMissingTarget) {
Log.d(TAG, "Missing activity found in getShortcutInfo: " + componentName);
return null;
}
final WorkspaceItemInfo info = new WorkspaceItemInfo();
info.itemType = LauncherSettings.Favorites.ITEM_TYPE_APPLICATION;
info.user = user;
info.intent = newIntent;
mIconCache.getTitleAndIcon(info, lai, useLowResIcon);
if (mIconCache.isDefaultIcon(info.bitmap, user)) {
loadIcon(info);
}
if (lai != null) {
AppInfo.updateRuntimeFlagsForActivityTarget(info, lai);
}
// from the db
if (TextUtils.isEmpty(info.title)) {
info.title = getTitle();
}
// fall back to the class name of the activity
if (info.title == null) {
info.title = componentName.getClassName();
}
info.contentDescription = mPM.getUserBadgedLabel(info.title, info.user);
return info;
}
Aggregations