use of com.android.launcher3.model.data.PackageItemInfo in project android_packages_apps_Launcher3 by ArrowOS.
the class WidgetsModel method getWidgetsListForPicker.
/**
* Returns a list of {@link WidgetsListBaseEntry}. All {@link WidgetItem} in a single row
* are sorted (based on label and user), but the overall list of
* {@link WidgetsListBaseEntry}s is not sorted. This list is sorted at the UI when using
* {@link WidgetsDiffReporter}
*
* @see com.android.launcher3.widget.picker.WidgetsListAdapter#setWidgets(List)
*/
public synchronized ArrayList<WidgetsListBaseEntry> getWidgetsListForPicker(Context context) {
ArrayList<WidgetsListBaseEntry> result = new ArrayList<>();
AlphabeticIndexCompat indexer = new AlphabeticIndexCompat(context);
for (Map.Entry<PackageItemInfo, List<WidgetItem>> entry : mWidgetsList.entrySet()) {
PackageItemInfo pkgItem = entry.getKey();
List<WidgetItem> widgetItems = entry.getValue();
String sectionName = (pkgItem.title == null) ? "" : indexer.computeSectionName(pkgItem.title);
result.add(new WidgetsListHeaderEntry(pkgItem, sectionName, widgetItems));
result.add(new WidgetsListContentEntry(pkgItem, sectionName, widgetItems));
}
return result;
}
use of com.android.launcher3.model.data.PackageItemInfo in project android_packages_apps_Launcher3 by ArrowOS.
the class WidgetsListAdapter method shouldClearVisibleEntries.
/**
* Returns {@code true} if there is a change in {@link #mAllEntries} that results in an
* invalidation of {@link #mVisibleEntries}. e.g. there is change in the device language.
*/
private boolean shouldClearVisibleEntries() {
Map<PackageUserKey, PackageItemInfo> packagesInfo = mAllEntries.stream().filter(entry -> entry instanceof WidgetsListHeaderEntry).map(entry -> entry.mPkgItem).collect(Collectors.toMap(entry -> PackageUserKey.fromPackageItemInfo(entry), entry -> entry));
for (WidgetsListBaseEntry visibleEntry : mVisibleEntries) {
PackageUserKey key = PackageUserKey.fromPackageItemInfo(visibleEntry.mPkgItem);
PackageItemInfo packageItemInfo = packagesInfo.get(key);
if (packageItemInfo != null && !visibleEntry.mPkgItem.title.equals(packageItemInfo.title)) {
return true;
}
}
return false;
}
use of com.android.launcher3.model.data.PackageItemInfo in project android_packages_apps_Launcher3 by ArrowOS.
the class WidgetsListHeader method applyIconAndLabel.
@UiThread
private void applyIconAndLabel(WidgetsListHeaderEntry entry) {
PackageItemInfo info = entry.mPkgItem;
setIcon(info);
setTitles(entry);
setExpanded(entry.isWidgetListShown());
super.setTag(info);
verifyHighRes();
}
use of com.android.launcher3.model.data.PackageItemInfo in project android_packages_apps_Launcher3 by ArrowOS.
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.data.PackageItemInfo in project android_packages_apps_Launcher3 by ArrowOS.
the class SearchActionItemInfo method createWorkspaceItem.
/**
* Creates a {@link WorkspaceItemInfo} coorsponding to search action to be stored in launcher db
*/
public WorkspaceItemInfo createWorkspaceItem(LauncherModel model) {
WorkspaceItemInfo info = new WorkspaceItemInfo();
info.title = title;
info.bitmap = bitmap;
info.intent = mIntent;
if (hasFlags(FLAG_SHOULD_START_FOR_RESULT)) {
info.options |= WorkspaceItemInfo.FLAG_START_FOR_RESULT;
}
model.enqueueModelUpdateTask(new BaseModelUpdateTask() {
@Override
public void execute(LauncherAppState app, BgDataModel dataModel, AllAppsList apps) {
model.updateAndBindWorkspaceItem(() -> {
PackageItemInfo pkgInfo = new PackageItemInfo(getIntentPackageName(), user);
app.getIconCache().getTitleAndIconForApp(pkgInfo, false);
try (LauncherIcons li = LauncherIcons.obtain(app.getContext())) {
info.bitmap = li.badgeBitmap(info.bitmap.icon, pkgInfo.bitmap);
}
return info;
});
}
});
return info;
}
Aggregations