Search in sources :

Example 86 with AppInfo

use of com.android.launcher3.model.data.AppInfo in project android_packages_apps_Launcher3 by ArrowOS.

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 87 with AppInfo

use of com.android.launcher3.model.data.AppInfo in project android_packages_apps_Launcher3 by ArrowOS.

the class AllAppsList method removeApp.

private void removeApp(int index) {
    AppInfo removed = data.remove(index);
    if (removed != null) {
        mDataChanged = true;
        mRemoveListener.accept(removed);
    }
}
Also used : AppInfo(com.android.launcher3.model.data.AppInfo)

Example 88 with AppInfo

use of com.android.launcher3.model.data.AppInfo in project android_packages_apps_Launcher3 by ArrowOS.

the class AllAppsList method updateIconsAndLabels.

public void updateIconsAndLabels(HashSet<String> packages, UserHandle user) {
    for (AppInfo info : data) {
        if (info.user.equals(user) && packages.contains(info.componentName.getPackageName())) {
            mIconCache.updateTitleAndIcon(info);
            info.sectionName = mIndex.computeSectionName(info.title);
            mDataChanged = true;
        }
    }
}
Also used : AppInfo(com.android.launcher3.model.data.AppInfo)

Example 89 with AppInfo

use of com.android.launcher3.model.data.AppInfo in project android_packages_apps_Launcher3 by ArrowOS.

the class WidgetsListSearchHeaderViewHolderBinderTest method generateSampleSearchHeader.

private WidgetsListSearchHeaderEntry generateSampleSearchHeader(String appName, String packageName, int numOfWidgets) {
    PackageItemInfo appInfo = new PackageItemInfo(packageName, UserHandle.CURRENT);
    appInfo.title = appName;
    appInfo.bitmap = BitmapInfo.of(Bitmap.createBitmap(10, 10, Bitmap.Config.ALPHA_8), 0);
    return new WidgetsListSearchHeaderEntry(appInfo, /* titleSectionName= */
    "", generateWidgetItems(packageName, numOfWidgets));
}
Also used : PackageItemInfo(com.android.launcher3.model.data.PackageItemInfo) WidgetsListSearchHeaderEntry(com.android.launcher3.widget.model.WidgetsListSearchHeaderEntry)

Example 90 with AppInfo

use of com.android.launcher3.model.data.AppInfo in project android_packages_apps_Launcher3 by ArrowOS.

the class LauncherModelHelper method initializeData.

/**
 * Initializes mock data for the test.
 */
public void initializeData(String resourceName) throws Exception {
    BgDataModel bgDataModel = getBgDataModel();
    AllAppsList allAppsList = getAllAppsList();
    MODEL_EXECUTOR.submit(() -> {
        // Copy apk from resources to a local file and install from there.
        Resources resources = testContext().getResources();
        int resId = resources.getIdentifier(resourceName, "raw", testContext().getPackageName());
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(resources.openRawResource(resId)))) {
            String line;
            HashMap<String, Class> classMap = new HashMap<>();
            while ((line = reader.readLine()) != null) {
                line = line.trim();
                if (line.startsWith("#") || line.isEmpty()) {
                    continue;
                }
                String[] commands = line.split(" ");
                switch(commands[0]) {
                    case "classMap":
                        classMap.put(commands[1], Class.forName(commands[2]));
                        break;
                    case "bgItem":
                        bgDataModel.addItem(sandboxContext, (ItemInfo) initItem(classMap.get(commands[1]), commands, 2), false);
                        break;
                    case "allApps":
                        allAppsList.add((AppInfo) initItem(AppInfo.class, commands, 1), null);
                        break;
                }
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }).get();
}
Also used : InputStreamReader(java.io.InputStreamReader) HashMap(java.util.HashMap) ItemInfo(com.android.launcher3.model.data.ItemInfo) BgDataModel(com.android.launcher3.model.BgDataModel) AllAppsList(com.android.launcher3.model.AllAppsList) BufferedReader(java.io.BufferedReader) Resources(android.content.res.Resources) FileNotFoundException(java.io.FileNotFoundException) ExecutionException(java.util.concurrent.ExecutionException) AppInfo(com.android.launcher3.model.data.AppInfo)

Aggregations

AppInfo (com.android.launcher3.model.data.AppInfo)181 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)86 ItemInfo (com.android.launcher3.model.data.ItemInfo)46 ArrayList (java.util.ArrayList)46 ComponentName (android.content.ComponentName)36 AppInfo (com.android.launcher3.AppInfo)33 View (android.view.View)32 LauncherActivityInfo (android.content.pm.LauncherActivityInfo)31 Intent (android.content.Intent)30 FolderInfo (com.android.launcher3.model.data.FolderInfo)30 LauncherAppWidgetInfo (com.android.launcher3.model.data.LauncherAppWidgetInfo)30 UserHandle (android.os.UserHandle)21 PackageItemInfo (com.android.launcher3.model.data.PackageItemInfo)21 PendingAddShortcutInfo (com.android.launcher3.widget.PendingAddShortcutInfo)21 Point (android.graphics.Point)19 BubbleTextView (com.android.launcher3.BubbleTextView)19 LauncherApps (android.content.pm.LauncherApps)17 ItemInfoWithIcon (com.android.launcher3.model.data.ItemInfoWithIcon)17 PendingAddItemInfo (com.android.launcher3.PendingAddItemInfo)15 AppWidgetHostView (android.appwidget.AppWidgetHostView)14