Search in sources :

Example 51 with WorkspaceItemInfo

use of com.android.launcher3.WorkspaceItemInfo in project android_packages_apps_Launcher3 by AOSPA.

the class LoaderCursorTest method getAppShortcutInfo_dontAllowMissing_validComponent.

@Test
public void getAppShortcutInfo_dontAllowMissing_validComponent() throws Exception {
    ComponentName cn = new ComponentName(getContext(), TEST_ACTIVITY);
    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) SmallTest(androidx.test.filters.SmallTest) Test(org.junit.Test)

Example 52 with WorkspaceItemInfo

use of com.android.launcher3.WorkspaceItemInfo in project android_packages_apps_Launcher3 by AOSPA.

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(), "placeholder-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) SmallTest(androidx.test.filters.SmallTest) Test(org.junit.Test)

Example 53 with WorkspaceItemInfo

use of com.android.launcher3.WorkspaceItemInfo in project android_packages_apps_Launcher3 by AOSPA.

the class FolderNameProviderTest method setUp.

@Before
public void setUp() {
    mContext = getApplicationContext();
    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 54 with WorkspaceItemInfo

use of com.android.launcher3.WorkspaceItemInfo in project android_packages_apps_Launcher3 by AOSPA.

the class TaskView method getItemInfo.

protected WorkspaceItemInfo getItemInfo(Task task) {
    ComponentKey componentKey = TaskUtils.getLaunchComponentKeyForTask(task.key);
    WorkspaceItemInfo stubInfo = new WorkspaceItemInfo();
    stubInfo.itemType = LauncherSettings.Favorites.ITEM_TYPE_TASK;
    stubInfo.container = LauncherSettings.Favorites.CONTAINER_TASKSWITCHER;
    stubInfo.user = componentKey.user;
    stubInfo.intent = new Intent().setComponent(componentKey.componentName);
    stubInfo.title = task.title;
    if (getRecentsView() != null) {
        stubInfo.screenId = getRecentsView().indexOfChild(this);
    }
    return stubInfo;
}
Also used : ComponentKey(com.android.launcher3.util.ComponentKey) Intent(android.content.Intent) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Example 55 with WorkspaceItemInfo

use of com.android.launcher3.WorkspaceItemInfo in project android_packages_apps_Launcher3 by AOSPA.

the class BaseDraggingActivity method startActivitySafely.

public boolean startActivitySafely(View v, Intent intent, @Nullable ItemInfo item) {
    if (mIsSafeModeEnabled && !PackageManagerHelper.isSystemApp(this, intent)) {
        Toast.makeText(this, R.string.safemode_shortcut_error, Toast.LENGTH_SHORT).show();
        return false;
    }
    Bundle optsBundle = (v != null) ? getActivityLaunchOptions(v, item).toBundle() : null;
    UserHandle user = item == null ? null : item.user;
    // Prepare intent
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    if (v != null) {
        intent.setSourceBounds(Utilities.getViewBounds(v));
    }
    try {
        boolean isShortcut = (item instanceof WorkspaceItemInfo) && (item.itemType == Favorites.ITEM_TYPE_SHORTCUT || item.itemType == Favorites.ITEM_TYPE_DEEP_SHORTCUT) && !((WorkspaceItemInfo) item).isPromise();
        if (isShortcut) {
            // Shortcuts need some special checks due to legacy reasons.
            startShortcutIntentSafely(intent, optsBundle, item);
        } else if (user == null || user.equals(Process.myUserHandle())) {
            // Could be launching some bookkeeping activity
            startActivity(intent, optsBundle);
        } else {
            getSystemService(LauncherApps.class).startMainActivity(intent.getComponent(), user, intent.getSourceBounds(), optsBundle);
        }
        if (item != null) {
            InstanceId instanceId = new InstanceIdSequence().newInstanceId();
            logAppLaunch(getStatsLogManager(), item, instanceId);
        }
        return true;
    } catch (NullPointerException | ActivityNotFoundException | SecurityException e) {
        Toast.makeText(this, R.string.activity_not_found, Toast.LENGTH_SHORT).show();
        Log.e(TAG, "Unable to launch. tag=" + item + " intent=" + intent, e);
    }
    return false;
}
Also used : InstanceId(com.android.launcher3.logging.InstanceId) InstanceIdSequence(com.android.launcher3.logging.InstanceIdSequence) ActivityNotFoundException(android.content.ActivityNotFoundException) Bundle(android.os.Bundle) UserHandle(android.os.UserHandle) 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