Moving side-page indicators to DragLayer to ensure it draws above hotseat gradient. (Bug 5117499)
Change-Id: Id0ab644f6631f4fd6be042b6be36ba8fe58eaae4
This commit is contained in:
@@ -517,6 +517,7 @@ public class DragController {
|
||||
mScrollState = SCROLL_OUTSIDE_ZONE;
|
||||
mScrollRunnable.setDirection(SCROLL_RIGHT);
|
||||
mDragScroller.onExitScrollArea();
|
||||
mLauncher.getDragLayer().onExitScrollArea();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -561,6 +562,7 @@ public class DragController {
|
||||
if (mScrollState == SCROLL_OUTSIDE_ZONE) {
|
||||
mScrollState = SCROLL_WAITING_IN_ZONE;
|
||||
if (mDragScroller.onEnterScrollArea(x, y, SCROLL_LEFT)) {
|
||||
mLauncher.getDragLayer().onEnterScrollArea(SCROLL_LEFT);
|
||||
mScrollRunnable.setDirection(SCROLL_LEFT);
|
||||
mHandler.postDelayed(mScrollRunnable, delay);
|
||||
}
|
||||
@@ -569,6 +571,7 @@ public class DragController {
|
||||
if (mScrollState == SCROLL_OUTSIDE_ZONE) {
|
||||
mScrollState = SCROLL_WAITING_IN_ZONE;
|
||||
if (mDragScroller.onEnterScrollArea(x, y, SCROLL_RIGHT)) {
|
||||
mLauncher.getDragLayer().onEnterScrollArea(SCROLL_RIGHT);
|
||||
mScrollRunnable.setDirection(SCROLL_RIGHT);
|
||||
mHandler.postDelayed(mScrollRunnable, delay);
|
||||
}
|
||||
@@ -831,6 +834,7 @@ public class DragController {
|
||||
mScrollState = SCROLL_OUTSIDE_ZONE;
|
||||
mDistanceSinceScroll = 0;
|
||||
mDragScroller.onExitScrollArea();
|
||||
mLauncher.getDragLayer().onExitScrollArea();
|
||||
|
||||
if (isDragging()) {
|
||||
// Force an update so that we can requeue the scroller if necessary
|
||||
|
||||
@@ -23,7 +23,11 @@ import android.animation.ValueAnimator;
|
||||
import android.animation.ValueAnimator.AnimatorUpdateListener;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffColorFilter;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
@@ -85,6 +89,9 @@ public class DragLayer extends FrameLayout implements ViewGroup.OnHierarchyChang
|
||||
setMotionEventSplittingEnabled(false);
|
||||
setChildrenDrawingOrderEnabled(true);
|
||||
setOnHierarchyChangeListener(this);
|
||||
|
||||
mLeftHoverDrawable = getResources().getDrawable(R.drawable.page_hover_left_holo);
|
||||
mRightHoverDrawable = getResources().getDrawable(R.drawable.page_hover_right_holo);
|
||||
}
|
||||
|
||||
public void setup(Launcher launcher, DragController controller) {
|
||||
@@ -720,4 +727,44 @@ public class DragLayer extends FrameLayout implements ViewGroup.OnHierarchyChang
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean mInScrollArea;
|
||||
private Drawable mLeftHoverDrawable;
|
||||
private Drawable mRightHoverDrawable;
|
||||
|
||||
void onEnterScrollArea(int direction) {
|
||||
mInScrollArea = true;
|
||||
invalidate();
|
||||
}
|
||||
|
||||
void onExitScrollArea() {
|
||||
mInScrollArea = false;
|
||||
invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dispatchDraw(Canvas canvas) {
|
||||
super.dispatchDraw(canvas);
|
||||
|
||||
if (mInScrollArea && !LauncherApplication.isScreenLarge()) {
|
||||
Workspace workspace = mLauncher.getWorkspace();
|
||||
int width = workspace.getWidth();
|
||||
Rect childRect = new Rect();
|
||||
getDescendantRectRelativeToSelf(workspace.getChildAt(0), childRect);
|
||||
|
||||
int page = workspace.getNextPage();
|
||||
CellLayout leftPage = (CellLayout) workspace.getChildAt(page - 1);
|
||||
CellLayout rightPage = (CellLayout) workspace.getChildAt(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(),
|
||||
childRect.top, width, childRect.bottom);
|
||||
mRightHoverDrawable.draw(canvas);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -270,6 +270,9 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
|
||||
int getCurrentPage() {
|
||||
return mCurrentPage;
|
||||
}
|
||||
int getNextPage() {
|
||||
return (mNextPage != INVALID_PAGE) ? mNextPage : mCurrentPage;
|
||||
}
|
||||
|
||||
int getPageCount() {
|
||||
return getChildCount();
|
||||
@@ -1858,9 +1861,8 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
|
||||
}
|
||||
|
||||
protected String getCurrentPageDescription() {
|
||||
int page = (mNextPage != INVALID_PAGE) ? mNextPage : mCurrentPage;
|
||||
return String.format(getContext().getString(R.string.default_scroll_format),
|
||||
page + 1, getChildCount());
|
||||
getNextPage() + 1, getChildCount());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -38,6 +38,8 @@ import android.graphics.Matrix;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffColorFilter;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.Region.Op;
|
||||
import android.graphics.drawable.Drawable;
|
||||
@@ -1313,38 +1315,6 @@ public class Workspace extends SmoothPagedView
|
||||
return (mBackground != null && mBackgroundAlpha > 0.0f && mDrawBackground);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dispatchDraw(Canvas canvas) {
|
||||
super.dispatchDraw(canvas);
|
||||
|
||||
if (mInScrollArea && !LauncherApplication.isScreenLarge()) {
|
||||
final int width = getWidth();
|
||||
final int height = getHeight();
|
||||
final int pageHeight = getChildAt(0).getHeight();
|
||||
|
||||
// Set the height of the outline to be the height of the page
|
||||
final int offset = (height - pageHeight - getPaddingTop() - getPaddingBottom()) / 2;
|
||||
final int paddingTop = getPaddingTop() + offset;
|
||||
final int paddingBottom = getPaddingBottom() + offset;
|
||||
|
||||
final int page = (mNextPage != INVALID_PAGE ? mNextPage : mCurrentPage);
|
||||
final CellLayout leftPage = (CellLayout) getChildAt(page - 1);
|
||||
final CellLayout rightPage = (CellLayout) getChildAt(page + 1);
|
||||
|
||||
if (leftPage != null && leftPage.getIsDragOverlapping()) {
|
||||
final Drawable d = getResources().getDrawable(R.drawable.page_hover_left_holo);
|
||||
d.setBounds(getScrollX(), paddingTop, getScrollX() + d.getIntrinsicWidth(),
|
||||
height - paddingBottom);
|
||||
d.draw(canvas);
|
||||
} else if (rightPage != null && rightPage.getIsDragOverlapping()) {
|
||||
final Drawable d = getResources().getDrawable(R.drawable.page_hover_right_holo);
|
||||
d.setBounds(getScrollX() + width - d.getIntrinsicWidth(), paddingTop,
|
||||
getScrollX() + width, height - paddingBottom);
|
||||
d.draw(canvas);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onRequestFocusInDescendants(int direction, Rect previouslyFocusedRect) {
|
||||
if (!mLauncher.isAllAppsVisible()) {
|
||||
@@ -1564,7 +1534,7 @@ public class Workspace extends SmoothPagedView
|
||||
AnimatorSet anim = animated ? new AnimatorSet() : null;
|
||||
|
||||
// Stop any scrolling, move to the current page right away
|
||||
setCurrentPage((mNextPage != INVALID_PAGE) ? mNextPage : mCurrentPage);
|
||||
setCurrentPage(getNextPage());
|
||||
|
||||
final State oldState = mState;
|
||||
final boolean oldStateIsNormal = (oldState == State.NORMAL);
|
||||
@@ -3285,7 +3255,7 @@ public class Workspace extends SmoothPagedView
|
||||
* screen while a scroll is in progress.
|
||||
*/
|
||||
public CellLayout getCurrentDropLayout() {
|
||||
return (CellLayout) getChildAt(mNextPage == INVALID_PAGE ? mCurrentPage : mNextPage);
|
||||
return (CellLayout) getChildAt(getNextPage());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3437,7 +3407,7 @@ public class Workspace extends SmoothPagedView
|
||||
if (!isSmall() && !mIsSwitchingState) {
|
||||
mInScrollArea = true;
|
||||
|
||||
final int page = (mNextPage != INVALID_PAGE ? mNextPage : mCurrentPage) +
|
||||
final int page = getNextPage() +
|
||||
(direction == DragController.SCROLL_LEFT ? -1 : 1);
|
||||
|
||||
// We always want to exit the current layout to ensure parity of enter / exit
|
||||
|
||||
Reference in New Issue
Block a user