Search in sources :

Example 1 with IconProvider

use of com.android.launcher3.icons.IconProvider in project android_packages_apps_Trebuchet by LineageOS.

the class IconPackHeaderPreference method onRadioElementSelected.

@Override
public void onRadioElementSelected(String key) {
    if (icons == null) {
        return;
    }
    final IconProvider iconProvider = new IconProvider(context);
    final PackageManager pm = context.getPackageManager();
    final LauncherApps launcherApps = context.getSystemService(LauncherApps.class);
    new GetLaunchableInfoTask(pm, launcherApps, PREVIEW_ICON_NUM, (aiList) -> {
        for (int i = 0; i < icons.length; i++) {
            icons[i].setImageDrawable(iconProvider.getIcon(aiList.get(i), PREVIEW_ICON_DPI));
        }
    }).execute();
}
Also used : Context(android.content.Context) PackageManager(android.content.pm.PackageManager) IconProvider(com.android.launcher3.icons.IconProvider) ImageView(android.widget.ImageView) Intent(android.content.Intent) LauncherApps(android.content.pm.LauncherApps) CheckBoxPreference(androidx.preference.CheckBoxPreference) AttributeSet(android.util.AttributeSet) R(com.android.launcher3.R) PreferenceViewHolder(androidx.preference.PreferenceViewHolder) View(android.view.View) RadioHeaderPreference(com.android.launcher3.lineage.settings.RadioHeaderPreference) TypedArrayUtils(androidx.core.content.res.TypedArrayUtils) Log(android.util.Log) Resources(android.content.res.Resources) PackageManager(android.content.pm.PackageManager) LauncherApps(android.content.pm.LauncherApps) IconProvider(com.android.launcher3.icons.IconProvider)

Example 2 with IconProvider

use of com.android.launcher3.icons.IconProvider in project android_packages_apps_Trebuchet by LineageOS.

the class Utilities method getFullDrawable.

/**
 * Returns the full drawable for info without any flattening or pre-processing.
 *
 * @param outObj this is set to the internal data associated with {@param info},
 *               eg {@link LauncherActivityInfo} or {@link ShortcutInfo}.
 */
public static Drawable getFullDrawable(Launcher launcher, ItemInfo info, int width, int height, Object[] outObj) {
    LauncherAppState appState = LauncherAppState.getInstance(launcher);
    if (info.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION) {
        LauncherActivityInfo activityInfo = launcher.getSystemService(LauncherApps.class).resolveActivity(info.getIntent(), info.user);
        outObj[0] = activityInfo;
        return activityInfo == null ? null : new IconProvider(launcher).getIconForUI(activityInfo, launcher.getDeviceProfile().inv.fillResIconDpi);
    } else if (info.itemType == LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT) {
        if (info instanceof PendingAddShortcutInfo) {
            ShortcutConfigActivityInfo activityInfo = ((PendingAddShortcutInfo) info).activityInfo;
            outObj[0] = activityInfo;
            return activityInfo.getFullResIcon(appState.getIconCache());
        }
        if (info.getIntent() == null || info.getIntent().getPackage() == null)
            return null;
        List<ShortcutInfo> si = ShortcutKey.fromItemInfo(info).buildRequest(launcher).query(ShortcutRequest.ALL);
        if (si.isEmpty()) {
            return null;
        } else {
            outObj[0] = si.get(0);
            return ShortcutCachingLogic.getIcon(launcher, si.get(0), appState.getInvariantDeviceProfile().fillResIconDpi);
        }
    } else if (info.itemType == LauncherSettings.Favorites.ITEM_TYPE_FOLDER) {
        FolderAdaptiveIcon icon = FolderAdaptiveIcon.createFolderAdaptiveIcon(launcher, info.id, new Point(width, height));
        if (icon == null) {
            return null;
        }
        outObj[0] = icon;
        return icon;
    } else {
        return null;
    }
}
Also used : FolderAdaptiveIcon(com.android.launcher3.dragndrop.FolderAdaptiveIcon) LauncherActivityInfo(android.content.pm.LauncherActivityInfo) PendingAddShortcutInfo(com.android.launcher3.widget.PendingAddShortcutInfo) ShortcutConfigActivityInfo(com.android.launcher3.pm.ShortcutConfigActivityInfo) LauncherApps(android.content.pm.LauncherApps) List(java.util.List) Point(android.graphics.Point) IconProvider(com.android.launcher3.icons.IconProvider)

Aggregations

LauncherApps (android.content.pm.LauncherApps)2 IconProvider (com.android.launcher3.icons.IconProvider)2 Context (android.content.Context)1 Intent (android.content.Intent)1 LauncherActivityInfo (android.content.pm.LauncherActivityInfo)1 PackageManager (android.content.pm.PackageManager)1 Resources (android.content.res.Resources)1 Point (android.graphics.Point)1 AttributeSet (android.util.AttributeSet)1 Log (android.util.Log)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 TypedArrayUtils (androidx.core.content.res.TypedArrayUtils)1 CheckBoxPreference (androidx.preference.CheckBoxPreference)1 PreferenceViewHolder (androidx.preference.PreferenceViewHolder)1 R (com.android.launcher3.R)1 FolderAdaptiveIcon (com.android.launcher3.dragndrop.FolderAdaptiveIcon)1 RadioHeaderPreference (com.android.launcher3.lineage.settings.RadioHeaderPreference)1 ShortcutConfigActivityInfo (com.android.launcher3.pm.ShortcutConfigActivityInfo)1 PendingAddShortcutInfo (com.android.launcher3.widget.PendingAddShortcutInfo)1