diff options
author | Sunny Goyal <sunnygoyal@google.com> | 2016-06-07 17:10:33 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2016-06-07 17:10:33 +0000 |
commit | 2a5b356375e15602acab429642064c566a1a1f4d (patch) | |
tree | e1438922ab4896b68be623249849aaebd7cd69b1 | |
parent | 4c395f23673f9a42b51ce7b47be0940ce846e03d (diff) | |
parent | 7c786f75d131addf849551a8cbc084c7c4ed0730 (diff) | |
download | android_packages_apps_Trebuchet-2a5b356375e15602acab429642064c566a1a1f4d.tar.gz android_packages_apps_Trebuchet-2a5b356375e15602acab429642064c566a1a1f4d.tar.bz2 android_packages_apps_Trebuchet-2a5b356375e15602acab429642064c566a1a1f4d.zip |
Merge "Allowing the first screen to expand to the screen edge" into ub-launcher3-calgary
-rw-r--r-- | src/com/android/launcher3/CellLayout.java | 32 | ||||
-rw-r--r-- | src/com/android/launcher3/PagedView.java | 13 | ||||
-rw-r--r-- | src/com/android/launcher3/ShortcutAndWidgetContainer.java | 8 | ||||
-rw-r--r-- | src/com/android/launcher3/Workspace.java | 6 | ||||
-rw-r--r-- | src/com/android/launcher3/dragndrop/DragLayer.java | 7 |
5 files changed, 50 insertions, 16 deletions
diff --git a/src/com/android/launcher3/CellLayout.java b/src/com/android/launcher3/CellLayout.java index cfaa6a34d..6755ff70a 100644 --- a/src/com/android/launcher3/CellLayout.java +++ b/src/com/android/launcher3/CellLayout.java @@ -896,14 +896,30 @@ public class CellLayout extends ViewGroup implements BubbleTextShadowHandler { if (!isFullscreen) { left += (int) Math.ceil(getUnusedHorizontalSpace() / 2f); } + int right = r - l - getPaddingRight(); + if (!isFullscreen) { + right -= (int) Math.ceil(getUnusedHorizontalSpace() / 2f); + } + int top = getPaddingTop(); + int bottom = b - t - getPaddingBottom(); mTouchFeedbackView.layout(left, top, left + mTouchFeedbackView.getMeasuredWidth(), top + mTouchFeedbackView.getMeasuredHeight()); - mShortcutsAndWidgets.layout(left, top, - left + r - l, - top + b - t); + mShortcutsAndWidgets.layout(left, top, right, bottom); + + // Expand the background drawing bounds by the padding baked into the background drawable + mBackground.getPadding(mTempRect); + mBackground.setBounds( + left - mTempRect.left, + top - mTempRect.top, + right + mTempRect.right, + bottom + mTempRect.bottom); + } + + public Rect getBackgroundBounds() { + return mBackground.getBounds(); } /** @@ -916,16 +932,6 @@ public class CellLayout extends ViewGroup implements BubbleTextShadowHandler { } @Override - protected void onSizeChanged(int w, int h, int oldw, int oldh) { - super.onSizeChanged(w, h, oldw, oldh); - - // Expand the background drawing bounds by the padding baked into the background drawable - mBackground.getPadding(mTempRect); - mBackground.setBounds(-mTempRect.left, -mTempRect.top, - w + mTempRect.right, h + mTempRect.bottom); - } - - @Override protected void setChildrenDrawingCacheEnabled(boolean enabled) { mShortcutsAndWidgets.setChildrenDrawingCacheEnabled(enabled); } diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java index 4af53d279..bf9a421b1 100644 --- a/src/com/android/launcher3/PagedView.java +++ b/src/com/android/launcher3/PagedView.java @@ -647,6 +647,9 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc public static class LayoutParams extends ViewGroup.LayoutParams { public boolean isFullScreenPage = false; + // If true, the start edge of the page snaps to the start edge of the viewport. + public boolean matchStartEdge = false; + /** * {@inheritDoc} */ @@ -778,6 +781,10 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc childWidth = getViewportWidth() - horizontalPadding - mInsets.left - mInsets.right; + + if (lp.matchStartEdge) { + childWidth += getPaddingStart(); + } childHeight = getViewportHeight() - verticalPadding - mInsets.top - mInsets.bottom; mNormalChildHeight = childHeight; @@ -827,7 +834,8 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc LayoutParams lp = (LayoutParams) getChildAt(startIndex).getLayoutParams(); LayoutParams nextLp; - int childLeft = offsetX + (lp.isFullScreenPage ? 0 : getPaddingLeft()); + int childLeft = offsetX + + ((lp.isFullScreenPage || (!mIsRtl && lp.matchStartEdge)) ? 0 : getPaddingLeft()); if (mPageScrolls == null || childCount != mChildCountOnLastLayout) { mPageScrolls = new int[childCount]; } @@ -851,7 +859,8 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc child.layout(childLeft, childTop, childLeft + child.getMeasuredWidth(), childTop + childHeight); - int scrollOffsetLeft = lp.isFullScreenPage ? 0 : getPaddingLeft(); + int scrollOffsetLeft = (lp.isFullScreenPage || (!mIsRtl & lp.matchStartEdge)) ? + 0 : getPaddingLeft(); mPageScrolls[i] = childLeft - scrollOffsetLeft - offsetX; int pageGap = mPageSpacing; diff --git a/src/com/android/launcher3/ShortcutAndWidgetContainer.java b/src/com/android/launcher3/ShortcutAndWidgetContainer.java index 008dd847e..c016aa989 100644 --- a/src/com/android/launcher3/ShortcutAndWidgetContainer.java +++ b/src/com/android/launcher3/ShortcutAndWidgetContainer.java @@ -18,6 +18,7 @@ package com.android.launcher3; import android.app.WallpaperManager; import android.content.Context; +import android.graphics.Paint; import android.graphics.Rect; import android.view.View; import android.view.ViewGroup; @@ -217,4 +218,11 @@ public class ShortcutAndWidgetContainer extends ViewGroup { protected void setChildrenDrawnWithCacheEnabled(boolean enabled) { super.setChildrenDrawnWithCacheEnabled(enabled); } + + @Override + public void setLayerType(int layerType, Paint paint) { + // When clip children is disabled do not use hardware layer, + // as hardware layer forces clip children. + super.setLayerType(getClipChildren() ? layerType : LAYER_TYPE_NONE, paint); + } } diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index dd487fd93..bf8e31498 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -506,6 +506,12 @@ public class Workspace extends PagedView // Add the first page CellLayout firstPage = insertNewWorkspaceScreen(Workspace.FIRST_SCREEN_ID, 0); + if (!mIsRtl || !mLauncher.getDeviceProfile().isVerticalBarLayout()) { + // Let the cell layout extend the start padding. + ((LayoutParams) firstPage.getLayoutParams()).matchStartEdge = true; + firstPage.setPaddingRelative(getPaddingStart(), 0, 0, 0); + } + if (qsb == null) { // Always add a QSB on the first screen. qsb = mLauncher.getLayoutInflater().inflate(R.layout.qsb_container, diff --git a/src/com/android/launcher3/dragndrop/DragLayer.java b/src/com/android/launcher3/dragndrop/DragLayer.java index 4efcb3d5b..472da44ac 100644 --- a/src/com/android/launcher3/dragndrop/DragLayer.java +++ b/src/com/android/launcher3/dragndrop/DragLayer.java @@ -954,7 +954,12 @@ public class DragLayer extends InsettableFrameLayout { canvas.save(); if (currCellLayout != null && currCellLayout != mLauncher.getHotseat().getLayout()) { // Cut a hole in the darkening scrim on the page that should be highlighted, if any. - getDescendantRectRelativeToSelf(currCellLayout, mHighlightRect); + float scale = getDescendantRectRelativeToSelf(currCellLayout, mHighlightRect); + Rect backBounds = currCellLayout.getBackgroundBounds(); + mHighlightRect.left += (int) (backBounds.left * scale); + mHighlightRect.top += (int) (backBounds.top * scale); + mHighlightRect.right = (int) (mHighlightRect.left + backBounds.width() * scale); + mHighlightRect.bottom = (int) (mHighlightRect.top + backBounds.height() * scale); canvas.clipRect(mHighlightRect, Region.Op.DIFFERENCE); } canvas.drawColor((alpha << 24) | SCRIM_COLOR); |