Enabling framework DND in N+.
Also, making the drag shadow opaque.
Bug: 22028725
Change-Id: I2aa61d3906cb9e9c33003bc6e485b9ff1980b9f4
diff --git a/src/com/android/launcher3/DragDriver.java b/src/com/android/launcher3/DragDriver.java
index 56b7632..b4e7bda 100644
--- a/src/com/android/launcher3/DragDriver.java
+++ b/src/com/android/launcher3/DragDriver.java
@@ -47,10 +47,7 @@
public static DragDriver create(
DragController dragController, ItemInfo dragInfo, DragView dragView) {
- // TODO: Replace the hardcoded constant with looking at the API version.
- final boolean useSystemDrag = false;
-
- if (useSystemDrag) {
+ if (Utilities.isNycOrAbove()) {
return new SystemDragDriver(dragController, dragInfo.getIntent(), dragView);
} else {
return new InternalDragDriver(dragController);
@@ -108,7 +105,9 @@
View.DragShadowBuilder shadowBuilder = new ShadowBuilder(mDragView);
// TODO: DND flags are in flux, once settled, use the appropriate constant.
- final int flags = mDragIntent != null ? 1 : 0;
+ final int flagGlobal = 1 << 0;
+ final int flagOpaque = 1 << 9;
+ final int flags = (mDragIntent != null ? flagGlobal : 0) | flagOpaque;
mDragging = true;
diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java
index 9ae989f..00d4c8d 100644
--- a/src/com/android/launcher3/Utilities.java
+++ b/src/com/android/launcher3/Utilities.java
@@ -130,6 +130,18 @@
return Build.VERSION.SDK_INT == 22;
}
+ public static boolean isNycOrAbove() {
+ // TODO(vadimt): Replace using reflection with looking at the API version once
+ // Build.VERSION.SDK_INT gets bumped to 24. b/22942492.
+ try {
+ View.class.getDeclaredField("DRAG_FLAG_OPAQUE");
+ // View.DRAG_FLAG_OPAQUE doesn't exist in M-release, so it's an indication of N+.
+ return true;
+ } catch (NoSuchFieldException e) {
+ return false;
+ }
+ }
+
public static Bitmap createIconBitmap(Cursor c, int iconIndex, Context context) {
byte[] data = c.getBlob(iconIndex);
try {