use of com.android.launcher3.util.PackageUserKey in project android_packages_apps_Launcher3 by ArrowOS.
the class LauncherModel method onUpdateSessionDisplay.
/**
* Updates the icons and label of all pending icons for the provided package name.
*/
@Override
public void onUpdateSessionDisplay(PackageUserKey key, PackageInstaller.SessionInfo info) {
mApp.getIconCache().updateSessionCache(key, info);
HashSet<String> packages = new HashSet<>();
packages.add(key.mPackageName);
enqueueModelUpdateTask(new CacheDataUpdatedTask(CacheDataUpdatedTask.OP_SESSION_UPDATE, key.mUser, packages));
}
use of com.android.launcher3.util.PackageUserKey in project android_packages_apps_Launcher3 by ArrowOS.
the class WidgetsBottomSheet method onWidgetsBound.
@Override
public void onWidgetsBound() {
List<WidgetItem> widgets = mActivityContext.getPopupDataProvider().getWidgetsForPackageUser(new PackageUserKey(mOriginalItemInfo.getTargetComponent().getPackageName(), mOriginalItemInfo.user));
TableLayout widgetsTable = findViewById(R.id.widgets_table);
widgetsTable.removeAllViews();
WidgetsTableUtils.groupWidgetItemsIntoTableWithReordering(widgets, mMaxHorizontalSpan).forEach(row -> {
TableRow tableRow = new TableRow(getContext());
tableRow.setGravity(Gravity.TOP);
row.forEach(widgetItem -> {
WidgetCell widget = addItemCell(tableRow);
widget.applyFromCellItem(widgetItem);
});
widgetsTable.addView(tableRow);
});
}
use of com.android.launcher3.util.PackageUserKey in project android_packages_apps_Launcher3 by ArrowOS.
the class WidgetsPredictionUpdateTask method execute.
/**
* Uses the app predication result to infer widgets that the user may want to use.
*
* <p>The algorithm uses the app prediction ranking to create a widgets ranking which only
* includes one widget per app and excludes widgets that have already been added to the
* workspace.
*/
@Override
public void execute(LauncherAppState appState, BgDataModel dataModel, AllAppsList apps) {
Set<ComponentKey> widgetsInWorkspace = dataModel.appWidgets.stream().map(widget -> new ComponentKey(widget.providerName, widget.user)).collect(Collectors.toSet());
Map<PackageUserKey, List<WidgetItem>> allWidgets = dataModel.widgetsModel.getAllWidgetsWithoutShortcuts();
FixedContainerItems fixedContainerItems = mPredictorState.items;
fixedContainerItems.items.clear();
if (FeatureFlags.ENABLE_LOCAL_RECOMMENDED_WIDGETS_FILTER.get()) {
for (AppTarget app : mTargets) {
PackageUserKey packageUserKey = new PackageUserKey(app.getPackageName(), app.getUser());
if (allWidgets.containsKey(packageUserKey)) {
List<WidgetItem> notAddedWidgets = allWidgets.get(packageUserKey).stream().filter(item -> !widgetsInWorkspace.contains(new ComponentKey(item.componentName, item.user))).collect(Collectors.toList());
if (notAddedWidgets.size() > 0) {
// Even an apps have more than one widgets, we only include one widget.
fixedContainerItems.items.add(new PendingAddWidgetInfo(notAddedWidgets.get(0).widgetInfo, CONTAINER_WIDGETS_PREDICTION));
}
}
}
} else {
Map<ComponentKey, WidgetItem> widgetItems = allWidgets.values().stream().flatMap(List::stream).distinct().collect(Collectors.toMap(widget -> (ComponentKey) widget, widget -> widget));
for (AppTarget app : mTargets) {
if (TextUtils.isEmpty(app.getClassName())) {
continue;
}
ComponentKey targetWidget = new ComponentKey(new ComponentName(app.getPackageName(), app.getClassName()), app.getUser());
if (widgetItems.containsKey(targetWidget)) {
fixedContainerItems.items.add(new PendingAddWidgetInfo(widgetItems.get(targetWidget).widgetInfo, CONTAINER_WIDGETS_PREDICTION));
}
}
}
bindExtraContainerItems(fixedContainerItems);
// Don't store widgets prediction to disk because it is not used frequently.
}
use of com.android.launcher3.util.PackageUserKey in project android_packages_apps_Launcher3 by ArrowOS.
the class PopupDataProvider method onNotificationPosted.
@Override
public void onNotificationPosted(PackageUserKey postedPackageUserKey, NotificationKeyData notificationKey) {
DotInfo dotInfo = mPackageUserToDotInfos.get(postedPackageUserKey);
if (dotInfo == null) {
dotInfo = new DotInfo();
mPackageUserToDotInfos.put(postedPackageUserKey, dotInfo);
}
if (dotInfo.addOrUpdateNotificationKey(notificationKey)) {
updateNotificationDots(postedPackageUserKey::equals);
}
}
use of com.android.launcher3.util.PackageUserKey in project android_packages_apps_Launcher3 by ArrowOS.
the class PopupDataProvider method onNotificationRemoved.
@Override
public void onNotificationRemoved(PackageUserKey removedPackageUserKey, NotificationKeyData notificationKey) {
DotInfo oldDotInfo = mPackageUserToDotInfos.get(removedPackageUserKey);
if (oldDotInfo != null && oldDotInfo.removeNotificationKey(notificationKey)) {
if (oldDotInfo.getNotificationKeys().size() == 0) {
mPackageUserToDotInfos.remove(removedPackageUserKey);
}
updateNotificationDots(removedPackageUserKey::equals);
trimNotifications(mPackageUserToDotInfos);
}
}
Aggregations