summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher2/ApplicationInfo.java
diff options
context:
space:
mode:
authorJoe Onorato <joeo@android.com>2010-02-08 13:44:00 -0800
committerJoe Onorato <joeo@android.com>2010-02-12 12:18:40 -0500
commit0589f0f66ce498512c6ee47482c649d88294c9d0 (patch)
tree42d42799a5578bde35a79b18ab8b28d301c663fe /src/com/android/launcher2/ApplicationInfo.java
parent3e244cf9d2da4fb04ef095f8b752a2a2c6e2f287 (diff)
downloadandroid_packages_apps_Trebuchet-0589f0f66ce498512c6ee47482c649d88294c9d0.tar.gz
android_packages_apps_Trebuchet-0589f0f66ce498512c6ee47482c649d88294c9d0.tar.bz2
android_packages_apps_Trebuchet-0589f0f66ce498512c6ee47482c649d88294c9d0.zip
Split ApplicationInfo into ApplicationInfo which is used for AllAppsView and ShortcutInfo which is
used for the workspace. Consolidate the three icon resampling functions into one. Ensure that the icons stored in LauncherProvider are the right size, so we don't have to resample them each time we load them.
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);
+ }
}