Merge branch 'master' into honeycomb-release

This commit is contained in:
The Android Automerger
2010-11-03 15:34:30 -07:00
11 changed files with 87 additions and 59 deletions
+2 -2
View File
@@ -25,8 +25,8 @@
<!-- The corner radius to draw the external drop icon rounded rect -->
<dimen name="external_drop_icon_rect_radius">10dp</dimen>
<!-- Temporary scaled icon size -->
<dimen name="temp_scaled_icon_size">72dp</dimen>
<!-- Size of icons in workspace -->
<dimen name="app_icon_size">72dp</dimen>
<!-- extra horizontal spacing between mini screen thumbnails ie. in all
apps and in customization mode -->
+3
View File
@@ -32,6 +32,9 @@
button cluster in landscape) -->
<dimen name="half_status_bar_height">12dip</dimen>
<!-- Size of icons in workspace -->
<dimen name="app_icon_size">50dp</dimen>
<!-- height & width of the drop rectangle for the trash icon -->
<dimen name="delete_zone_size">70dip</dimen>
@@ -639,7 +639,8 @@ public class CustomizePagedView extends PagedView
PagedViewIcon icon = (PagedViewIcon) mInflater.inflate(
R.layout.customize_paged_view_item, layout, false);
icon.applyFromResolveInfo(info, mPackageManager, mPageViewIconCache, true);
icon.applyFromResolveInfo(info, mPackageManager, mPageViewIconCache,
((LauncherApplication)mLauncher.getApplication()).getIconCache());
switch (mCustomizationType) {
case WallpaperCustomization:
icon.setOnClickListener(this);
+3 -3
View File
@@ -48,14 +48,14 @@ public class FolderIcon extends DimmableBubbleTextView implements DropTarget {
}
static FolderIcon fromXml(int resId, Launcher launcher, ViewGroup group,
UserFolderInfo folderInfo) {
UserFolderInfo folderInfo, IconCache iconCache) {
FolderIcon icon = (FolderIcon) LayoutInflater.from(launcher).inflate(resId, group, false);
final Resources resources = launcher.getResources();
Drawable d = resources.getDrawable(R.drawable.ic_launcher_folder);
Drawable d = iconCache.getFullResIcon(resources, R.drawable.ic_launcher_folder);
icon.mCloseIcon = d;
icon.mOpenIcon = resources.getDrawable(R.drawable.ic_launcher_folder_open);
icon.mOpenIcon = iconCache.getFullResIcon(resources, R.drawable.ic_launcher_folder_open);
icon.setCompoundDrawablesWithIntrinsicBounds(null, d, null, null);
icon.setText(folderInfo.title);
icon.setTag(folderInfo);
+39 -2
View File
@@ -16,13 +16,17 @@
package com.android.launcher2;
import com.android.launcher.R;
import android.content.ComponentName;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.util.DisplayMetrics;
import java.util.HashMap;
@@ -46,16 +50,49 @@ public class IconCache {
private final Utilities.BubbleText mBubble;
private final HashMap<ComponentName, CacheEntry> mCache =
new HashMap<ComponentName, CacheEntry>(INITIAL_ICON_CACHE_CAPACITY);
private int mIconDpi;
public IconCache(LauncherApplication context) {
mContext = context;
mPackageManager = context.getPackageManager();
mBubble = new Utilities.BubbleText(context);
if (LauncherApplication.isScreenXLarge()) {
mIconDpi = DisplayMetrics.DENSITY_HIGH;
} else {
mIconDpi = context.getResources().getDisplayMetrics().densityDpi;
}
// need to set mIconDpi before getting default icon
mDefaultIcon = makeDefaultIcon();
}
public Drawable getFullResDefaultActivityIcon() {
return getFullResIcon(Resources.getSystem(),
com.android.internal.R.drawable.sym_def_app_icon);
}
public Drawable getFullResIcon(Resources resources, int iconId) {
return resources.getDrawableForDensity(iconId, mIconDpi);
}
public Drawable getFullResIcon(ResolveInfo info, PackageManager packageManager) {
Resources resources;
try {
resources = packageManager.getResourcesForApplication(
info.activityInfo.applicationInfo);
} catch (PackageManager.NameNotFoundException e) {
resources = null;
}
if (resources != null) {
int iconId = info.activityInfo.getIconResource();
if (iconId != 0) {
return getFullResIcon(resources, iconId);
}
}
return getFullResDefaultActivityIcon();
}
private Bitmap makeDefaultIcon() {
Drawable d = mPackageManager.getDefaultActivityIcon();
Drawable d = getFullResDefaultActivityIcon();
Bitmap b = Bitmap.createBitmap(Math.max(d.getIntrinsicWidth(), 1),
Math.max(d.getIntrinsicHeight(), 1),
Bitmap.Config.ARGB_8888);
@@ -140,7 +177,7 @@ public class IconCache {
entry.title = info.activityInfo.name;
}
entry.icon = Utilities.createIconBitmap(
info.activityInfo.loadIcon(mPackageManager), mContext);
getFullResIcon(info, mPackageManager), mContext);
}
return entry;
}
+3 -8
View File
@@ -993,12 +993,6 @@ public final class Launcher extends Activity
Bitmap b = info.getIcon(mIconCache);
if (LauncherApplication.isScreenXLarge()) {
// Temporarily, we are scaling up all shortcuts on the workspace
int scaledSize = getResources().getDimensionPixelSize(R.dimen.temp_scaled_icon_size);
b = Bitmap.createScaledBitmap(b, scaledSize, scaledSize, true);
}
favorite.setCompoundDrawablesWithIntrinsicBounds(null,
new FastBitmapDrawable(b),
null, null);
@@ -1552,7 +1546,8 @@ public final class Launcher extends Activity
// Create the view
FolderIcon newFolder = FolderIcon.fromXml(R.layout.folder_icon, this,
(ViewGroup) mWorkspace.getChildAt(mWorkspace.getCurrentPage()), folderInfo);
(ViewGroup) mWorkspace.getChildAt(mWorkspace.getCurrentPage()),
folderInfo, mIconCache);
mWorkspace.addInScreen(newFolder, screen, cellXY[0], cellXY[1], 1, 1, isWorkspaceLocked());
}
@@ -2987,7 +2982,7 @@ public final class Launcher extends Activity
case LauncherSettings.Favorites.ITEM_TYPE_USER_FOLDER:
final FolderIcon newFolder = FolderIcon.fromXml(R.layout.folder_icon, this,
(ViewGroup) workspace.getChildAt(workspace.getCurrentPage()),
(UserFolderInfo) item);
(UserFolderInfo) item, mIconCache);
workspace.addInScreen(newFolder, item.screen, item.cellX, item.cellY, 1, 1,
false);
break;
@@ -38,11 +38,13 @@ public class LauncherApplication extends Application {
super.onCreate();
mIconCache = new IconCache(this);
mModel = new LauncherModel(this, mIconCache);
// set sIsScreenXLarge and sScreenDensity *before* creating icon cache
sIsScreenXLarge = (getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE;
sScreenDensity = getResources().getDisplayMetrics().density;
mIconCache = new IconCache(this);
mModel = new LauncherModel(this, mIconCache);
// Register intent receivers
IntentFilter filter = new IntentFilter(Intent.ACTION_PACKAGE_ADDED);
filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
+24 -20
View File
@@ -16,14 +16,7 @@
package com.android.launcher2;
import java.lang.ref.WeakReference;
import java.net.URISyntaxException;
import java.text.Collator;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import com.android.launcher.R;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProviderInfo;
@@ -52,7 +45,14 @@ import android.os.RemoteException;
import android.os.SystemClock;
import android.util.Log;
import com.android.launcher.R;
import java.lang.ref.WeakReference;
import java.net.URISyntaxException;
import java.text.Collator;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
/**
* Maintains in-memory state of the Launcher. It is expected that there should be only one
@@ -119,7 +119,7 @@ public class LauncherModel extends BroadcastReceiver {
mIconCache = iconCache;
mDefaultIcon = Utilities.createIconBitmap(
app.getPackageManager().getDefaultActivityIcon(), app);
mIconCache.getFullResDefaultActivityIcon(), app);
mAllAppsLoadDelay = app.getResources().getInteger(R.integer.config_allAppsBatchLoadDelay);
@@ -1469,7 +1469,8 @@ public class LauncherModel extends BroadcastReceiver {
Resources resources = packageManager.getResourcesForApplication(packageName);
if (resources != null) {
final int id = resources.getIdentifier(resourceName, null, null);
icon = Utilities.createIconBitmap(resources.getDrawable(id), context);
icon = Utilities.createIconBitmap(
mIconCache.getFullResIcon(resources, id), context);
}
} catch (Exception e) {
// drop this. we have other places to look for icons
@@ -1587,7 +1588,8 @@ public class LauncherModel extends BroadcastReceiver {
Resources resources = packageManager.getResourcesForApplication(
iconResource.packageName);
final int id = resources.getIdentifier(iconResource.resourceName, null, null);
icon = Utilities.createIconBitmap(resources.getDrawable(id), context);
icon = Utilities.createIconBitmap(
mIconCache.getFullResIcon(resources, id), context);
} catch (Exception e) {
Log.w(TAG, "Could not load shortcut icon: " + extra);
}
@@ -1614,7 +1616,7 @@ public class LauncherModel extends BroadcastReceiver {
return info;
}
private static void loadLiveFolderIcon(Context context, Cursor c, int iconTypeIndex,
private void loadLiveFolderIcon(Context context, Cursor c, int iconTypeIndex,
int iconPackageIndex, int iconResourceIndex, LiveFolderInfo liveFolderInfo) {
int iconType = c.getInt(iconTypeIndex);
@@ -1624,13 +1626,14 @@ public class LauncherModel extends BroadcastReceiver {
String resourceName = c.getString(iconResourceIndex);
PackageManager packageManager = context.getPackageManager();
try {
Resources resources = packageManager.getResourcesForApplication(packageName);
final int id = resources.getIdentifier(resourceName, null, null);
liveFolderInfo.icon = Utilities.createIconBitmap(resources.getDrawable(id),
context);
} catch (Exception e) {
Resources appResources = packageManager.getResourcesForApplication(packageName);
final int id = appResources.getIdentifier(resourceName, null, null);
liveFolderInfo.icon = Utilities.createIconBitmap(
context.getResources().getDrawable(R.drawable.ic_launcher_folder),
mIconCache.getFullResIcon(appResources, id), context);
} catch (Exception e) {
Resources resources = context.getResources();
liveFolderInfo.icon = Utilities.createIconBitmap(
mIconCache.getFullResIcon(resources, R.drawable.ic_launcher_folder),
context);
}
liveFolderInfo.iconResource = new Intent.ShortcutIconResource();
@@ -1638,8 +1641,9 @@ public class LauncherModel extends BroadcastReceiver {
liveFolderInfo.iconResource.resourceName = resourceName;
break;
default:
Resources resources = context.getResources();
liveFolderInfo.icon = Utilities.createIconBitmap(
context.getResources().getDrawable(R.drawable.ic_launcher_folder),
mIconCache.getFullResIcon(resources, R.drawable.ic_launcher_folder),
context);
}
}
+5 -19
View File
@@ -48,20 +48,17 @@ public class PagedViewIcon extends TextView implements Checkable {
private static HolographicOutlineHelper sHolographicOutlineHelper;
private Bitmap mCheckedOutline;
private Bitmap mHolographicOutline;
private Canvas mHolographicOutlineCanvas;
private Rect mDrawableClipRect;
private Bitmap mIcon;
private Object mIconCacheKey;
private PagedViewIconCache mIconCache;
private int mScaledIconSize;
private int mAlpha;
private int mHolographicAlpha;
private boolean mIsChecked;
// Highlight colours
// Highlight colors
private int mHoloBlurColor;
private int mHoloOutlineColor;
private int mCheckedBlurColor;
@@ -113,15 +110,12 @@ public class PagedViewIcon extends TextView implements Checkable {
mHoloOutlineColor = a.getColor(R.styleable.PagedViewIcon_outlineColor, 0);
mCheckedBlurColor = a.getColor(R.styleable.PagedViewIcon_checkedBlurColor, 0);
mCheckedOutlineColor = a.getColor(R.styleable.PagedViewIcon_checkedOutlineColor, 0);
mScaledIconSize =
context.getResources().getDimensionPixelSize(R.dimen.temp_scaled_icon_size);
a.recycle();
if (sHolographicOutlineHelper == null) {
sHolographicOutlineHelper = new HolographicOutlineHelper();
}
mDrawableClipRect = new Rect();
setFocusable(true);
setBackgroundDrawable(null);
@@ -142,12 +136,7 @@ public class PagedViewIcon extends TextView implements Checkable {
mIconCacheKey = info;
mHolographicOutline = mIconCache.getOutline(mIconCacheKey);
if (scaleUp) {
mIcon = Bitmap.createScaledBitmap(info.iconBitmap, mScaledIconSize,
mScaledIconSize, true);
} else {
mIcon = info.iconBitmap;
}
mIcon = info.iconBitmap;
setCompoundDrawablesWithIntrinsicBounds(null, new FastBitmapDrawable(mIcon), null, null);
setText(info.title);
setTag(info);
@@ -156,16 +145,13 @@ public class PagedViewIcon extends TextView implements Checkable {
}
public void applyFromResolveInfo(ResolveInfo info, PackageManager packageManager,
PagedViewIconCache cache, boolean scaleUp) {
PagedViewIconCache cache, IconCache modelIconCache) {
mIconCache = cache;
mIconCacheKey = info;
mHolographicOutline = mIconCache.getOutline(mIconCacheKey);
mIcon = Utilities.createIconBitmap(info.loadIcon(packageManager), mContext);
if (scaleUp) {
mIcon = Bitmap.createScaledBitmap(mIcon, mScaledIconSize,
mScaledIconSize, true);
}
mIcon = Utilities.createIconBitmap(
modelIconCache.getFullResIcon(info, packageManager), mContext);
setCompoundDrawablesWithIntrinsicBounds(null, new FastBitmapDrawable(mIcon), null, null);
setText(info.loadLabel(packageManager));
setTag(info);
+1 -1
View File
@@ -237,7 +237,7 @@ final class Utilities {
final DisplayMetrics metrics = resources.getDisplayMetrics();
final float density = metrics.density;
sIconWidth = sIconHeight = (int) resources.getDimension(android.R.dimen.app_icon_size);
sIconWidth = sIconHeight = (int) resources.getDimension(R.dimen.app_icon_size);
sIconTextureWidth = sIconTextureHeight = sIconWidth + 2;
sBlurPaint.setMaskFilter(new BlurMaskFilter(5 * density, BlurMaskFilter.Blur.NORMAL));
+1 -1
View File
@@ -1768,7 +1768,7 @@ public class Workspace extends SmoothPagedView
break;
case LauncherSettings.Favorites.ITEM_TYPE_USER_FOLDER:
view = FolderIcon.fromXml(R.layout.folder_icon, mLauncher,
cellLayout, ((UserFolderInfo) info));
cellLayout, (UserFolderInfo) info, mIconCache);
break;
default:
throw new IllegalStateException("Unknown item type: " + info.itemType);