summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2015-05-11 18:54:11 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-05-11 18:54:11 +0000
commit484d56b4750c84351496ed95b4473d2eb2fc43cf (patch)
treeff0645711e93b396f7d540fd507f519a594a2747
parent9c6e175a1863855cefc298b800d8d1982f38efeb (diff)
parentccc414bb1e18206d2a3d8d797070278bdb286354 (diff)
downloadandroid_packages_apps_Trebuchet-484d56b4750c84351496ed95b4473d2eb2fc43cf.tar.gz
android_packages_apps_Trebuchet-484d56b4750c84351496ed95b4473d2eb2fc43cf.tar.bz2
android_packages_apps_Trebuchet-484d56b4750c84351496ed95b4473d2eb2fc43cf.zip
Merge "Accessibility: Folder drag and drop fixes" into ub-launcher3-burnaby
-rw-r--r--src/com/android/launcher3/DragLayer.java49
-rw-r--r--src/com/android/launcher3/Folder.java3
-rw-r--r--src/com/android/launcher3/FolderPagedView.java4
-rw-r--r--src/com/android/launcher3/accessibility/FolderAccessibilityHelper.java16
4 files changed, 57 insertions, 15 deletions
diff --git a/src/com/android/launcher3/DragLayer.java b/src/com/android/launcher3/DragLayer.java
index 91f97fa4a..2efdb06b9 100644
--- a/src/com/android/launcher3/DragLayer.java
+++ b/src/com/android/launcher3/DragLayer.java
@@ -38,7 +38,6 @@ import android.view.animation.Interpolator;
import android.widget.FrameLayout;
import android.widget.TextView;
-import com.android.launcher3.InsettableFrameLayout.LayoutParams;
import com.android.launcher3.util.Thunk;
import java.util.ArrayList;
@@ -153,6 +152,14 @@ public class DragLayer extends InsettableFrameLayout {
return false;
}
+ private boolean isEventOverDropTargetBar(MotionEvent ev) {
+ getDescendantRectRelativeToSelf(mLauncher.getSearchBar(), mHitRect);
+ if (mHitRect.contains((int) ev.getX(), (int) ev.getY())) {
+ return true;
+ }
+ return false;
+ }
+
public void setBlockTouch(boolean block) {
mBlockTouches = block;
}
@@ -188,10 +195,16 @@ public class DragLayer extends InsettableFrameLayout {
}
}
- getDescendantRectRelativeToSelf(currentFolder, hitRect);
if (!isEventOverFolder(currentFolder, ev)) {
- mLauncher.closeFolder();
- return true;
+ if (isInAccessibleDrag()) {
+ // Do not close the folder if in drag and drop.
+ if (!isEventOverDropTargetBar(ev)) {
+ return true;
+ }
+ } else {
+ mLauncher.closeFolder();
+ return true;
+ }
}
}
return false;
@@ -228,11 +241,12 @@ public class DragLayer extends InsettableFrameLayout {
getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
if (accessibilityManager.isTouchExplorationEnabled()) {
final int action = ev.getAction();
- boolean isOverFolder;
+ boolean isOverFolderOrSearchBar;
switch (action) {
case MotionEvent.ACTION_HOVER_ENTER:
- isOverFolder = isEventOverFolder(currentFolder, ev);
- if (!isOverFolder) {
+ isOverFolderOrSearchBar = isEventOverFolder(currentFolder, ev) ||
+ (isInAccessibleDrag() && isEventOverDropTargetBar(ev));
+ if (!isOverFolderOrSearchBar) {
sendTapOutsideFolderAccessibilityEvent(currentFolder.isEditingName());
mHoverPointClosesFolder = true;
return true;
@@ -240,12 +254,13 @@ public class DragLayer extends InsettableFrameLayout {
mHoverPointClosesFolder = false;
break;
case MotionEvent.ACTION_HOVER_MOVE:
- isOverFolder = isEventOverFolder(currentFolder, ev);
- if (!isOverFolder && !mHoverPointClosesFolder) {
+ isOverFolderOrSearchBar = isEventOverFolder(currentFolder, ev) ||
+ (isInAccessibleDrag() && isEventOverDropTargetBar(ev));
+ if (!isOverFolderOrSearchBar && !mHoverPointClosesFolder) {
sendTapOutsideFolderAccessibilityEvent(currentFolder.isEditingName());
mHoverPointClosesFolder = true;
return true;
- } else if (!isOverFolder) {
+ } else if (!isOverFolderOrSearchBar) {
return true;
}
mHoverPointClosesFolder = false;
@@ -268,6 +283,12 @@ public class DragLayer extends InsettableFrameLayout {
}
}
+ private boolean isInAccessibleDrag() {
+ LauncherAccessibilityDelegate delegate = LauncherAppState
+ .getInstance().getAccessibilityDelegate();
+ return delegate != null && delegate.isInAccessibleDrag();
+ }
+
@Override
public boolean onRequestSendAccessibilityEvent(View child, AccessibilityEvent event) {
Folder currentFolder = mLauncher.getWorkspace().getOpenFolder();
@@ -275,6 +296,10 @@ public class DragLayer extends InsettableFrameLayout {
if (child == currentFolder) {
return super.onRequestSendAccessibilityEvent(child, event);
}
+
+ if (isInAccessibleDrag() && child instanceof SearchDropTargetBar) {
+ return super.onRequestSendAccessibilityEvent(child, event);
+ }
// Skip propagating onRequestSendAccessibilityEvent all for other children
// when a folder is open
return false;
@@ -288,6 +313,10 @@ public class DragLayer extends InsettableFrameLayout {
if (currentFolder != null) {
// Only add the folder as a child for accessibility when it is open
childrenForAccessibility.add(currentFolder);
+
+ if (isInAccessibleDrag()) {
+ childrenForAccessibility.add(mLauncher.getSearchBar());
+ }
} else {
super.addChildrenForAccessibility(childrenForAccessibility);
}
diff --git a/src/com/android/launcher3/Folder.java b/src/com/android/launcher3/Folder.java
index a2828054c..b1aba63c3 100644
--- a/src/com/android/launcher3/Folder.java
+++ b/src/com/android/launcher3/Folder.java
@@ -275,6 +275,9 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
for (int i = 0; i < mContent.getChildCount(); i++) {
mContent.getPageAt(i).enableAccessibleDrag(enable, CellLayout.FOLDER_ACCESSIBILITY_DRAG);
}
+
+ mFooter.setImportantForAccessibility(enable ? IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS :
+ IMPORTANT_FOR_ACCESSIBILITY_AUTO);
mLauncher.getWorkspace().setAddNewPageOnDrag(!enable);
}
diff --git a/src/com/android/launcher3/FolderPagedView.java b/src/com/android/launcher3/FolderPagedView.java
index a1c909a1f..211bbfe74 100644
--- a/src/com/android/launcher3/FolderPagedView.java
+++ b/src/com/android/launcher3/FolderPagedView.java
@@ -504,6 +504,10 @@ public class FolderPagedView extends PagedView {
}
}
+ public int getAllocatedContentSize() {
+ return mAllocatedContentSize;
+ }
+
/**
* Reorders the items such that the {@param empty} spot moves to {@param target}
*/
diff --git a/src/com/android/launcher3/accessibility/FolderAccessibilityHelper.java b/src/com/android/launcher3/accessibility/FolderAccessibilityHelper.java
index fc105b4a4..ff9989036 100644
--- a/src/com/android/launcher3/accessibility/FolderAccessibilityHelper.java
+++ b/src/com/android/launcher3/accessibility/FolderAccessibilityHelper.java
@@ -24,23 +24,29 @@ import com.android.launcher3.R;
* Implementation of {@link DragAndDropAccessibilityDelegate} to support DnD in a folder.
*/
public class FolderAccessibilityHelper extends DragAndDropAccessibilityDelegate {
+
+ /**
+ * 0-index position for the first cell in {@link #mView} in {@link #mParent}.
+ */
private final int mStartPosition;
+ private final FolderPagedView mParent;
+
public FolderAccessibilityHelper(CellLayout layout) {
super(layout);
- FolderPagedView parent = (FolderPagedView) layout.getParent();
+ mParent = (FolderPagedView) layout.getParent();
- int index = parent.indexOfChild(layout);
- mStartPosition = 1 + index * layout.getCountX() * layout.getCountY();
+ int index = mParent.indexOfChild(layout);
+ mStartPosition = index * layout.getCountX() * layout.getCountY();
}
@Override
protected int intersectsValidDropTarget(int id) {
- return id;
+ return Math.min(id, mParent.getAllocatedContentSize() - mStartPosition - 1);
}
@Override
protected String getLocationDescriptionForIconDrop(int id) {
- return mContext.getString(R.string.move_to_position, id + mStartPosition);
+ return mContext.getString(R.string.move_to_position, id + mStartPosition + 1);
}
@Override