Adding some wallpaper buttons on the customization tray.
Also tweaking the fading algorithm for side pages.
Change-Id: Ia7743c2b71741926ff9ae52e6965d7aefc86604e
diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java
index 2cd7f20..9dbe61d 100644
--- a/src/com/android/launcher2/PagedView.java
+++ b/src/com/android/launcher2/PagedView.java
@@ -374,17 +374,23 @@
int childWidth = layout.getMeasuredWidth();
int halfChildWidth = (childWidth / 2);
int childCenter = getChildOffset(i) + halfChildWidth;
- int distanceFromScreenCenter = Math.abs(childCenter - screenCenter);
- float alpha = 0.0f;
- if (distanceFromScreenCenter < halfChildWidth) {
- alpha = 1.0f;
- } else if (distanceFromScreenCenter > childWidth) {
- alpha = 0.0f;
+
+ int d = halfChildWidth;
+ int distanceFromScreenCenter = childCenter - screenCenter;
+ if (distanceFromScreenCenter > 0) {
+ if (i > 0) {
+ d += getChildAt(i - 1).getMeasuredWidth() / 2;
+ }
} else {
- float dimAlpha = (float) (distanceFromScreenCenter - halfChildWidth) / halfChildWidth;
- dimAlpha = Math.max(0.0f, Math.min(1.0f, (dimAlpha * dimAlpha)));
- alpha = 1.0f - dimAlpha;
+ if (i < childCount - 1) {
+ d += getChildAt(i + 1).getMeasuredWidth() / 2;
+ }
}
+
+ float dimAlpha = (float) (Math.abs(distanceFromScreenCenter)) / d;
+ dimAlpha = Math.max(0.0f, Math.min(1.0f, (dimAlpha * dimAlpha)));
+ float alpha = 1.0f - dimAlpha;
+
if (Float.compare(alpha, layout.getAlpha()) != 0) {
layout.setAlpha(alpha);
}