Allowing the first screen to expand to the screen edge
This allows the QSB to extend all the way to the edge
Change-Id: I43c6e21e44fef7fffe6fb12b7afb95549b68679f
diff --git a/src/com/android/launcher3/CellLayout.java b/src/com/android/launcher3/CellLayout.java
index cfaa6a3..6755ff7 100644
--- a/src/com/android/launcher3/CellLayout.java
+++ b/src/com/android/launcher3/CellLayout.java
@@ -896,14 +896,30 @@
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 @@
}
@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 4af53d2..bf9a421 100644
--- a/src/com/android/launcher3/PagedView.java
+++ b/src/com/android/launcher3/PagedView.java
@@ -647,6 +647,9 @@
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 @@
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 @@
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 @@
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 008dd84..c016aa9 100644
--- a/src/com/android/launcher3/ShortcutAndWidgetContainer.java
+++ b/src/com/android/launcher3/ShortcutAndWidgetContainer.java
@@ -18,6 +18,7 @@
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 @@
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 4439266..faaca72 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -512,6 +512,12 @@
// 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 33ce683..9bb6cec 100644
--- a/src/com/android/launcher3/dragndrop/DragLayer.java
+++ b/src/com/android/launcher3/dragndrop/DragLayer.java
@@ -950,7 +950,12 @@
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);