summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAdam Cohen <adamcohen@google.com>2013-06-14 15:33:35 -0700
committerAdam Cohen <adamcohen@google.com>2013-06-14 15:33:47 -0700
commita0b5749433c66b6fed5c6026414ef438a938089b (patch)
tree2e92f719dcca4169c27654ec2954fd9a1005cf0a /src
parent99894d9bb73fdc4bf9bba8423b5c5d5715a4f5d5 (diff)
downloadandroid_packages_apps_Trebuchet-a0b5749433c66b6fed5c6026414ef438a938089b.tar.gz
android_packages_apps_Trebuchet-a0b5749433c66b6fed5c6026414ef438a938089b.tar.bz2
android_packages_apps_Trebuchet-a0b5749433c66b6fed5c6026414ef438a938089b.zip
Easier way to handle shortcuts
Change-Id: I91c4a25e961774de0bed51ba986802a1834173f9
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher3/Launcher.java24
-rw-r--r--src/com/android/launcher3/Workspace.java24
2 files changed, 9 insertions, 39 deletions
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index db7a2ba76..2634e21de 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -3643,9 +3643,8 @@ public class Launcher extends Activity
mWorkspaceLoading = false;
if (upgradePath) {
mWorkspace.saveWorkspaceToDb();
- ArrayList<ComponentName> allApps = constructAllAppsComponents();
- mWorkspace.stripDuplicateApps(allApps);
- mIntentsOnWorkspaceFromUpgradePath = mWorkspace.stripDuplicateApps(allApps);
+ mWorkspace.stripDuplicateApps();
+ mIntentsOnWorkspaceFromUpgradePath = mWorkspace.stripDuplicateApps();
}
mWorkspace.post(new Runnable() {
@@ -3656,25 +3655,6 @@ public class Launcher extends Activity
});
}
- private ArrayList<ComponentName> constructAllAppsComponents() {
- // Run through this twice... a little hackleberry, but the right solution is complex.
- final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
- mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
-
- List<ResolveInfo> apps = getPackageManager().queryIntentActivities(mainIntent, 0);
- ArrayList<ComponentName> allApps = new ArrayList<ComponentName>();
-
- int count = apps.size();
- for (int i = 0; i < count; i++) {
- ActivityInfo ai = apps.get(i).activityInfo;
-
- ComponentName cn =
- new ComponentName(ai.applicationInfo.packageName, ai.name);
- allApps.add(cn);
- }
- return allApps;
- }
-
private boolean canRunNewAppsAnimation() {
long diff = System.currentTimeMillis() - mDragController.getLastGestureUpTime();
return diff > (NEW_APPS_ANIMATION_INACTIVE_TIMEOUT_SECONDS * 1000);
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index dc784ee93..41f0242c2 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -3430,19 +3430,18 @@ public class Workspace extends SmoothPagedView
}
}
- ArrayList<ComponentName> stripDuplicateApps(ArrayList<ComponentName> allApps) {
+ ArrayList<ComponentName> stripDuplicateApps() {
ArrayList<ComponentName> uniqueIntents = new ArrayList<ComponentName>();
- stripDuplicateApps((CellLayout) mLauncher.getHotseat().getLayout(), uniqueIntents, allApps);
+ stripDuplicateApps((CellLayout) mLauncher.getHotseat().getLayout(), uniqueIntents);
int count = getChildCount();
for (int i = 0; i < count; i++) {
CellLayout cl = (CellLayout) getChildAt(i);
- stripDuplicateApps(cl, uniqueIntents, allApps);
+ stripDuplicateApps(cl, uniqueIntents);
}
return uniqueIntents;
}
- void stripDuplicateApps(CellLayout cl, ArrayList<ComponentName> uniqueIntents,
- ArrayList<ComponentName> allApps) {
+ void stripDuplicateApps(CellLayout cl, ArrayList<ComponentName> uniqueIntents) {
int count = cl.getShortcutsAndWidgets().getChildCount();
ArrayList<View> children = new ArrayList<View>();
@@ -3458,15 +3457,11 @@ public class Workspace extends SmoothPagedView
if (info instanceof ShortcutInfo) {
ShortcutInfo si = (ShortcutInfo) info;
ComponentName cn = si.intent.getComponent();
- Uri dataUri = si.intent.getData();
- // If dataUri is not null / empty or if this component isn't one that would
- // have previously showed up in the AllApps list, then this is a widget-type
- // shortcut, so ignore it.
- if ((dataUri != null && !dataUri.equals(Uri.EMPTY))
- || !allApps.contains(cn)) {
+ if (si.itemType == LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT) {
continue;
}
+
if (!uniqueIntents.contains(cn)) {
uniqueIntents.add(cn);
} else {
@@ -3481,13 +3476,8 @@ public class Workspace extends SmoothPagedView
if (items.get(j).getTag() instanceof ShortcutInfo) {
ShortcutInfo si = (ShortcutInfo) items.get(j).getTag();
ComponentName cn = si.intent.getComponent();
- Uri dataUri = si.intent.getData();
- // If dataUri is not null / empty or if this component isn't one that would
- // have previously showed up in the AllApps list, then this is a widget-type
- // shortcut, so ignore it.
- if (dataUri != null && !dataUri.equals(Uri.EMPTY)
- || !allApps.contains(cn)) {
+ if (si.itemType == LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT) {
continue;
}
if (!uniqueIntents.contains(cn)) {