Search in sources :

Example 1 with ThemeData

use of com.android.launcher3.icons.ThemedIconDrawable.ThemeData in project android_packages_apps_404Launcher by P-404.

the class ThirdPartyIconProvider method getThemedIconMap.

private ArrayMap<String, ThemeData> getThemedIconMap() {
    if (mThemedIconMap != null) {
        return mThemedIconMap;
    }
    ArrayMap<String, ThemeData> map = new ArrayMap<>();
    try {
        Resources res = mContext.getResources();
        int resID = res.getIdentifier(THEMED_ICON_MAP_FILE, "xml", mContext.getPackageName());
        if (resID != 0) {
            XmlResourceParser parser = res.getXml(resID);
            final int depth = parser.getDepth();
            int type;
            while ((type = parser.next()) != XmlPullParser.START_TAG && type != XmlPullParser.END_DOCUMENT) ;
            while (((type = parser.next()) != XmlPullParser.END_TAG || parser.getDepth() > depth) && type != XmlPullParser.END_DOCUMENT) {
                if (type != XmlPullParser.START_TAG) {
                    continue;
                }
                if (TAG_ICON.equals(parser.getName())) {
                    String pkg = parser.getAttributeValue(null, ATTR_PACKAGE);
                    int iconId = parser.getAttributeResourceValue(null, ATTR_DRAWABLE, 0);
                    if (iconId != 0 && !TextUtils.isEmpty(pkg)) {
                        map.put(pkg, new ThemeData(res, iconId));
                    }
                }
            }
        }
    } catch (Exception e) {
    }
    mThemedIconMap = map;
    return mThemedIconMap;
}
Also used : ThemeData(com.android.launcher3.icons.ThemedIconDrawable.ThemeData) XmlResourceParser(android.content.res.XmlResourceParser) ArrayMap(android.util.ArrayMap) Resources(android.content.res.Resources) SuppressLint(android.annotation.SuppressLint)

Example 2 with ThemeData

use of com.android.launcher3.icons.ThemedIconDrawable.ThemeData in project android_packages_apps_404Launcher by P-404.

the class ThirdPartyIconProvider method getIcon.

@SuppressLint("WrongConstant")
@Override
public Drawable getIcon(LauncherActivityInfo launcherActivityInfo, int iconDpi) {
    ComponentKey key = new ComponentKey(launcherActivityInfo.getComponentName(), launcherActivityInfo.getUser());
    String packageName = key.componentName.getPackageName();
    IconResolver.DefaultDrawableProvider fallback = () -> super.getIcon(launcherActivityInfo, iconDpi);
    Drawable icon = ThirdPartyIconUtils.getByKey(mContext, key, iconDpi, fallback);
    icon = icon == null ? fallback.get() : icon;
    icon.setChangingConfigurations(icon.getChangingConfigurations() | CONFIG_HINT_NO_WRAP);
    if (isThemedIconEnabled(mContext)) {
        ThemeData td = getThemedIconMap().get(packageName);
        icon = td != null ? td.wrapDrawable(icon, ICON_TYPE_DEFAULT) : icon;
    }
    return icon;
}
Also used : ThemeData(com.android.launcher3.icons.ThemedIconDrawable.ThemeData) IconResolver(com.android.launcher3.icons.pack.IconResolver) ComponentKey(com.android.launcher3.util.ComponentKey) Drawable(android.graphics.drawable.Drawable) SuppressLint(android.annotation.SuppressLint)

Aggregations

SuppressLint (android.annotation.SuppressLint)2 ThemeData (com.android.launcher3.icons.ThemedIconDrawable.ThemeData)2 Resources (android.content.res.Resources)1 XmlResourceParser (android.content.res.XmlResourceParser)1 Drawable (android.graphics.drawable.Drawable)1 ArrayMap (android.util.ArrayMap)1 IconResolver (com.android.launcher3.icons.pack.IconResolver)1 ComponentKey (com.android.launcher3.util.ComponentKey)1