Search in sources :

Example 11 with AppInfo

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

the class LauncherModel method dumpState.

public void dumpState(String prefix, FileDescriptor fd, PrintWriter writer, String[] args) {
    if (args.length > 0 && TextUtils.equals(args[0], "--all")) {
        writer.println(prefix + "All apps list: size=" + mBgAllAppsList.data.size());
        for (AppInfo info : mBgAllAppsList.data) {
            writer.println(prefix + "   title=\"" + info.title + "\" bitmapIcon=" + info.bitmap.icon + " componentName=" + info.componentName.getPackageName());
        }
        writer.println();
    }
    mModelDelegate.dump(prefix, fd, writer, args);
    mBgDataModel.dump(prefix, fd, writer, args);
}
Also used : AppInfo(com.android.launcher3.model.data.AppInfo)

Example 12 with AppInfo

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

the class DefaultAppSearchAlgorithm method getTitleMatchResult.

/**
 * Filters {@link AppInfo}s matching specified query
 */
@AnyThread
public static ArrayList<AdapterItem> getTitleMatchResult(List<AppInfo> apps, String query) {
    // Do an intersection of the words in the query and each title, and filter out all the
    // apps that don't match all of the words in the query.
    final String queryTextLower = query.toLowerCase();
    final ArrayList<AdapterItem> result = new ArrayList<>();
    StringMatcherUtility.StringMatcher matcher = StringMatcherUtility.StringMatcher.getInstance();
    int resultCount = 0;
    int total = apps.size();
    for (int i = 0; i < total && resultCount < MAX_RESULTS_COUNT; i++) {
        AppInfo info = apps.get(i);
        if (StringMatcherUtility.matches(queryTextLower, info.title.toString(), matcher)) {
            AdapterItem appItem = AdapterItem.asApp(resultCount, "", info, resultCount);
            result.add(appItem);
            resultCount++;
        }
    }
    return result;
}
Also used : StringMatcherUtility(com.android.launcher3.search.StringMatcherUtility) ArrayList(java.util.ArrayList) AdapterItem(com.android.launcher3.allapps.AllAppsGridAdapter.AdapterItem) AppInfo(com.android.launcher3.model.data.AppInfo) AnyThread(androidx.annotation.AnyThread)

Example 13 with AppInfo

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

the class AlphabeticalAppsList method onAppsUpdated.

/**
 * Updates internals when the set of apps are updated.
 */
@Override
public void onAppsUpdated() {
    // Sort the list of apps
    mApps.clear();
    for (AppInfo app : mAllAppsStore.getApps()) {
        if (mItemFilter == null || mItemFilter.matches(app, null) || hasFilter()) {
            mApps.add(app);
        }
    }
    Collections.sort(mApps, mAppNameComparator);
    // As a special case for some languages (currently only Simplified Chinese), we may need to
    // coalesce sections
    Locale curLocale = mLauncher.getResources().getConfiguration().locale;
    boolean localeRequiresSectionSorting = curLocale.equals(Locale.SIMPLIFIED_CHINESE);
    if (localeRequiresSectionSorting) {
        // Compute the section headers. We use a TreeMap with the section name comparator to
        // ensure that the sections are ordered when we iterate over it later
        TreeMap<String, ArrayList<AppInfo>> sectionMap = new TreeMap<>(new LabelComparator());
        for (AppInfo info : mApps) {
            // Add the section to the cache
            String sectionName = info.sectionName;
            // Add it to the mapping
            ArrayList<AppInfo> sectionApps = sectionMap.get(sectionName);
            if (sectionApps == null) {
                sectionApps = new ArrayList<>();
                sectionMap.put(sectionName, sectionApps);
            }
            sectionApps.add(info);
        }
        // Add each of the section apps to the list in order
        mApps.clear();
        for (Map.Entry<String, ArrayList<AppInfo>> entry : sectionMap.entrySet()) {
            mApps.addAll(entry.getValue());
        }
    }
    // Recompose the set of adapter items from the current set of apps
    if (mSearchResults == null) {
        updateAdapterItems();
    }
}
Also used : Locale(java.util.Locale) ArrayList(java.util.ArrayList) LabelComparator(com.android.launcher3.util.LabelComparator) TreeMap(java.util.TreeMap) TreeMap(java.util.TreeMap) Map(java.util.Map) AppInfo(com.android.launcher3.model.data.AppInfo)

Example 14 with AppInfo

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

the class PackageInstallStateChangedTask method execute.

@Override
public void execute(LauncherAppState app, BgDataModel dataModel, AllAppsList apps) {
    if (mInstallInfo.state == PackageInstallInfo.STATUS_INSTALLED) {
        try {
            // For instant apps we do not get package-add. Use setting events to update
            // any pinned icons.
            ApplicationInfo ai = app.getContext().getPackageManager().getApplicationInfo(mInstallInfo.packageName, 0);
            if (InstantAppResolver.newInstance(app.getContext()).isInstantApp(ai)) {
                app.getModel().onPackageAdded(ai.packageName, mInstallInfo.user);
            }
        } catch (PackageManager.NameNotFoundException e) {
        // Ignore
        }
        // Ignore install success events as they are handled by Package add events.
        return;
    }
    synchronized (apps) {
        List<AppInfo> updatedAppInfos = apps.updatePromiseInstallInfo(mInstallInfo);
        if (!updatedAppInfos.isEmpty()) {
            for (AppInfo appInfo : updatedAppInfos) {
                scheduleCallbackTask(c -> c.bindIncrementalDownloadProgressUpdated(appInfo));
            }
        }
        bindApplicationsIfNeeded();
    }
    synchronized (dataModel) {
        final HashSet<ItemInfo> updates = new HashSet<>();
        dataModel.forAllWorkspaceItemInfos(mInstallInfo.user, si -> {
            if (si.hasPromiseIconUi() && mInstallInfo.packageName.equals(si.getTargetPackage())) {
                si.setProgressLevel(mInstallInfo);
                updates.add(si);
            }
        });
        for (LauncherAppWidgetInfo widget : dataModel.appWidgets) {
            if (widget.providerName.getPackageName().equals(mInstallInfo.packageName)) {
                widget.installProgress = mInstallInfo.progress;
                updates.add(widget);
            }
        }
        if (!updates.isEmpty()) {
            scheduleCallbackTask(callbacks -> callbacks.bindRestoreItemsChange(updates));
        }
    }
}
Also used : PackageManager(android.content.pm.PackageManager) ItemInfo(com.android.launcher3.model.data.ItemInfo) ApplicationInfo(android.content.pm.ApplicationInfo) LauncherAppWidgetInfo(com.android.launcher3.model.data.LauncherAppWidgetInfo) AppInfo(com.android.launcher3.model.data.AppInfo) HashSet(java.util.HashSet)

Example 15 with AppInfo

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

the class FolderNameProviderTest method setUp.

@Before
public void setUp() {
    mContext = RuntimeEnvironment.application;
    mItem1 = new WorkspaceItemInfo(new AppInfo(new ComponentName("a.b.c", "a.b.c/a.b.c.d"), "title1", UserHandle.of(10), new Intent().setComponent(new ComponentName("a.b.c", "a.b.c/a.b.c.d"))));
    mItem2 = new WorkspaceItemInfo(new AppInfo(new ComponentName("a.b.c", "a.b.c/a.b.c.d"), "title2", UserHandle.of(10), new Intent().setComponent(new ComponentName("a.b.c", "a.b.c/a.b.c.d"))));
}
Also used : ComponentName(android.content.ComponentName) Intent(android.content.Intent) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) AppInfo(com.android.launcher3.model.data.AppInfo) Before(org.junit.Before)

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