Search in sources :

Example 1 with PackageItemInfo

use of com.android.launcher3.model.data.PackageItemInfo in project android_packages_apps_Launcher3 by crdroidandroid.

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 -> new PackageUserKey(entry.packageName, entry.user), entry -> entry));
    for (WidgetsListBaseEntry visibleEntry : mVisibleEntries) {
        PackageUserKey key = new PackageUserKey(visibleEntry.mPkgItem.packageName, visibleEntry.mPkgItem.user);
        PackageItemInfo packageItemInfo = packagesInfo.get(key);
        if (packageItemInfo != null && !visibleEntry.mPkgItem.title.equals(packageItemInfo.title)) {
            return true;
        }
    }
    return false;
}
Also used : IntStream(java.util.stream.IntStream) Context(android.content.Context) Rect(android.graphics.Rect) Arrays(java.util.Arrays) NonNull(androidx.annotation.NonNull) LabelComparator(com.android.launcher3.util.LabelComparator) IconCache(com.android.launcher3.icons.IconCache) OptionalInt(java.util.OptionalInt) Process(android.os.Process) PackageItemInfo(com.android.launcher3.model.data.PackageItemInfo) ArrayList(java.util.ArrayList) WidgetPreviewLoadedCallback(com.android.launcher3.widget.WidgetPreviewLoader.WidgetPreviewLoadedCallback) CachingWidgetPreviewLoader(com.android.launcher3.widget.CachingWidgetPreviewLoader) BaseActivity(com.android.launcher3.BaseActivity) WidgetItem(com.android.launcher3.model.WidgetItem) Map(java.util.Map) View(android.view.View) ViewHolder(androidx.recyclerview.widget.RecyclerView.ViewHolder) RecyclerView(androidx.recyclerview.widget.RecyclerView) Log(android.util.Log) Launcher(com.android.launcher3.Launcher) WidgetsListHeaderEntry(com.android.launcher3.widget.model.WidgetsListHeaderEntry) LayoutInflater(android.view.LayoutInflater) Adapter(androidx.recyclerview.widget.RecyclerView.Adapter) WidgetsListContentEntry(com.android.launcher3.widget.model.WidgetsListContentEntry) Predicate(java.util.function.Predicate) WidgetCell(com.android.launcher3.widget.WidgetCell) LAUNCHER_WIDGETSTRAY_APP_EXPANDED(com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_WIDGETSTRAY_APP_EXPANDED) PackageUserKey(com.android.launcher3.util.PackageUserKey) DatabaseWidgetPreviewLoader(com.android.launcher3.widget.DatabaseWidgetPreviewLoader) WidgetsListSearchHeaderEntry(com.android.launcher3.widget.model.WidgetsListSearchHeaderEntry) Collectors(java.util.stream.Collectors) ViewGroup(android.view.ViewGroup) ViewHolderBinder(com.android.launcher3.recyclerview.ViewHolderBinder) DeviceProfile(com.android.launcher3.DeviceProfile) SparseArray(android.util.SparseArray) WidgetSizes(com.android.launcher3.widget.util.WidgetSizes) List(java.util.List) Nullable(androidx.annotation.Nullable) WidgetsListBaseEntry(com.android.launcher3.widget.model.WidgetsListBaseEntry) R(com.android.launcher3.R) TableRow(android.widget.TableRow) LayoutParams(androidx.recyclerview.widget.RecyclerView.LayoutParams) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) Comparator(java.util.Comparator) OnLongClickListener(android.view.View.OnLongClickListener) Size(android.util.Size) OnClickListener(android.view.View.OnClickListener) WidgetsListBaseEntry(com.android.launcher3.widget.model.WidgetsListBaseEntry) PackageItemInfo(com.android.launcher3.model.data.PackageItemInfo) PackageUserKey(com.android.launcher3.util.PackageUserKey) WidgetsListHeaderEntry(com.android.launcher3.widget.model.WidgetsListHeaderEntry)

Example 2 with PackageItemInfo

use of com.android.launcher3.model.data.PackageItemInfo in project android_packages_apps_Launcher3 by crdroidandroid.

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();
}
Also used : PackageItemInfo(com.android.launcher3.model.data.PackageItemInfo) UiThread(androidx.annotation.UiThread)

Example 3 with PackageItemInfo

use of com.android.launcher3.model.data.PackageItemInfo in project android_packages_apps_Launcher3 by crdroidandroid.

the class WidgetsListHeader method setIcon.

private void setIcon(PackageItemInfo info) {
    Drawable icon;
    switch(info.category) {
        case PackageItemInfo.CONVERSATIONS:
            icon = getContext().getDrawable(R.drawable.ic_conversations_widget_category);
            break;
        default:
            icon = info.newIcon(getContext());
    }
    applyDrawables(icon);
    mIconDrawable = icon;
    if (mIconDrawable != null) {
        mIconDrawable.setVisible(/* visible= */
        getWindowVisibility() == VISIBLE && isShown(), /* restart= */
        false);
    }
}
Also used : Drawable(android.graphics.drawable.Drawable) PlaceHolderIconDrawable(com.android.launcher3.icons.PlaceHolderIconDrawable)

Example 4 with PackageItemInfo

use of com.android.launcher3.model.data.PackageItemInfo in project android_packages_apps_Launcher3 by crdroidandroid.

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();
}
Also used : PackageItemInfo(com.android.launcher3.model.data.PackageItemInfo) UiThread(androidx.annotation.UiThread)

Example 5 with PackageItemInfo

use of com.android.launcher3.model.data.PackageItemInfo in project android_packages_apps_Launcher3 by crdroidandroid.

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(new WidgetPackageOrCategoryKey(packageUser)));
    }
    // add and update.
    mWidgetsList.putAll(rawWidgetsShortcuts.stream().filter(new WidgetValidityCheck(app)).collect(Collectors.groupingBy(item -> packageItemInfoCache.getOrCreate(getWidgetPackageOrCategoryKey(item)))));
    // Update each package entry
    IconCache iconCache = app.getIconCache();
    for (PackageItemInfo p : packageItemInfoCache.values()) {
        iconCache.getTitleAndIconForApp(p, true);
    }
}
Also used : IconCache(com.android.launcher3.icons.IconCache) PackageItemInfo(com.android.launcher3.model.data.PackageItemInfo)

Aggregations

PackageItemInfo (com.android.launcher3.model.data.PackageItemInfo)17 WidgetsListContentEntry (com.android.launcher3.widget.model.WidgetsListContentEntry)7 WidgetsListHeaderEntry (com.android.launcher3.widget.model.WidgetsListHeaderEntry)7 WidgetItem (com.android.launcher3.model.WidgetItem)6 WidgetsListBaseEntry (com.android.launcher3.widget.model.WidgetsListBaseEntry)4 ArrayList (java.util.ArrayList)4 IconCache (com.android.launcher3.icons.IconCache)3 List (java.util.List)3 Map (java.util.Map)3 ComponentName (android.content.ComponentName)2 Context (android.content.Context)2 Log (android.util.Log)2 Nullable (androidx.annotation.Nullable)2 UiThread (androidx.annotation.UiThread)2 ArrayMap (androidx.collection.ArrayMap)2 AlphabeticIndexCompat (com.android.launcher3.compat.AlphabeticIndexCompat)2 ShortcutConfigActivityInfo.queryList (com.android.launcher3.pm.ShortcutConfigActivityInfo.queryList)2 PackageUserKey (com.android.launcher3.util.PackageUserKey)2 Arrays (java.util.Arrays)2 HashMap (java.util.HashMap)2