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.
}
}
- void setIsDragOverlapping(boolean isDragOverlapping) {
- if (mIsDragOverlapping != isDragOverlapping) {
- mIsDragOverlapping = isDragOverlapping;
- setUseActiveGlowBackground(mIsDragOverlapping);
- invalidate();
- }
- }
-
void setUseActiveGlowBackground(boolean use) {
mUseActiveGlowBackground = use;
}
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;
}
}
public void setBackgroundAlphaMultiplier(float multiplier) {
+
if (mBackgroundAlphaMultiplier != multiplier) {
mBackgroundAlphaMultiplier = multiplier;
invalidate();
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);
}
}
private boolean mInScrollArea;
+ private boolean mShowPageHints;
private Drawable mLeftHoverDrawable;
private Drawable mRightHoverDrawable;
+ private Drawable mLeftHoverDrawableActive;
+ private Drawable mRightHoverDrawableActive;
void onEnterScrollArea(int direction) {
mInScrollArea = true;
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.
*/
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);
}
}
}
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);
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++) {
float scrollProgress = getScrollProgress(screenCenter, child, i);
float alpha = 1 - Math.abs(scrollProgress);
child.getShortcutsAndWidgets().setAlpha(alpha);
+ //child.setBackgroundAlphaMultiplier(1 - alpha);
}
}
}
updateStateForCustomContent(screenCenter);
enableHwLayersOnVisiblePages();
- boolean shouldOverScroll = (mOverScrollEffect < 0 && (!hasCustomContent() || isLayoutRtl())) ||
- (mOverScrollEffect > 0 && (!hasCustomContent() || !isLayoutRtl()));
+ boolean shouldOverScroll = mOverScrollX < 0 || mOverScrollX > mMaxScrollX;
if (shouldOverScroll) {
int index = 0;
}
}
- 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() {
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();
}
}
if (!mIsPageMoving) {
hideOutlines();
}
+ mLauncher.getDragLayer().hidePageHints();
}
void setCurrentDropLayout(CellLayout layout) {