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

Commit 317698bd authored by Sunny Goyal's avatar Sunny Goyal
Browse files

Loading high resolution icons for first 3 items in a folder

 > Sometimes a folder gets rearranged, without updating the model,
   like when an app in uninstalled. In that case, we need to update
   the icons for folder items, which were previously hidden

Bug: 22813360
Change-Id: I99754911c969bf2153efb2948c226c1c69219b88
parent 3f7550c1
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -34,11 +34,13 @@ import android.util.SparseArray;
import android.util.TypedValue;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewParent;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.DecelerateInterpolator;
import android.widget.TextView;

import com.android.launcher3.IconCache.IconLoadRequest;
import com.android.launcher3.model.PackageItemInfo;

@@ -538,6 +540,13 @@ public class BubbleTextView extends TextView
            } else if (info instanceof ShortcutInfo) {
                applyFromShortcutInfo((ShortcutInfo) info,
                        LauncherAppState.getInstance().getIconCache());
                if ((info.rank < FolderIcon.NUM_ITEMS_IN_PREVIEW) && (info.container >= 0)) {
                    View folderIcon =
                            mLauncher.getWorkspace().getHomescreenIconByItemId(info.container);
                    if (folderIcon != null) {
                        folderIcon.invalidate();
                    }
                }
            } else if (info instanceof PackageItemInfo) {
                applyFromPackageItemInfo((PackageItemInfo) info);
            }
+1 −1
Original line number Diff line number Diff line
@@ -1389,7 +1389,7 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
    }

    // Compares item position based on rank and position giving priority to the rank.
    private static final Comparator<ItemInfo> ITEM_POS_COMPARATOR = new Comparator<ItemInfo>() {
    public static final Comparator<ItemInfo> ITEM_POS_COMPARATOR = new Comparator<ItemInfo>() {

        @Override
        public int compare(ItemInfo lhs, ItemInfo rhs) {
+4 −0
Original line number Diff line number Diff line
@@ -329,6 +329,10 @@ public class FolderPagedView extends PagedView {
                lp.cellY = info.cellY;
                currentPage.addViewToCellLayout(
                        v, -1, mFolder.mLauncher.getViewIdForItem(info), lp, true);

                if (rank < FolderIcon.NUM_ITEMS_IN_PREVIEW && v instanceof BubbleTextView) {
                    ((BubbleTextView) v).verifyHighRes();
                }
            }

            rank ++;
+1 −0
Original line number Diff line number Diff line
@@ -2662,6 +2662,7 @@ public class Launcher extends Activity
            throw new IllegalArgumentException("Input must be a FolderIcon");
        }

        // TODO(sunnygoyal): Re-evaluate this code.
        FolderIcon folderIcon = (FolderIcon) v;
        final FolderInfo info = folderIcon.getFolderInfo();
        Folder openFolder = mWorkspace.getFolderForTag(info);
+15 −0
Original line number Diff line number Diff line
@@ -2303,6 +2303,21 @@ public class LauncherModel extends BroadcastReceiver
                    }
                }

                // Sort all the folder items and make sure the first 3 items are high resolution.
                for (FolderInfo folder : sBgFolders) {
                    Collections.sort(folder.contents, Folder.ITEM_POS_COMPARATOR);
                    int pos = 0;
                    for (ShortcutInfo info : folder.contents) {
                        if (info.usingLowResIcon) {
                            info.updateIcon(mIconCache, false);
                        }
                        pos ++;
                        if (pos >= FolderIcon.NUM_ITEMS_IN_PREVIEW) {
                            break;
                        }
                    }
                }

                if (restoredRows.size() > 0) {
                    // Update restored items that no longer require special handling
                    ContentValues values = new ContentValues();
Loading