summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAdam Cohen <adamcohen@google.com>2013-06-14 11:22:59 -0700
committerAdam Cohen <adamcohen@google.com>2013-06-14 14:19:19 -0700
commit99894d9bb73fdc4bf9bba8423b5c5d5715a4f5d5 (patch)
treea81e6b7edd165b48fb58a3edeed6c0cf0f35a6b7 /src
parent876a846edc6a9d9c6957ee0f63b01951763e3606 (diff)
downloadandroid_packages_apps_Trebuchet-99894d9bb73fdc4bf9bba8423b5c5d5715a4f5d5.tar.gz
android_packages_apps_Trebuchet-99894d9bb73fdc4bf9bba8423b5c5d5715a4f5d5.tar.bz2
android_packages_apps_Trebuchet-99894d9bb73fdc4bf9bba8423b5c5d5715a4f5d5.zip
Fixing up handling of shortcuts
Change-Id: I70dd044b608f4ef18a9c436964a11122168305d0
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher3/Launcher.java31
-rw-r--r--src/com/android/launcher3/Workspace.java32
2 files changed, 52 insertions, 11 deletions
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 46943b510..db7a2ba76 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -44,6 +44,7 @@ import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Configuration;
import android.content.res.Resources;
@@ -2042,7 +2043,8 @@ public class Launcher extends Activity
final Intent intent = ((ShortcutInfo) tag).intent;
ComponentName widgetComp = new ComponentName(this, WidgetAdder.class);
- if (intent.getComponent().getClassName().equals(widgetComp.getClassName())) {
+ if (intent.getComponent() != null &&
+ intent.getComponent().getClassName().equals(widgetComp.getClassName())) {
showAllApps(true);
return;
}
@@ -3641,11 +3643,11 @@ public class Launcher extends Activity
mWorkspaceLoading = false;
if (upgradePath) {
mWorkspace.saveWorkspaceToDb();
-
- // Run through this twice... a little hackleberry, but the right solution is complex.
- mWorkspace.stripDuplicateApps();
- mIntentsOnWorkspaceFromUpgradePath = mWorkspace.stripDuplicateApps();
+ ArrayList<ComponentName> allApps = constructAllAppsComponents();
+ mWorkspace.stripDuplicateApps(allApps);
+ mIntentsOnWorkspaceFromUpgradePath = mWorkspace.stripDuplicateApps(allApps);
}
+
mWorkspace.post(new Runnable() {
@Override
public void run() {
@@ -3654,6 +3656,25 @@ 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 abf3b9832..dc784ee93 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -29,6 +29,7 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
+import android.content.pm.ResolveInfo;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
@@ -39,6 +40,7 @@ import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.Region.Op;
import android.graphics.drawable.Drawable;
+import android.net.Uri;
import android.os.IBinder;
import android.os.Parcelable;
import android.util.AttributeSet;
@@ -60,6 +62,7 @@ import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.List;
import java.util.Set;
/**
@@ -3427,18 +3430,19 @@ public class Workspace extends SmoothPagedView
}
}
- ArrayList<ComponentName> stripDuplicateApps() {
+ ArrayList<ComponentName> stripDuplicateApps(ArrayList<ComponentName> allApps) {
ArrayList<ComponentName> uniqueIntents = new ArrayList<ComponentName>();
- stripDuplicateApps((CellLayout) mLauncher.getHotseat().getLayout(), uniqueIntents);
+ stripDuplicateApps((CellLayout) mLauncher.getHotseat().getLayout(), uniqueIntents, allApps);
int count = getChildCount();
for (int i = 0; i < count; i++) {
CellLayout cl = (CellLayout) getChildAt(i);
- stripDuplicateApps(cl, uniqueIntents);
+ stripDuplicateApps(cl, uniqueIntents, allApps);
}
return uniqueIntents;
}
- void stripDuplicateApps(CellLayout cl, ArrayList<ComponentName> uniqueIntents) {
+ void stripDuplicateApps(CellLayout cl, ArrayList<ComponentName> uniqueIntents,
+ ArrayList<ComponentName> allApps) {
int count = cl.getShortcutsAndWidgets().getChildCount();
ArrayList<View> children = new ArrayList<View>();
@@ -3454,7 +3458,15 @@ 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)) {
+ continue;
+ }
if (!uniqueIntents.contains(cn)) {
uniqueIntents.add(cn);
} else {
@@ -3469,7 +3481,15 @@ 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)) {
+ continue;
+ }
if (!uniqueIntents.contains(cn)) {
uniqueIntents.add(cn);
} else {