am 5cafbe93: am 9e8e38a8: am 681a4ace: Merge "Updating folder icons when the shortcut is updated. (Bug 10803060)" into jb-ub-now-jetsonic

* commit '5cafbe930e61015a1e3b200669a56d1bd743b771':
  Updating folder icons when the shortcut is updated. (Bug 10803060)
This commit is contained in:
Winson Chung
2014-02-14 20:52:27 +00:00
committed by Android Git Automerger
+35 -19
View File
@@ -4382,29 +4382,45 @@ public class Workspace extends SmoothPagedView
stripEmptyScreens(); stripEmptyScreens();
} }
private void updateShortcut(HashMap<ComponentName, AppInfo> appsMap, ItemInfo info,
View child) {
ComponentName cn = info.getIntent().getComponent();
if (cn != null) {
AppInfo appInfo = appsMap.get(info.getIntent().getComponent());
if ((appInfo != null) && LauncherModel.isShortcutInfoUpdateable(info)) {
ShortcutInfo shortcutInfo = (ShortcutInfo) info;
BubbleTextView shortcut = (BubbleTextView) child;
shortcutInfo.updateIcon(mIconCache);
shortcutInfo.title = appInfo.title.toString();
shortcut.applyFromShortcutInfo(shortcutInfo, mIconCache);
}
}
}
void updateShortcuts(ArrayList<AppInfo> apps) { void updateShortcuts(ArrayList<AppInfo> apps) {
// Create a map of the apps to test against
final HashMap<ComponentName, AppInfo> appsMap = new HashMap<ComponentName, AppInfo>();
for (AppInfo ai : apps) {
appsMap.put(ai.componentName, ai);
}
ArrayList<ShortcutAndWidgetContainer> childrenLayouts = getAllShortcutAndWidgetContainers(); ArrayList<ShortcutAndWidgetContainer> childrenLayouts = getAllShortcutAndWidgetContainers();
for (ShortcutAndWidgetContainer layout: childrenLayouts) { for (ShortcutAndWidgetContainer layout: childrenLayouts) {
int childCount = layout.getChildCount(); // Update all the children shortcuts
for (int j = 0; j < childCount; j++) { final HashMap<ItemInfo, View> children = new HashMap<ItemInfo, View>();
final View view = layout.getChildAt(j); for (int j = 0; j < layout.getChildCount(); j++) {
Object tag = view.getTag(); View v = layout.getChildAt(j);
ItemInfo info = (ItemInfo) v.getTag();
if (LauncherModel.isShortcutInfoUpdateable((ItemInfo) tag)) { if (info instanceof FolderInfo && v instanceof FolderIcon) {
ShortcutInfo info = (ShortcutInfo) tag; FolderIcon folder = (FolderIcon) v;
ArrayList<View> folderChildren = folder.getFolder().getItemsInReadingOrder();
final Intent intent = info.intent; for (View fv : folderChildren) {
final ComponentName name = intent.getComponent(); info = (ItemInfo) fv.getTag();
final int appCount = apps.size(); updateShortcut(appsMap, info, fv);
for (int k = 0; k < appCount; k++) {
AppInfo app = apps.get(k);
if (app.componentName.equals(name)) {
BubbleTextView shortcut = (BubbleTextView) view;
info.updateIcon(mIconCache);
info.title = app.title.toString();
shortcut.applyFromShortcutInfo(info, mIconCache);
}
} }
folder.invalidate();
} else if (info instanceof ShortcutInfo) {
updateShortcut(appsMap, info, v);
} }
} }
} }