Search in sources :

Example 31 with WorkspaceItemInfo

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

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) Test(org.junit.Test)

Example 32 with WorkspaceItemInfo

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

the class OptionsPopupView method placeholderInfo.

static WorkspaceItemInfo placeholderInfo(Intent intent) {
    WorkspaceItemInfo placeholderInfo = new WorkspaceItemInfo();
    placeholderInfo.intent = intent;
    placeholderInfo.itemType = LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT;
    placeholderInfo.container = LauncherSettings.Favorites.CONTAINER_SETTINGS;
    return placeholderInfo;
}
Also used : WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Example 33 with WorkspaceItemInfo

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

the class ItemClickHandler method startAppShortcutOrInfoActivity.

private static void startAppShortcutOrInfoActivity(View v, ItemInfo item, Launcher launcher) {
    TestLogging.recordEvent(TestProtocol.SEQUENCE_MAIN, "start: startAppShortcutOrInfoActivity");
    Intent intent;
    if (item instanceof ItemInfoWithIcon && (((ItemInfoWithIcon) item).runtimeStatusFlags & ItemInfoWithIcon.FLAG_INSTALL_SESSION_ACTIVE) != 0) {
        ItemInfoWithIcon appInfo = (ItemInfoWithIcon) item;
        intent = new PackageManagerHelper(launcher).getMarketIntent(appInfo.getTargetComponent().getPackageName());
    } else {
        intent = item.getIntent();
    }
    if (intent == null) {
        throw new IllegalArgumentException("Input must have a valid intent");
    }
    if (item instanceof WorkspaceItemInfo) {
        WorkspaceItemInfo si = (WorkspaceItemInfo) item;
        if (si.hasStatusFlag(WorkspaceItemInfo.FLAG_SUPPORTS_WEB_UI) && Intent.ACTION_VIEW.equals(intent.getAction())) {
            // make a copy of the intent that has the package set to null
            // we do this because the platform sometimes disables instant
            // apps temporarily (triggered by the user) and fallbacks to the
            // web ui. This only works though if the package isn't set
            intent = new Intent(intent);
            intent.setPackage(null);
        }
    }
    if (v != null && launcher.supportsAdaptiveIconAnimation(v)) {
        // Preload the icon to reduce latency b/w swapping the floating view with the original.
        FloatingIconView.fetchIcon(launcher, v, item, true);
    }
    TrustDatabaseHelper db = TrustDatabaseHelper.getInstance(launcher);
    ComponentName cn = item.getTargetComponent();
    boolean isProtected = cn != null && db.isPackageProtected(cn.getPackageName());
    if (isProtected) {
        launcher.startActivitySafelyAuth(v, intent, item);
    } else {
        launcher.startActivitySafely(v, intent, item);
    }
}
Also used : TrustDatabaseHelper(com.android.launcher3.lineage.trust.db.TrustDatabaseHelper) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PackageManagerHelper(com.android.launcher3.util.PackageManagerHelper) ComponentName(android.content.ComponentName) ItemInfoWithIcon(com.android.launcher3.model.data.ItemInfoWithIcon) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Example 34 with WorkspaceItemInfo

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

the class PredictedAppIcon method updateRingPath.

private void updateRingPath() {
    boolean isBadged = false;
    if (getTag() instanceof WorkspaceItemInfo) {
        WorkspaceItemInfo info = (WorkspaceItemInfo) getTag();
        isBadged = !Process.myUserHandle().equals(info.user) || info.itemType == LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT || info.itemType == LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT;
    }
    mRingPath.reset();
    mTmpMatrix.setTranslate(getOutlineOffsetX(), getOutlineOffsetY());
    mRingPath.addPath(mShapePath, mTmpMatrix);
    if (isBadged) {
        float outlineSize = mNormalizedIconSize * RING_EFFECT_RATIO;
        float iconSize = getIconSize() * (1 - 2 * RING_EFFECT_RATIO);
        float badgeSize = LauncherIcons.getBadgeSizeForIconSize((int) iconSize) + outlineSize;
        float scale = badgeSize / mNormalizedIconSize;
        mTmpMatrix.postTranslate(mNormalizedIconSize, mNormalizedIconSize);
        mTmpMatrix.preScale(scale, scale);
        mTmpMatrix.preTranslate(-mNormalizedIconSize, -mNormalizedIconSize);
        mRingPath.addPath(mShapePath, mTmpMatrix);
    }
}
Also used : WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Example 35 with WorkspaceItemInfo

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

the class ItemClickHandler method startAppShortcutOrInfoActivity.

private static void startAppShortcutOrInfoActivity(View v, ItemInfo item, Launcher launcher) {
    TestLogging.recordEvent(TestProtocol.SEQUENCE_MAIN, "start: startAppShortcutOrInfoActivity");
    Intent intent;
    if (item instanceof ItemInfoWithIcon && (((ItemInfoWithIcon) item).runtimeStatusFlags & ItemInfoWithIcon.FLAG_INSTALL_SESSION_ACTIVE) != 0) {
        ItemInfoWithIcon appInfo = (ItemInfoWithIcon) item;
        intent = new PackageManagerHelper(launcher).getMarketIntent(appInfo.getTargetComponent().getPackageName());
    } else {
        intent = item.getIntent();
    }
    if (intent == null) {
        throw new IllegalArgumentException("Input must have a valid intent");
    }
    if (item instanceof WorkspaceItemInfo) {
        WorkspaceItemInfo si = (WorkspaceItemInfo) item;
        if (si.hasStatusFlag(WorkspaceItemInfo.FLAG_SUPPORTS_WEB_UI) && Intent.ACTION_VIEW.equals(intent.getAction())) {
            // make a copy of the intent that has the package set to null
            // we do this because the platform sometimes disables instant
            // apps temporarily (triggered by the user) and fallbacks to the
            // web ui. This only works though if the package isn't set
            intent = new Intent(intent);
            intent.setPackage(null);
        }
        if ((si.options & WorkspaceItemInfo.FLAG_START_FOR_RESULT) != 0) {
            launcher.startActivityForResult(item.getIntent(), 0);
            InstanceId instanceId = new InstanceIdSequence().newInstanceId();
            launcher.logAppLaunch(launcher.getStatsLogManager(), item, instanceId);
            return;
        }
    }
    if (v != null && launcher.supportsAdaptiveIconAnimation(v)) {
        // Preload the icon to reduce latency b/w swapping the floating view with the original.
        FloatingIconView.fetchIcon(launcher, v, item, true);
    }
    launcher.startActivitySafely(v, intent, item);
}
Also used : InstanceId(com.android.launcher3.logging.InstanceId) InstanceIdSequence(com.android.launcher3.logging.InstanceIdSequence) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) PackageManagerHelper(com.android.launcher3.util.PackageManagerHelper) ItemInfoWithIcon(com.android.launcher3.model.data.ItemInfoWithIcon) 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