Moving side-page indicators to DragLayer to ensure it draws above hotseat gradient. (Bug 5117499)

Change-Id: Id0ab644f6631f4fd6be042b6be36ba8fe58eaae4
This commit is contained in:
Winson Chung
2012-04-27 13:48:05 -07:00
parent 840ebf6277
commit 360e63fd3e
4 changed files with 60 additions and 37 deletions
+47
View File
@@ -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);
}
}
}
}