Adding MSDL haptics for dragging app icons in Workspace and Hotseat.
The feedback occurs when an icon hovers over an empty available space in
Workspace and Hotseat, as well as over other icons to create folders.
This is now compliant with the Multi-sensory Design Language spec.
Test: manual. Verified haptics while dragging icons over Workspace and
Hotseat.
Test: manual. Verified haptics with adb shell dumpsys of Launcher and
checking the MSDL token history.
Flag: com.android.launcher3.msdl_feedback
Bug: 371314631
Change-Id: I7d039ddf9d05faa39a6e6e3f9a84217d8916adc0
diff --git a/src/com/android/launcher3/CellLayout.java b/src/com/android/launcher3/CellLayout.java
index ee72c22..df5f520 100644
--- a/src/com/android/launcher3/CellLayout.java
+++ b/src/com/android/launcher3/CellLayout.java
@@ -71,6 +71,7 @@
import com.android.launcher3.model.data.LauncherAppWidgetInfo;
import com.android.launcher3.util.CellAndSpan;
import com.android.launcher3.util.GridOccupancy;
+import com.android.launcher3.util.MSDLPlayerWrapper;
import com.android.launcher3.util.MultiTranslateDelegate;
import com.android.launcher3.util.ParcelableSparseArray;
import com.android.launcher3.util.Themes;
@@ -78,6 +79,8 @@
import com.android.launcher3.views.ActivityContext;
import com.android.launcher3.widget.LauncherAppWidgetHostView;
+import com.google.android.msdl.data.model.MSDLToken;
+
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
@@ -204,6 +207,8 @@
private static final Paint sPaint = new Paint();
+ private final MSDLPlayerWrapper mMSDLPlayerWrapper;
+
// Related to accessible drag and drop
DragAndDropAccessibilityDelegate mTouchHelper;
@@ -237,6 +242,8 @@
mContainerType = a.getInteger(R.styleable.CellLayout_containerType, WORKSPACE);
a.recycle();
+ mMSDLPlayerWrapper = MSDLPlayerWrapper.INSTANCE.get(context);
+
// A ViewGroup usually does not draw, but CellLayout needs to draw a rectangle to show
// the user where a dragged item will land when dropped.
setWillNotDraw(false);
@@ -1153,6 +1160,9 @@
DropTarget.DragObject dragObject) {
if (mDragCell[0] != cellX || mDragCell[1] != cellY || mDragCellSpan[0] != spanX
|| mDragCellSpan[1] != spanY) {
+ if (Flags.msdlFeedback()) {
+ mMSDLPlayerWrapper.playToken(MSDLToken.DRAG_INDICATOR_DISCRETE);
+ }
mDragCell[0] = cellX;
mDragCell[1] = cellY;
mDragCellSpan[0] = spanX;