summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Cohen <adamcohen@google.com>2014-08-18 14:23:44 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-08-18 14:23:44 +0000
commitf81eb912b0b7641433d042b4a50cd50b572dcff3 (patch)
treee076471861d972951e8c77c022bff08ab41e8b4f
parente8f27a97273802fbf55874cf34b6d2ed14165640 (diff)
parentb8d9e90918730d8bcfba162cf307ffedee777aae (diff)
downloadandroid_packages_apps_Trebuchet-f81eb912b0b7641433d042b4a50cd50b572dcff3.tar.gz
android_packages_apps_Trebuchet-f81eb912b0b7641433d042b4a50cd50b572dcff3.tar.bz2
android_packages_apps_Trebuchet-f81eb912b0b7641433d042b4a50cd50b572dcff3.zip
am b8d9e909: Merge "Get rid of pages overhang in AppsCustomizePagedView" into ub-now-porkchop
* commit 'b8d9e90918730d8bcfba162cf307ffedee777aae': Get rid of pages overhang in AppsCustomizePagedView
-rw-r--r--src/com/android/launcher3/AppsCustomizePagedView.java1
-rw-r--r--src/com/android/launcher3/PagedView.java20
2 files changed, 21 insertions, 0 deletions
diff --git a/src/com/android/launcher3/AppsCustomizePagedView.java b/src/com/android/launcher3/AppsCustomizePagedView.java
index 787bf96d2..d23e65f81 100644
--- a/src/com/android/launcher3/AppsCustomizePagedView.java
+++ b/src/com/android/launcher3/AppsCustomizePagedView.java
@@ -259,6 +259,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
if (getImportantForAccessibility() == View.IMPORTANT_FOR_ACCESSIBILITY_AUTO) {
setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES);
}
+ setSinglePageInViewport();
}
@Override
diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java
index cd0d55021..0dbcd97f0 100644
--- a/src/com/android/launcher3/PagedView.java
+++ b/src/com/android/launcher3/PagedView.java
@@ -166,6 +166,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
protected int mUnboundedScrollX;
protected int[] mTempVisiblePagesRange = new int[2];
protected boolean mForceDrawAllChildrenNextFrame;
+ private boolean mSpacePagesAutomatically = false;
// mOverScrollX is equal to getScrollX() when we're within the normal scroll range. Otherwise
// it is equal to the scaled overscroll position. We use a separate value so as to prevent
@@ -844,6 +845,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
final int verticalPadding = getPaddingTop() + getPaddingBottom();
final int horizontalPadding = getPaddingLeft() + getPaddingRight();
+ int referenceChildWidth = 0;
// The children are given the same width and height as the workspace
// unless they were set to WRAP_CONTENT
if (DEBUG) Log.d(TAG, "PagedView.onMeasure(): " + widthSize + ", " + heightSize);
@@ -888,6 +890,9 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
childWidth = getViewportWidth() - mInsets.left - mInsets.right;
childHeight = getViewportHeight();
}
+ if (referenceChildWidth == 0) {
+ referenceChildWidth = childWidth;
+ }
final int childWidthMeasureSpec =
MeasureSpec.makeMeasureSpec(childWidth, childWidthMode);
@@ -896,9 +901,24 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
}
}
+ if (mSpacePagesAutomatically) {
+ int spacing = (getViewportWidth() - mInsets.left - mInsets.right
+ - referenceChildWidth) / 2;
+ if (spacing >= 0) {
+ setPageSpacing(spacing);
+ }
+ mSpacePagesAutomatically = false;
+ }
setMeasuredDimension(scaledWidthSize, scaledHeightSize);
}
+ /**
+ * This method should be called once before first layout / measure pass.
+ */
+ protected void setSinglePageInViewport() {
+ mSpacePagesAutomatically = true;
+ }
+
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
if (!mIsDataReady || getChildCount() == 0) {