From: Winson Chung Date: Fri, 6 May 2011 00:06:13 +0000 (-0700) Subject: Minor changes to help address some hiccups when panning, changing tabs and rotating... X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=63257c110a4ee54d5e8872c471cce254cf613c7a;p=android-x86%2Fpackages-apps-Trebuchet.git Minor changes to help address some hiccups when panning, changing tabs and rotating in AppsCustomize. - Also removing references to old all-apps 2d/3d Change-Id: Ibe07ad8b4facc5c57b3c82ccf0b55260be61a31b --- diff --git a/CleanSpec.mk b/CleanSpec.mk index eb24cca08..f78a1b2a4 100644 --- a/CleanSpec.mk +++ b/CleanSpec.mk @@ -46,7 +46,8 @@ $(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/Launcher2_intermediates) $(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/Launcher2_intermediates) +$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/Launcher2_intermediates) # ************************************************ # NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST -# ************************************************ \ No newline at end of file +# ************************************************ diff --git a/res/layout-land/all_apps_2d.xml b/res/layout-land/all_apps_2d.xml deleted file mode 100644 index b7fcd4585..000000000 --- a/res/layout-land/all_apps_2d.xml +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - - - - - - diff --git a/res/layout-port/all_apps_2d.xml b/res/layout-port/all_apps_2d.xml deleted file mode 100644 index 081cba292..000000000 --- a/res/layout-port/all_apps_2d.xml +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - - - - - - diff --git a/res/layout/all_apps.xml b/res/layout/all_apps.xml deleted file mode 100644 index fadf736a6..000000000 --- a/res/layout/all_apps.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - diff --git a/res/layout/all_apps_3d.xml b/res/layout/all_apps_3d.xml deleted file mode 100644 index 7975df40a..000000000 --- a/res/layout/all_apps_3d.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - diff --git a/src/com/android/launcher2/AllAppsPagedView.java b/src/com/android/launcher2/AllAppsPagedView.java index 1c4b9dbdb..a9c08efa3 100644 --- a/src/com/android/launcher2/AllAppsPagedView.java +++ b/src/com/android/launcher2/AllAppsPagedView.java @@ -508,6 +508,7 @@ public class AllAppsPagedView extends PagedViewWithDraggableItems implements All @Override public void syncPageItems(int page) { // Ensure that we have the right number of items on the pages + final int numPages = getPageCount(); final int cellsPerPage = mCellCountX * mCellCountY; final int startIndex = page * cellsPerPage; final int endIndex = Math.min(startIndex + cellsPerPage, mFilteredApps.size()); @@ -540,6 +541,7 @@ public class AllAppsPagedView extends PagedViewWithDraggableItems implements All // Add any necessary items for (int i = curNumPageItems; i < numPageItems; ++i) { + final boolean createHolographicOutlines = isHardwareAccelerated() && (numPages > 1); TextView text = (TextView) mInflater.inflate( R.layout.all_apps_paged_view_application, layout, false); text.setOnClickListener(this); @@ -547,17 +549,17 @@ public class AllAppsPagedView extends PagedViewWithDraggableItems implements All text.setOnTouchListener(this); layout.addViewToCellLayout(text, -1, i, - new PagedViewCellLayout.LayoutParams(0, 0, 1, 1)); + new PagedViewCellLayout.LayoutParams(0, 0, 1, 1), createHolographicOutlines); } // 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); + final boolean createHolographicOutlines = isHardwareAccelerated() && (numPages > 1); PagedViewIcon icon = (PagedViewIcon) layout.getChildOnPageAt(index); icon.applyFromApplicationInfo( - info, mPageViewIconCache, true, isHardwareAccelerated() && (numPages > 1)); + info, mPageViewIconCache, true, createHolographicOutlines); PagedViewCellLayout.LayoutParams params = (PagedViewCellLayout.LayoutParams) icon.getLayoutParams(); @@ -579,10 +581,11 @@ public class AllAppsPagedView extends PagedViewWithDraggableItems implements All } // Center-align the message + final boolean createHolographicOutlines = isHardwareAccelerated() && (numPages > 1); layout.enableCenteredContent(true); layout.removeAllViewsOnPage(); layout.addViewToCellLayout(icon, -1, 0, - new PagedViewCellLayout.LayoutParams(0, 0, 4, 1)); + new PagedViewCellLayout.LayoutParams(0, 0, 4, 1), createHolographicOutlines); } layout.createHardwareLayers(); } diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java index 307140d1d..a1e61714a 100644 --- a/src/com/android/launcher2/AppsCustomizePagedView.java +++ b/src/com/android/launcher2/AppsCustomizePagedView.java @@ -44,6 +44,7 @@ import android.util.LruCache; import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; +import android.view.ViewGroup; import android.view.animation.DecelerateInterpolator; import android.view.animation.LinearInterpolator; import android.widget.FrameLayout; @@ -471,17 +472,28 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen /* * Apps PagedView implementation */ + private void setVisibilityOnChildren(ViewGroup layout, int visibility) { + int childCount = layout.getChildCount(); + for (int i = 0; i < childCount; ++i) { + layout.getChildAt(i).setVisibility(visibility); + } + } private void setupPage(PagedViewCellLayout layout) { layout.setCellCount(mCellCountX, mCellCountY); layout.setGap(mPageLayoutWidthGap, mPageLayoutHeightGap); layout.setPadding(mPageLayoutPaddingLeft, mPageLayoutPaddingTop, mPageLayoutPaddingRight, mPageLayoutPaddingBottom); - // We force a measure here to get around the fact that when we do layout calculations - // immediately after syncing, we don't have a proper width. + // Note: We force a measure here to get around the fact that when we do layout calculations + // immediately after syncing, we don't have a proper width. That said, we already know the + // expected page width, so we can actually optimize by hiding all the TextView-based + // children that are expensive to measure, and let that happen naturally later. + setVisibilityOnChildren(layout, View.GONE); int widthSpec = MeasureSpec.makeMeasureSpec(getMeasuredWidth(), MeasureSpec.AT_MOST); int heightSpec = MeasureSpec.makeMeasureSpec(getMeasuredHeight(), MeasureSpec.AT_MOST); + layout.setMinimumWidth(getPageContentWidth()); layout.measure(widthSpec, heightSpec); + setVisibilityOnChildren(layout, View.VISIBLE); } public void syncAppsPages() { // Ensure that we have the right number of pages @@ -514,8 +526,8 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen int index = i - startIndex; int x = index % mCellCountX; int y = index / mCellCountX; - setupPage(layout); - layout.addViewToCellLayout(icon, -1, i, new PagedViewCellLayout.LayoutParams(x,y, 1,1)); + layout.addViewToCellLayout(icon, -1, i, new PagedViewCellLayout.LayoutParams(x,y, 1,1), + isHardwareAccelerated() && (numPages > 1)); } } /* @@ -525,7 +537,17 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen layout.setGravity(Gravity.LEFT); layout.setPadding(mPageLayoutPaddingLeft, mPageLayoutPaddingTop, mPageLayoutPaddingRight, mPageLayoutPaddingBottom); + + // Note: We force a measure here to get around the fact that when we do layout calculations + // immediately after syncing, we don't have a proper width. That said, we already know the + // expected page width, so we can actually optimize by hiding all the TextView-based + // children that are expensive to measure, and let that happen naturally later. + setVisibilityOnChildren(layout, View.GONE); + int widthSpec = MeasureSpec.makeMeasureSpec(getMeasuredWidth(), MeasureSpec.AT_MOST); + int heightSpec = MeasureSpec.makeMeasureSpec(getMeasuredHeight(), MeasureSpec.AT_MOST); layout.setMinimumWidth(getPageContentWidth()); + layout.measure(widthSpec, heightSpec); + setVisibilityOnChildren(layout, View.VISIBLE); } private void renderDrawableToBitmap(Drawable d, Bitmap bitmap, int x, int y, int w, int h, float scaleX, float scaleY) { diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java index b41972ac1..52b59f10c 100644 --- a/src/com/android/launcher2/CellLayout.java +++ b/src/com/android/launcher2/CellLayout.java @@ -103,7 +103,7 @@ public class CellLayout extends ViewGroup { // These arrays are used to implement the drag visualization on x-large screens. // They are used as circular arrays, indexed by mDragOutlineCurrent. - private Point[] mDragOutlines = new Point[8]; + private Point[] mDragOutlines = new Point[4]; private float[] mDragOutlineAlphas = new float[mDragOutlines.length]; private InterruptibleInOutAnimator[] mDragOutlineAnims = new InterruptibleInOutAnimator[mDragOutlines.length]; diff --git a/src/com/android/launcher2/CustomizePagedView.java b/src/com/android/launcher2/CustomizePagedView.java index b61713a76..fd88eb665 100644 --- a/src/com/android/launcher2/CustomizePagedView.java +++ b/src/com/android/launcher2/CustomizePagedView.java @@ -929,12 +929,13 @@ public class CustomizePagedView extends PagedViewWithDraggableItems final int[] cellSpans = CellLayout.rectToCell(getResources(), info.minWidth, info.minHeight, null); final FastBitmapDrawable icon = getWidgetPreview(info); + final boolean createHolographicOutlines = isHardwareAccelerated() && (numPages > 1); PagedViewWidget l = (PagedViewWidget) mInflater.inflate( R.layout.customize_paged_view_widget, layout, false); l.applyFromAppWidgetProviderInfo(info, icon, mMaxWidgetWidth, cellSpans, - mPageViewIconCache, (numPages > 1)); + mPageViewIconCache, createHolographicOutlines); l.setTag(createItemInfo); l.setOnClickListener(this); l.setOnTouchListener(this); @@ -975,11 +976,12 @@ public class CustomizePagedView extends PagedViewWithDraggableItems for (int i = startIndex; i < endIndex; ++i) { final ResolveInfo info = mWallpaperList.get(i); final FastBitmapDrawable icon = getWallpaperPreview(info); + final boolean createHolographicOutlines = isHardwareAccelerated() && (numPages > 1); PagedViewWidget l = (PagedViewWidget) mInflater.inflate( R.layout.customize_paged_view_wallpaper, layout, false); l.applyFromWallpaperInfo(info, mPackageManager, icon, mMaxWidgetWidth, - mPageViewIconCache, (numPages > 1)); + mPageViewIconCache, createHolographicOutlines); l.setTag(info); l.setOnClickListener(this); @@ -1012,12 +1014,13 @@ public class CustomizePagedView extends PagedViewWithDraggableItems for (int i = startIndex; i < endIndex; ++i) { ResolveInfo info = list.get(i); PendingAddItemInfo createItemInfo = new PendingAddItemInfo(); + final boolean createHolographicOutlines = isHardwareAccelerated() && (numPages > 1); PagedViewIcon icon = (PagedViewIcon) mInflater.inflate( R.layout.customize_paged_view_item, layout, false); icon.applyFromResolveInfo(info, mPackageManager, mPageViewIconCache, ((LauncherApplication) mLauncher.getApplication()).getIconCache(), - (numPages > 1)); + createHolographicOutlines); switch (mCustomizationType) { case WallpaperCustomization: icon.setOnClickListener(this); @@ -1039,7 +1042,8 @@ public class CustomizePagedView extends PagedViewWithDraggableItems final int x = index % mCellCountX; final int y = index / mCellCountX; setupPage(layout); - layout.addViewToCellLayout(icon, -1, i, new PagedViewCellLayout.LayoutParams(x,y, 1,1)); + layout.addViewToCellLayout(icon, -1, i, new PagedViewCellLayout.LayoutParams(x,y, 1,1), + createHolographicOutlines); } } @@ -1071,10 +1075,11 @@ public class CustomizePagedView extends PagedViewWithDraggableItems layout.removeAllViewsOnPage(); for (int i = startIndex; i < endIndex; ++i) { final ApplicationInfo info = mApps.get(i); + final boolean createHolographicOutlines = isHardwareAccelerated() && (numPages > 1); PagedViewIcon icon = (PagedViewIcon) mInflater.inflate( R.layout.all_apps_paged_view_application, layout, false); icon.applyFromApplicationInfo( - info, mPageViewIconCache, true, isHardwareAccelerated() && (numPages > 1)); + info, mPageViewIconCache, true, createHolographicOutlines); icon.setOnClickListener(this); icon.setOnTouchListener(this); icon.setOnLongClickListener(this); @@ -1083,7 +1088,8 @@ public class CustomizePagedView extends PagedViewWithDraggableItems final int x = index % mCellCountX; final int y = index / mCellCountX; setupPage(layout); - layout.addViewToCellLayout(icon, -1, i, new PagedViewCellLayout.LayoutParams(x,y, 1,1)); + layout.addViewToCellLayout(icon, -1, i, new PagedViewCellLayout.LayoutParams(x,y, 1,1), + createHolographicOutlines); } } diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java index e75830fe6..ceb36be4a 100644 --- a/src/com/android/launcher2/Launcher.java +++ b/src/com/android/launcher2/Launcher.java @@ -896,7 +896,7 @@ public final class Launcher extends Activity dragLayer.setDragController(dragController); if (LauncherApplication.isScreenXLarge()) { - mAllAppsGrid = (AllAppsView)dragLayer.findViewById(R.id.all_apps_view); + mAllAppsGrid = (AllAppsView) dragLayer.findViewById(R.id.all_apps_view); mAllAppsGrid.setup(this, dragController); // We don't want a hole punched in our window. ((View) mAllAppsGrid).setWillNotDraw(false); diff --git a/src/com/android/launcher2/LauncherModel.java b/src/com/android/launcher2/LauncherModel.java index 6240c8fab..d5505c5fa 100644 --- a/src/com/android/launcher2/LauncherModel.java +++ b/src/com/android/launcher2/LauncherModel.java @@ -652,22 +652,6 @@ public class LauncherModel extends BroadcastReceiver { mLoaderTask = null; } } - - // Trigger a gc to try to clean up after the stuff is done, since the - // renderscript allocations aren't charged to the java heap. - if (mStopped) { - mHandler.post(new Runnable() { - public void run() { - System.gc(); - } - }); - } else { - mHandler.postIdle(new Runnable() { - public void run() { - System.gc(); - } - }); - } } public void stopLocked() { diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java index 3bef69e66..1180106c9 100644 --- a/src/com/android/launcher2/PagedView.java +++ b/src/com/android/launcher2/PagedView.java @@ -531,7 +531,8 @@ public abstract class PagedView extends ViewGroup { protected void updateAdjacentPagesAlpha() { if (mFadeInAdjacentScreens) { if (mDirtyPageAlpha || (mTouchState == TOUCH_STATE_SCROLLING) || !mScroller.isFinished()) { - int halfScreenSize = getMeasuredWidth() / 2; + int screenWidth = getMeasuredWidth(); + int halfScreenSize = screenWidth / 2; int screenCenter = mScrollX + halfScreenSize; final int childCount = getChildCount(); for (int i = 0; i < childCount; ++i) { @@ -544,7 +545,7 @@ public abstract class PagedView extends ViewGroup { // we should just assume full page width (and calculate the offset according to // that). if (childWidth <= 0) { - childWidth = getMeasuredWidth(); + childWidth = screenWidth; childCenter = (i * childWidth) + (childWidth / 2); } @@ -1203,7 +1204,11 @@ public abstract class PagedView extends ViewGroup { } protected int getChildWidth(int index) { - return Math.max(mMinimumWidth, getChildAt(index).getMeasuredWidth()); + // This functions are called enough times that it actually makes a difference in the + // profiler -- so just inline the max() here + final int measuredWidth = getChildAt(index).getMeasuredWidth(); + final int minWidth = mMinimumWidth; + return (minWidth > measuredWidth) ? minWidth : measuredWidth; } protected int getRelativeChildOffset(int index) { @@ -1222,7 +1227,12 @@ public abstract class PagedView extends ViewGroup { } protected int getScaledMeasuredWidth(View child) { - return (int) (Math.max(mMinimumWidth, child.getMeasuredWidth()) * mLayoutScale + 0.5f); + // This functions are called enough times that it actually makes a difference in the + // profiler -- so just inline the max() here + final int measuredWidth = child.getMeasuredWidth(); + final int minWidth = mMinimumWidth; + final int maxWidth = (minWidth > measuredWidth) ? minWidth : measuredWidth; + return (int) (maxWidth * mLayoutScale + 0.5f); } int getPageNearestToCenterOfScreen() { diff --git a/src/com/android/launcher2/PagedViewCellLayout.java b/src/com/android/launcher2/PagedViewCellLayout.java index 40be03d49..92459d8eb 100644 --- a/src/com/android/launcher2/PagedViewCellLayout.java +++ b/src/com/android/launcher2/PagedViewCellLayout.java @@ -129,7 +129,7 @@ public class PagedViewCellLayout extends ViewGroup implements Page { } public boolean addViewToCellLayout(View child, int index, int childId, - PagedViewCellLayout.LayoutParams params) { + PagedViewCellLayout.LayoutParams params, boolean createHolographicOutlines) { final PagedViewCellLayout.LayoutParams lp = params; // Generate an id for each view, this assumes we have at most 256x256 cells @@ -149,7 +149,10 @@ public class PagedViewCellLayout extends ViewGroup implements Page { if (mAllowHardwareLayerCreation) { pagedViewIcon.disableCache(); } - mHolographicChildren.addView(pagedViewIcon.getHolographicOutlineView(), index, lp); + if (createHolographicOutlines) { + mHolographicChildren.addView(pagedViewIcon.getHolographicOutlineView(), + index, lp); + } } return true; } diff --git a/src/com/android/launcher2/PagedViewIcon.java b/src/com/android/launcher2/PagedViewIcon.java index 7aeb0af15..e23f1c6d1 100644 --- a/src/com/android/launcher2/PagedViewIcon.java +++ b/src/com/android/launcher2/PagedViewIcon.java @@ -16,8 +16,6 @@ package com.android.launcher2; -import com.android.launcher.R; - import android.animation.ObjectAnimator; import android.content.ComponentName; import android.content.Context; @@ -33,8 +31,10 @@ import android.os.HandlerThread; import android.os.Message; import android.util.AttributeSet; import android.view.KeyEvent; +import android.view.View; import android.widget.Checkable; +import com.android.launcher.R; /** diff --git a/src/com/android/launcher2/PagedViewWidget.java b/src/com/android/launcher2/PagedViewWidget.java index 88c553757..46bf532b4 100644 --- a/src/com/android/launcher2/PagedViewWidget.java +++ b/src/com/android/launcher2/PagedViewWidget.java @@ -64,6 +64,7 @@ public class PagedViewWidget extends LinearLayout implements Checkable { private PagedViewIconCache.Key mIconCacheKey; private PagedViewIconCache mIconCache; + private String mDimensionsFormatString; private int mAlpha = 255; private int mHolographicAlpha; @@ -162,6 +163,7 @@ public class PagedViewWidget extends LinearLayout implements Checkable { mCheckedFadeOutDuration = r.getInteger(R.integer.config_dragAppsCustomizeIconFadeOutDuration); } + mDimensionsFormatString = r.getString(R.string.widget_dims_format); setWillNotDraw(false); setClipToPadding(false); @@ -189,7 +191,7 @@ public class PagedViewWidget extends LinearLayout implements Checkable { name.setText(info.label); name.setLayerType(View.LAYER_TYPE_SOFTWARE, null); final TextView dims = (TextView) findViewById(R.id.widget_dims); - dims.setText(mContext.getString(R.string.widget_dims_format, cellSpan[0], cellSpan[1])); + dims.setText(String.format(mDimensionsFormatString, cellSpan[0], cellSpan[1])); dims.setLayerType(View.LAYER_TYPE_SOFTWARE, null); if (createHolographicOutline) { @@ -209,7 +211,7 @@ public class PagedViewWidget extends LinearLayout implements Checkable { name.setText(info.loadLabel(pm)); name.setLayerType(View.LAYER_TYPE_SOFTWARE, null); final TextView dims = (TextView) findViewById(R.id.widget_dims); - dims.setText(mContext.getString(R.string.widget_dims_format, 1, 1)); + dims.setText(String.format(mDimensionsFormatString, 1, 1)); dims.setLayerType(View.LAYER_TYPE_SOFTWARE, null); if (createHolographicOutline) { diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java index d394016f3..2bbfc1854 100644 --- a/src/com/android/launcher2/Workspace.java +++ b/src/com/android/launcher2/Workspace.java @@ -1881,7 +1881,14 @@ public class Workspace extends SmoothPagedView ((i == mCurrentPage) && (mShrinkState != ShrinkState.SPRING_LOADED)) ? 0.0f : 1.0f; - float translation = getOffsetXForRotation(rotation, cl.getWidth(), cl.getHeight()); + float translation = 0f; + + // If the screen is not xlarge, then don't rotate the CellLayouts + // NOTE: If we don't update the side pages alpha, then we should not hide the side + // pages. see unshrink(). + if (LauncherApplication.isScreenXLarge()) { + translation = getOffsetXForRotation(rotation, cl.getWidth(), cl.getHeight()); + } oldAlphas[i] = cl.getAlpha(); newAlphas[i] = finalAlphaValue; @@ -1951,10 +1958,13 @@ public class Workspace extends SmoothPagedView ValueAnimator.ofFloat(0f, 1f).setDuration(duration); animWithInterpolator.setInterpolator(mZoomInInterpolator); - final float oldHorizontalWallpaperOffset = getHorizontalWallpaperOffset(); - final float oldVerticalWallpaperOffset = getVerticalWallpaperOffset(); - final float newHorizontalWallpaperOffset = wallpaperOffsetForCurrentScroll(); - final float newVerticalWallpaperOffset = 0.5f; + final float oldHorizontalWallpaperOffset = enableWallpaperEffects ? + getHorizontalWallpaperOffset() : 0; + final float oldVerticalWallpaperOffset = enableWallpaperEffects ? + getVerticalWallpaperOffset() : 0; + final float newHorizontalWallpaperOffset = enableWallpaperEffects ? + wallpaperOffsetForCurrentScroll() : 0; + final float newVerticalWallpaperOffset = enableWallpaperEffects ? 0.5f : 0; animWithInterpolator.addUpdateListener(new LauncherAnimatorUpdateListener() { public void onAnimationUpdate(float a, float b) { if (b == 0f) {