Tweaking spacing and layout of AllApps/Customize in portrait.
- Also added workaround for tab label not being initially selected
- Added fix for initial layout of PagedViews preventing side pages from having proper alpha
- Marking widget dims format string as not translatable
Change-Id: I74a5410b88e2766816a87b14e64058b4288c214d
diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java
index 8332053..97bbbdf 100644
--- a/src/com/android/launcher2/PagedView.java
+++ b/src/com/android/launcher2/PagedView.java
@@ -406,6 +406,14 @@
int halfChildWidth = (childWidth / 2);
int childCenter = getChildOffset(i) + halfChildWidth;
+ // On the first layout, we may not have a width nor a proper offset, so for now
+ // we should just assume full page width (and calculate the offset according to
+ // that).
+ if (childWidth <= 0) {
+ childWidth = getMeasuredWidth();
+ childCenter = (i * childWidth) + (childWidth / 2);
+ }
+
int d = halfChildWidth;
int distanceFromScreenCenter = childCenter - screenCenter;
if (distanceFromScreenCenter > 0) {
@@ -419,6 +427,9 @@
}
d += mPageSpacing;
+ // Preventing potential divide-by-zero
+ d = Math.max(1, d);
+
float dimAlpha = (float) (Math.abs(distanceFromScreenCenter)) / d;
dimAlpha = Math.max(0.0f, Math.min(1.0f, (dimAlpha * dimAlpha)));
float alpha = 1.0f - dimAlpha;
@@ -1237,6 +1248,7 @@
// Load any pages that are necessary for the current window of views
loadAssociatedPages(mCurrentPage);
mDirtyPageAlpha = true;
+ updateAdjacentPagesAlpha();
requestLayout();
}
}