summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2010-11-17 17:39:27 -0800
committerWinson Chung <winsonc@google.com>2010-11-17 17:39:58 -0800
commit9171e6d8a2b7b5aa136617b9779a8bbadc5259f7 (patch)
treeae08781088b5d576554d3883539af4d255f88dc7 /src/com
parent6d7fe506fcfbc7bd6810ec8dd48c214e856aa87a (diff)
downloadandroid_packages_apps_Trebuchet-9171e6d8a2b7b5aa136617b9779a8bbadc5259f7.tar.gz
android_packages_apps_Trebuchet-9171e6d8a2b7b5aa136617b9779a8bbadc5259f7.tar.bz2
android_packages_apps_Trebuchet-9171e6d8a2b7b5aa136617b9779a8bbadc5259f7.zip
Adding initial background protection to AllApps/Customize drawer.
Change-Id: Id5e2b2dd82c2ee82526ae5c5179345275af246c6
Diffstat (limited to 'src/com')
-rw-r--r--src/com/android/launcher2/Workspace.java87
1 files changed, 70 insertions, 17 deletions
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 169f53fab..a8981775b 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -92,13 +92,22 @@ public class Workspace extends SmoothPagedView
private static final float EXTRA_SCALE_FACTOR_1 = 1.0f;
private static final float EXTRA_SCALE_FACTOR_2 = 1.10f;
- private static final int BACKGROUND_FADE_OUT_DELAY = 300;
- private static final int BACKGROUND_FADE_OUT_DURATION = 300;
- private static final int BACKGROUND_FADE_IN_DURATION = 100;
+ private static final int CHILDREN_OUTLINE_FADE_OUT_DELAY = 300;
+ private static final int CHILDREN_OUTLINE_FADE_OUT_DURATION = 300;
+ private static final int CHILDREN_OUTLINE_FADE_IN_DURATION = 100;
- // These animators are used to fade the background
+ private static final int BACKGROUND_FADE_OUT_DURATION = 450;
+ private static final int BACKGROUND_FADE_IN_DURATION = 350;
+
+ // These animators are used to fade the children's outlines
+ private ObjectAnimator mChildrenOutlineFadeInAnimation;
+ private ObjectAnimator mChildrenOutlineFadeOutAnimation;
+ private float mChildrenOutlineAlpha = 0;
+
+ // These properties refer to the background protection gradient used for AllApps and Customize
private ObjectAnimator mBackgroundFadeInAnimation;
private ObjectAnimator mBackgroundFadeOutAnimation;
+ private Drawable mBackground;
private float mBackgroundAlpha = 0;
private final WallpaperManager mWallpaperManager;
@@ -236,6 +245,9 @@ public class Workspace extends SmoothPagedView
mExternalDragOutlinePaint.setAntiAlias(true);
setWillNotDraw(false);
+ final Resources res = getResources();
+ mBackground = res.getDrawable(R.drawable.all_apps_bg_gradient);
+
mUnshrinkAnimationListener = new LauncherAnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
@@ -539,33 +551,58 @@ public class Workspace extends SmoothPagedView
public void showOutlines() {
if (!mIsSmall && !mIsInUnshrinkAnimation) {
- if (mBackgroundFadeOutAnimation != null) mBackgroundFadeOutAnimation.cancel();
- if (mBackgroundFadeInAnimation != null) mBackgroundFadeInAnimation.cancel();
- mBackgroundFadeInAnimation = ObjectAnimator.ofFloat(this, "backgroundAlpha", 1.0f);
- mBackgroundFadeInAnimation.setDuration(BACKGROUND_FADE_IN_DURATION);
- mBackgroundFadeInAnimation.start();
+ if (mChildrenOutlineFadeOutAnimation != null) mChildrenOutlineFadeOutAnimation.cancel();
+ if (mChildrenOutlineFadeInAnimation != null) mChildrenOutlineFadeInAnimation.cancel();
+ mChildrenOutlineFadeInAnimation = ObjectAnimator.ofFloat(this, "childrenOutlineAlpha", 1.0f);
+ mChildrenOutlineFadeInAnimation.setDuration(CHILDREN_OUTLINE_FADE_IN_DURATION);
+ mChildrenOutlineFadeInAnimation.start();
}
}
public void hideOutlines() {
if (!mIsSmall && !mIsInUnshrinkAnimation) {
- if (mBackgroundFadeInAnimation != null) mBackgroundFadeInAnimation.cancel();
- if (mBackgroundFadeOutAnimation != null) mBackgroundFadeOutAnimation.cancel();
- mBackgroundFadeOutAnimation = ObjectAnimator.ofFloat(this, "backgroundAlpha", 0.0f);
- mBackgroundFadeOutAnimation.setDuration(BACKGROUND_FADE_OUT_DURATION);
- mBackgroundFadeOutAnimation.setStartDelay(BACKGROUND_FADE_OUT_DELAY);
- mBackgroundFadeOutAnimation.start();
+ if (mChildrenOutlineFadeInAnimation != null) mChildrenOutlineFadeInAnimation.cancel();
+ if (mChildrenOutlineFadeOutAnimation != null) mChildrenOutlineFadeOutAnimation.cancel();
+ mChildrenOutlineFadeOutAnimation = ObjectAnimator.ofFloat(this, "childrenOutlineAlpha", 0.0f);
+ mChildrenOutlineFadeOutAnimation.setDuration(CHILDREN_OUTLINE_FADE_OUT_DURATION);
+ mChildrenOutlineFadeOutAnimation.setStartDelay(CHILDREN_OUTLINE_FADE_OUT_DELAY);
+ mChildrenOutlineFadeOutAnimation.start();
}
}
- public void setBackgroundAlpha(float alpha) {
- mBackgroundAlpha = alpha;
+ public void setChildrenOutlineAlpha(float alpha) {
+ mChildrenOutlineAlpha = alpha;
for (int i = 0; i < getChildCount(); i++) {
CellLayout cl = (CellLayout) getChildAt(i);
cl.setBackgroundAlpha(alpha);
}
}
+ public float getChildrenOutlineAlpha() {
+ return mChildrenOutlineAlpha;
+ }
+
+ public void showBackgroundGradient() {
+ if (mBackgroundFadeOutAnimation != null) mBackgroundFadeOutAnimation.cancel();
+ if (mBackgroundFadeInAnimation != null) mBackgroundFadeInAnimation.cancel();
+ mBackgroundFadeInAnimation = ObjectAnimator.ofFloat(this, "backgroundAlpha", 1.0f);
+ mBackgroundFadeInAnimation.setDuration(BACKGROUND_FADE_IN_DURATION);
+ mBackgroundFadeInAnimation.start();
+ }
+
+ public void hideBackgroundGradient() {
+ if (mBackgroundFadeInAnimation != null) mBackgroundFadeInAnimation.cancel();
+ if (mBackgroundFadeOutAnimation != null) mBackgroundFadeOutAnimation.cancel();
+ mBackgroundFadeOutAnimation = ObjectAnimator.ofFloat(this, "backgroundAlpha", 0.0f);
+ mBackgroundFadeOutAnimation.setDuration(BACKGROUND_FADE_OUT_DURATION);
+ mBackgroundFadeOutAnimation.start();
+ }
+
+ public void setBackgroundAlpha(float alpha) {
+ mBackgroundAlpha = alpha;
+ invalidate();
+ }
+
public float getBackgroundAlpha() {
return mBackgroundAlpha;
}
@@ -644,6 +681,18 @@ public class Workspace extends SmoothPagedView
}
@Override
+ protected void onDraw(Canvas canvas) {
+ // Draw the background gradient if necessary
+ if (mBackgroundAlpha > 0.0f) {
+ mBackground.setAlpha((int) (mBackgroundAlpha * 255));
+ mBackground.setBounds(mScrollX, 0, mScrollX + getMeasuredWidth(), getMeasuredHeight());
+ mBackground.draw(canvas);
+ }
+
+ super.onDraw(canvas);
+ }
+
+ @Override
protected void dispatchDraw(Canvas canvas) {
if (mIsSmall || mIsInUnshrinkAnimation) {
// Draw all the workspaces if we're small
@@ -822,6 +871,8 @@ public class Workspace extends SmoothPagedView
// we use this to shrink the workspace for the all apps view and the customize view
private void shrink(ShrinkPosition shrinkPosition, boolean animated) {
+ showBackgroundGradient();
+
if (mFirstLayout) {
// (mFirstLayout == "first layout has not happened yet")
// if we get a call to shrink() as part of our initialization (for example, if
@@ -1103,6 +1154,8 @@ public class Workspace extends SmoothPagedView
}
void unshrink(boolean animated) {
+ hideBackgroundGradient();
+
if (mIsSmall) {
mIsSmall = false;
if (mAnimator != null) {