Unify next / prev page hints for drag and drop across devices
-> Eliminate the white bgs on tablets during drag (issue 15880213) -> Add stateful (active and rest) next / prev page hints (issue 15937059) -> Fix recent regression which allowed overscroll in custom content area Change-Id: I1198dc88ca8570cb9e1afd3ca939be06a8dea92e
Before Width: | Height: | Size: 718 B After Width: | Height: | Size: 945 B |
Before Width: | Height: | Size: 730 B After Width: | Height: | Size: 1013 B |
Before Width: | Height: | Size: 471 B After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 170 B |
After Width: | Height: | Size: 160 B |
Before Width: | Height: | Size: 2.8 KiB |
After Width: | Height: | Size: 155 B |
After Width: | Height: | Size: 158 B |
Before Width: | Height: | Size: 243 B |
Before Width: | Height: | Size: 636 B After Width: | Height: | Size: 705 B |
Before Width: | Height: | Size: 549 B After Width: | Height: | Size: 669 B |
Before Width: | Height: | Size: 579 B After Width: | Height: | Size: 738 B |
Before Width: | Height: | Size: 412 B After Width: | Height: | Size: 746 B |
After Width: | Height: | Size: 141 B |
After Width: | Height: | Size: 156 B |
Before Width: | Height: | Size: 2.8 KiB |
After Width: | Height: | Size: 140 B |
After Width: | Height: | Size: 153 B |
Before Width: | Height: | Size: 180 B |
Before Width: | Height: | Size: 438 B After Width: | Height: | Size: 462 B |
Before Width: | Height: | Size: 809 B After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 872 B After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 531 B After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 166 B |
After Width: | Height: | Size: 166 B |
Before Width: | Height: | Size: 2.9 KiB |
After Width: | Height: | Size: 177 B |
After Width: | Height: | Size: 182 B |
Before Width: | Height: | Size: 272 B |
Before Width: | Height: | Size: 908 B After Width: | Height: | Size: 900 B |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 648 B After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 206 B |
After Width: | Height: | Size: 207 B |
Before Width: | Height: | Size: 3.0 KiB |
After Width: | Height: | Size: 199 B |
After Width: | Height: | Size: 203 B |
Before Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
|
@ -72,6 +72,7 @@ public class CellLayout extends ViewGroup {
|
|||
private int mHeightGap;
|
||||
private int mMaxGap;
|
||||
private boolean mDropPending = false;
|
||||
private boolean mIsDragTarget = true;
|
||||
|
||||
// These are temporary variables to prevent having to allocate a new object just to
|
||||
// return an (x, y) value from helper functions. Do NOT use them to maintain other state.
|
||||
|
@ -367,14 +368,6 @@ public class CellLayout extends ViewGroup {
|
|||
}
|
||||
}
|
||||
|
||||
void setIsDragOverlapping(boolean isDragOverlapping) {
|
||||
if (mIsDragOverlapping != isDragOverlapping) {
|
||||
mIsDragOverlapping = isDragOverlapping;
|
||||
setUseActiveGlowBackground(mIsDragOverlapping);
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
void setUseActiveGlowBackground(boolean use) {
|
||||
mUseActiveGlowBackground = use;
|
||||
}
|
||||
|
@ -383,6 +376,22 @@ public class CellLayout extends ViewGroup {
|
|||
mDrawBackground = false;
|
||||
}
|
||||
|
||||
void disableDragTarget() {
|
||||
mIsDragTarget = false;
|
||||
}
|
||||
|
||||
boolean isDragTarget() {
|
||||
return mIsDragTarget;
|
||||
}
|
||||
|
||||
void setIsDragOverlapping(boolean isDragOverlapping) {
|
||||
if (mIsDragOverlapping != isDragOverlapping) {
|
||||
mIsDragOverlapping = isDragOverlapping;
|
||||
setUseActiveGlowBackground(mIsDragOverlapping);
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
boolean getIsDragOverlapping() {
|
||||
return mIsDragOverlapping;
|
||||
}
|
||||
|
@ -946,6 +955,7 @@ public class CellLayout extends ViewGroup {
|
|||
}
|
||||
|
||||
public void setBackgroundAlphaMultiplier(float multiplier) {
|
||||
|
||||
if (mBackgroundAlphaMultiplier != multiplier) {
|
||||
mBackgroundAlphaMultiplier = multiplier;
|
||||
invalidate();
|
||||
|
|
|
@ -96,8 +96,10 @@ public class DragLayer extends FrameLayout implements ViewGroup.OnHierarchyChang
|
|||
setOnHierarchyChangeListener(this);
|
||||
|
||||
final Resources res = getResources();
|
||||
mLeftHoverDrawable = res.getDrawable(R.drawable.page_hover_left_holo);
|
||||
mRightHoverDrawable = res.getDrawable(R.drawable.page_hover_right_holo);
|
||||
mLeftHoverDrawable = res.getDrawable(R.drawable.page_hover_left);
|
||||
mRightHoverDrawable = res.getDrawable(R.drawable.page_hover_right);
|
||||
mLeftHoverDrawableActive = res.getDrawable(R.drawable.page_hover_left_active);
|
||||
mRightHoverDrawableActive = res.getDrawable(R.drawable.page_hover_right_active);
|
||||
mBackground = res.getDrawable(R.drawable.apps_customize_bg);
|
||||
}
|
||||
|
||||
|
@ -850,8 +852,11 @@ public class DragLayer extends FrameLayout implements ViewGroup.OnHierarchyChang
|
|||
}
|
||||
|
||||
private boolean mInScrollArea;
|
||||
private boolean mShowPageHints;
|
||||
private Drawable mLeftHoverDrawable;
|
||||
private Drawable mRightHoverDrawable;
|
||||
private Drawable mLeftHoverDrawableActive;
|
||||
private Drawable mRightHoverDrawableActive;
|
||||
|
||||
void onEnterScrollArea(int direction) {
|
||||
mInScrollArea = true;
|
||||
|
@ -863,6 +868,16 @@ public class DragLayer extends FrameLayout implements ViewGroup.OnHierarchyChang
|
|||
invalidate();
|
||||
}
|
||||
|
||||
void showPageHints() {
|
||||
mShowPageHints = true;
|
||||
invalidate();
|
||||
}
|
||||
|
||||
void hidePageHints() {
|
||||
mShowPageHints = false;
|
||||
invalidate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Note: this is a reimplementation of View.isLayoutRtl() since that is currently hidden api.
|
||||
*/
|
||||
|
@ -883,25 +898,32 @@ public class DragLayer extends FrameLayout implements ViewGroup.OnHierarchyChang
|
|||
super.dispatchDraw(canvas);
|
||||
|
||||
// Draw screen hover indicators above children.
|
||||
if (mInScrollArea && !LauncherAppState.getInstance().isScreenLarge()) {
|
||||
if (mShowPageHints) {
|
||||
Workspace workspace = mLauncher.getWorkspace();
|
||||
int width = getMeasuredWidth();
|
||||
Rect childRect = new Rect();
|
||||
getDescendantRectRelativeToSelf(workspace.getChildAt(0), childRect);
|
||||
getDescendantRectRelativeToSelf(workspace.getChildAt(workspace.getChildCount() - 1),
|
||||
childRect);
|
||||
|
||||
int page = workspace.getNextPage();
|
||||
final boolean isRtl = isLayoutRtl();
|
||||
CellLayout leftPage = (CellLayout) workspace.getChildAt(isRtl ? page + 1 : page - 1);
|
||||
CellLayout rightPage = (CellLayout) workspace.getChildAt(isRtl ? page - 1 : page + 1);
|
||||
|
||||
if (leftPage != null && leftPage.getIsDragOverlapping()) {
|
||||
mLeftHoverDrawable.setBounds(0, childRect.top,
|
||||
mLeftHoverDrawable.getIntrinsicWidth(), childRect.bottom);
|
||||
mLeftHoverDrawable.draw(canvas);
|
||||
} else if (rightPage != null && rightPage.getIsDragOverlapping()) {
|
||||
mRightHoverDrawable.setBounds(width - mRightHoverDrawable.getIntrinsicWidth(),
|
||||
if (leftPage != null && leftPage.isDragTarget()) {
|
||||
Drawable left = mInScrollArea && leftPage.getIsDragOverlapping() ?
|
||||
mLeftHoverDrawableActive : mLeftHoverDrawable;
|
||||
left.setBounds(0, childRect.top,
|
||||
left.getIntrinsicWidth(), childRect.bottom);
|
||||
left.draw(canvas);
|
||||
}
|
||||
if (rightPage != null && rightPage.isDragTarget()) {
|
||||
Drawable right = mInScrollArea && rightPage.getIsDragOverlapping() ?
|
||||
mRightHoverDrawableActive : mRightHoverDrawable;
|
||||
|
||||
right.setBounds(width - right.getIntrinsicWidth(),
|
||||
childRect.top, width, childRect.bottom);
|
||||
mRightHoverDrawable.draw(canvas);
|
||||
right.draw(canvas);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -585,6 +585,7 @@ public class Workspace extends SmoothPagedView
|
|||
CellLayout customScreen = (CellLayout)
|
||||
mLauncher.getLayoutInflater().inflate(R.layout.workspace_screen, null);
|
||||
customScreen.disableBackground();
|
||||
customScreen.disableDragTarget();
|
||||
|
||||
mWorkspaceScreens.put(CUSTOM_CONTENT_SCREEN_ID, customScreen);
|
||||
mScreenOrder.add(0, CUSTOM_CONTENT_SCREEN_ID);
|
||||
|
@ -1583,7 +1584,7 @@ public class Workspace extends SmoothPagedView
|
|||
private void updatePageAlphaValues(int screenCenter) {
|
||||
boolean isInOverscroll = mOverScrollX < 0 || mOverScrollX > mMaxScrollX;
|
||||
if (mWorkspaceFadeInAdjacentScreens &&
|
||||
mState == State.NORMAL &&
|
||||
!workspaceInModalState() &&
|
||||
!mIsSwitchingState &&
|
||||
!isInOverscroll) {
|
||||
for (int i = numCustomPages(); i < getChildCount(); i++) {
|
||||
|
@ -1592,6 +1593,7 @@ public class Workspace extends SmoothPagedView
|
|||
float scrollProgress = getScrollProgress(screenCenter, child, i);
|
||||
float alpha = 1 - Math.abs(scrollProgress);
|
||||
child.getShortcutsAndWidgets().setAlpha(alpha);
|
||||
//child.setBackgroundAlphaMultiplier(1 - alpha);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1685,8 +1687,7 @@ public class Workspace extends SmoothPagedView
|
|||
updateStateForCustomContent(screenCenter);
|
||||
enableHwLayersOnVisiblePages();
|
||||
|
||||
boolean shouldOverScroll = (mOverScrollEffect < 0 && (!hasCustomContent() || isLayoutRtl())) ||
|
||||
(mOverScrollEffect > 0 && (!hasCustomContent() || !isLayoutRtl()));
|
||||
boolean shouldOverScroll = mOverScrollX < 0 || mOverScrollX > mMaxScrollX;
|
||||
|
||||
if (shouldOverScroll) {
|
||||
int index = 0;
|
||||
|
@ -1710,14 +1711,16 @@ public class Workspace extends SmoothPagedView
|
|||
}
|
||||
}
|
||||
|
||||
private void computeOverScrollEffect(float amount) {
|
||||
mOverScrollEffect = acceleratedOverFactor(amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void overScroll(float amount) {
|
||||
computeOverScrollEffect(amount);
|
||||
dampedOverScroll(amount);
|
||||
boolean shouldOverScroll = (amount < 0 && (!hasCustomContent() || isLayoutRtl())) ||
|
||||
(amount > 0 && (!hasCustomContent() || !isLayoutRtl()));
|
||||
if (shouldOverScroll) {
|
||||
dampedOverScroll(amount);
|
||||
mOverScrollEffect = acceleratedOverFactor(amount);
|
||||
} else {
|
||||
mOverScrollEffect = 0;
|
||||
}
|
||||
}
|
||||
|
||||
protected void onAttachedToWindow() {
|
||||
|
@ -3242,10 +3245,8 @@ public class Workspace extends SmoothPagedView
|
|||
setCurrentDropLayout(layout);
|
||||
setCurrentDragOverlappingLayout(layout);
|
||||
|
||||
// Because we don't have space in the Phone UI (the CellLayouts run to the edge) we
|
||||
// don't need to show the outlines
|
||||
if (LauncherAppState.getInstance().isScreenLarge()) {
|
||||
showOutlines();
|
||||
if (!workspaceInModalState()) {
|
||||
mLauncher.getDragLayer().showPageHints();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3320,6 +3321,7 @@ public class Workspace extends SmoothPagedView
|
|||
if (!mIsPageMoving) {
|
||||
hideOutlines();
|
||||
}
|
||||
mLauncher.getDragLayer().hidePageHints();
|
||||
}
|
||||
|
||||
void setCurrentDropLayout(CellLayout layout) {
|
||||
|
|