am 484d56b4: Merge "Accessibility: Folder drag and drop fixes" into ub-launcher3-burnaby
* commit '484d56b4750c84351496ed95b4473d2eb2fc43cf': Accessibility: Folder drag and drop fixes
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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}
|
||||
*/
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user