Merge "Removing developer options check for app info target" into ub-launcher3-burnaby
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 076a6e6..796de3f 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -98,7 +98,6 @@
 
 import com.android.launcher3.DropTarget.DragObject;
 import com.android.launcher3.PagedView.PageSwitchListener;
-import com.android.launcher3.accessibility.LauncherAccessibilityDelegate;
 import com.android.launcher3.allapps.AllAppsContainerView;
 import com.android.launcher3.allapps.AppSearchManager;
 import com.android.launcher3.compat.AppWidgetManagerCompat;
@@ -2470,9 +2469,8 @@
             return;
         }
 
-        LauncherAccessibilityDelegate delegate =
-                LauncherAppState.getInstance().getAccessibilityDelegate();
-        if (delegate != null && delegate.onBackPressed()) {
+        if (mDragController.isDragging()) {
+            mDragController.cancelDrag();
             return;
         }
 
diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java
index 18832c6..4a85b44 100644
--- a/src/com/android/launcher3/PagedView.java
+++ b/src/com/android/launcher3/PagedView.java
@@ -567,6 +567,13 @@
     public void scrollTo(int x, int y) {
         // In free scroll mode, we clamp the scrollX
         if (mFreeScroll) {
+            // If the scroller is trying to move to a location beyond the maximum allowed
+            // in the free scroll mode, we make sure to end the scroll operation.
+            if (!mScroller.isFinished() &&
+                    (x > mFreeScrollMaxScrollX || x < mFreeScrollMinScrollX)) {
+                forceFinishScroller();
+            }
+
             x = Math.min(x, mFreeScrollMaxScrollX);
             x = Math.max(x, mFreeScrollMinScrollX);
         }
diff --git a/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java b/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java
index 3c49ccc..fe7b25e 100644
--- a/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java
+++ b/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java
@@ -20,6 +20,8 @@
 import com.android.launcher3.AppWidgetResizeFrame;
 import com.android.launcher3.CellLayout;
 import com.android.launcher3.DeleteDropTarget;
+import com.android.launcher3.DragController.DragListener;
+import com.android.launcher3.DragSource;
 import com.android.launcher3.Folder;
 import com.android.launcher3.FolderInfo;
 import com.android.launcher3.InfoDropTarget;
@@ -39,7 +41,7 @@
 import java.util.ArrayList;
 
 @TargetApi(Build.VERSION_CODES.LOLLIPOP)
-public class LauncherAccessibilityDelegate extends AccessibilityDelegate {
+public class LauncherAccessibilityDelegate extends AccessibilityDelegate implements DragListener {
 
     private static final String TAG = "LauncherAccessibilityDelegate";
 
@@ -328,7 +330,6 @@
         mLauncher.getDragLayer().getDescendantCoordRelativeToSelf(clickedTarget, loc);
         mLauncher.getDragController().completeAccessibleDrag(loc);
 
-        endAccessibleDrag();
         if (!TextUtils.isEmpty(confirmation)) {
             announceConfirmation(confirmation);
         }
@@ -366,22 +367,21 @@
         }
         mDragSource.enableAccessibleDrag(true);
         mDragSource.startDrag(cellInfo, true);
-    }
 
-    public boolean onBackPressed() {
-        if (isInAccessibleDrag()) {
-            cancelAccessibleDrag();
-            return true;
+        if (mLauncher.getDragController().isDragging()) {
+            mLauncher.getDragController().addDragListener(this);
         }
-        return false;
     }
 
-    private void cancelAccessibleDrag() {
-        mLauncher.getDragController().cancelDrag();
-        endAccessibleDrag();
+
+    @Override
+    public void onDragStart(DragSource source, Object info, int dragAction) {
+        // No-op
     }
 
-    private void endAccessibleDrag() {
+    @Override
+    public void onDragEnd() {
+        mLauncher.getDragController().removeDragListener(this);
         mDragInfo = null;
         if (mDragSource != null) {
             mDragSource.enableAccessibleDrag(false);