Merge "Allowing the first screen to expand to the screen edge" into ub-launcher3-calgary

This commit is contained in:
Sunny Goyal 2016-06-07 17:10:33 +00:00 committed by Android (Google) Code Review
commit 2a5b356375
5 changed files with 50 additions and 16 deletions

View File

@ -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();
}
/**
@ -915,16 +931,6 @@ public class CellLayout extends ViewGroup implements BubbleTextShadowHandler {
return getMeasuredWidth() - getPaddingLeft() - getPaddingRight() - (mCountX * mCellWidth);
}
@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);

View File

@ -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;

View File

@ -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);
}
}

View File

@ -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,

View File

@ -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);