From 10ad1b9761d27008cb16aaec3bafe752fa891185 Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Wed, 13 Jul 2016 16:44:34 -0700 Subject: Fixing Virtual nodes getting wrong screen bounds, when dragging in spring loaded mode Bug: 29582251 Change-Id: I614d387a9b12d812ebb84c7739e8d9ae1bc057b2 --- .../WorkspaceAccessibilityHelper.java | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src/com/android/launcher3/accessibility/WorkspaceAccessibilityHelper.java') diff --git a/src/com/android/launcher3/accessibility/WorkspaceAccessibilityHelper.java b/src/com/android/launcher3/accessibility/WorkspaceAccessibilityHelper.java index 73b824bb5..c71307d48 100644 --- a/src/com/android/launcher3/accessibility/WorkspaceAccessibilityHelper.java +++ b/src/com/android/launcher3/accessibility/WorkspaceAccessibilityHelper.java @@ -17,6 +17,8 @@ package com.android.launcher3.accessibility; import android.content.Context; +import android.graphics.Rect; +import android.support.v4.view.accessibility.AccessibilityNodeInfoCompat; import android.text.TextUtils; import android.view.View; @@ -24,15 +26,20 @@ import com.android.launcher3.AppInfo; import com.android.launcher3.CellLayout; import com.android.launcher3.FolderInfo; import com.android.launcher3.ItemInfo; +import com.android.launcher3.Launcher; import com.android.launcher3.accessibility.LauncherAccessibilityDelegate.DragType; import com.android.launcher3.R; import com.android.launcher3.ShortcutInfo; +import com.android.launcher3.dragndrop.DragLayer; /** * Implementation of {@link DragAndDropAccessibilityDelegate} to support DnD on workspace. */ public class WorkspaceAccessibilityHelper extends DragAndDropAccessibilityDelegate { + private final Rect mTempRect = new Rect(); + private final int[] mTempCords = new int[2]; + public WorkspaceAccessibilityHelper(CellLayout layout) { super(layout); } @@ -127,6 +134,25 @@ public class WorkspaceAccessibilityHelper extends DragAndDropAccessibilityDelega return ""; } + @Override + protected void onPopulateNodeForVirtualView(int id, AccessibilityNodeInfoCompat node) { + super.onPopulateNodeForVirtualView(id, node); + + + // ExploreByTouchHelper does not currently handle view scale. + // Update BoundsInScreen to appropriate value. + DragLayer dragLayer = Launcher.getLauncher(mView.getContext()).getDragLayer(); + mTempCords[0] = mTempCords[1] = 0; + float scale = dragLayer.getDescendantCoordRelativeToSelf(mView, mTempCords); + + node.getBoundsInParent(mTempRect); + mTempRect.left = mTempCords[0] + (int) (mTempRect.left * scale); + mTempRect.right = mTempCords[0] + (int) (mTempRect.right * scale); + mTempRect.top = mTempCords[1] + (int) (mTempRect.top * scale); + mTempRect.bottom = mTempCords[1] + (int) (mTempRect.bottom * scale); + node.setBoundsInScreen(mTempRect); + } + @Override protected String getLocationDescriptionForIconDrop(int id) { int x = id % mView.getCountX(); -- cgit v1.2.3