merge in honeycomb-release history after reset to honeycomb
diff --git a/res/drawable-hdpi/default_widget_preview.9.png b/res/drawable-hdpi/default_widget_preview.9.png
index ecc02de..833daff 100644
--- a/res/drawable-hdpi/default_widget_preview.9.png
+++ b/res/drawable-hdpi/default_widget_preview.9.png
Binary files differ
diff --git a/res/drawable-mdpi/default_widget_preview.9.png b/res/drawable-mdpi/default_widget_preview.9.png
index 5fedcc8..ed9c6ee 100644
--- a/res/drawable-mdpi/default_widget_preview.9.png
+++ b/res/drawable-mdpi/default_widget_preview.9.png
Binary files differ
diff --git a/res/layout-xlarge/live_wallpaper_entry.xml b/res/layout-xlarge/live_wallpaper_entry.xml
deleted file mode 100644
index 4a9c840..0000000
--- a/res/layout-xlarge/live_wallpaper_entry.xml
+++ /dev/null
@@ -1,45 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2010 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:orientation="vertical"
- android:padding="@dimen/live_wallpaper_grid_item_padding">
- <ImageView
- android:id="@+id/thumbnail"
- android:layout_width="@dimen/live_wallpaper_grid_item_width"
- android:layout_height="@dimen/live_wallpaper_grid_item_height"
- android:layout_gravity="center"
- android:layout_weight="1"
- android:scaleType="centerCrop" />
- <TextView
- android:id="@+id/title"
- android:layout_width="match_parent"
- android:layout_height="22dp"
- android:layout_weight="0"
- android:layout_gravity="center"
- android:gravity="bottom"
- android:singleLine="true"
- android:ellipsize="marquee"
-
- android:textColor="#FFFFFFFF"
- android:textSize="14sp"
- android:shadowColor="#FF000000"
- android:shadowDx="0.0"
- android:shadowDy="1.0"
- android:shadowRadius="1.0" />
-</LinearLayout>
\ No newline at end of file
diff --git a/res/layout-xlarge/live_wallpaper_list.xml b/res/layout-xlarge/live_wallpaper_list.xml
deleted file mode 100644
index 3d71f08..0000000
--- a/res/layout-xlarge/live_wallpaper_list.xml
+++ /dev/null
@@ -1,54 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2010 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:paddingLeft="24dp"
- android:paddingRight="24dp"
- android:paddingTop="24dp"
- android:paddingBottom="24dp"
- android:gravity="center">
- <GridView
- android:id="@android:id/list"
- android:layout_width="636dp"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:numColumns="3"
- android:stretchMode="none"
- android:columnWidth="@dimen/live_wallpaper_column_width"
- android:verticalSpacing="0dp"
- android:horizontalSpacing="0dp"
- android:drawSelectorOnTop="false" />
- <!--
- android:text="@string/live_wallpaper_empty"
- -->
-
- <TextView
- android:id="@android:id/empty"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
-
- android:gravity="center"
- android:visibility="gone"
-
- android:textColor="#FFFFFFFF"
- android:textSize="14sp"
- android:shadowColor="#FF000000"
- android:shadowDx="0.0"
- android:shadowDy="1.0"
- android:shadowRadius="1.0" />
-</FrameLayout>
\ No newline at end of file
diff --git a/res/layout-xlarge/wallpaper_chooser.xml b/res/layout-xlarge/wallpaper_chooser.xml
index 76a896d..b48dbd9 100644
--- a/res/layout-xlarge/wallpaper_chooser.xml
+++ b/res/layout-xlarge/wallpaper_chooser.xml
@@ -18,13 +18,34 @@
*/
-->
-<GridView xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/gallery"
- android:layout_width="match_parent"
- android:layout_height="400dp"
- android:layout_gravity="center"
- android:numColumns="3"
- android:stretchMode="spacingWidth"
- android:columnWidth="@dimen/wallpaper_chooser_grid_width"
- android:verticalSpacing="15dp"
- android:drawSelectorOnTop="false" />
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/wallpaper_list"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:paddingLeft="24dp"
+ android:paddingRight="24dp"
+ android:paddingTop="24dp"
+ android:paddingBottom="24dp"
+ android:gravity="center">
+ <GridView
+ android:id="@+id/gallery"
+ android:layout_width="636dp"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:numColumns="3"
+ android:stretchMode="none"
+ android:columnWidth="@dimen/live_wallpaper_column_width"
+ android:verticalSpacing="0dp"
+ android:horizontalSpacing="0dp"
+ android:drawSelectorOnTop="false" />
+ <TextView
+ android:id="@android:id/empty"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+
+ android:gravity="center"
+ android:visibility="gone"
+
+ android:text="@string/wallpaper_chooser_empty"
+ android:textAppearance="?android:attr/textAppearanceMedium" />
+</FrameLayout>
\ No newline at end of file
diff --git a/res/layout-xlarge/wallpaper_chooser_base.xml b/res/layout-xlarge/wallpaper_chooser_base.xml
index 16888ec..ba5ac53 100644
--- a/res/layout-xlarge/wallpaper_chooser_base.xml
+++ b/res/layout-xlarge/wallpaper_chooser_base.xml
@@ -19,5 +19,5 @@
-->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent" />
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content" />
diff --git a/res/layout-xlarge/wallpaper_item.xml b/res/layout-xlarge/wallpaper_item.xml
index e17c046..9a596cb 100644
--- a/res/layout-xlarge/wallpaper_item.xml
+++ b/res/layout-xlarge/wallpaper_item.xml
@@ -13,11 +13,16 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-
-<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="@dimen/wallpaper_chooser_grid_height"
- android:padding="6dp"
- android:scaleType="fitXY"
- android:adjustViewBounds="false"
- android:focusable="false" />
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="@dimen/live_wallpaper_grid_item_padding">
+ <ImageView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/wallpaper_image"
+ android:layout_width="@dimen/wallpaper_chooser_grid_width"
+ android:layout_height="@dimen/wallpaper_chooser_grid_height"
+ android:scaleType="centerCrop"
+ android:adjustViewBounds="false"
+ android:focusable="false"
+ android:padding="0dp" />
+</FrameLayout>
\ No newline at end of file
diff --git a/res/layout/wallpaper_item.xml b/res/layout/wallpaper_item.xml
index 6727483..cfd79e2 100644
--- a/res/layout/wallpaper_item.xml
+++ b/res/layout/wallpaper_item.xml
@@ -15,6 +15,7 @@
-->
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/wallpaper_image"
android:background="?android:attr/galleryItemBackground"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
diff --git a/res/values-xlarge/config.xml b/res/values-xlarge/config.xml
index d8ed214..8a103a3 100644
--- a/res/values-xlarge/config.xml
+++ b/res/values-xlarge/config.xml
@@ -54,6 +54,12 @@
<integer name="config_screenOnDropAlphaFadeDelay">350</integer>
<integer name="config_screenOnDropAlphaFadeDuration">50</integer>
+ <!-- Workspace screens are cached to bitmaps only when they're smaller than a certain size
+ (maxScaleForUsingWorkspaceScreenBitmapCache), since the bitmap cache itself is smaller
+ than the view itself (workspaceScreenBitmapCacheScale) -->
+ <integer name="config_workspaceScreenBitmapCacheScale">20</integer>
+ <integer name="config_maxScaleForUsingWorkspaceScreenBitmapCache">50</integer>
+
<!-- The slope, in percent, of the drag movement needed to drag an item out of the customization
drawer (y / x * 100%) -->
<integer name="config_customizationDrawerDragSlopeThreshold">150</integer>
diff --git a/res/values-xlarge/dimens.xml b/res/values-xlarge/dimens.xml
index dd6cf13..22f4134 100644
--- a/res/values-xlarge/dimens.xml
+++ b/res/values-xlarge/dimens.xml
@@ -53,6 +53,14 @@
<dimen name="delete_zone_horizontal_drag_padding">20dip</dimen>
<!-- dimensions for the wallpaper picker wallpaper thumbnail width -->
- <dimen name="wallpaper_chooser_grid_width">230dp</dimen>
- <dimen name="wallpaper_chooser_grid_height">185dp</dimen>
+ <dimen name="wallpaper_chooser_grid_width">196dp</dimen>
+ <dimen name="wallpaper_chooser_grid_height">140dp</dimen>
+ <dimen name="live_wallpaper_grid_item_padding">8dip</dimen>
+
+ <!-- live_wallpaper_grid_item_width + 2 * live_wallpaper_grid_item_padding-->
+ <dimen name="live_wallpaper_column_width">212dip</dimen>
+
+ <!-- How much the content view of an alert dialog should be inset (currently used
+ for the WallpaperChooser in XLarge mode) -->
+ <dimen name="alert_dialog_content_inset">0dp</dimen>
</resources>
diff --git a/res/values-xlarge/dimensions.xml b/res/values-xlarge/dimensions.xml
deleted file mode 100644
index 7213ff5..0000000
--- a/res/values-xlarge/dimensions.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-* copyright (c) 2010 the android open source project
-*
-* licensed under the apache license, version 2.0 (the "license");
-* you may not use this file except in compliance with the license.
-* you may obtain a copy of the license at
-*
-* http://www.apache.org/licenses/license-2.0
-*
-* unless required by applicable law or agreed to in writing, software
-* distributed under the license is distributed on an "as is" basis,
-* without warranties or conditions of any kind, either express or implied.
-* see the license for the specific language governing permissions and
-* limitations under the license.
-*/
--->
-
-<resources>
- <dimen name="live_wallpaper_preview_button_width">200dip</dimen>
- <dimen name="live_wallpaper_grid_item_width">196dip</dimen>
- <dimen name="live_wallpaper_grid_item_height">140dip</dimen>
- <dimen name="live_wallpaper_grid_item_padding">8dip</dimen>
-
- <!-- live_wallpaper_grid_item_width + 2 * live_wallpaper_grid_item_padding-->
- <dimen name="live_wallpaper_column_width">212dip</dimen>
-</resources>
diff --git a/res/values-xlarge/strings.xml b/res/values-xlarge/strings.xml
index d8bdbbc..75a22a2 100644
--- a/res/values-xlarge/strings.xml
+++ b/res/values-xlarge/strings.xml
@@ -21,6 +21,9 @@
<!-- Title of the wallpaper selection dialog [CHAR_LIMIT=40]-->
<string name="wallpaper_dialog_title">Select wallpaper</string>
+ <!-- Text to show when there are no wallpapers [CHAR_LIMIT=40]-->
+ <string name="wallpaper_chooser_empty">No wallpapers available</string>
+
<!-- Negative button text for the wallpaper selection dialog [CHAR_LIMIT=40]-->
<string name="wallpaper_cancel">Cancel</string>
</resources>
\ No newline at end of file
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 39739c2..d6cd3ee 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -44,8 +44,4 @@
<!-- the area at the edge of the screen that makes the workspace go left
or right while you're dragging. -->
<dimen name="scroll_zone">20dp</dimen>
-
- <!-- How much the content view of an alert dialog should be inset (currently used
- for the WallpaperChooser in XLarge mode) -->
- <dimen name="alert_dialog_content_inset">15dp</dimen>
</resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index c56ee9e..05d37d9 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -143,12 +143,11 @@
for accessibilty (spoken when the button gets focus). -->
<string name="all_apps_home_button_label">Home</string>
<!-- Label for trash icon on workspace. Meant to communicate the idea of removing the
- icon/widget from the home screen, but not permanently. Contrast with the label for trash
- icon in All Apps [CHAR_LIMIT=30] -->
+ icon/widget from the home screen, but not permanently. [CHAR_LIMIT=30] -->
<string name="delete_zone_label_workspace">Remove</string>
<!-- Label for trash icon in All Apps. The icon/widget will become completely unavailable on the
device. [CHAR_LIMIT=30]-->
- <string name="delete_zone_label_all_apps">Delete</string>
+ <string name="delete_zone_label_all_apps">Uninstall</string>
<!-- Menus items: -->
<skip />
diff --git a/src/com/android/launcher2/AllAppsPagedView.java b/src/com/android/launcher2/AllAppsPagedView.java
index a424bc6..f7d9f0e 100644
--- a/src/com/android/launcher2/AllAppsPagedView.java
+++ b/src/com/android/launcher2/AllAppsPagedView.java
@@ -322,7 +322,7 @@
mApps = list;
Collections.sort(mApps, LauncherModel.APP_NAME_COMPARATOR);
mFilteredApps = rebuildFilteredApps(mApps);
- mPageViewIconCache.clear();
+ mPageViewIconCache.retainAllApps(list);
invalidatePageData();
}
@@ -367,7 +367,7 @@
int removeIndex = findAppByComponent(mApps, info);
if (removeIndex > -1) {
mApps.remove(removeIndex);
- mPageViewIconCache.removeOutline(info);
+ mPageViewIconCache.removeOutline(new PagedViewIconCache.Key(info));
}
}
mFilteredApps = rebuildFilteredApps(mApps);
@@ -478,11 +478,12 @@
}
// Actually reapply to the existing text views
+ final int numPages = getPageCount();
for (int i = startIndex; i < endIndex; ++i) {
final int index = i - startIndex;
final ApplicationInfo info = mFilteredApps.get(i);
PagedViewIcon icon = (PagedViewIcon) layout.getChildAt(index);
- icon.applyFromApplicationInfo(info, mPageViewIconCache, true);
+ icon.applyFromApplicationInfo(info, mPageViewIconCache, true, (numPages > 1));
PagedViewCellLayout.LayoutParams params =
(PagedViewCellLayout.LayoutParams) icon.getLayoutParams();
diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java
index 70fe8f9..53a584e 100644
--- a/src/com/android/launcher2/CellLayout.java
+++ b/src/com/android/launcher2/CellLayout.java
@@ -37,6 +37,8 @@
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Region;
+import android.graphics.Bitmap.Config;
+import android.graphics.PorterDuff.Mode;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.util.Log;
@@ -97,6 +99,18 @@
private float mGlowBackgroundScale;
private float mGlowBackgroundAlpha;
+ private Bitmap mCache;
+ private Canvas mCacheCanvas;
+ private Rect mCacheRect;
+ private Paint mCachePaint;
+
+ private boolean mIsCacheEnabled = true;
+ private boolean mDisableCacheUpdates = false;
+ private boolean mForceCacheUpdate = false;
+ private boolean mIsCacheDirty = true;
+ private float mBitmapCacheScale;
+ private float mMaxScaleForUsingBitmapCache;
+
private boolean mAcceptsDrops = false;
// If we're actively dragging something over this screen, mIsDragOverlapping is true
private boolean mIsDragOverlapping = false;
@@ -265,8 +279,15 @@
mBackgroundRect = new Rect();
mGlowBackgroundRect = new Rect();
+ mCacheRect = new Rect();
setHoverScale(1.0f);
setHoverAlpha(1.0f);
+
+ mBitmapCacheScale =
+ res.getInteger(R.integer.config_workspaceScreenBitmapCacheScale) / 100.0f;
+ mMaxScaleForUsingBitmapCache =
+ res.getInteger(R.integer.config_maxScaleForUsingWorkspaceScreenBitmapCache) / 100.0f;
+ mCacheCanvas = new Canvas();
}
public void setIsDefaultDropTarget(boolean isDefaultDropTarget) {
@@ -276,13 +297,6 @@
}
}
- public void setAcceptsDrops(boolean acceptsDrops) {
- if (mAcceptsDrops != acceptsDrops) {
- mAcceptsDrops = acceptsDrops;
- invalidate();
- }
- }
-
void setIsDragOccuring(boolean isDragOccuring) {
if (mIsDragOccuring != isDragOccuring) {
mIsDragOccuring = isDragOccuring;
@@ -366,6 +380,93 @@
super.dispatchDraw(canvas);
}
+ private void invalidateIfNeeded() {
+ if (mIsCacheDirty) {
+ // Force a redraw to update the cache if it's dirty
+ invalidate();
+ }
+ }
+
+ public void enableCache() {
+ mIsCacheEnabled = true;
+ invalidateIfNeeded();
+ }
+
+ public void disableCache() {
+ mIsCacheEnabled = false;
+ }
+
+ public void disableCacheUpdates() {
+ mDisableCacheUpdates = true;
+ // Force just one update before we enter a period of no cache updates
+ mForceCacheUpdate = true;
+ }
+
+ public void enableCacheUpdates() {
+ mDisableCacheUpdates = false;
+ invalidateIfNeeded();
+ }
+
+ private void invalidateCache() {
+ mIsCacheDirty = true;
+ invalidateIfNeeded();
+ }
+
+ public void updateCache() {
+ mCacheCanvas.drawColor(0x00000000, Mode.CLEAR);
+
+ float alpha = getAlpha();
+ setAlpha(1.0f);
+ drawChildren(mCacheCanvas);
+ setAlpha(alpha);
+
+ mIsCacheDirty = false;
+ }
+
+ public void dispatchDraw(Canvas canvas) {
+ final int count = getChildCount();
+
+ if (!mIsCacheDirty) {
+ // Check if one of the children (an icon or widget) is dirty
+ for (int i = 0; i < count; i++) {
+ final View child = getChildAt(i);
+ if (child.isDirty()) {
+ mIsCacheDirty = true;
+ break;
+ }
+ }
+ }
+
+ if (mForceCacheUpdate ||
+ (mIsCacheEnabled && !mDisableCacheUpdates)) {
+ // Sometimes we force a cache update-- this is used to make sure the cache will look as
+ // up-to-date as possible right when we disable cache updates
+ if (mIsCacheDirty) {
+ updateCache();
+ }
+ mForceCacheUpdate = false;
+ }
+
+ if (mIsCacheEnabled && getScaleX() < mMaxScaleForUsingBitmapCache) {
+ mCachePaint.setAlpha((int)(255*getAlpha()));
+ canvas.drawBitmap(mCache, mCacheRect, mBackgroundRect, mCachePaint);
+ } else {
+ super.dispatchDraw(canvas);
+ }
+ }
+
+ private void prepareCacheBitmap() {
+ if (mCache == null) {
+ mCache = Bitmap.createBitmap((int) (getWidth() * mBitmapCacheScale),
+ (int) (getHeight() * mBitmapCacheScale), Config.ARGB_8888);
+
+ mCachePaint = new Paint();
+ mCachePaint.setFilterBitmap(true);
+ mCacheCanvas.setBitmap(mCache);
+ mCacheCanvas.scale(mBitmapCacheScale, mBitmapCacheScale);
+ }
+ }
+
@Override
protected void onDraw(Canvas canvas) {
// When we're large, we are either drawn in a "hover" state (ie when dragging an item to
@@ -523,6 +624,8 @@
child.setAlpha(getAlpha());
addView(child, index, lp);
+ // invalidate the cache to have it reflect the new item
+ invalidateCache();
if (markCells) markCellsAsOccupiedForView(child);
return true;
@@ -530,6 +633,13 @@
return false;
}
+ public void setAcceptsDrops(boolean acceptsDrops) {
+ if (mAcceptsDrops != acceptsDrops) {
+ mAcceptsDrops = acceptsDrops;
+ invalidate();
+ }
+ }
+
public boolean getAcceptsDrops() {
return mAcceptsDrops;
}
@@ -841,6 +951,7 @@
}
}
}
+ prepareCacheBitmap();
}
@Override
@@ -848,6 +959,10 @@
super.onSizeChanged(w, h, oldw, oldh);
mBackgroundRect.set(0, 0, w, h);
updateGlowRect();
+ mCacheRect.set(0, 0, (int) (mBitmapCacheScale * w), (int) (mBitmapCacheScale * h));
+ mCache = null;
+ prepareCacheBitmap();
+ invalidateCache();
}
@Override
diff --git a/src/com/android/launcher2/CustomizePagedView.java b/src/com/android/launcher2/CustomizePagedView.java
index d2edd38..0b874bc 100644
--- a/src/com/android/launcher2/CustomizePagedView.java
+++ b/src/com/android/launcher2/CustomizePagedView.java
@@ -180,7 +180,8 @@
Collections.sort(mApps, LauncherModel.APP_NAME_COMPARATOR);
// Update the widgets/shortcuts to reflect changes in the set of available apps
- invalidatePageDataAndIconCache();
+ mPageViewIconCache.retainAllApps(list);
+ invalidatePageData();
}
/**
@@ -206,7 +207,7 @@
addAppsWithoutInvalidate(list);
// Update the widgets/shortcuts to reflect changes in the set of available apps
- invalidatePageDataAndIconCache();
+ invalidatePageData();
}
/**
@@ -221,7 +222,7 @@
int removeIndex = findAppByComponent(mApps, info);
if (removeIndex > -1) {
mApps.remove(removeIndex);
- mPageViewIconCache.removeOutline(info);
+ mPageViewIconCache.removeOutline(new PagedViewIconCache.Key(info));
}
}
}
@@ -233,7 +234,7 @@
removeAppsWithoutInvalidate(list);
// Update the widgets/shortcuts to reflect changes in the set of available apps
- invalidatePageDataAndIconCache();
+ invalidatePageData();
}
/**
@@ -248,7 +249,7 @@
addAppsWithoutInvalidate(list);
// Update the widgets/shortcuts to reflect changes in the set of available apps
- invalidatePageDataAndIconCache();
+ invalidatePageData();
}
/**
@@ -295,14 +296,10 @@
PackageManager.GET_META_DATA);
Collections.sort(mWallpaperList, resolveInfoComparator);
- invalidatePageDataAndIconCache();
- }
-
- private void invalidatePageDataAndIconCache() {
- // Reset the icon cache
- mPageViewIconCache.clear();
-
- // Refresh all the tabs
+ ArrayList<ResolveInfo> retainShortcutList = new ArrayList<ResolveInfo>(mShortcutList);
+ retainShortcutList.addAll(mWallpaperList);
+ mPageViewIconCache.retainAllShortcuts(retainShortcutList);
+ mPageViewIconCache.retainAllAppWidgets(mWidgetList);
invalidatePageData();
}
@@ -838,6 +835,7 @@
LinearLayout layout = (LinearLayout) getChildAt(page);
final ArrayList<AppWidgetProviderInfo> list = mWidgetPages.get(page);
final int count = list.size();
+ final int numPages = getPageCount();
layout.removeAllViews();
for (int i = 0; i < count; ++i) {
final AppWidgetProviderInfo info = (AppWidgetProviderInfo) list.get(i);
@@ -848,7 +846,8 @@
PagedViewWidget l = (PagedViewWidget) mInflater.inflate(
R.layout.customize_paged_view_widget, layout, false);
- l.applyFromAppWidgetProviderInfo(info, icon, mMaxWidgetWidth, cellSpans);
+ l.applyFromAppWidgetProviderInfo(info, icon, mMaxWidgetWidth, cellSpans,
+ mPageViewIconCache, (numPages > 1));
l.setTag(createItemInfo);
l.setOnClickListener(this);
l.setOnTouchListener(this);
@@ -882,6 +881,7 @@
LinearLayout layout = (LinearLayout) getChildAt(page);
layout.removeAllViews();
final int count = mWallpaperList.size();
+ final int numPages = getPageCount();
final int numItemsPerPage = mMaxWallpaperCellHSpan / mWallpaperCellHSpan;
final int startIndex = page * numItemsPerPage;
final int endIndex = Math.min(count, startIndex + numItemsPerPage);
@@ -891,7 +891,8 @@
PagedViewWidget l = (PagedViewWidget) mInflater.inflate(
R.layout.customize_paged_view_wallpaper, layout, false);
- l.applyFromWallpaperInfo(info, mPackageManager, icon, mMaxWidgetWidth);
+ l.applyFromWallpaperInfo(info, mPackageManager, icon, mMaxWidgetWidth,
+ mPageViewIconCache, (numPages > 1));
l.setTag(info);
l.setOnClickListener(this);
@@ -914,10 +915,11 @@
private void syncListPageItems(int page, List<ResolveInfo> list) {
// ensure that we have the right number of items on the pages
- int numCells = mCellCountX * mCellCountY;
- int startIndex = page * numCells;
- int endIndex = Math.min(startIndex + numCells, list.size());
- PagedViewCellLayout layout = (PagedViewCellLayout) getChildAt(page);
+ final int numPages = getPageCount();
+ final int numCells = mCellCountX * mCellCountY;
+ final int startIndex = page * numCells;
+ final int endIndex = Math.min(startIndex + numCells, list.size());
+ final PagedViewCellLayout layout = (PagedViewCellLayout) getChildAt(page);
// TODO: we can optimize by just re-applying to existing views
layout.removeAllViews();
for (int i = startIndex; i < endIndex; ++i) {
@@ -927,7 +929,8 @@
PagedViewIcon icon = (PagedViewIcon) mInflater.inflate(
R.layout.customize_paged_view_item, layout, false);
icon.applyFromResolveInfo(info, mPackageManager, mPageViewIconCache,
- ((LauncherApplication) mLauncher.getApplication()).getIconCache());
+ ((LauncherApplication) mLauncher.getApplication()).getIconCache(),
+ (numPages > 1));
switch (mCustomizationType) {
case WallpaperCustomization:
icon.setOnClickListener(this);
@@ -972,17 +975,18 @@
if (mApps == null) return;
// ensure that we have the right number of items on the pages
- int numCells = mCellCountX * mCellCountY;
- int startIndex = page * numCells;
- int endIndex = Math.min(startIndex + numCells, mApps.size());
- PagedViewCellLayout layout = (PagedViewCellLayout) getChildAt(page);
+ final int numPages = getPageCount();
+ final int numCells = mCellCountX * mCellCountY;
+ final int startIndex = page * numCells;
+ final int endIndex = Math.min(startIndex + numCells, mApps.size());
+ final PagedViewCellLayout layout = (PagedViewCellLayout) getChildAt(page);
// TODO: we can optimize by just re-applying to existing views
layout.removeAllViews();
for (int i = startIndex; i < endIndex; ++i) {
final ApplicationInfo info = mApps.get(i);
PagedViewIcon icon = (PagedViewIcon) mInflater.inflate(
R.layout.all_apps_paged_view_application, layout, false);
- icon.applyFromApplicationInfo(info, mPageViewIconCache, true);
+ icon.applyFromApplicationInfo(info, mPageViewIconCache, true, (numPages > 1));
icon.setOnClickListener(this);
icon.setOnTouchListener(this);
icon.setOnLongClickListener(this);
diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java
index 68833f9..6c9aac1 100644
--- a/src/com/android/launcher2/PagedView.java
+++ b/src/com/android/launcher2/PagedView.java
@@ -16,7 +16,10 @@
package com.android.launcher2;
-import com.android.launcher.R;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.TreeMap;
+import java.util.TreeSet;
import android.content.Context;
import android.content.res.TypedArray;
@@ -34,14 +37,13 @@
import android.view.ViewGroup;
import android.view.ViewParent;
import android.view.animation.Animation;
+import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationUtils;
import android.view.animation.Interpolator;
-import android.view.animation.Animation.AnimationListener;
import android.widget.Checkable;
import android.widget.Scroller;
-import java.util.ArrayList;
-import java.util.HashMap;
+import com.android.launcher.R;
/**
* An abstraction of the original Workspace which supports browsing through a
@@ -132,7 +134,10 @@
protected int mChoiceMode;
private ActionMode mActionMode;
- protected PagedViewIconCache mPageViewIconCache;
+ // NOTE: This is a shared icon cache across all the PagedViews. Currently it is only used in
+ // AllApps and Customize, and allows them to share holographic icons for the application view
+ // (which is in both).
+ protected static PagedViewIconCache mPageViewIconCache = new PagedViewIconCache();
// If true, syncPages and syncPageItems will be called to refresh pages
protected boolean mContentIsRefreshable = true;
@@ -150,28 +155,6 @@
protected boolean mIsPageMoving = false;
- /**
- * Simple cache mechanism for PagedViewIcon outlines.
- */
- class PagedViewIconCache {
- private final HashMap<Object, Bitmap> iconOutlineCache = new HashMap<Object, Bitmap>();
-
- public void clear() {
- iconOutlineCache.clear();
- }
- public void addOutline(Object key, Bitmap b) {
- iconOutlineCache.put(key, b);
- }
- public void removeOutline(Object key) {
- if (iconOutlineCache.containsKey(key)) {
- iconOutlineCache.remove(key);
- }
- }
- public Bitmap getOutline(Object key) {
- return iconOutlineCache.get(key);
- }
- }
-
public interface PageSwitchListener {
void onPageSwitch(View newPage, int newPageIndex);
}
@@ -215,7 +198,6 @@
protected void init() {
mDirtyPageContent = new ArrayList<Boolean>();
mDirtyPageContent.ensureCapacity(32);
- mPageViewIconCache = new PagedViewIconCache();
mScroller = new Scroller(getContext(), new ScrollInterpolator());
mCurrentPage = 0;
mCenterPagesVertically = true;
diff --git a/src/com/android/launcher2/PagedViewIcon.java b/src/com/android/launcher2/PagedViewIcon.java
index e4049eb..6ce308b 100644
--- a/src/com/android/launcher2/PagedViewIcon.java
+++ b/src/com/android/launcher2/PagedViewIcon.java
@@ -32,7 +32,6 @@
import android.widget.Checkable;
import com.android.launcher.R;
-import com.android.launcher2.PagedView.PagedViewIconCache;
@@ -50,7 +49,7 @@
private Bitmap mHolographicOutline;
private Bitmap mIcon;
- private Object mIconCacheKey;
+ private PagedViewIconCache.Key mIconCacheKey;
private PagedViewIconCache mIconCache;
private int mAlpha = 255;
@@ -140,26 +139,23 @@
}
public void applyFromApplicationInfo(ApplicationInfo info, PagedViewIconCache cache,
- boolean scaleUp) {
- mIconCache = cache;
- mIconCacheKey = info;
- mHolographicOutline = mIconCache.getOutline(mIconCacheKey);
-
+ boolean scaleUp, boolean createHolographicOutlines) {
mIcon = info.iconBitmap;
setCompoundDrawablesWithIntrinsicBounds(null, new FastBitmapDrawable(mIcon), null, null);
setText(info.title);
buildAndEnableCache();
setTag(info);
- queueHolographicOutlineCreation();
+ if (createHolographicOutlines) {
+ mIconCache = cache;
+ mIconCacheKey = new PagedViewIconCache.Key(info);
+ mHolographicOutline = mIconCache.getOutline(mIconCacheKey);
+ queueHolographicOutlineCreation();
+ }
}
public void applyFromResolveInfo(ResolveInfo info, PackageManager packageManager,
- PagedViewIconCache cache, IconCache modelIconCache) {
- mIconCache = cache;
- mIconCacheKey = info;
- mHolographicOutline = mIconCache.getOutline(mIconCacheKey);
-
+ PagedViewIconCache cache, IconCache modelIconCache, boolean createHolographicOutlines) {
mIcon = Utilities.createIconBitmap(
modelIconCache.getFullResIcon(info, packageManager), mContext);
setCompoundDrawablesWithIntrinsicBounds(null, new FastBitmapDrawable(mIcon), null, null);
@@ -167,7 +163,12 @@
buildAndEnableCache();
setTag(info);
- queueHolographicOutlineCreation();
+ if (createHolographicOutlines) {
+ mIconCache = cache;
+ mIconCacheKey = new PagedViewIconCache.Key(info);
+ mHolographicOutline = mIconCache.getOutline(mIconCacheKey);
+ queueHolographicOutlineCreation();
+ }
}
@Override
diff --git a/src/com/android/launcher2/PagedViewIconCache.java b/src/com/android/launcher2/PagedViewIconCache.java
new file mode 100644
index 0000000..de05ff1
--- /dev/null
+++ b/src/com/android/launcher2/PagedViewIconCache.java
@@ -0,0 +1,133 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.launcher2;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+
+import android.appwidget.AppWidgetProviderInfo;
+import android.content.ComponentName;
+import android.content.pm.ComponentInfo;
+import android.content.pm.ResolveInfo;
+import android.graphics.Bitmap;
+
+/**
+ * Simple cache mechanism for PagedView outlines.
+ */
+public class PagedViewIconCache {
+ public static class Key {
+ public enum Type {
+ ApplicationInfoKey,
+ AppWidgetProviderInfoKey,
+ ResolveInfoKey
+ }
+ private final ComponentName mComponentName;
+ private final Type mType;
+
+ public Key(ApplicationInfo info) {
+ mComponentName = info.componentName;
+ mType = Type.ApplicationInfoKey;
+ }
+ public Key(ResolveInfo info) {
+ final ComponentInfo ci = info.activityInfo != null ? info.activityInfo :
+ info.serviceInfo;
+ mComponentName = new ComponentName(ci.packageName, ci.name);
+ mType = Type.AppWidgetProviderInfoKey;
+ }
+ public Key(AppWidgetProviderInfo info) {
+ mComponentName = info.provider;
+ mType = Type.ResolveInfoKey;
+ }
+
+ private ComponentName getComponentName() {
+ return mComponentName;
+ }
+ public boolean isKeyType(Type t) {
+ return (mType == t);
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (o instanceof Key) {
+ Key k = (Key) o;
+ return mComponentName.equals(k.mComponentName);
+ }
+ return super.equals(o);
+ }
+ @Override
+ public int hashCode() {
+ return getComponentName().hashCode();
+ }
+ }
+
+ private final HashMap<Key, Bitmap> mIconOutlineCache = new HashMap<Key, Bitmap>();
+
+ public void clear() {
+ for (Key key : mIconOutlineCache.keySet()) {
+ mIconOutlineCache.get(key).recycle();
+ }
+ mIconOutlineCache.clear();
+ }
+ private void retainAll(HashSet<Key> keysToKeep, Key.Type t) {
+ HashSet<Key> keysToRemove = new HashSet<Key>(mIconOutlineCache.keySet());
+ keysToRemove.removeAll(keysToKeep);
+ for (Key key : keysToRemove) {
+ if (key.isKeyType(t)) {
+ mIconOutlineCache.get(key).recycle();
+ mIconOutlineCache.remove(key);
+ }
+ }
+ }
+ /** Removes all the keys to applications that aren't in the passed in collection */
+ public void retainAllApps(ArrayList<ApplicationInfo> keys) {
+ HashSet<Key> keysSet = new HashSet<Key>();
+ for (ApplicationInfo info : keys) {
+ keysSet.add(new Key(info));
+ }
+ retainAll(keysSet, Key.Type.ApplicationInfoKey);
+ }
+ /** Removes all the keys to shortcuts that aren't in the passed in collection */
+ public void retainAllShortcuts(List<ResolveInfo> keys) {
+ HashSet<Key> keysSet = new HashSet<Key>();
+ for (ResolveInfo info : keys) {
+ keysSet.add(new Key(info));
+ }
+ retainAll(keysSet, Key.Type.ResolveInfoKey);
+ }
+ /** Removes all the keys to widgets that aren't in the passed in collection */
+ public void retainAllAppWidgets(List<AppWidgetProviderInfo> keys) {
+ HashSet<Key> keysSet = new HashSet<Key>();
+ for (AppWidgetProviderInfo info : keys) {
+ keysSet.add(new Key(info));
+ }
+ retainAll(keysSet, Key.Type.AppWidgetProviderInfoKey);
+ }
+ public void addOutline(Key key, Bitmap b) {
+ mIconOutlineCache.put(key, b);
+ }
+ public void removeOutline(Key key) {
+ if (mIconOutlineCache.containsKey(key)) {
+ mIconOutlineCache.get(key).recycle();
+ mIconOutlineCache.remove(key);
+ }
+ }
+ public Bitmap getOutline(Key key) {
+ return mIconOutlineCache.get(key);
+ }
+}
diff --git a/src/com/android/launcher2/PagedViewWidget.java b/src/com/android/launcher2/PagedViewWidget.java
index 8c729b1..07a59ee 100644
--- a/src/com/android/launcher2/PagedViewWidget.java
+++ b/src/com/android/launcher2/PagedViewWidget.java
@@ -52,6 +52,9 @@
private final Canvas mHolographicOutlineCanvas = new Canvas();
private FastBitmapDrawable mPreview;
+ private PagedViewIconCache.Key mIconCacheKey;
+ private PagedViewIconCache mIconCache;
+
private int mAlpha = 255;
private int mHolographicAlpha;
@@ -97,6 +100,7 @@
mHandler.post(new Runnable() {
public void run() {
widget.mHolographicOutline = outline;
+ widget.mIconCache.addOutline(widget.mIconCacheKey, outline);
widget.invalidate();
}
});
@@ -140,7 +144,7 @@
private void queueHolographicOutlineCreation() {
// Generate the outline in the background
- if (mHolographicOutline == null) {
+ if (mHolographicOutline == null && mPreview != null) {
Message m = sWorker.obtainMessage(MESSAGE_CREATE_HOLOGRAPHIC_OUTLINE);
m.obj = this;
sWorker.sendMessage(m);
@@ -148,7 +152,8 @@
}
public void applyFromAppWidgetProviderInfo(AppWidgetProviderInfo info,
- FastBitmapDrawable preview, int maxWidth, int[] cellSpan) {
+ FastBitmapDrawable preview, int maxWidth, int[] cellSpan,
+ PagedViewIconCache cache, boolean createHolographicOutline) {
final ImageView image = (ImageView) findViewById(R.id.widget_preview);
image.setMaxWidth(maxWidth);
image.setImageDrawable(preview);
@@ -156,17 +161,30 @@
name.setText(info.label);
final TextView dims = (TextView) findViewById(R.id.widget_dims);
dims.setText(mContext.getString(R.string.widget_dims_format, cellSpan[0], cellSpan[1]));
- mPreview = preview;
+
+ if (createHolographicOutline) {
+ mIconCache = cache;
+ mIconCacheKey = new PagedViewIconCache.Key(info);
+ mHolographicOutline = mIconCache.getOutline(mIconCacheKey);
+ mPreview = preview;
+ }
}
public void applyFromWallpaperInfo(ResolveInfo info, PackageManager packageManager,
- FastBitmapDrawable preview, int maxWidth) {
+ FastBitmapDrawable preview, int maxWidth, PagedViewIconCache cache,
+ boolean createHolographicOutline) {
ImageView image = (ImageView) findViewById(R.id.wallpaper_preview);
image.setMaxWidth(maxWidth);
image.setImageDrawable(preview);
TextView name = (TextView) findViewById(R.id.wallpaper_name);
name.setText(info.loadLabel(packageManager));
- mPreview = preview;
+
+ if (createHolographicOutline) {
+ mIconCache = cache;
+ mIconCacheKey = new PagedViewIconCache.Key(info);
+ mHolographicOutline = mIconCache.getOutline(mIconCacheKey);
+ mPreview = preview;
+ }
}
@Override
diff --git a/src/com/android/launcher2/WallpaperChooserDialogFragment.java b/src/com/android/launcher2/WallpaperChooserDialogFragment.java
index 10bfc56..ec0f8a2 100644
--- a/src/com/android/launcher2/WallpaperChooserDialogFragment.java
+++ b/src/com/android/launcher2/WallpaperChooserDialogFragment.java
@@ -37,6 +37,7 @@
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
+import android.widget.FrameLayout;
import android.widget.Gallery;
import android.widget.GridView;
import android.widget.ImageView;
@@ -120,10 +121,11 @@
final int viewInset =
getResources().getDimensionPixelSize(R.dimen.alert_dialog_content_inset);
+ FrameLayout wallPaperList = (FrameLayout) v.findViewById(R.id.wallpaper_list);
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setNegativeButton(R.string.wallpaper_cancel, null);
builder.setTitle(R.string.wallpaper_dialog_title);
- builder.setView(gridView, viewInset, viewInset, viewInset, viewInset);
+ builder.setView(wallPaperList, viewInset, viewInset, viewInset, viewInset);
return builder.create();
}
@@ -241,14 +243,16 @@
}
public View getView(int position, View convertView, ViewGroup parent) {
- ImageView image;
+ View view;
if (convertView == null) {
- image = (ImageView) mLayoutInflater.inflate(R.layout.wallpaper_item, parent, false);
+ view = mLayoutInflater.inflate(R.layout.wallpaper_item, parent, false);
} else {
- image = (ImageView) convertView;
+ view = convertView;
}
+ ImageView image = (ImageView) view.findViewById(R.id.wallpaper_image);
+
int thumbRes = mThumbs.get(position);
image.setImageResource(thumbRes);
Drawable thumbDrawable = image.getDrawable();
@@ -259,7 +263,7 @@
+ position);
}
- return image;
+ return view;
}
}
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 0352176..1085083 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -170,6 +170,7 @@
// in all apps or customize mode)
private boolean mIsSmall = false;
private boolean mIsInUnshrinkAnimation = false;
+ private AnimatorListener mShrinkAnimationListener;
private AnimatorListener mUnshrinkAnimationListener;
enum ShrinkState { TOP, SPRING_LOADED, MIDDLE, BOTTOM_HIDDEN, BOTTOM_VISIBLE };
private ShrinkState mShrinkState;
@@ -266,6 +267,7 @@
@Override
public void onAnimationStart(Animator animation) {
mIsInUnshrinkAnimation = true;
+ disableCacheUpdates();
}
@Override
public void onAnimationEnd(Animator animation) {
@@ -273,6 +275,17 @@
if (mShrinkState != ShrinkState.SPRING_LOADED) {
mDrawCustomizeTrayBackground = false;
}
+ enableCacheUpdates();
+ }
+ };
+ mShrinkAnimationListener = new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationStart(Animator animation) {
+ disableCacheUpdates();
+ }
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ enableCacheUpdates();
}
};
mSnapVelocity = 600;
@@ -746,6 +759,22 @@
}
}
+ public void enableCacheUpdates() {
+ final int pageCount = getChildCount();
+ for (int i = 0; i < pageCount; i++) {
+ final CellLayout page = (CellLayout) getChildAt(i);
+ page.enableCacheUpdates();
+ }
+ }
+
+ public void disableCacheUpdates() {
+ final int pageCount = getChildCount();
+ for (int i = 0; i < pageCount; i++) {
+ final CellLayout page = (CellLayout) getChildAt(i);
+ page.disableCacheUpdates();
+ }
+ }
+
@Override
protected void onDraw(Canvas canvas) {
// Draw the background gradient if necessary
@@ -1066,12 +1095,14 @@
cl.setBackgroundAlpha(finalAlpha);
cl.setAlpha(finalAlpha);
cl.setRotationY(rotation);
+ mShrinkAnimationListener.onAnimationEnd(null);
}
// increment newX for the next screen
newX += scaledPageWidth + extraScaledSpacing;
}
setLayoutScale(1.0f);
if (animated) {
+ mAnimator.addListener(mShrinkAnimationListener);
mAnimator.start();
}
setChildrenDrawnWithCacheEnabled(true);
@@ -1297,6 +1328,7 @@
cl.setBackgroundAlpha(0.0f);
cl.setAlpha(finalAlphaValue);
cl.setRotationY(rotation);
+ mUnshrinkAnimationListener.onAnimationEnd(null);
}
}
@@ -1589,6 +1621,13 @@
originY = (int)mTempOriginXY[1];
}
+ // When you drag to a particular screen, make that the new current/default screen, so any
+ // subsequent taps add items to that screen
+ int dragTargetIndex = indexOfChild(mDragTargetLayout);
+ if (mCurrentPage != dragTargetIndex && (mIsSmall || mIsInUnshrinkAnimation)) {
+ moveToNewPageWithoutMovingCellLayouts(dragTargetIndex);
+ }
+
if (source != this) {
if (!mIsSmall || mWasSpringLoadedOnDragExit) {
onDropExternal(originX, originY, dragInfo, mDragTargetLayout, false);