Search in sources :

Example 1 with IconResolver

use of com.android.launcher3.icons.pack.IconResolver in project android_packages_apps_404Launcher by P-404.

the class ThirdPartyDrawableFactory method newIcon.

@Override
public FastBitmapDrawable newIcon(Context context, ItemInfoWithIcon info) {
    if (info != null && info.getTargetComponent() != null && info.itemType == ITEM_TYPE_APPLICATION) {
        ComponentKey key = new ComponentKey(info.getTargetComponent(), info.user);
        IconResolver resolver = mManager.resolve(key);
        mCalendars.setIsDynamic(key, (resolver != null && resolver.isCalendar()) || info.getTargetComponent().getPackageName().equals(DynamicCalendar.CALENDAR));
        if (Utilities.ATLEAST_OREO) {
            if (resolver != null) {
                if (resolver.isClock()) {
                    Drawable drawable = resolver.getIcon(0, () -> null);
                    if (drawable != null) {
                        FastBitmapDrawable fb = mCustomClockDrawer.drawIcon(info, drawable, resolver.clockData());
                        fb.setIsDisabled(info.isDisabled());
                        return fb;
                    }
                }
            } else if (info.getTargetComponent().equals(DynamicClock.DESK_CLOCK)) {
                return mDynamicClockDrawer.drawIcon(info);
            }
        }
    }
    return super.newIcon(context, info);
}
Also used : FastBitmapDrawable(com.android.launcher3.icons.FastBitmapDrawable) IconResolver(com.android.launcher3.icons.pack.IconResolver) ComponentKey(com.android.launcher3.util.ComponentKey) FastBitmapDrawable(com.android.launcher3.icons.FastBitmapDrawable) Drawable(android.graphics.drawable.Drawable)

Example 2 with IconResolver

use of com.android.launcher3.icons.pack.IconResolver in project android_packages_apps_404Launcher by P-404.

the class ThirdPartyIconUtils method getByKey.

static Drawable getByKey(Context context, ComponentKey key, int iconDpi, IconResolver.DefaultDrawableProvider fallback) {
    IconResolver resolver = IconPackManager.get(context).resolve(key);
    Drawable icon = resolver == null ? null : resolver.getIcon(iconDpi, fallback);
    if (Utilities.ATLEAST_OREO) {
        // Icon pack clocks go first.
        if (icon != null && resolver.isClock()) {
            return CustomClock.getClock(context, icon, resolver.clockData());
        }
        // Google Clock goes second, but only if the icon pack does not override it.
        if (icon == null && key.componentName.equals(DynamicClock.DESK_CLOCK)) {
            return DynamicClock.getClock(context, iconDpi);
        }
    }
    // Google Calendar is checked last. Only applied if the icon pack does not override it.
    if (icon == null && key.componentName.getPackageName().equals(DynamicCalendar.CALENDAR)) {
        return DynamicCalendar.load(context, key.componentName, iconDpi);
    }
    return icon;
}
Also used : IconResolver(com.android.launcher3.icons.pack.IconResolver) Drawable(android.graphics.drawable.Drawable)

Aggregations

Drawable (android.graphics.drawable.Drawable)2 IconResolver (com.android.launcher3.icons.pack.IconResolver)2 FastBitmapDrawable (com.android.launcher3.icons.FastBitmapDrawable)1 ComponentKey (com.android.launcher3.util.ComponentKey)1