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);
}
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;
}
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();
}
}
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));
}
}
}
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"))));
}
Aggregations