Search in sources :

Example 56 with Launcher

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

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

Example 58 with Launcher

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

the class ItemClickHandler method onClickPendingWidget.

/**
 * Event handler for the app widget view which has not fully restored.
 */
private static void onClickPendingWidget(PendingAppWidgetHostView v, Launcher launcher) {
    if (launcher.getPackageManager().isSafeMode()) {
        Toast.makeText(launcher, R.string.safemode_widget_error, Toast.LENGTH_SHORT).show();
        return;
    }
    final LauncherAppWidgetInfo info = (LauncherAppWidgetInfo) v.getTag();
    if (v.isReadyForClickSetup()) {
        LauncherAppWidgetProviderInfo appWidgetInfo = new WidgetManagerHelper(launcher).findProvider(info.providerName, info.user);
        if (appWidgetInfo == null) {
            return;
        }
        WidgetAddFlowHandler addFlowHandler = new WidgetAddFlowHandler(appWidgetInfo);
        if (info.hasRestoreFlag(LauncherAppWidgetInfo.FLAG_ID_NOT_VALID)) {
            if (!info.hasRestoreFlag(LauncherAppWidgetInfo.FLAG_ID_ALLOCATED)) {
                // This should not happen, as we make sure that an Id is allocated during bind.
                return;
            }
            addFlowHandler.startBindFlow(launcher, info.appWidgetId, info, REQUEST_BIND_PENDING_APPWIDGET);
        } else {
            addFlowHandler.startConfigActivity(launcher, info, REQUEST_RECONFIGURE_APPWIDGET);
        }
    } else {
        final String packageName = info.providerName.getPackageName();
        onClickPendingAppItem(v, launcher, packageName, info.installProgress >= 0);
    }
}
Also used : LauncherAppWidgetProviderInfo(com.android.launcher3.widget.LauncherAppWidgetProviderInfo) WidgetManagerHelper(com.android.launcher3.widget.WidgetManagerHelper) LauncherAppWidgetInfo(com.android.launcher3.model.data.LauncherAppWidgetInfo) WidgetAddFlowHandler(com.android.launcher3.widget.WidgetAddFlowHandler)

Example 59 with Launcher

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

the class ItemClickHandler method onClick.

private static void onClick(View v) {
    // view has detached (it's possible for this to happen if the view is removed mid touch).
    if (v.getWindowToken() == null)
        return;
    Launcher launcher = Launcher.getLauncher(v.getContext());
    if (!launcher.getWorkspace().isFinishedSwitchingState())
        return;
    Object tag = v.getTag();
    if (tag instanceof WorkspaceItemInfo) {
        onClickAppShortcut(v, (WorkspaceItemInfo) tag, launcher);
    } else if (tag instanceof FolderInfo) {
        if (v instanceof FolderIcon) {
            onClickFolderIcon(v);
        }
    } else if (tag instanceof AppInfo) {
        startAppShortcutOrInfoActivity(v, (AppInfo) tag, launcher);
    } else if (tag instanceof LauncherAppWidgetInfo) {
        if (v instanceof PendingAppWidgetHostView) {
            onClickPendingWidget((PendingAppWidgetHostView) v, launcher);
        }
    } else if (tag instanceof SearchActionItemInfo) {
        onClickSearchAction(launcher, (SearchActionItemInfo) tag);
    }
}
Also used : FolderIcon(com.android.launcher3.folder.FolderIcon) Launcher(com.android.launcher3.Launcher) LauncherAppWidgetInfo(com.android.launcher3.model.data.LauncherAppWidgetInfo) SearchActionItemInfo(com.android.launcher3.model.data.SearchActionItemInfo) PendingAppWidgetHostView(com.android.launcher3.widget.PendingAppWidgetHostView) FolderInfo(com.android.launcher3.model.data.FolderInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) AppInfo(com.android.launcher3.model.data.AppInfo)

Example 60 with Launcher

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

the class ItemClickHandler method onClickPendingAppItem.

private static void onClickPendingAppItem(View v, Launcher launcher, String packageName, boolean downloadStarted) {
    if (downloadStarted) {
        // If the download has started, simply direct to the market app.
        startMarketIntentForPackage(v, launcher, packageName);
        return;
    }
    UserHandle user = v.getTag() instanceof ItemInfo ? ((ItemInfo) v.getTag()).user : Process.myUserHandle();
    new AlertDialog.Builder(launcher).setTitle(R.string.abandoned_promises_title).setMessage(R.string.abandoned_promise_explanation).setPositiveButton(R.string.abandoned_search, (d, i) -> startMarketIntentForPackage(v, launcher, packageName)).setNeutralButton(R.string.abandoned_clean_this, (d, i) -> launcher.getWorkspace().removeAbandonedPromise(packageName, user)).create().show();
}
Also used : REQUEST_RECONFIGURE_APPWIDGET(com.android.launcher3.Launcher.REQUEST_RECONFIGURE_APPWIDGET) TestProtocol(com.android.launcher3.testing.TestProtocol) PendingIntent(android.app.PendingIntent) Process(android.os.Process) BubbleTextView(com.android.launcher3.BubbleTextView) FLAG_DISABLED_BY_PUBLISHER(com.android.launcher3.model.data.ItemInfoWithIcon.FLAG_DISABLED_BY_PUBLISHER) FolderInfo(com.android.launcher3.model.data.FolderInfo) View(android.view.View) Log(android.util.Log) LAUNCHER_APP_LAUNCH_TAP(com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_APP_LAUNCH_TAP) Utilities(com.android.launcher3.Utilities) Launcher(com.android.launcher3.Launcher) FLAG_DISABLED_SAFEMODE(com.android.launcher3.model.data.ItemInfoWithIcon.FLAG_DISABLED_SAFEMODE) PendingAppWidgetHostView(com.android.launcher3.widget.PendingAppWidgetHostView) AlertDialog(android.app.AlertDialog) LauncherApps(android.content.pm.LauncherApps) FLAG_DISABLED_QUIET_USER(com.android.launcher3.model.data.ItemInfoWithIcon.FLAG_DISABLED_QUIET_USER) LauncherAppWidgetProviderInfo(com.android.launcher3.widget.LauncherAppWidgetProviderInfo) LAUNCHER_FOLDER_OPEN(com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_FOLDER_OPEN) PackageManagerHelper(com.android.launcher3.util.PackageManagerHelper) Folder(com.android.launcher3.folder.Folder) LAUNCHER_ALLAPPS_SEARCHINAPP_LAUNCH(com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_SEARCHINAPP_LAUNCH) Context(android.content.Context) AppInfo(com.android.launcher3.model.data.AppInfo) WidgetAddFlowHandler(com.android.launcher3.widget.WidgetAddFlowHandler) ItemInfo(com.android.launcher3.model.data.ItemInfo) FolderIcon(com.android.launcher3.folder.FolderIcon) Intent(android.content.Intent) SearchActionItemInfo(com.android.launcher3.model.data.SearchActionItemInfo) SessionInfo(android.content.pm.PackageInstaller.SessionInfo) InstanceIdSequence(com.android.launcher3.logging.InstanceIdSequence) FLAG_DISABLED_SUSPENDED(com.android.launcher3.model.data.ItemInfoWithIcon.FLAG_DISABLED_SUSPENDED) IntentSender(android.content.IntentSender) FloatingIconView(com.android.launcher3.views.FloatingIconView) FLAG_DISABLED_LOCKED_USER(com.android.launcher3.model.data.ItemInfoWithIcon.FLAG_DISABLED_LOCKED_USER) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) UserHandle(android.os.UserHandle) Toast(android.widget.Toast) InstanceId(com.android.launcher3.logging.InstanceId) LauncherAppWidgetInfo(com.android.launcher3.model.data.LauncherAppWidgetInfo) TextUtils(android.text.TextUtils) REQUEST_BIND_PENDING_APPWIDGET(com.android.launcher3.Launcher.REQUEST_BIND_PENDING_APPWIDGET) WidgetManagerHelper(com.android.launcher3.widget.WidgetManagerHelper) StatsLogManager(com.android.launcher3.logging.StatsLogManager) R(com.android.launcher3.R) TestLogging(com.android.launcher3.testing.TestLogging) InstallSessionHelper(com.android.launcher3.pm.InstallSessionHelper) OnClickListener(android.view.View.OnClickListener) ItemInfoWithIcon(com.android.launcher3.model.data.ItemInfoWithIcon) ItemInfo(com.android.launcher3.model.data.ItemInfo) SearchActionItemInfo(com.android.launcher3.model.data.SearchActionItemInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) UserHandle(android.os.UserHandle)

Aggregations

Launcher (com.android.launcher3.Launcher)194 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)102 Test (org.junit.Test)102 View (android.view.View)87 LargeTest (androidx.test.filters.LargeTest)83 ItemInfo (com.android.launcher3.model.data.ItemInfo)83 Rect (android.graphics.Rect)80 Point (android.graphics.Point)77 Intent (android.content.Intent)71 ArrayList (java.util.ArrayList)69 DeviceProfile (com.android.launcher3.DeviceProfile)66 BaseQuickstepLauncher (com.android.launcher3.BaseQuickstepLauncher)64 Context (android.content.Context)61 LauncherAppWidgetInfo (com.android.launcher3.model.data.LauncherAppWidgetInfo)49 RecentsView (com.android.quickstep.views.RecentsView)46 DragLayer (com.android.launcher3.dragndrop.DragLayer)45 ComponentName (android.content.ComponentName)43 FolderInfo (com.android.launcher3.model.data.FolderInfo)42 ViewGroup (android.view.ViewGroup)41 AllApps (com.android.launcher3.tapl.AllApps)40