Search in sources :

Example 96 with WorkspaceItemInfo

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"))));
}
Also used : ComponentName(android.content.ComponentName) Intent(android.content.Intent) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) AppInfo(com.android.launcher3.model.data.AppInfo) Before(org.junit.Before)

Example 97 with WorkspaceItemInfo

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);
}
Also used : WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) Test(org.junit.Test)

Example 98 with WorkspaceItemInfo

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()));
}
Also used : ComponentName(android.content.ComponentName) Intent(android.content.Intent) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) Test(org.junit.Test)

Example 99 with WorkspaceItemInfo

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()));
}
Also used : ComponentName(android.content.ComponentName) Intent(android.content.Intent) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) Test(org.junit.Test)

Example 100 with WorkspaceItemInfo

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;
}
Also used : LauncherActivityInfo(android.content.pm.LauncherActivityInfo) ComponentName(android.content.ComponentName) Intent(android.content.Intent) LauncherApps(android.content.pm.LauncherApps) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Aggregations

WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)418 View (android.view.View)168 ArrayList (java.util.ArrayList)145 ItemInfo (com.android.launcher3.model.data.ItemInfo)125 Intent (android.content.Intent)119 FolderInfo (com.android.launcher3.model.data.FolderInfo)100 AppInfo (com.android.launcher3.model.data.AppInfo)94 BubbleTextView (com.android.launcher3.BubbleTextView)87 AppWidgetHostView (android.appwidget.AppWidgetHostView)84 SuppressLint (android.annotation.SuppressLint)78 DragView (com.android.launcher3.dragndrop.DragView)78 ComponentName (android.content.ComponentName)76 LauncherAppWidgetInfo (com.android.launcher3.model.data.LauncherAppWidgetInfo)73 PendingAppWidgetHostView (com.android.launcher3.widget.PendingAppWidgetHostView)72 Rect (android.graphics.Rect)68 FolderIcon (com.android.launcher3.folder.FolderIcon)68 Context (android.content.Context)62 HashSet (java.util.HashSet)62 Point (android.graphics.Point)59 LauncherAppWidgetHostView (com.android.launcher3.widget.LauncherAppWidgetHostView)57