Prioritizing Wallpapers and Live Wallpapers.

Change-Id: Iec8e8b42687ce95b08b086f4e7012e0fd0737684
This commit is contained in:
Winson Chung
2011-05-24 14:19:56 -07:00
parent effe1afd42
commit 34efdaf24d
2 changed files with 38 additions and 0 deletions
@@ -18,6 +18,7 @@ package com.android.launcher2;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import org.xmlpull.v1.XmlPullParser;
@@ -167,6 +168,22 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
setDragSlopeThreshold(r.getInteger(R.integer.config_appsCustomizeDragSlopeThreshold)/100f);
}
/** Removes and returns the ResolveInfo with the specified ComponentName */
private ResolveInfo removeResolveInfoWithComponentName(List<ResolveInfo> list,
ComponentName cn) {
Iterator<ResolveInfo> iter = list.iterator();
while (iter.hasNext()) {
ResolveInfo rinfo = iter.next();
ActivityInfo info = rinfo.activityInfo;
ComponentName c = new ComponentName(info.packageName, info.name);
if (c.equals(cn)) {
iter.remove();
return rinfo;
}
}
return null;
}
public void onPackagesUpdated() {
// Get the list of widgets and shortcuts
mWidgets.clear();
@@ -182,6 +199,20 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
PackageManager.GET_META_DATA);
Collections.sort(mWallpapers,
new LauncherModel.ShortcutNameComparator(mPackageManager));
// Move Live Wallpapers to the front of the list
Context c = getContext();
ResolveInfo liveWallpapers = removeResolveInfoWithComponentName(mWallpapers,
new ComponentName(c.getString(R.string.live_wallpaper_picker_package_name),
c.getString(R.string.live_wallpaper_picker_class_name)));
if (liveWallpapers != null) {
mWallpapers.add(0, liveWallpapers);
}
// Move Wallpapers to the front of the list
ResolveInfo wallpapers = removeResolveInfoWithComponentName(mWallpapers,
new ComponentName(c.getPackageName(), WallpaperChooser.class.getName()));
if (wallpapers != null) {
mWallpapers.add(0, wallpapers);
}
}
/**