From 34efdaf24d4da2c1429e1a244d101d686b951080 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Tue, 24 May 2011 14:19:56 -0700 Subject: [PATCH] Prioritizing Wallpapers and Live Wallpapers. Change-Id: Iec8e8b42687ce95b08b086f4e7012e0fd0737684 --- res/values/strings.xml | 7 +++++ .../launcher2/AppsCustomizePagedView.java | 31 +++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/res/values/strings.xml b/res/values/strings.xml index 9ad3e2462d..7e8bec048e 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -25,6 +25,13 @@ + + com.android.wallpaper.livepicker + com.android.wallpaper.livepicker.LiveWallpaperActivity + diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java index fabd9e40b2..4500744a10 100644 --- a/src/com/android/launcher2/AppsCustomizePagedView.java +++ b/src/com/android/launcher2/AppsCustomizePagedView.java @@ -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 list, + ComponentName cn) { + Iterator 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); + } } /**