Search in sources :

Example 56 with ItemInfo

use of com.android.launcher3.ItemInfo 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 57 with ItemInfo

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

the class ItemLongClickListener method onAllAppsItemLongClick.

private static boolean onAllAppsItemLongClick(View v) {
    TestLogging.recordEvent(TestProtocol.SEQUENCE_MAIN, "onAllAppsItemLongClick");
    v.cancelLongPress();
    Launcher launcher = Launcher.getLauncher(v.getContext());
    if (!canStartDrag(launcher))
        return false;
    // When we have exited all apps or are in transition, disregard long clicks
    if (!launcher.isInState(ALL_APPS) && !launcher.isInState(OVERVIEW))
        return false;
    if (launcher.getWorkspace().isSwitchingState())
        return false;
    StatsLogger logger = launcher.getStatsLogManager().logger();
    if (v.getTag() instanceof ItemInfo) {
        logger.withItemInfo((ItemInfo) v.getTag());
    }
    logger.log(LAUNCHER_ALLAPPS_ITEM_LONG_PRESSED);
    // Start the drag
    final DragController dragController = launcher.getDragController();
    dragController.addDragListener(new DragController.DragListener() {

        @Override
        public void onDragStart(DropTarget.DragObject dragObject, DragOptions options) {
            v.setVisibility(INVISIBLE);
        }

        @Override
        public void onDragEnd() {
            v.setVisibility(VISIBLE);
            dragController.removeDragListener(this);
        }
    });
    DeviceProfile grid = launcher.getDeviceProfile();
    DragOptions options = new DragOptions();
    options.intrinsicIconScaleFactor = (float) grid.allAppsIconSizePx / grid.iconSizePx;
    launcher.getWorkspace().beginDragShared(v, launcher.getAppsView(), options);
    return false;
}
Also used : DragOptions(com.android.launcher3.dragndrop.DragOptions) DeviceProfile(com.android.launcher3.DeviceProfile) StatsLogger(com.android.launcher3.logging.StatsLogManager.StatsLogger) ItemInfo(com.android.launcher3.model.data.ItemInfo) DragController(com.android.launcher3.dragndrop.DragController) Launcher(com.android.launcher3.Launcher) DropTarget(com.android.launcher3.DropTarget)

Example 58 with ItemInfo

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

the class QuickstepLauncher method logAppLaunch.

@Override
public void logAppLaunch(StatsLogManager statsLogManager, ItemInfo info, InstanceId instanceId) {
    // LiveSearchManager to recreate the AllApps session on the server side.
    if (mAllAppsSessionLogId != null && ALL_APPS.equals(getStateManager().getCurrentStableState())) {
        instanceId = mAllAppsSessionLogId;
    }
    StatsLogger logger = statsLogManager.logger().withItemInfo(info).withInstanceId(instanceId);
    if (mAllAppsPredictions != null && (info.itemType == ITEM_TYPE_APPLICATION || info.itemType == ITEM_TYPE_SHORTCUT || info.itemType == ITEM_TYPE_DEEP_SHORTCUT)) {
        int count = mAllAppsPredictions.items.size();
        for (int i = 0; i < count; i++) {
            ItemInfo targetInfo = mAllAppsPredictions.items.get(i);
            if (targetInfo.itemType == info.itemType && targetInfo.user.equals(info.user) && Objects.equals(targetInfo.getIntent(), info.getIntent())) {
                logger.withRank(i);
                break;
            }
        }
    }
    logger.log(LAUNCHER_APP_LAUNCH_TAP);
    mHotseatPredictionController.logLaunchedAppRankingInfo(info, instanceId);
}
Also used : StatsLogger(com.android.launcher3.logging.StatsLogManager.StatsLogger) ItemInfo(com.android.launcher3.model.data.ItemInfo)

Example 59 with ItemInfo

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

the class ItemClickHandler method startMarketIntentForPackage.

private static void startMarketIntentForPackage(View v, Launcher launcher, String packageName) {
    ItemInfo item = (ItemInfo) v.getTag();
    if (Utilities.ATLEAST_Q) {
        SessionInfo sessionInfo = InstallSessionHelper.INSTANCE.get(launcher).getActiveSessionInfo(item.user, packageName);
        if (sessionInfo != null) {
            LauncherApps launcherApps = launcher.getSystemService(LauncherApps.class);
            try {
                launcherApps.startPackageInstallerSessionDetailsActivity(sessionInfo, null, launcher.getActivityLaunchOptions(v, item).toBundle());
                return;
            } catch (Exception e) {
                Log.e(TAG, "Unable to launch market intent for package=" + packageName, e);
            }
        }
    }
    // Fallback to using custom market intent.
    Intent intent = new PackageManagerHelper(launcher).getMarketIntent(packageName);
    launcher.startActivitySafely(v, intent, item);
}
Also used : ItemInfo(com.android.launcher3.model.data.ItemInfo) SearchActionItemInfo(com.android.launcher3.model.data.SearchActionItemInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) SessionInfo(android.content.pm.PackageInstaller.SessionInfo) LauncherApps(android.content.pm.LauncherApps) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) PackageManagerHelper(com.android.launcher3.util.PackageManagerHelper)

Example 60 with ItemInfo

use of com.android.launcher3.ItemInfo 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

ItemInfo (com.android.launcher3.model.data.ItemInfo)457 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)373 View (android.view.View)199 ArrayList (java.util.ArrayList)169 Point (android.graphics.Point)159 FolderInfo (com.android.launcher3.model.data.FolderInfo)113 SuppressLint (android.annotation.SuppressLint)110 LauncherAppWidgetInfo (com.android.launcher3.model.data.LauncherAppWidgetInfo)100 DragView (com.android.launcher3.dragndrop.DragView)98 LauncherAppWidgetHostView (com.android.launcher3.widget.LauncherAppWidgetHostView)98 AppWidgetHostView (android.appwidget.AppWidgetHostView)94 PendingAppWidgetHostView (com.android.launcher3.widget.PendingAppWidgetHostView)94 BubbleTextView (com.android.launcher3.BubbleTextView)85 Context (android.content.Context)82 List (java.util.List)80 AppInfo (com.android.launcher3.model.data.AppInfo)79 Intent (android.content.Intent)78 Rect (android.graphics.Rect)76 DraggableView (com.android.launcher3.dragndrop.DraggableView)73 ComponentName (android.content.ComponentName)72