am 20382a3f: am 8a097659: Merge "Turning on hardware layers for the workspace" into honeycomb

* commit '20382a3fafc44f32c29c5955d765ddec070c5cf1':
  Turning on hardware layers for the workspace
This commit is contained in:
Michael Jurka
2011-02-01 16:51:45 -08:00
committed by Android Git Automerger
4 changed files with 28 additions and 61 deletions
+26 -37
View File
@@ -31,13 +31,14 @@ import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.widget.TextView;
/**
* TextView that draws a bubble behind the text. We cannot use a LineBackgroundSpan
* because we want to make the bubble taller than the text and TextView's clip is
* too aggressive.
*/
public class BubbleTextView extends CachedTextView implements VisibilityChangedBroadcaster {
public class BubbleTextView extends TextView implements VisibilityChangedBroadcaster {
static final float CORNER_RADIUS = 4.0f;
static final float SHADOW_LARGE_RADIUS = 4.0f;
static final float SHADOW_SMALL_RADIUS = 1.75f;
@@ -98,19 +99,6 @@ public class BubbleTextView extends CachedTextView implements VisibilityChangedB
mPressedGlowColor = res.getColor(R.color.workspace_item_pressed_glow_color);
}
protected int getCacheTopPadding() {
return (int) PADDING_V;
}
protected int getCacheBottomPadding() {
return (int) (PADDING_V + SHADOW_LARGE_RADIUS + SHADOW_Y_OFFSET);
}
protected int getCacheLeftPadding() {
return (int) (PADDING_H + SHADOW_LARGE_RADIUS);
}
protected int getCacheRightPadding() {
return (int) (PADDING_H + SHADOW_LARGE_RADIUS);
}
public void applyFromShortcutInfo(ShortcutInfo info, IconCache iconCache) {
Bitmap b = info.getIcon(iconCache);
@@ -269,33 +257,34 @@ public class BubbleTextView extends CachedTextView implements VisibilityChangedB
mScrollX - padding, mScrollY - padding, mTempPaint);
canvas.restore();
}
if (isBuildingCache()) {
// We enhance the shadow by drawing the shadow twice
this.setShadowLayer(SHADOW_LARGE_RADIUS, 0.0f, SHADOW_Y_OFFSET, SHADOW_LARGE_COLOUR);
super.draw(canvas);
this.setShadowLayer(SHADOW_SMALL_RADIUS, 0.0f, 0.0f, SHADOW_SMALL_COLOUR);
super.draw(canvas);
} else {
final Drawable background = mBackground;
if (background != null) {
final int scrollX = mScrollX;
final int scrollY = mScrollY;
if (mBackgroundSizeChanged) {
background.setBounds(0, 0, mRight - mLeft, mBottom - mTop);
mBackgroundSizeChanged = false;
}
final Drawable background = mBackground;
if (background != null) {
final int scrollX = mScrollX;
final int scrollY = mScrollY;
if ((scrollX | scrollY) == 0) {
background.draw(canvas);
} else {
canvas.translate(scrollX, scrollY);
background.draw(canvas);
canvas.translate(-scrollX, -scrollY);
}
if (mBackgroundSizeChanged) {
background.setBounds(0, 0, mRight - mLeft, mBottom - mTop);
mBackgroundSizeChanged = false;
}
if ((scrollX | scrollY) == 0) {
background.draw(canvas);
} else {
canvas.translate(scrollX, scrollY);
background.draw(canvas);
canvas.translate(-scrollX, -scrollY);
}
super.draw(canvas);
}
// We enhance the shadow by drawing the shadow twice
setShadowLayer(SHADOW_LARGE_RADIUS, 0.0f, SHADOW_Y_OFFSET, SHADOW_LARGE_COLOUR);
super.draw(canvas);
canvas.save(Canvas.CLIP_SAVE_FLAG);
canvas.clipRect(mScrollX, mScrollY + getExtendedPaddingTop(), mScrollX + getWidth(),
mScrollY + getHeight(), Region.Op.REPLACE);
setShadowLayer(SHADOW_SMALL_RADIUS, 0.0f, 0.0f, SHADOW_SMALL_COLOUR);
super.draw(canvas);
canvas.restore();
}
@Override
+1 -1
View File
@@ -50,7 +50,7 @@ import android.view.animation.LayoutAnimationController;
import java.util.Arrays;
public class CellLayout extends CachedViewGroup {
public class CellLayout extends ViewGroup {
static final String TAG = "CellLayout";
private int mCellWidth;
@@ -44,6 +44,7 @@ public class CellLayoutChildren extends ViewGroup {
public CellLayoutChildren(Context context) {
super(context);
mWallpaperManager = WallpaperManager.getInstance(context);
setLayerType(LAYER_TYPE_HARDWARE, null);
}
public void setCellDimensions(int cellWidth, int cellHeight,
-23
View File
@@ -281,7 +281,6 @@ public class Workspace extends SmoothPagedView
@Override
public void onAnimationStart(Animator animation) {
mIsInUnshrinkAnimation = true;
disableCacheUpdates();
}
@Override
@@ -299,19 +298,13 @@ public class Workspace extends SmoothPagedView
mDrawCustomizeTrayBackground = false;
}
mWallpaperOffset.setOverrideHorizontalCatchupConstant(false);
enableCacheUpdates();
mAnimator = null;
}
};
mShrinkAnimationListener = new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
disableCacheUpdates();
}
@Override
public void onAnimationEnd(Animator animation) {
mWallpaperOffset.setOverrideHorizontalCatchupConstant(false);
enableCacheUpdates();
mAnimator = null;
}
};
@@ -1039,22 +1032,6 @@ public class Workspace extends SmoothPagedView
}
}
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) {
updateWallpaperOffsets();