summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher2/ApplicationInfo.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/launcher2/ApplicationInfo.java')
-rw-r--r--src/com/android/launcher2/ApplicationInfo.java89
1 files changed, 24 insertions, 65 deletions
diff --git a/src/com/android/launcher2/ApplicationInfo.java b/src/com/android/launcher2/ApplicationInfo.java
index 0fe84e731..f50b88930 100644
--- a/src/com/android/launcher2/ApplicationInfo.java
+++ b/src/com/android/launcher2/ApplicationInfo.java
@@ -18,7 +18,9 @@ package com.android.launcher2;
import android.content.ComponentName;
import android.content.ContentValues;
+import android.content.Context;
import android.content.Intent;
+import android.content.pm.ResolveInfo;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.util.Log;
@@ -26,8 +28,7 @@ import android.util.Log;
import java.util.ArrayList;
/**
- * Represents a launchable application. An application is made of a name (or title),
- * an intent and an icon.
+ * Represents an app in AllAppsView.
*/
class ApplicationInfo extends ItemInfo {
@@ -47,48 +48,37 @@ class ApplicationInfo extends ItemInfo {
Intent intent;
/**
- * The application icon.
- */
- Drawable icon;
-
- /**
* A bitmap version of the application icon.
*/
Bitmap iconBitmap;
- /**
- * When set to true, indicates that the icon has been resized.
- */
- boolean filtered;
+ ComponentName componentName;
- /**
- * Indicates whether the icon comes from an application's resource (if false)
- * or from a custom Bitmap (if true.)
- */
- boolean customIcon;
+
+ ApplicationInfo() {
+ itemType = LauncherSettings.BaseLauncherColumns.ITEM_TYPE_SHORTCUT;
+ }
/**
- * If isShortcut=true and customIcon=false, this contains a reference to the
- * shortcut icon as an application's resource.
+ * Must not hold the Context.
*/
- Intent.ShortcutIconResource iconResource;
+ public ApplicationInfo(ResolveInfo info, IconCache iconCache) {
+ this.componentName = new ComponentName(
+ info.activityInfo.applicationInfo.packageName,
+ info.activityInfo.name);
- ApplicationInfo() {
- itemType = LauncherSettings.BaseLauncherColumns.ITEM_TYPE_SHORTCUT;
+ this.container = ItemInfo.NO_ID;
+ this.setActivity(componentName,
+ Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
+
+ iconCache.getTitleAndIcon(this, info);
}
public ApplicationInfo(ApplicationInfo info) {
super(info);
+ componentName = info.componentName;
title = info.title.toString();
intent = new Intent(info.intent);
- if (info.iconResource != null) {
- iconResource = new Intent.ShortcutIconResource();
- iconResource.packageName = info.iconResource.packageName;
- iconResource.resourceName = info.iconResource.resourceName;
- }
- icon = info.icon;
- filtered = info.filtered;
- customIcon = info.customIcon;
}
/**
@@ -107,51 +97,20 @@ class ApplicationInfo extends ItemInfo {
}
@Override
- void onAddToDatabase(ContentValues values) {
- super.onAddToDatabase(values);
-
- String titleStr = title != null ? title.toString() : null;
- values.put(LauncherSettings.BaseLauncherColumns.TITLE, titleStr);
-
- String uri = intent != null ? intent.toUri(0) : null;
- values.put(LauncherSettings.BaseLauncherColumns.INTENT, uri);
-
- if (customIcon) {
- values.put(LauncherSettings.BaseLauncherColumns.ICON_TYPE,
- LauncherSettings.BaseLauncherColumns.ICON_TYPE_BITMAP);
- Bitmap bitmap = ((FastBitmapDrawable) icon).getBitmap();
- writeBitmap(values, bitmap);
- } else {
- values.put(LauncherSettings.BaseLauncherColumns.ICON_TYPE,
- LauncherSettings.BaseLauncherColumns.ICON_TYPE_RESOURCE);
- if (iconResource != null) {
- values.put(LauncherSettings.BaseLauncherColumns.ICON_PACKAGE,
- iconResource.packageName);
- values.put(LauncherSettings.BaseLauncherColumns.ICON_RESOURCE,
- iconResource.resourceName);
- }
- }
- }
-
- @Override
public String toString() {
return title.toString();
}
- @Override
- void unbind() {
- super.unbind();
- icon.setCallback(null);
- }
-
-
public static void dumpApplicationInfoList(String tag, String label,
ArrayList<ApplicationInfo> list) {
Log.d(tag, label + " size=" + list.size());
for (ApplicationInfo info: list) {
Log.d(tag, " title=\"" + info.title + "\" titleBitmap=" + info.titleBitmap
- + " icon=" + info.icon + " iconBitmap=" + info.iconBitmap
- + " filtered=" + info.filtered + " customIcon=" + info.customIcon);
+ + " iconBitmap=" + info.iconBitmap);
}
}
+
+ public ShortcutInfo makeShortcut() {
+ return new ShortcutInfo(this);
+ }
}