summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/CellLayout.java
diff options
context:
space:
mode:
authorMady Mellor <madym@google.com>2015-06-02 15:35:07 -0700
committerMady Mellor <madym@google.com>2015-06-02 15:35:07 -0700
commitef044dd380ac3abf354027750efdc16d5d48ac70 (patch)
tree4e1e94f011c84d407395617315504b6ae3d67c7e /src/com/android/launcher3/CellLayout.java
parent585b764ae24c7869704c428d1739e151e989674d (diff)
downloadandroid_packages_apps_Trebuchet-ef044dd380ac3abf354027750efdc16d5d48ac70.tar.gz
android_packages_apps_Trebuchet-ef044dd380ac3abf354027750efdc16d5d48ac70.tar.bz2
android_packages_apps_Trebuchet-ef044dd380ac3abf354027750efdc16d5d48ac70.zip
Stylus support: creating and setting listeners for stylus button press
This updates almost(*) all locations that use a long press listener to also set a custom touch listener that recognizes the stylus button press action. The stylus button press action is: when a stylus touches a view while the primary stylus button is pressed which may occur on a DOWN or MOVE event. *The location this is *not* enabled for is: Longpress to enter "overview" mode -- this isn't really a selection or drag n drop action; it is also easy to accidentally do this while using the stylus gesture to drag n drop items which is not an ideal interaction. Also not set for the "cling" that demonstrates this. Bug: 20430722 Change-Id: I9343f143261a7b4fada9afca28b8a11a60dbecca
Diffstat (limited to 'src/com/android/launcher3/CellLayout.java')
-rw-r--r--src/com/android/launcher3/CellLayout.java17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/com/android/launcher3/CellLayout.java b/src/com/android/launcher3/CellLayout.java
index 61567ac00..a57c1fe98 100644
--- a/src/com/android/launcher3/CellLayout.java
+++ b/src/com/android/launcher3/CellLayout.java
@@ -95,6 +95,7 @@ public class CellLayout extends ViewGroup implements BubbleTextShadowHandler {
boolean[][] mTmpOccupied;
private OnTouchListener mInterceptTouchListener;
+ private StylusEventHelper mStylusEventHelper;
private ArrayList<FolderRingAnimator> mFolderOuterRings = new ArrayList<FolderRingAnimator>();
private int[] mFolderLeaveBehindCell = {-1, -1};
@@ -286,6 +287,8 @@ public class CellLayout extends ViewGroup implements BubbleTextShadowHandler {
mShortcutsAndWidgets.setCellDimensions(mCellWidth, mCellHeight, mWidthGap, mHeightGap,
mCountX, mCountY);
+ mStylusEventHelper = new StylusEventHelper(this);
+
mTouchFeedbackView = new ClickShadowView(context);
addView(mTouchFeedbackView);
addView(mShortcutsAndWidgets);
@@ -338,6 +341,20 @@ public class CellLayout extends ViewGroup implements BubbleTextShadowHandler {
return false;
}
+ @Override
+ public boolean onTouchEvent(MotionEvent ev) {
+ boolean handled = super.onTouchEvent(ev);
+ // Stylus button press on a home screen should not switch between overview mode and
+ // the home screen mode, however, once in overview mode stylus button press should be
+ // enabled to allow rearranging the different home screens. So check what mode
+ // the workspace is in, and only perform stylus button presses while in overview mode.
+ if (mLauncher.mWorkspace.isInOverviewMode()
+ && mStylusEventHelper.checkAndPerformStylusEvent(ev)) {
+ return true;
+ }
+ return handled;
+ }
+
public void enableHardwareLayer(boolean hasLayer) {
mShortcutsAndWidgets.setLayerType(hasLayer ? LAYER_TYPE_HARDWARE : LAYER_TYPE_NONE, sPaint);
}