Search in sources :

Example 86 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 87 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)

Example 88 with LauncherActivityInfo

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

the class LoaderTask method run.

public void run() {
    synchronized (this) {
        // Skip fast if we are already stopped.
        if (mStopped) {
            return;
        }
    }
    TraceHelper.beginSection(TAG);
    try (LauncherModel.LoaderTransaction transaction = mApp.getModel().beginLoader(this)) {
        TraceHelper.partitionSection(TAG, "step 1.1: loading workspace");
        loadWorkspace();
        verifyNotStopped();
        TraceHelper.partitionSection(TAG, "step 1.2: bind workspace workspace");
        mResults.bindWorkspace();
        // Notify the installer packages of packages with active installs on the first screen.
        TraceHelper.partitionSection(TAG, "step 1.3: send first screen broadcast");
        sendFirstScreenActiveInstallsBroadcast();
        // Take a break
        TraceHelper.partitionSection(TAG, "step 1 completed, wait for idle");
        waitForIdle();
        verifyNotStopped();
        // second step
        TraceHelper.partitionSection(TAG, "step 2.1: loading all apps");
        List<LauncherActivityInfo> allActivityList = loadAllApps();
        TraceHelper.partitionSection(TAG, "step 2.2: Binding all apps");
        verifyNotStopped();
        mResults.bindAllApps();
        verifyNotStopped();
        TraceHelper.partitionSection(TAG, "step 2.3: Update icon cache");
        IconCacheUpdateHandler updateHandler = mIconCache.getUpdateHandler();
        setIgnorePackages(updateHandler);
        updateHandler.updateIcons(allActivityList, LauncherActivityCachingLogic.newInstance(mApp.getContext()), mApp.getModel()::onPackageIconsUpdated);
        // Take a break
        TraceHelper.partitionSection(TAG, "step 2 completed, wait for idle");
        waitForIdle();
        verifyNotStopped();
        // third step
        TraceHelper.partitionSection(TAG, "step 3.1: loading deep shortcuts");
        loadDeepShortcuts();
        verifyNotStopped();
        TraceHelper.partitionSection(TAG, "step 3.2: bind deep shortcuts");
        mResults.bindDeepShortcuts();
        // Take a break
        TraceHelper.partitionSection(TAG, "step 3 completed, wait for idle");
        waitForIdle();
        verifyNotStopped();
        // fourth step
        TraceHelper.partitionSection(TAG, "step 4.1: loading widgets");
        List<ComponentWithLabel> allWidgetsList = mBgDataModel.widgetsModel.update(mApp, null);
        verifyNotStopped();
        TraceHelper.partitionSection(TAG, "step 4.2: Binding widgets");
        mResults.bindWidgets();
        verifyNotStopped();
        TraceHelper.partitionSection(TAG, "step 4.3: save widgets in icon cache");
        updateHandler.updateIcons(allWidgetsList, new ComponentCachingLogic(mApp.getContext(), true), mApp.getModel()::onWidgetLabelsUpdated);
        verifyNotStopped();
        TraceHelper.partitionSection(TAG, "step 5: Finish icon cache update");
        updateHandler.finish();
        transaction.commit();
    } catch (CancellationException e) {
        // Loader stopped, ignore
        TraceHelper.partitionSection(TAG, "Cancelled");
    }
    TraceHelper.endSection(TAG);
}
Also used : LauncherModel(com.android.launcher3.LauncherModel) ComponentCachingLogic(com.android.launcher3.icons.ComponentWithLabel.ComponentCachingLogic) CancellationException(java.util.concurrent.CancellationException) LauncherActivityInfo(android.content.pm.LauncherActivityInfo) IconCacheUpdateHandler(com.android.launcher3.icons.cache.IconCacheUpdateHandler) ComponentWithLabel(com.android.launcher3.icons.ComponentWithLabel)

Example 89 with LauncherActivityInfo

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

the class AllAppsList method reloadPackages.

/**
 * Add and remove icons for this package, depending on visibility.
 */
public void reloadPackages(Context context, UserHandle user) {
    for (final LauncherActivityInfo info : LauncherAppsCompat.getInstance(context).getActivityList(null, user)) {
        AppInfo applicationInfo = findAppInfo(info.getComponentName(), user);
        if (applicationInfo == null) {
            add(new AppInfo(context, info, user), info);
        }
    }
    for (int i = data.size() - 1; i >= 0; i--) {
        final AppInfo applicationInfo = data.get(i);
        if (user.equals(applicationInfo.user) && !mAppFilter.shouldShowApp(applicationInfo.componentName, applicationInfo.user)) {
            removed.add(applicationInfo);
            data.remove(i);
        }
    }
}
Also used : LauncherActivityInfo(android.content.pm.LauncherActivityInfo) AppInfo(com.android.launcher3.AppInfo) PromiseAppInfo(com.android.launcher3.PromiseAppInfo)

Example 90 with LauncherActivityInfo

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

the class AllAppsList method updatePackage.

/**
 * Add and remove icons for this package which has been updated.
 */
public void updatePackage(Context context, String packageName, UserHandle user) {
    final LauncherAppsCompat launcherApps = LauncherAppsCompat.getInstance(context);
    final List<LauncherActivityInfo> matches = launcherApps.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 {
                mIconCache.getTitleAndIcon(applicationInfo, info, true);
                applicationInfo.sectionName = mIndex.computeSectionName(applicationInfo.title);
                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);
            }
        }
    }
}
Also used : LauncherAppsCompat(com.android.launcher3.compat.LauncherAppsCompat) LauncherActivityInfo(android.content.pm.LauncherActivityInfo) AppInfo(com.android.launcher3.AppInfo) PromiseAppInfo(com.android.launcher3.PromiseAppInfo)

Aggregations

LauncherActivityInfo (android.content.pm.LauncherActivityInfo)122 LauncherApps (android.content.pm.LauncherApps)62 ArrayList (java.util.ArrayList)51 UserHandle (android.os.UserHandle)44 Intent (android.content.Intent)32 ComponentName (android.content.ComponentName)27 List (java.util.List)26 AppInfo (com.android.launcher3.model.data.AppInfo)23 ShortcutInfo (android.content.pm.ShortcutInfo)22 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)21 Context (android.content.Context)19 Point (android.graphics.Point)19 SessionInfo (android.content.pm.PackageInstaller.SessionInfo)16 SuppressLint (android.annotation.SuppressLint)14 LauncherAppWidgetInfo (com.android.launcher3.model.data.LauncherAppWidgetInfo)13 PackageManager (android.content.pm.PackageManager)12 PackageUserKey (com.android.launcher3.util.PackageUserKey)11 UserManager (android.os.UserManager)10 CancellationException (java.util.concurrent.CancellationException)10 PackageInstaller (android.content.pm.PackageInstaller)9