use of com.android.launcher3.model.PackageItemInfo in project android_packages_apps_Launcher3 by AOSPA.
the class WidgetsModel method getAllWidgetsWithoutShortcuts.
/**
* Returns a mapping of packages to their widgets without static shortcuts.
*/
public synchronized Map<PackageUserKey, List<WidgetItem>> getAllWidgetsWithoutShortcuts() {
Map<PackageUserKey, List<WidgetItem>> packagesToWidgets = new HashMap<>();
mWidgetsList.forEach((packageItemInfo, widgetsAndShortcuts) -> {
List<WidgetItem> widgets = widgetsAndShortcuts.stream().filter(item -> item.widgetInfo != null).collect(toList());
if (widgets.size() > 0) {
packagesToWidgets.put(new PackageUserKey(packageItemInfo.packageName, packageItemInfo.user), widgets);
}
});
return packagesToWidgets;
}
use of com.android.launcher3.model.PackageItemInfo in project android_packages_apps_Launcher3 by AOSPA.
the class WidgetsListHeader method setIcon.
private void setIcon(PackageItemInfo info) {
Drawable icon;
if (info.widgetCategory == NO_CATEGORY) {
icon = info.newIcon(getContext());
} else {
WidgetSection widgetSection = WidgetSections.getWidgetSections(getContext()).get(info.widgetCategory);
icon = getContext().getDrawable(widgetSection.mSectionDrawable);
}
applyDrawables(icon);
mIconDrawable = icon;
if (mIconDrawable != null) {
mIconDrawable.setVisible(/* visible= */
getWindowVisibility() == VISIBLE && isShown(), /* restart= */
false);
}
}
use of com.android.launcher3.model.PackageItemInfo in project android_packages_apps_Launcher3 by AOSPA.
the class WidgetsListHeader method applyIconAndLabel.
@UiThread
private void applyIconAndLabel(WidgetsListSearchHeaderEntry entry) {
PackageItemInfo info = entry.mPkgItem;
setIcon(info);
setTitles(entry);
setExpanded(entry.isWidgetListShown());
super.setTag(info);
verifyHighRes();
}
use of com.android.launcher3.model.PackageItemInfo in project android_packages_apps_Launcher3 by ArrowOS.
the class WidgetsModel method getAllWidgetsWithoutShortcuts.
/**
* Returns a mapping of packages to their widgets without static shortcuts.
*/
public synchronized Map<PackageUserKey, List<WidgetItem>> getAllWidgetsWithoutShortcuts() {
Map<PackageUserKey, List<WidgetItem>> packagesToWidgets = new HashMap<>();
mWidgetsList.forEach((packageItemInfo, widgetsAndShortcuts) -> {
List<WidgetItem> widgets = widgetsAndShortcuts.stream().filter(item -> item.widgetInfo != null).collect(toList());
if (widgets.size() > 0) {
packagesToWidgets.put(new PackageUserKey(packageItemInfo.packageName, packageItemInfo.user), widgets);
}
});
return packagesToWidgets;
}
use of com.android.launcher3.model.PackageItemInfo in project android_packages_apps_Launcher3 by ArrowOS.
the class WidgetsModel method setWidgetsAndShortcuts.
private synchronized void setWidgetsAndShortcuts(ArrayList<WidgetItem> rawWidgetsShortcuts, LauncherAppState app, @Nullable PackageUserKey packageUser) {
if (DEBUG) {
Log.d(TAG, "addWidgetsAndShortcuts, widgetsShortcuts#=" + rawWidgetsShortcuts.size());
}
// Temporary cache for {@link PackageItemInfos} to avoid having to go through
// {@link mPackageItemInfos} to locate the key to be used for {@link #mWidgetsList}
PackageItemInfoCache packageItemInfoCache = new PackageItemInfoCache();
if (packageUser == null) {
// Clear the list if this is an update on all widgets and shortcuts.
mWidgetsList.clear();
} else {
// Otherwise, only clear the widgets and shortcuts for the changed package.
mWidgetsList.remove(packageItemInfoCache.getOrCreate(packageUser));
}
// add and update.
mWidgetsList.putAll(rawWidgetsShortcuts.stream().filter(new WidgetValidityCheck(app)).flatMap(widgetItem -> getPackageUserKeys(app.getContext(), widgetItem).stream().map(key -> new Pair<>(packageItemInfoCache.getOrCreate(key), widgetItem))).collect(groupingBy(pair -> pair.first, mapping(pair -> pair.second, toList()))));
// Update each package entry
IconCache iconCache = app.getIconCache();
for (PackageItemInfo p : packageItemInfoCache.values()) {
iconCache.getTitleAndIconForApp(p, true);
}
}
Aggregations