summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher2/DimmableBubbleTextView.java
diff options
context:
space:
mode:
authorAdam Cohen <adamcohen@google.com>2010-09-29 13:02:43 -0700
committerAdam Cohen <adamcohen@google.com>2010-09-29 13:04:32 -0700
commit0fb7db5a3771223bc86fdf0e01665e69c1309cc1 (patch)
tree032c664a02611f0820e1d85f21d898844c3e812a /src/com/android/launcher2/DimmableBubbleTextView.java
parentde7658b5e02ae10010e44fcf8d9c5814f54d9eb0 (diff)
downloadandroid_packages_apps_Trebuchet-0fb7db5a3771223bc86fdf0e01665e69c1309cc1.tar.gz
android_packages_apps_Trebuchet-0fb7db5a3771223bc86fdf0e01665e69c1309cc1.tar.bz2
android_packages_apps_Trebuchet-0fb7db5a3771223bc86fdf0e01665e69c1309cc1.zip
Fixing boot stall.
Revert "-Added 3D effect to home screen scrolling" This reverts commit 9415d87eda0cf28b8df1eccde39b0ca1646be3b9. Change-Id: Ib8d6602f5d82884eb1f6cc44c0cc71cc563a3a59
Diffstat (limited to 'src/com/android/launcher2/DimmableBubbleTextView.java')
-rw-r--r--src/com/android/launcher2/DimmableBubbleTextView.java57
1 files changed, 48 insertions, 9 deletions
diff --git a/src/com/android/launcher2/DimmableBubbleTextView.java b/src/com/android/launcher2/DimmableBubbleTextView.java
index cb3b8efd6..66cc97a1b 100644
--- a/src/com/android/launcher2/DimmableBubbleTextView.java
+++ b/src/com/android/launcher2/DimmableBubbleTextView.java
@@ -21,17 +21,18 @@ import com.android.launcher.R;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
+import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.util.AttributeSet;
-public class DimmableBubbleTextView extends BubbleTextView implements Dimmable {
+public class DimmableBubbleTextView extends BubbleTextView {
private Paint mDimmedPaint = new Paint();
private int mAlpha;
+ private int mDimmedAlpha;
private Bitmap mDimmedView;
private Canvas mDimmedViewCanvas;
private boolean isDimmedViewUpdatePass;
- private float mDimmableProgress;
public DimmableBubbleTextView(Context context) {
super(context);
@@ -48,12 +49,48 @@ public class DimmableBubbleTextView extends BubbleTextView implements Dimmable {
mDimmedPaint.setFilterBitmap(true);
}
- public void setDimmableProgress(float progress) {
- mDimmableProgress = progress;
+ private static float cubic(float r) {
+ return (float) (Math.pow(r-1, 3) + 1);
}
- public float getDimmableProgress() {
- return mDimmableProgress;
+ /**
+ * Returns the interpolated holographic highlight alpha for the effect we want when scrolling
+ * pages.
+ */
+ public static float highlightAlphaInterpolator(float r) {
+ final float pivot = 0.3f;
+ if (r < pivot) {
+ return Math.max(0.5f, 0.65f*cubic(r/pivot));
+ } else {
+ return Math.min(1.0f, 0.65f*cubic(1 - (r-pivot)/(1-pivot)));
+ }
+ }
+
+ /**
+ * Returns the interpolated view alpha for the effect we want when scrolling pages.
+ */
+ public static float viewAlphaInterpolator(float r) {
+ final float pivot = 0.6f;
+ if (r < pivot) {
+ return r/pivot;
+ } else {
+ return 1.0f;
+ }
+ }
+
+ @Override
+ public boolean onSetAlpha(int alpha) {
+ super.onSetAlpha(alpha);
+ return true;
+ }
+
+ @Override
+ public void setAlpha(float alpha) {
+ final float viewAlpha = viewAlphaInterpolator(alpha);
+ final float dimmedAlpha = highlightAlphaInterpolator(alpha);
+ mAlpha = (int) (viewAlpha * 255);
+ mDimmedAlpha = (int) (dimmedAlpha * 255);
+ super.setAlpha(viewAlpha);
}
@Override
@@ -87,11 +124,13 @@ public class DimmableBubbleTextView extends BubbleTextView implements Dimmable {
super.setAlpha(alpha);
canvas.restore();
} else {
- super.onDraw(canvas);
+ if (mAlpha > 0) {
+ super.onDraw(canvas);
+ }
}
- if (mDimmedView != null && mDimmableProgress > 0) {
- mDimmedPaint.setAlpha((int) (mDimmableProgress * 255));
+ if (mDimmedView != null && mDimmedAlpha > 0) {
+ mDimmedPaint.setAlpha(mDimmedAlpha);
canvas.drawBitmap(mDimmedView, mScrollX, mScrollY, mDimmedPaint);
}
}