-Added 3D effect to home screen scrolling

-Added background outline fade in / out
-Modified the feel of scrolling: now using quintic
 interpolator and modified the influence of
 scroll velocity

Change-Id: Ifddcab5223ac20be7d9f800ccf09442d9b4db781
This commit is contained in:
Adam Cohen
2010-09-13 14:49:43 -07:00
parent 163c9c0236
commit 9415d87eda
9 changed files with 263 additions and 124 deletions

View File

@@ -37,7 +37,7 @@ import android.view.animation.LayoutAnimationController;
import java.util.Arrays;
public class CellLayout extends ViewGroup {
public class CellLayout extends ViewGroup implements Dimmable {
static final String TAG = "CellLayout";
private int mCellWidth;
@@ -68,8 +68,10 @@ public class CellLayout extends ViewGroup {
private float mBackgroundAlpha;
private final Rect mBackgroundLayoutRect = new Rect();
private Drawable mBackground;
private Drawable mBackgroundHover;
private Drawable mBackgroundMini;
private Drawable mBackgroundMiniHover;
// If we're actively dragging something over this screen and it's small,
// mHover is true
private boolean mHover = false;
@@ -108,10 +110,12 @@ public class CellLayout extends ViewGroup {
mOccupiedDrawable = getResources().getDrawable(R.drawable.rounded_rect_red);
if (LauncherApplication.isScreenXLarge()) {
mBackground = getResources().getDrawable(R.drawable.mini_home_screen_bg);
mBackgroundMini = getResources().getDrawable(R.drawable.mini_home_screen_bg);
mBackgroundMini.setFilterBitmap(true);
mBackground = getResources().getDrawable(R.drawable.home_screen_bg);
mBackground.setFilterBitmap(true);
mBackgroundHover = getResources().getDrawable(R.drawable.mini_home_screen_bg_hover);
mBackgroundHover.setFilterBitmap(true);
mBackgroundMiniHover = getResources().getDrawable(R.drawable.mini_home_screen_bg_hover);
mBackgroundMiniHover.setFilterBitmap(true);
}
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CellLayout, defStyle, 0);
@@ -149,7 +153,14 @@ public class CellLayout extends ViewGroup {
@Override
public void dispatchDraw(Canvas canvas) {
if (mBackgroundAlpha > 0.0f) {
final Drawable bg = mHover ? mBackgroundHover : mBackground;
Drawable bg;
if (mHover && getScaleX() < 0.5f) {
bg = mBackgroundMiniHover;
} else if (getScaleX() < 0.5f) {
bg = mBackgroundMini;
} else {
bg = mBackground;
}
bg.setAlpha((int) (mBackgroundAlpha * 255));
bg.draw(canvas);
}
@@ -169,6 +180,20 @@ public class CellLayout extends ViewGroup {
super.onDraw(canvas);
}
public void setDimmableProgress(float progress) {
for (int i = 0; i < getChildCount(); i++) {
Dimmable d = (Dimmable) getChildAt(i);
d.setDimmableProgress(progress);
}
}
public float getDimmableProgress() {
if (getChildCount() > 0) {
return ((Dimmable) getChildAt(0)).getDimmableProgress();
}
return 0.0f;
}
@Override
public void cancelLongPress() {
super.cancelLongPress();
@@ -523,8 +548,11 @@ public class CellLayout extends ViewGroup {
if (mBackground != null) {
mBackground.setBounds(mBackgroundLayoutRect);
}
if (mBackgroundHover != null) {
mBackgroundHover.setBounds(mBackgroundLayoutRect);
if (mBackgroundMiniHover != null) {
mBackgroundMiniHover.setBounds(mBackgroundLayoutRect);
}
if (mBackgroundMini != null) {
mBackgroundMini.setBounds(mBackgroundLayoutRect);
}
}