Search in sources :

Example 1 with WidgetSection

use of com.android.launcher3.widget.WidgetSections.WidgetSection in project android_packages_apps_Launcher3 by AOSPA.

the class IconCache method getTitleAndIconForApp.

/**
 * Fill in {@param infoInOut} with the corresponding icon and label.
 */
public synchronized void getTitleAndIconForApp(PackageItemInfo infoInOut, boolean useLowResIcon) {
    CacheEntry entry = getEntryForPackageLocked(infoInOut.packageName, infoInOut.user, useLowResIcon);
    applyCacheEntry(entry, infoInOut);
    if (infoInOut.widgetCategory != NO_CATEGORY) {
        WidgetSection widgetSection = WidgetSections.getWidgetSections(mContext).get(infoInOut.widgetCategory);
        infoInOut.title = mContext.getString(widgetSection.mSectionTitle);
        infoInOut.contentDescription = mPackageManager.getUserBadgedLabel(infoInOut.title, infoInOut.user);
    }
}
Also used : WidgetSection(com.android.launcher3.widget.WidgetSections.WidgetSection)

Example 2 with WidgetSection

use of com.android.launcher3.widget.WidgetSections.WidgetSection in project android_packages_apps_Launcher3 by ProtonAOSP.

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);
    }
}
Also used : WidgetSection(com.android.launcher3.widget.WidgetSections.WidgetSection) Drawable(android.graphics.drawable.Drawable) PlaceHolderIconDrawable(com.android.launcher3.icons.PlaceHolderIconDrawable)

Example 3 with WidgetSection

use of com.android.launcher3.widget.WidgetSections.WidgetSection in project android_packages_apps_404Launcher by P-404.

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);
    }
}
Also used : WidgetSection(com.android.launcher3.widget.WidgetSections.WidgetSection) Drawable(android.graphics.drawable.Drawable) PlaceHolderIconDrawable(com.android.launcher3.icons.PlaceHolderIconDrawable)

Example 4 with WidgetSection

use of com.android.launcher3.widget.WidgetSections.WidgetSection in project android_packages_apps_404Launcher by P-404.

the class WidgetSections method parseWidgetSectionsXml.

private static synchronized void parseWidgetSectionsXml(Context context) {
    SparseArray<WidgetSection> widgetSections = new SparseArray();
    Map<ComponentName, IntSet> widgetsToCategories = new ArrayMap<>();
    try (XmlResourceParser parser = context.getResources().getXml(R.xml.widget_sections)) {
        final int depth = parser.getDepth();
        int type;
        while (((type = parser.next()) != XmlPullParser.END_TAG || parser.getDepth() > depth) && type != XmlPullParser.END_DOCUMENT) {
            if ((type == XmlPullParser.START_TAG) && TAG_SECTION_NAME.equals(parser.getName())) {
                AttributeSet sectionAttributes = Xml.asAttributeSet(parser);
                WidgetSection section = new WidgetSection(context, sectionAttributes);
                final int sectionDepth = parser.getDepth();
                while (((type = parser.next()) != XmlPullParser.END_TAG || parser.getDepth() > sectionDepth) && type != XmlPullParser.END_DOCUMENT) {
                    if ((type == XmlPullParser.START_TAG) && TAG_WIDGET_NAME.equals(parser.getName())) {
                        TypedArray a = context.obtainStyledAttributes(Xml.asAttributeSet(parser), R.styleable.WidgetSections);
                        ComponentName provider = ComponentName.unflattenFromString(a.getString(R.styleable.WidgetSections_provider));
                        boolean alsoKeepInApp = a.getBoolean(R.styleable.WidgetSections_alsoKeepInApp, /* defValue= */
                        false);
                        final IntSet categories;
                        if (widgetsToCategories.containsKey(provider)) {
                            categories = widgetsToCategories.get(provider);
                        } else {
                            categories = new IntSet();
                            widgetsToCategories.put(provider, categories);
                        }
                        if (alsoKeepInApp) {
                            categories.add(NO_CATEGORY);
                        }
                        categories.add(section.mCategory);
                    }
                }
                widgetSections.put(section.mCategory, section);
            }
        }
        sWidgetSections = widgetSections;
        sWidgetsToCategories = widgetsToCategories;
    } catch (IOException | XmlPullParserException e) {
        throw new RuntimeException(e);
    }
}
Also used : XmlResourceParser(android.content.res.XmlResourceParser) IntSet(com.android.launcher3.util.IntSet) ArrayMap(android.util.ArrayMap) IOException(java.io.IOException) SparseArray(android.util.SparseArray) AttributeSet(android.util.AttributeSet) TypedArray(android.content.res.TypedArray) ComponentName(android.content.ComponentName) XmlPullParserException(org.xmlpull.v1.XmlPullParserException)

Example 5 with WidgetSection

use of com.android.launcher3.widget.WidgetSections.WidgetSection in project android_packages_apps_404Launcher by P-404.

the class IconCache method getTitleAndIconForApp.

/**
 * Fill in {@param infoInOut} with the corresponding icon and label.
 */
public synchronized void getTitleAndIconForApp(PackageItemInfo infoInOut, boolean useLowResIcon) {
    CacheEntry entry = getEntryForPackageLocked(infoInOut.packageName, infoInOut.user, useLowResIcon);
    applyCacheEntry(entry, infoInOut);
    if (infoInOut.widgetCategory != NO_CATEGORY) {
        WidgetSection widgetSection = WidgetSections.getWidgetSections(mContext).get(infoInOut.widgetCategory);
        infoInOut.title = mContext.getString(widgetSection.mSectionTitle);
        infoInOut.contentDescription = mPackageManager.getUserBadgedLabel(infoInOut.title, infoInOut.user);
    }
}
Also used : WidgetSection(com.android.launcher3.widget.WidgetSections.WidgetSection)

Aggregations

WidgetSection (com.android.launcher3.widget.WidgetSections.WidgetSection)8 ComponentName (android.content.ComponentName)4 TypedArray (android.content.res.TypedArray)4 XmlResourceParser (android.content.res.XmlResourceParser)4 Drawable (android.graphics.drawable.Drawable)4 ArrayMap (android.util.ArrayMap)4 AttributeSet (android.util.AttributeSet)4 SparseArray (android.util.SparseArray)4 PlaceHolderIconDrawable (com.android.launcher3.icons.PlaceHolderIconDrawable)4 IntSet (com.android.launcher3.util.IntSet)4 IOException (java.io.IOException)4 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)4