Merge "Prioritizing Wallpapers and Live Wallpapers."

This commit is contained in:
Winson Chung 2011-05-24 15:07:34 -07:00 committed by Android (Google) Code Review
commit 169c20a5e5
2 changed files with 38 additions and 0 deletions

View File

@ -25,6 +25,13 @@
<!-- Do not translate. android:process of this application. -->
<string name="process" translate="false"><xliff:g id="x"></xliff:g></string>
<!-- Do not translate. We wish to prioritize the Wallpaper and Live Wallpaper pickers,
but because they are in a different package, we need to reference the component in
a non language-dependent way. If the Live Wallpaper picker component name changes
this will have to be updated as well. -->
<string name="live_wallpaper_picker_package_name" translate="false">com.android.wallpaper.livepicker</string>
<string name="live_wallpaper_picker_class_name" translate="false">com.android.wallpaper.livepicker.LiveWallpaperActivity</string>
<!-- General -->
<skip />
<!-- Application name -->

View File

@ -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);
}
}
/**