Search in sources :

Example 96 with LauncherActivityInfo

use of android.content.pm.LauncherActivityInfo in project android_packages_apps_Launcher3 by crdroidandroid.

the class AllAppsList method updatePackage.

/**
 * Add and remove icons for this package which has been updated.
 */
public List<LauncherActivityInfo> updatePackage(Context context, String packageName, UserHandle user) {
    final List<LauncherActivityInfo> matches = context.getSystemService(LauncherApps.class).getActivityList(packageName, user);
    if (matches.size() > 0) {
        // to the removed list.
        for (int i = data.size() - 1; i >= 0; i--) {
            final AppInfo applicationInfo = data.get(i);
            if (user.equals(applicationInfo.user) && packageName.equals(applicationInfo.componentName.getPackageName())) {
                if (!findActivity(matches, applicationInfo.componentName)) {
                    Log.w(TAG, "Changing shortcut target due to app component name change.");
                    removeApp(i);
                }
            }
        }
        // Also updates existing activities with new labels/icons
        for (final LauncherActivityInfo info : matches) {
            AppInfo applicationInfo = findAppInfo(info.getComponentName(), user);
            if (applicationInfo == null) {
                add(new AppInfo(context, info, user), info);
            } else {
                Intent launchIntent = AppInfo.makeLaunchIntent(info);
                mIconCache.getTitleAndIcon(applicationInfo, info, false);
                applicationInfo.sectionName = mIndex.computeSectionName(applicationInfo.title);
                applicationInfo.setProgressLevel(PackageManagerHelper.getLoadingProgress(info), PackageInstallInfo.STATUS_INSTALLED_DOWNLOADING);
                applicationInfo.intent = launchIntent;
                mDataChanged = true;
            }
        }
    } else {
        // Remove all data for this package.
        for (int i = data.size() - 1; i >= 0; i--) {
            final AppInfo applicationInfo = data.get(i);
            if (user.equals(applicationInfo.user) && packageName.equals(applicationInfo.componentName.getPackageName())) {
                mIconCache.remove(applicationInfo.componentName, user);
                removeApp(i);
            }
        }
    }
    return matches;
}
Also used : LauncherActivityInfo(android.content.pm.LauncherActivityInfo) LauncherApps(android.content.pm.LauncherApps) Intent(android.content.Intent) AppInfo(com.android.launcher3.model.data.AppInfo)

Example 97 with LauncherActivityInfo

use of android.content.pm.LauncherActivityInfo in project android_packages_apps_Launcher3 by crdroidandroid.

the class SecondaryDropTarget method getUninstallTarget.

/**
 * @return the component name that should be uninstalled or null.
 */
private ComponentName getUninstallTarget(ItemInfo item) {
    Intent intent = null;
    UserHandle user = null;
    if (item != null && item.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION) {
        intent = item.getIntent();
        user = item.user;
    }
    if (intent != null) {
        LauncherActivityInfo info = mLauncher.getSystemService(LauncherApps.class).resolveActivity(intent, user);
        if (info != null && (info.getApplicationInfo().flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
            return info.getComponentName();
        }
    }
    return null;
}
Also used : UserHandle(android.os.UserHandle) LauncherActivityInfo(android.content.pm.LauncherActivityInfo) Intent(android.content.Intent) LauncherApps(android.content.pm.LauncherApps)

Example 98 with LauncherActivityInfo

use of android.content.pm.LauncherActivityInfo in project android_packages_apps_Launcher3 by crdroidandroid.

the class Utilities method loadFullDrawableWithoutTheme.

private static Drawable loadFullDrawableWithoutTheme(Launcher launcher, ItemInfo info, int width, int height, Object[] outObj) {
    LauncherAppState appState = LauncherAppState.getInstance(launcher);
    if (info.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION) {
        LauncherActivityInfo activityInfo = launcher.getSystemService(LauncherApps.class).resolveActivity(info.getIntent(), info.user);
        outObj[0] = activityInfo;
        return activityInfo == null ? null : LauncherAppState.getInstance(launcher).getIconProvider().getIcon(activityInfo, launcher.getDeviceProfile().inv.fillResIconDpi);
    } else if (info.itemType == LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT) {
        if (info instanceof PendingAddShortcutInfo) {
            ShortcutConfigActivityInfo activityInfo = ((PendingAddShortcutInfo) info).activityInfo;
            outObj[0] = activityInfo;
            return activityInfo.getFullResIcon(appState.getIconCache());
        }
        List<ShortcutInfo> si = ShortcutKey.fromItemInfo(info).buildRequest(launcher).query(ShortcutRequest.ALL);
        if (si.isEmpty()) {
            return null;
        } else {
            outObj[0] = si.get(0);
            return ShortcutCachingLogic.getIcon(launcher, si.get(0), appState.getInvariantDeviceProfile().fillResIconDpi);
        }
    } else if (info.itemType == LauncherSettings.Favorites.ITEM_TYPE_FOLDER) {
        FolderAdaptiveIcon icon = FolderAdaptiveIcon.createFolderAdaptiveIcon(launcher, info.id, new Point(width, height));
        if (icon == null) {
            return null;
        }
        outObj[0] = icon;
        return icon;
    } else {
        return null;
    }
}
Also used : FolderAdaptiveIcon(com.android.launcher3.dragndrop.FolderAdaptiveIcon) LauncherActivityInfo(android.content.pm.LauncherActivityInfo) PendingAddShortcutInfo(com.android.launcher3.widget.PendingAddShortcutInfo) ShortcutConfigActivityInfo(com.android.launcher3.pm.ShortcutConfigActivityInfo) LauncherApps(android.content.pm.LauncherApps) List(java.util.List) Point(android.graphics.Point)

Example 99 with LauncherActivityInfo

use of android.content.pm.LauncherActivityInfo in project Neo-Launcher by NeoApplications.

the class DefaultAppSearchAlgorithm method getApps.

public static List<AppInfo> getApps(Context context, List<AppInfo> defaultApps, AppFilter filter) {
    if (!Utilities.getPrefs(context).getBoolean(SEARCH_HIDDEN_APPS, false)) {
        return defaultApps;
    }
    final List<AppInfo> apps = new ArrayList<>();
    final IconCache iconCache = LauncherAppState.getInstance(context).getIconCache();
    for (UserHandle user : UserManagerCompat.getInstance(context).getUserProfiles()) {
        final List<ComponentName> duplicatePreventionCache = new ArrayList<>();
        for (LauncherActivityInfo info : LauncherAppsCompat.getInstance(context).getActivityList(null, user)) {
            if (!filter.shouldShowApp(info.getComponentName(), user)) {
                continue;
            }
            if (!duplicatePreventionCache.contains(info.getComponentName())) {
                duplicatePreventionCache.add(info.getComponentName());
                final AppInfo appInfo = new AppInfo(context, info, user);
                iconCache.getTitleAndIcon(appInfo, false);
                apps.add(appInfo);
            }
        }
    }
    return apps;
}
Also used : IconCache(com.android.launcher3.icons.IconCache) UserHandle(android.os.UserHandle) ArrayList(java.util.ArrayList) LauncherActivityInfo(android.content.pm.LauncherActivityInfo) ComponentName(android.content.ComponentName) AppInfo(com.android.launcher3.AppInfo)

Example 100 with LauncherActivityInfo

use of android.content.pm.LauncherActivityInfo in project Neo-Launcher by NeoApplications.

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 = LauncherAppsCompat.getInstance(mContext).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.iconBitmap, 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) WorkspaceItemInfo(com.android.launcher3.WorkspaceItemInfo)

Aggregations

LauncherActivityInfo (android.content.pm.LauncherActivityInfo)134 LauncherApps (android.content.pm.LauncherApps)70 ArrayList (java.util.ArrayList)57 UserHandle (android.os.UserHandle)50 Intent (android.content.Intent)36 ComponentName (android.content.ComponentName)31 List (java.util.List)30 AppInfo (com.android.launcher3.model.data.AppInfo)28 ShortcutInfo (android.content.pm.ShortcutInfo)27 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)26 Context (android.content.Context)23 Point (android.graphics.Point)22 SessionInfo (android.content.pm.PackageInstaller.SessionInfo)19 SuppressLint (android.annotation.SuppressLint)16 LauncherAppWidgetInfo (com.android.launcher3.model.data.LauncherAppWidgetInfo)16 PackageUserKey (com.android.launcher3.util.PackageUserKey)14 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)13 IconRequestInfo (com.android.launcher3.model.data.IconRequestInfo)12 CancellationException (java.util.concurrent.CancellationException)12 PackageInstaller (android.content.pm.PackageInstaller)11