diff options
author | Patrick Dubroy <dubroy@google.com> | 2011-03-01 16:03:43 -0800 |
---|---|---|
committer | Patrick Dubroy <dubroy@google.com> | 2011-03-01 17:04:40 -0800 |
commit | e708c5249b26978057acb9370cbfb8f6f747f5b8 (patch) | |
tree | bb4e9c9f0f880b6a89314ffbc3c85316f9608e32 /src/com | |
parent | fecd3b8e36dc0b785271b7a501ed174247c412a4 (diff) | |
download | android_packages_apps_Trebuchet-e708c5249b26978057acb9370cbfb8f6f747f5b8.tar.gz android_packages_apps_Trebuchet-e708c5249b26978057acb9370cbfb8f6f747f5b8.tar.bz2 android_packages_apps_Trebuchet-e708c5249b26978057acb9370cbfb8f6f747f5b8.zip |
Fix 3457875: Mini workspace should zoom on tap, not touch down
Change-Id: I2e9bb6267048f2b2fb97070029f3a0ad2a28cc32
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/android/launcher2/Launcher.java | 5 | ||||
-rw-r--r-- | src/com/android/launcher2/Workspace.java | 41 |
2 files changed, 34 insertions, 12 deletions
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java index 195b671e0..9cea69b49 100644 --- a/src/com/android/launcher2/Launcher.java +++ b/src/com/android/launcher2/Launcher.java @@ -2245,6 +2245,10 @@ public final class Launcher extends Activity } public boolean onLongClick(View v) { + if (mState != State.WORKSPACE) { + return false; + } + switch (v.getId()) { case R.id.previous_screen: if (mState != State.ALL_APPS) { @@ -2277,7 +2281,6 @@ public final class Launcher extends Activity v = (View) v.getParent().getParent(); } - resetAddInfo(); CellLayout.CellInfo longClickCellInfo = (CellLayout.CellInfo) v.getTag(); // This happens when long clicking an item with the dpad/trackball diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java index 3e5a96795..e108f3821 100644 --- a/src/com/android/launcher2/Workspace.java +++ b/src/com/android/launcher2/Workspace.java @@ -76,7 +76,8 @@ import java.util.List; * interact with. A workspace is meant to be used with a fixed width only. */ public class Workspace extends SmoothPagedView - implements DropTarget, DragSource, DragScroller, View.OnTouchListener { + implements DropTarget, DragSource, DragScroller, View.OnTouchListener, + View.OnClickListener { @SuppressWarnings({"UnusedDeclaration"}) private static final String TAG = "Launcher.Workspace"; @@ -343,6 +344,8 @@ public class Workspace extends SmoothPagedView throw new IllegalArgumentException("A Workspace can only have CellLayout children."); } ((CellLayout) child).setOnInterceptTouchListener(this); + child.setOnClickListener(this); + child.setClickable(true); super.addView(child, index, params); } @@ -352,6 +355,8 @@ public class Workspace extends SmoothPagedView throw new IllegalArgumentException("A Workspace can only have CellLayout children."); } ((CellLayout) child).setOnInterceptTouchListener(this); + child.setOnClickListener(this); + child.setClickable(true); super.addView(child); } @@ -361,6 +366,8 @@ public class Workspace extends SmoothPagedView throw new IllegalArgumentException("A Workspace can only have CellLayout children."); } ((CellLayout) child).setOnInterceptTouchListener(this); + child.setOnClickListener(this); + child.setClickable(true); super.addView(child, index); } @@ -370,6 +377,8 @@ public class Workspace extends SmoothPagedView throw new IllegalArgumentException("A Workspace can only have CellLayout children."); } ((CellLayout) child).setOnInterceptTouchListener(this); + child.setOnClickListener(this); + child.setClickable(true); super.addView(child, width, height); } @@ -379,6 +388,8 @@ public class Workspace extends SmoothPagedView throw new IllegalArgumentException("A Workspace can only have CellLayout children."); } ((CellLayout) child).setOnInterceptTouchListener(this); + child.setOnClickListener(this); + child.setClickable(true); super.addView(child, params); } @@ -521,16 +532,25 @@ public class Workspace extends SmoothPagedView return hitsPage(current + 1, x, y); } + /** + * Called directly from a CellLayout (not by the framework), after we've been added as a + * listener via setOnInterceptTouchEventListener(). This allows us to tell the CellLayout + * that it should intercept touch events, which is not something that is normally supported. + */ + @Override public boolean onTouch(View v, MotionEvent event) { - // this is an intercepted event being forwarded from a cell layout - if (mIsSmall || mIsInUnshrinkAnimation) { - // Only allow clicks on a CellLayout if it is visible - if (mShrinkState != ShrinkState.BOTTOM_HIDDEN) { - mLauncher.onWorkspaceClick((CellLayout) v); - } - return true; + return (mIsSmall || mIsInUnshrinkAnimation); + } + + /** + * Handle a click event on a CellLayout. + */ + @Override + public void onClick(View cellLayout) { + // Only allow clicks on a CellLayout if it is shrunken and visible. + if ((mIsSmall || mIsInUnshrinkAnimation) && mShrinkState != ShrinkState.BOTTOM_HIDDEN) { + mLauncher.onWorkspaceClick((CellLayout) cellLayout); } - return false; } protected void onWindowVisibilityChanged (int visibility) { @@ -554,8 +574,7 @@ public class Workspace extends SmoothPagedView } if (mIsSmall || mIsInUnshrinkAnimation) { - if (mLauncher.isAllAppsVisible() && - mShrinkState == ShrinkState.BOTTOM_HIDDEN) { + if (mLauncher.isAllAppsVisible() && mShrinkState == ShrinkState.BOTTOM_HIDDEN) { // Intercept this event so we can show the workspace in full view // when it is clicked on and it is small AllAppsPagedView allApps = (AllAppsPagedView) |