From 0207c522472d7252f146f4d39efa456ca5248c6b Mon Sep 17 00:00:00 2001 From: Patrick Dubroy Date: Wed, 3 Nov 2010 22:12:02 -0700 Subject: [PATCH] Draw glow along screen edge when dragging in portrait. --- res/drawable/page_hover_left.9.png | Bin 0 -> 413 bytes res/drawable/page_hover_right.9.png | Bin 0 -> 415 bytes res/values-xlarge-port/dimens.xml | 4 +++ src/com/android/launcher2/CellLayout.java | 4 +++ src/com/android/launcher2/Workspace.java | 32 +++++++++++++++++++--- 5 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 res/drawable/page_hover_left.9.png create mode 100644 res/drawable/page_hover_right.9.png diff --git a/res/drawable/page_hover_left.9.png b/res/drawable/page_hover_left.9.png new file mode 100644 index 0000000000000000000000000000000000000000..5d5e0c8118cdef5b885a4aebc9caf555b0340e20 GIT binary patch literal 413 zcmV;O0b>4%P)jiU=aQ%ptN91VPlpxbP) zybwd5ME@(%6F}*}J2Ck|jLCU8gfg={62%*$AW2g(Wb!hzl!^U2V%s3gWb&-0AWIUs zCTjY*C$MPptR`Cs%aRJ*5*0;16ttq~)72=8)e^}{0+Mqf=t%EXMW2)7gw+zr$|V4O zJeM8c6Ke;=d@M`#^f3)k*v(=)NZUG65%k zB)VRS-Unjfi5SYv9v5pKd?8BD#8_r_v*E=0J$_Cs-Vo(9Aj)o@&4y(*@g=cYBX&~( z%Wexa&t^lyvXbna5sd_3cFenF7g*9fA@P!`>|GG`uRy`sG4F~|RhgEZWr_DSpCkZ9 zQNDYeol|1wida#i1I2M_1>2n}F>Je|DzjR{ssXBSlnU5_oqtuDyCv3|Ks6VTl}SPK z^1rVC4{LeAJuxCXQw?Il0Tv0s&Op&02b5sr$3S#fE0y + + 40dp + 0dp 32dp diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java index 66d5cb500d..11c0c1822d 100644 --- a/src/com/android/launcher2/CellLayout.java +++ b/src/com/android/launcher2/CellLayout.java @@ -327,6 +327,10 @@ public class CellLayout extends ViewGroup implements Dimmable { } } + public boolean getHover() { + return mHover; + } + public void drawChildren(Canvas canvas) { super.dispatchDraw(canvas); } diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java index 4679c645d8..df3d2de528 100644 --- a/src/com/android/launcher2/Workspace.java +++ b/src/com/android/launcher2/Workspace.java @@ -605,6 +605,30 @@ public class Workspace extends SmoothPagedView } else { super.dispatchDraw(canvas); + final int width = getWidth(); + final int height = getHeight(); + + // In portrait orientation, draw the glowing edge when dragging to adjacent screens + if (mInScrollArea && (height > width)) { + final int pageHeight = getChildAt(0).getHeight(); + + // This determines the height of the glowing edge: 90% of the page height + final int padding = (int) ((height - pageHeight) * 0.5f + pageHeight * 0.1f); + + final CellLayout leftPage = (CellLayout) getChildAt(mCurrentPage - 1); + final CellLayout rightPage = (CellLayout) getChildAt(mCurrentPage + 1); + + if (leftPage != null && leftPage.getHover()) { + final Drawable d = getResources().getDrawable(R.drawable.page_hover_left); + d.setBounds(mScrollX, padding, mScrollX + d.getIntrinsicWidth(), height - padding); + d.draw(canvas); + } else if (rightPage != null && rightPage.getHover()) { + final Drawable d = getResources().getDrawable(R.drawable.page_hover_right); + d.setBounds(mScrollX + width - d.getIntrinsicWidth(), padding, mScrollX + width, height - padding); + d.draw(canvas); + } + } + if (mDropView != null) { // We are animating an item that was just dropped on the home screen. // Render its View in the current animation position. @@ -1909,11 +1933,11 @@ public class Workspace extends SmoothPagedView final int screen = getCurrentPage() + ((direction == DragController.SCROLL_LEFT) ? -1 : 1); if (0 <= screen && screen < getChildCount()) { ((CellLayout) getChildAt(screen)).setHover(true); - } - if (mDragTargetLayout != null) { - mDragTargetLayout.onDragExit(); - mDragTargetLayout = null; + if (mDragTargetLayout != null) { + mDragTargetLayout.onDragExit(); + mDragTargetLayout = null; + } } } }