Search in sources :

Example 11 with PromiseAppInfo

use of com.android.launcher3.model.data.PromiseAppInfo in project android_packages_apps_Launcher3 by ProtonAOSP.

the class AllAppsList method addPromiseApp.

@Nullable
public AppInfo addPromiseApp(Context context, PackageInstallInfo installInfo, boolean loadIcon) {
    // only if not yet installed
    if (new PackageManagerHelper(context).isAppInstalled(installInfo.packageName, installInfo.user)) {
        return null;
    }
    AppInfo promiseAppInfo = new AppInfo(installInfo);
    if (loadIcon) {
        mIconCache.getTitleAndIcon(promiseAppInfo, promiseAppInfo.usingLowResIcon());
        promiseAppInfo.sectionName = mIndex.computeSectionName(promiseAppInfo.title);
    }
    data.add(promiseAppInfo);
    mDataChanged = true;
    return promiseAppInfo;
}
Also used : PackageManagerHelper(com.android.launcher3.util.PackageManagerHelper) AppInfo(com.android.launcher3.model.data.AppInfo) Nullable(androidx.annotation.Nullable)

Example 12 with PromiseAppInfo

use of com.android.launcher3.model.data.PromiseAppInfo in project android_packages_apps_404Launcher by P-404.

the class AllAppsList method addPromiseApp.

@Nullable
public AppInfo addPromiseApp(Context context, PackageInstallInfo installInfo, boolean loadIcon) {
    // only if not yet installed
    if (new PackageManagerHelper(context).isAppInstalled(installInfo.packageName, installInfo.user)) {
        return null;
    }
    AppInfo promiseAppInfo = new AppInfo(installInfo);
    if (loadIcon) {
        mIconCache.getTitleAndIcon(promiseAppInfo, promiseAppInfo.usingLowResIcon());
        promiseAppInfo.sectionName = mIndex.computeSectionName(promiseAppInfo.title);
    }
    data.add(promiseAppInfo);
    mDataChanged = true;
    return promiseAppInfo;
}
Also used : PackageManagerHelper(com.android.launcher3.util.PackageManagerHelper) AppInfo(com.android.launcher3.model.data.AppInfo) Nullable(androidx.annotation.Nullable)

Example 13 with PromiseAppInfo

use of com.android.launcher3.model.data.PromiseAppInfo in project android_packages_apps_404Launcher by P-404.

the class LoaderTask method loadAllApps.

private List<LauncherActivityInfo> loadAllApps() {
    final List<UserHandle> profiles = mUserCache.getUserProfiles();
    List<LauncherActivityInfo> allActivityList = new ArrayList<>();
    // Clear the list of apps
    mBgAllAppsList.clear();
    List<IconRequestInfo<AppInfo>> iconRequestInfos = new ArrayList<>();
    for (UserHandle user : profiles) {
        // Query for the set of apps
        final List<LauncherActivityInfo> apps = mLauncherApps.getActivityList(null, user);
        // TODO: Fix this. Only fail for the current user.
        if (apps == null || apps.isEmpty()) {
            return allActivityList;
        }
        boolean quietMode = mUserManagerState.isUserQuiet(user);
        // Create the ApplicationInfos
        for (int i = 0; i < apps.size(); i++) {
            LauncherActivityInfo app = apps.get(i);
            AppInfo appInfo = new AppInfo(app, user, quietMode);
            iconRequestInfos.add(new IconRequestInfo<>(appInfo, app, /* useLowResIcon= */
            false));
            mBgAllAppsList.add(appInfo, app, !FeatureFlags.ENABLE_BULK_ALL_APPS_ICON_LOADING.get());
        }
        allActivityList.addAll(apps);
    }
    if (FeatureFlags.PROMISE_APPS_IN_ALL_APPS.get()) {
        // get all active sessions and add them to the all apps list
        for (PackageInstaller.SessionInfo info : mSessionHelper.getAllVerifiedSessions()) {
            AppInfo promiseAppInfo = mBgAllAppsList.addPromiseApp(mApp.getContext(), PackageInstallInfo.fromInstallingState(info), !FeatureFlags.ENABLE_BULK_ALL_APPS_ICON_LOADING.get());
            if (promiseAppInfo != null) {
                iconRequestInfos.add(new IconRequestInfo<>(promiseAppInfo, /* launcherActivityInfo= */
                null, promiseAppInfo.usingLowResIcon()));
            }
        }
    }
    if (FeatureFlags.ENABLE_BULK_ALL_APPS_ICON_LOADING.get()) {
        Trace.beginSection("LoadAllAppsIconsInBulk");
        try {
            mIconCache.getTitlesAndIconsInBulk(iconRequestInfos);
            iconRequestInfos.forEach(iconRequestInfo -> mBgAllAppsList.updateSectionName(iconRequestInfo.itemInfo));
        } finally {
            Trace.endSection();
        }
    }
    mBgAllAppsList.setFlags(FLAG_QUIET_MODE_ENABLED, mUserManagerState.isAnyProfileQuietModeEnabled());
    mBgAllAppsList.setFlags(FLAG_HAS_SHORTCUT_PERMISSION, hasShortcutsPermission(mApp.getContext()));
    mBgAllAppsList.setFlags(FLAG_QUIET_MODE_CHANGE_PERMISSION, mApp.getContext().checkSelfPermission("android.permission.MODIFY_QUIET_MODE") == PackageManager.PERMISSION_GRANTED);
    mBgAllAppsList.getAndResetChangeFlag();
    return allActivityList;
}
Also used : ArrayList(java.util.ArrayList) IconRequestInfo(com.android.launcher3.model.data.IconRequestInfo) SuppressLint(android.annotation.SuppressLint) Point(android.graphics.Point) AppInfo(com.android.launcher3.model.data.AppInfo) SessionInfo(android.content.pm.PackageInstaller.SessionInfo) UserHandle(android.os.UserHandle) LauncherActivityInfo(android.content.pm.LauncherActivityInfo) PackageInstaller(android.content.pm.PackageInstaller)

Example 14 with PromiseAppInfo

use of com.android.launcher3.model.data.PromiseAppInfo in project Neo-Launcher by NeoApplications.

the class AllAppsList method updatePromiseInstallInfo.

public PromiseAppInfo updatePromiseInstallInfo(PackageInstallInfo installInfo) {
    UserHandle user = Process.myUserHandle();
    for (int i = 0; i < data.size(); i++) {
        final AppInfo appInfo = data.get(i);
        final ComponentName tgtComp = appInfo.getTargetComponent();
        if (tgtComp != null && tgtComp.getPackageName().equals(installInfo.packageName) && appInfo.user.equals(user) && appInfo instanceof PromiseAppInfo) {
            final PromiseAppInfo promiseAppInfo = (PromiseAppInfo) appInfo;
            if (installInfo.state == PackageInstallerCompat.STATUS_INSTALLING) {
                promiseAppInfo.level = installInfo.progress;
                return promiseAppInfo;
            } else if (installInfo.state == PackageInstallerCompat.STATUS_FAILED) {
                removeApp(i);
            }
        }
    }
    return null;
}
Also used : UserHandle(android.os.UserHandle) PromiseAppInfo(com.android.launcher3.PromiseAppInfo) ComponentName(android.content.ComponentName) AppInfo(com.android.launcher3.AppInfo) PromiseAppInfo(com.android.launcher3.PromiseAppInfo)

Example 15 with PromiseAppInfo

use of com.android.launcher3.model.data.PromiseAppInfo in project Neo-Launcher by NeoApplications.

the class PackageManagerHelper method startDetailsActivityForInfo.

/**
 * Starts the details activity for {@code info}
 */
public void startDetailsActivityForInfo(ItemInfo info, Rect sourceBounds, Bundle opts) {
    if (info instanceof PromiseAppInfo) {
        PromiseAppInfo promiseAppInfo = (PromiseAppInfo) info;
        mContext.startActivity(promiseAppInfo.getMarketIntent(mContext));
        return;
    }
    ComponentName componentName = null;
    if (info instanceof AppInfo) {
        componentName = ((AppInfo) info).componentName;
    } else if (info instanceof WorkspaceItemInfo) {
        componentName = info.getTargetComponent();
    } else if (info instanceof PendingAddItemInfo) {
        componentName = ((PendingAddItemInfo) info).componentName;
    } else if (info instanceof LauncherAppWidgetInfo) {
        componentName = ((LauncherAppWidgetInfo) info).providerName;
    }
    if (componentName != null) {
        try {
            mLauncherApps.showAppDetailsForProfile(componentName, info.user, sourceBounds, opts);
        } catch (SecurityException | ActivityNotFoundException e) {
            Toast.makeText(mContext, R.string.activity_not_found, Toast.LENGTH_SHORT).show();
            Log.e(TAG, "Unable to launch settings", e);
        }
    }
}
Also used : PendingAddItemInfo(com.android.launcher3.PendingAddItemInfo) ActivityNotFoundException(android.content.ActivityNotFoundException) PromiseAppInfo(com.android.launcher3.PromiseAppInfo) ComponentName(android.content.ComponentName) LauncherAppWidgetInfo(com.android.launcher3.LauncherAppWidgetInfo) AppInfo(com.android.launcher3.AppInfo) PromiseAppInfo(com.android.launcher3.PromiseAppInfo) WorkspaceItemInfo(com.android.launcher3.WorkspaceItemInfo)

Aggregations

AppInfo (com.android.launcher3.model.data.AppInfo)10 ComponentName (android.content.ComponentName)7 PromiseAppInfo (com.android.launcher3.model.data.PromiseAppInfo)7 UserHandle (android.os.UserHandle)6 PromiseAppInfo (com.android.launcher3.PromiseAppInfo)5 PackageManagerHelper (com.android.launcher3.util.PackageManagerHelper)5 SuppressLint (android.annotation.SuppressLint)4 ApplicationInfo (android.content.pm.ApplicationInfo)4 LauncherActivityInfo (android.content.pm.LauncherActivityInfo)4 PackageInstaller (android.content.pm.PackageInstaller)4 SessionInfo (android.content.pm.PackageInstaller.SessionInfo)4 Point (android.graphics.Point)4 Nullable (androidx.annotation.Nullable)4 IconRequestInfo (com.android.launcher3.model.data.IconRequestInfo)4 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)4 ArrayList (java.util.ArrayList)4 Intent (android.content.Intent)3 AppInfo (com.android.launcher3.AppInfo)3 WorkspaceItemInfo (com.android.launcher3.WorkspaceItemInfo)3 ActivityNotFoundException (android.content.ActivityNotFoundException)2