summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher2/Workspace.java
diff options
context:
space:
mode:
authorPatrick Dubroy <dubroy@google.com>2011-03-01 16:03:43 -0800
committerPatrick Dubroy <dubroy@google.com>2011-03-01 17:04:40 -0800
commite708c5249b26978057acb9370cbfb8f6f747f5b8 (patch)
treebb4e9c9f0f880b6a89314ffbc3c85316f9608e32 /src/com/android/launcher2/Workspace.java
parentfecd3b8e36dc0b785271b7a501ed174247c412a4 (diff)
downloadandroid_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/android/launcher2/Workspace.java')
-rw-r--r--src/com/android/launcher2/Workspace.java41
1 files changed, 30 insertions, 11 deletions
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)