Merge "Tying accessibility drag lifecycle to that of dragController" into ub-launcher3-burnaby

This commit is contained in:
Sunny Goyal
2015-06-11 18:43:26 +00:00
committed by Android (Google) Code Review
2 changed files with 14 additions and 16 deletions

View File

@@ -98,7 +98,6 @@ import android.widget.Toast;
import com.android.launcher3.DropTarget.DragObject; import com.android.launcher3.DropTarget.DragObject;
import com.android.launcher3.PagedView.PageSwitchListener; import com.android.launcher3.PagedView.PageSwitchListener;
import com.android.launcher3.accessibility.LauncherAccessibilityDelegate;
import com.android.launcher3.allapps.AllAppsContainerView; import com.android.launcher3.allapps.AllAppsContainerView;
import com.android.launcher3.allapps.AppSearchManager; import com.android.launcher3.allapps.AppSearchManager;
import com.android.launcher3.compat.AppWidgetManagerCompat; import com.android.launcher3.compat.AppWidgetManagerCompat;
@@ -2470,9 +2469,8 @@ public class Launcher extends Activity
return; return;
} }
LauncherAccessibilityDelegate delegate = if (mDragController.isDragging()) {
LauncherAppState.getInstance().getAccessibilityDelegate(); mDragController.cancelDrag();
if (delegate != null && delegate.onBackPressed()) {
return; return;
} }

View File

@@ -20,6 +20,8 @@ import com.android.launcher3.AppInfo;
import com.android.launcher3.AppWidgetResizeFrame; import com.android.launcher3.AppWidgetResizeFrame;
import com.android.launcher3.CellLayout; import com.android.launcher3.CellLayout;
import com.android.launcher3.DeleteDropTarget; 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.Folder;
import com.android.launcher3.FolderInfo; import com.android.launcher3.FolderInfo;
import com.android.launcher3.InfoDropTarget; import com.android.launcher3.InfoDropTarget;
@@ -39,7 +41,7 @@ import com.android.launcher3.util.Thunk;
import java.util.ArrayList; import java.util.ArrayList;
@TargetApi(Build.VERSION_CODES.LOLLIPOP) @TargetApi(Build.VERSION_CODES.LOLLIPOP)
public class LauncherAccessibilityDelegate extends AccessibilityDelegate { public class LauncherAccessibilityDelegate extends AccessibilityDelegate implements DragListener {
private static final String TAG = "LauncherAccessibilityDelegate"; private static final String TAG = "LauncherAccessibilityDelegate";
@@ -328,7 +330,6 @@ public class LauncherAccessibilityDelegate extends AccessibilityDelegate {
mLauncher.getDragLayer().getDescendantCoordRelativeToSelf(clickedTarget, loc); mLauncher.getDragLayer().getDescendantCoordRelativeToSelf(clickedTarget, loc);
mLauncher.getDragController().completeAccessibleDrag(loc); mLauncher.getDragController().completeAccessibleDrag(loc);
endAccessibleDrag();
if (!TextUtils.isEmpty(confirmation)) { if (!TextUtils.isEmpty(confirmation)) {
announceConfirmation(confirmation); announceConfirmation(confirmation);
} }
@@ -366,22 +367,21 @@ public class LauncherAccessibilityDelegate extends AccessibilityDelegate {
} }
mDragSource.enableAccessibleDrag(true); mDragSource.enableAccessibleDrag(true);
mDragSource.startDrag(cellInfo, true); mDragSource.startDrag(cellInfo, true);
}
public boolean onBackPressed() { if (mLauncher.getDragController().isDragging()) {
if (isInAccessibleDrag()) { mLauncher.getDragController().addDragListener(this);
cancelAccessibleDrag();
return true;
} }
return false;
} }
private void cancelAccessibleDrag() {
mLauncher.getDragController().cancelDrag(); @Override
endAccessibleDrag(); public void onDragStart(DragSource source, Object info, int dragAction) {
// No-op
} }
private void endAccessibleDrag() { @Override
public void onDragEnd() {
mLauncher.getDragController().removeDragListener(this);
mDragInfo = null; mDragInfo = null;
if (mDragSource != null) { if (mDragSource != null) {
mDragSource.enableAccessibleDrag(false); mDragSource.enableAccessibleDrag(false);