Search in sources :

Example 71 with ComponentKey

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());
    }
}
Also used : ComponentKey(com.android.launcher3.util.ComponentKey) HashSet(java.util.HashSet)

Example 72 with ComponentKey

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));
}
Also used : AppWidgetProviderInfo(android.appwidget.AppWidgetProviderInfo) LauncherAppWidgetProviderInfo(com.android.launcher3.widget.LauncherAppWidgetProviderInfo) ComponentKey(com.android.launcher3.util.ComponentKey)

Example 73 with ComponentKey

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);
        }
    }
}
Also used : ShortcutInfo(android.content.pm.ShortcutInfo) ComponentKey(com.android.launcher3.util.ComponentKey)

Example 74 with ComponentKey

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;
}
Also used : Task(com.android.systemui.shared.recents.model.Task) CancellableTask(com.android.quickstep.util.CancellableTask) ComponentKey(com.android.launcher3.util.ComponentKey) Intent(android.content.Intent) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Example 75 with ComponentKey

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;
    }
}
Also used : Size(android.util.Size) ComponentKey(com.android.launcher3.util.ComponentKey) Nullable(androidx.annotation.Nullable)

Aggregations

ComponentKey (com.android.launcher3.util.ComponentKey)98 ComponentName (android.content.ComponentName)40 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)26 ArrayList (java.util.ArrayList)26 ShortcutInfo (android.content.pm.ShortcutInfo)21 UserHandle (android.os.UserHandle)20 HashMap (java.util.HashMap)19 ShortcutKey (com.android.launcher3.shortcuts.ShortcutKey)17 PackageUserKey (com.android.launcher3.util.PackageUserKey)17 Intent (android.content.Intent)16 HashSet (java.util.HashSet)16 Context (android.content.Context)15 ItemInfo (com.android.launcher3.model.data.ItemInfo)14 List (java.util.List)13 AppWidgetProviderInfo (android.appwidget.AppWidgetProviderInfo)12 LauncherAppWidgetInfo (com.android.launcher3.model.data.LauncherAppWidgetInfo)11 AppTarget (android.app.prediction.AppTarget)10 FixedContainerItems (com.android.launcher3.model.BgDataModel.FixedContainerItems)10 ShortcutRequest (com.android.launcher3.shortcuts.ShortcutRequest)10 QueryResult (com.android.launcher3.shortcuts.ShortcutRequest.QueryResult)10