diff options
Diffstat (limited to 'src/com/android')
9 files changed, 38 insertions, 22 deletions
diff --git a/src/com/android/launcher3/AppInfoDropTargetBar.java b/src/com/android/launcher3/AppInfoDropTargetBar.java index 31ff42a7f..99a1f415d 100644 --- a/src/com/android/launcher3/AppInfoDropTargetBar.java +++ b/src/com/android/launcher3/AppInfoDropTargetBar.java @@ -54,12 +54,12 @@ public class AppInfoDropTargetBar extends BaseDropTargetBar { } @Override - public void showDropTarget() { + public void showDropTargets() { animateDropTargetBarToAlpha(1f, DEFAULT_DRAG_FADE_DURATION); } @Override - public void hideDropTarget() { + public void hideDropTargets() { animateDropTargetBarToAlpha(0f, DEFAULT_DRAG_FADE_DURATION); } diff --git a/src/com/android/launcher3/BaseDropTargetBar.java b/src/com/android/launcher3/BaseDropTargetBar.java index f478a3530..303acd702 100644 --- a/src/com/android/launcher3/BaseDropTargetBar.java +++ b/src/com/android/launcher3/BaseDropTargetBar.java @@ -101,7 +101,7 @@ public abstract class BaseDropTargetBar extends FrameLayout implements DragContr */ @Override public void onDragStart(DragSource source, ItemInfo info, int dragAction) { - showDropTarget(); + showDropTargets(); } /** @@ -115,15 +115,15 @@ public abstract class BaseDropTargetBar extends FrameLayout implements DragContr @Override public void onDragEnd() { if (!mDeferOnDragEnd) { - hideDropTarget(); + hideDropTargets(); } else { mDeferOnDragEnd = false; } } - public abstract void showDropTarget(); + public abstract void showDropTargets(); - public abstract void hideDropTarget(); + public abstract void hideDropTargets(); public abstract void enableAccessibleDrag(boolean enable); diff --git a/src/com/android/launcher3/ButtonDropTarget.java b/src/com/android/launcher3/ButtonDropTarget.java index a19f00d1f..4b94a1ab6 100644 --- a/src/com/android/launcher3/ButtonDropTarget.java +++ b/src/com/android/launcher3/ButtonDropTarget.java @@ -65,6 +65,8 @@ public abstract class ButtonDropTarget extends TextView protected ColorStateList mOriginalTextColor; protected Drawable mDrawable; + protected DeviceProfile mDeviceProfile; + private AnimatorSet mCurrentColorAnim; @Thunk ColorMatrix mSrcFilter, mDstFilter, mCurrentFilter; @@ -84,8 +86,8 @@ public abstract class ButtonDropTarget extends TextView mOriginalTextColor = getTextColors(); // Remove the text in the Phone UI in landscape - DeviceProfile grid = ((Launcher) getContext()).getDeviceProfile(); - if (grid.isVerticalBarLayout()) { + mDeviceProfile = ((Launcher) getContext()).getDeviceProfile(); + if (mDeviceProfile.isVerticalBarLayout()) { setText(""); } } @@ -193,7 +195,7 @@ public abstract class ButtonDropTarget extends TextView } @Override - public final void onDragStart(DragSource source, ItemInfo info, int dragAction) { + public void onDragStart(DragSource source, ItemInfo info, int dragAction) { mActive = supportsDrop(source, info); mDrawable.setColorFilter(null); if (mCurrentColorAnim != null) { diff --git a/src/com/android/launcher3/DeleteDropTarget.java b/src/com/android/launcher3/DeleteDropTarget.java index b792edd1f..173e6ab65 100644 --- a/src/com/android/launcher3/DeleteDropTarget.java +++ b/src/com/android/launcher3/DeleteDropTarget.java @@ -46,7 +46,14 @@ public class DeleteDropTarget extends ButtonDropTarget { setDrawable(R.drawable.ic_remove_launcher); } - public static boolean supportsDrop(ItemInfo info) { + @Override + public void onDragStart(DragSource source, ItemInfo info, int dragAction) { + super.onDragStart(source, info, dragAction); + setTextBasedOnDragSource(source); + } + + /** @return true for items that should have a "Remove" action in accessibility. */ + public static boolean supportsAccessibleDrop(ItemInfo info) { return (info instanceof ShortcutInfo) || (info instanceof LauncherAppWidgetInfo) || (info instanceof FolderInfo); @@ -54,7 +61,17 @@ public class DeleteDropTarget extends ButtonDropTarget { @Override protected boolean supportsDrop(DragSource source, ItemInfo info) { - return source.supportsDeleteDropTarget() && supportsDrop(info); + return true; + } + + /** + * Set the drop target's text to either "Remove" or "Cancel" depending on the drag source. + */ + public void setTextBasedOnDragSource(DragSource dragSource) { + if (!mDeviceProfile.isVerticalBarLayout()) { + setText(dragSource.supportsDeleteDropTarget() ? R.string.remove_drop_target_label + : android.R.string.cancel); + } } @Override diff --git a/src/com/android/launcher3/DragSource.java b/src/com/android/launcher3/DragSource.java index 2a1346ef5..da32d82a6 100644 --- a/src/com/android/launcher3/DragSource.java +++ b/src/com/android/launcher3/DragSource.java @@ -37,7 +37,7 @@ public interface DragSource { /** * @return whether items dragged from this source supports 'Delete' drop target (e.g. to remove - * a shortcut. + * a shortcut.) If this returns false, the drop target will say "Cancel" instead of "Remove." */ boolean supportsDeleteDropTarget(); diff --git a/src/com/android/launcher3/SearchDropTargetBar.java b/src/com/android/launcher3/SearchDropTargetBar.java index 878a474e6..9bda8b8f8 100644 --- a/src/com/android/launcher3/SearchDropTargetBar.java +++ b/src/com/android/launcher3/SearchDropTargetBar.java @@ -103,12 +103,12 @@ public class SearchDropTargetBar extends BaseDropTargetBar { } @Override - public void showDropTarget() { + public void showDropTargets() { animateToState(State.DROP_TARGET, DEFAULT_DRAG_FADE_DURATION); } @Override - public void hideDropTarget() { + public void hideDropTargets() { animateToState(State.SEARCH_BAR, DEFAULT_DRAG_FADE_DURATION); } diff --git a/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java b/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java index f8bf5a85b..f5db6c0b6 100644 --- a/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java +++ b/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java @@ -75,11 +75,11 @@ public class LauncherAccessibilityDelegate extends AccessibilityDelegate impleme mLauncher = launcher; mActions.put(REMOVE, new AccessibilityAction(REMOVE, - launcher.getText(R.string.delete_target_label))); + launcher.getText(R.string.remove_drop_target_label))); mActions.put(INFO, new AccessibilityAction(INFO, - launcher.getText(R.string.info_target_label))); + launcher.getText(R.string.app_info_drop_target_label))); mActions.put(UNINSTALL, new AccessibilityAction(UNINSTALL, - launcher.getText(R.string.delete_target_uninstall_label))); + launcher.getText(R.string.uninstall_drop_target_label))); mActions.put(ADD_TO_WORKSPACE, new AccessibilityAction(ADD_TO_WORKSPACE, launcher.getText(R.string.action_add_to_workspace))); mActions.put(MOVE, new AccessibilityAction(MOVE, @@ -96,7 +96,7 @@ public class LauncherAccessibilityDelegate extends AccessibilityDelegate impleme if (!(host.getTag() instanceof ItemInfo)) return; ItemInfo item = (ItemInfo) host.getTag(); - if (DeleteDropTarget.supportsDrop(item)) { + if (DeleteDropTarget.supportsAccessibleDrop(item)) { info.addAction(mActions.get(REMOVE)); } if (UninstallDropTarget.supportsDrop(host.getContext(), item)) { diff --git a/src/com/android/launcher3/dragndrop/DragController.java b/src/com/android/launcher3/dragndrop/DragController.java index 3aed4b65d..a4bd753ff 100644 --- a/src/com/android/launcher3/dragndrop/DragController.java +++ b/src/com/android/launcher3/dragndrop/DragController.java @@ -455,9 +455,6 @@ public class DragController implements DragDriver.EventListener { dropTarget = dropTargetOverride; } else { vec = isFlingingToDelete(mDragObject.dragSource); - if (!DeleteDropTarget.supportsDrop(mDragObject.dragInfo)) { - vec = null; - } if (vec != null) { dropTarget = mFlingToDeleteDropTarget; } else { diff --git a/src/com/android/launcher3/widget/WidgetsContainerView.java b/src/com/android/launcher3/widget/WidgetsContainerView.java index 0f5ca15b6..143f98988 100644 --- a/src/com/android/launcher3/widget/WidgetsContainerView.java +++ b/src/com/android/launcher3/widget/WidgetsContainerView.java @@ -271,7 +271,7 @@ public class WidgetsContainerView extends BaseContainerView @Override public boolean supportsFlingToDelete() { - return false; + return true; } @Override |