use of com.android.launcher3.util.ComponentKey in project android_packages_apps_Launcher3 by crdroidandroid.
the class PinnedAppsAdapter method update.
private void update(ItemInfo info, Function<ComponentKey, Boolean> op) {
ComponentKey key = new ComponentKey(info.getTargetComponent(), info.user);
if (op.apply(key)) {
createFilteredAppsList();
Set<ComponentKey> copy = new HashSet<>(mPinnedApps);
Executors.MODEL_EXECUTOR.submit(() -> mPrefs.edit().putStringSet(PINNED_APPS_KEY, copy.stream().map(this::encode).collect(Collectors.toSet())).apply());
}
}
use of com.android.launcher3.util.ComponentKey in project android_packages_apps_Launcher3 by crdroidandroid.
the class LauncherPreviewRenderer method inflateAndAddWidgets.
private void inflateAndAddWidgets(LauncherAppWidgetInfo info, Map<ComponentKey, AppWidgetProviderInfo> widgetProviderInfoMap) {
if (widgetProviderInfoMap == null) {
return;
}
AppWidgetProviderInfo providerInfo = widgetProviderInfoMap.get(new ComponentKey(info.providerName, info.user));
if (providerInfo == null) {
return;
}
inflateAndAddWidgets(info, LauncherAppWidgetProviderInfo.fromProviderInfo(getApplicationContext(), providerInfo));
}
use of com.android.launcher3.util.ComponentKey in project android_packages_apps_Launcher3 by crdroidandroid.
the class BgDataModel method updateDeepShortcutCounts.
/**
* Clear all the deep shortcut counts for the given package, and re-add the new shortcut counts.
*/
public synchronized void updateDeepShortcutCounts(String packageName, UserHandle user, List<ShortcutInfo> shortcuts) {
if (packageName != null) {
Iterator<ComponentKey> keysIter = deepShortcutMap.keySet().iterator();
while (keysIter.hasNext()) {
ComponentKey next = keysIter.next();
if (next.componentName.getPackageName().equals(packageName) && next.user.equals(user)) {
keysIter.remove();
}
}
}
// Now add the new shortcuts to the map.
for (ShortcutInfo shortcut : shortcuts) {
boolean shouldShowInContainer = shortcut.isEnabled() && (shortcut.isDeclaredInManifest() || shortcut.isDynamic()) && shortcut.getActivity() != null;
if (shouldShowInContainer) {
ComponentKey targetComponent = new ComponentKey(shortcut.getActivity(), shortcut.getUserHandle());
Integer previousCount = deepShortcutMap.get(targetComponent);
deepShortcutMap.put(targetComponent, previousCount == null ? 1 : previousCount + 1);
}
}
}
use of com.android.launcher3.util.ComponentKey in project android_packages_apps_Launcher3 by crdroidandroid.
the class TaskView method getItemInfo.
/**
* Builds proto for logging
*/
public WorkspaceItemInfo getItemInfo() {
final Task task = getTask();
ComponentKey componentKey = TaskUtils.getLaunchComponentKeyForTask(task.key);
WorkspaceItemInfo stubInfo = new WorkspaceItemInfo();
stubInfo.itemType = LauncherSettings.Favorites.ITEM_TYPE_TASK;
stubInfo.container = LauncherSettings.Favorites.CONTAINER_TASKSWITCHER;
stubInfo.user = componentKey.user;
stubInfo.intent = new Intent().setComponent(componentKey.componentName);
stubInfo.title = task.title;
stubInfo.screenId = getRecentsView().indexOfChild(this);
return stubInfo;
}
use of com.android.launcher3.util.ComponentKey in project android_packages_apps_Launcher3 by crdroidandroid.
the class CachingWidgetPreviewLoader method putCacheResult.
/**
* Puts the result in the cache for the item and size. Returns the value previously in the
* cache, or null if there was none.
*/
@Nullable
private CacheResult putCacheResult(@NonNull WidgetItem item, @NonNull Size previewSize, @Nullable CacheResult cacheResult) {
ComponentKey key = toComponentKey(item);
synchronized (mCache) {
Map<Size, CacheResult> cacheResults = mCache.getOrDefault(key, new ArrayMap<>());
CacheResult previous;
if (cacheResult == null) {
previous = cacheResults.remove(previewSize);
if (cacheResults.isEmpty()) {
mCache.remove(key);
} else {
previous = cacheResults.put(previewSize, cacheResult);
mCache.put(key, cacheResults);
}
} else {
previous = cacheResults.put(previewSize, cacheResult);
mCache.put(key, cacheResults);
}
return previous;
}
}
Aggregations