Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 338dee9d authored by Sunny Goyal's avatar Sunny Goyal Committed by Android (Google) Code Review
Browse files

Merge "Ensuring that ShortcutInfo always has an icon" into ub-launcher3-master

parents 99d814e5 1cd01b02
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -81,8 +81,14 @@ public class AppInfo extends ItemInfo {

    public AppInfo(Context context, LauncherActivityInfoCompat info, UserHandleCompat user,
            IconCache iconCache, boolean quietModeEnabled) {
        this(context, info, user, iconCache, quietModeEnabled, true /* useLowResIcon */);
    }

    public AppInfo(Context context, LauncherActivityInfoCompat info, UserHandleCompat user,
            IconCache iconCache, boolean quietModeEnabled, boolean useLowResIcon) {
        this.componentName = info.getComponentName();
        this.container = ItemInfo.NO_ID;
        this.user = user;
        if (PackageManagerHelper.isAppSuspended(info.getApplicationInfo())) {
            isDisabled |= ShortcutInfo.FLAG_DISABLED_SUSPENDED;
        }
@@ -90,9 +96,8 @@ public class AppInfo extends ItemInfo {
            isDisabled |= ShortcutInfo.FLAG_DISABLED_QUIET_USER;
        }

        iconCache.getTitleAndIcon(this, info, true /* useLowResIcon */);
        iconCache.getTitleAndIcon(this, info, useLowResIcon);
        intent = makeLaunchIntent(context, info, user);
        this.user = user;
    }

    public AppInfo(AppInfo info) {
+5 −7
Original line number Diff line number Diff line
@@ -155,13 +155,12 @@ public class BubbleTextView extends TextView
        setAccessibilityDelegate(mLauncher.getAccessibilityDelegate());
    }

    public void applyFromShortcutInfo(ShortcutInfo info, IconCache iconCache) {
        applyFromShortcutInfo(info, iconCache, false);
    public void applyFromShortcutInfo(ShortcutInfo info) {
        applyFromShortcutInfo(info, false);
    }

    public void applyFromShortcutInfo(ShortcutInfo info, IconCache iconCache,
            boolean promiseStateChanged) {
        applyIconAndLabel(info.getIcon(iconCache), info);
    public void applyFromShortcutInfo(ShortcutInfo info, boolean promiseStateChanged) {
        applyIconAndLabel(info.iconBitmap, info);
        setTag(info);
        if (promiseStateChanged || info.isPromise()) {
            applyState(promiseStateChanged);
@@ -557,8 +556,7 @@ public class BubbleTextView extends TextView
            if (info instanceof AppInfo) {
                applyFromApplicationInfo((AppInfo) info);
            } else if (info instanceof ShortcutInfo) {
                applyFromShortcutInfo((ShortcutInfo) info,
                        LauncherAppState.getInstance().getIconCache());
                applyFromShortcutInfo((ShortcutInfo) info);
                if ((info.rank < FolderIcon.NUM_ITEMS_IN_PREVIEW) && (info.container >= 0)) {
                    View folderIcon =
                            mLauncher.getWorkspace().getHomescreenIconByItemId(info.container);
+2 −2
Original line number Diff line number Diff line
@@ -490,7 +490,7 @@ public class IconCache {
        // null info means not installed, but if we have a component from the intent then
        // we should still look in the cache for restored app icons.
        if (component == null) {
            shortcutInfo.setIcon(getDefaultIcon(user));
            shortcutInfo.iconBitmap = getDefaultIcon(user);
            shortcutInfo.title = "";
            shortcutInfo.contentDescription = "";
            shortcutInfo.usingLowResIcon = false;
@@ -507,7 +507,7 @@ public class IconCache {
            ShortcutInfo shortcutInfo, ComponentName component, LauncherActivityInfoCompat info,
            UserHandleCompat user, boolean usePkgIcon, boolean useLowResIcon) {
        CacheEntry entry = cacheLocked(component, info, user, usePkgIcon, useLowResIcon);
        shortcutInfo.setIcon(getNonNullIcon(entry, user));
        shortcutInfo.iconBitmap = getNonNullIcon(entry, user);
        shortcutInfo.title = Utilities.trim(entry.title);
        shortcutInfo.contentDescription = entry.contentDescription;
        shortcutInfo.usingLowResIcon = entry.isLowResIcon;
+4 −1
Original line number Diff line number Diff line
@@ -433,7 +433,10 @@ public class InstallShortcutReceiver extends BroadcastReceiver {

        public ItemInfo getItemInfo() {
            if (activityInfo != null) {
                return new ShortcutInfo(activityInfo, mContext);
                return new AppInfo(mContext, activityInfo, user,
                        LauncherAppState.getInstance().getIconCache(),
                        UserManagerCompat.getInstance(mContext).isQuietModeEnabled(user),
                        false /* useLowResIcon */).makeShortcut();
            } else if (shortcutInfo != null) {
                return new ShortcutInfo(shortcutInfo, mContext);
            } else if (providerInfo != null) {
+3 −11
Original line number Diff line number Diff line
@@ -1424,7 +1424,7 @@ public class Launcher extends Activity
    public View createShortcut(ViewGroup parent, ShortcutInfo info) {
        BubbleTextView favorite = (BubbleTextView) getLayoutInflater().inflate(R.layout.app_icon,
                parent, false);
        favorite.applyFromShortcutInfo(info, mIconCache);
        favorite.applyFromShortcutInfo(info);
        favorite.setCompoundDrawablePadding(mDeviceProfile.iconDrawablePaddingPx);
        favorite.setOnClickListener(this);
        favorite.setOnFocusChangeListener(mFocusHandler);
@@ -2108,8 +2108,7 @@ public class Launcher extends Activity
                cellX, cellY);

        // Create the view
        FolderIcon newFolder =
            FolderIcon.fromXml(R.layout.folder_icon, this, layout, folderInfo, mIconCache);
        FolderIcon newFolder = FolderIcon.fromXml(R.layout.folder_icon, this, layout, folderInfo);
        mWorkspace.addInScreen(newFolder, folderInfo);
        // Force measure the new folder icon
        CellLayout parent = mWorkspace.getParentCellLayoutForView(newFolder);
@@ -3337,7 +3336,7 @@ public class Launcher extends Activity
                case LauncherSettings.Favorites.ITEM_TYPE_FOLDER: {
                    view = FolderIcon.fromXml(R.layout.folder_icon, this,
                            (ViewGroup) workspace.getChildAt(workspace.getCurrentPage()),
                            (FolderInfo) item, mIconCache);
                            (FolderInfo) item);
                    break;
                }
                case LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET: {
@@ -4028,13 +4027,6 @@ public class Launcher extends Activity
        return new AppInfo(this, activityInfo, user, mIconCache);
    }

    // TODO: This method should be a part of LauncherSearchCallback
    public ItemInfo createShortcutDragInfo(Intent shortcutIntent, CharSequence caption,
            Bitmap icon) {
        return new ShortcutInfo(shortcutIntent, caption, caption, icon,
                UserHandleCompat.myUserHandle());
    }

    protected void moveWorkspaceToDefaultScreen() {
        mWorkspace.moveToDefaultScreen(false);
    }
Loading