diff options
author | Tony Wickham <twickham@google.com> | 2015-10-05 19:42:24 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-10-05 19:42:24 +0000 |
commit | 8565e7eb2d78f6eb4caff79150ca2a0bc3b03b1a (patch) | |
tree | c97aae5ee431d10599f880ab34440428551220d5 | |
parent | fd4e8f5ff1daeeae35d25dcf03222eec8feaa473 (diff) | |
parent | 9aae47f8a6e23f1805ee3d44512fc1f80286e6dd (diff) | |
download | android_packages_apps_Trebuchet-8565e7eb2d78f6eb4caff79150ca2a0bc3b03b1a.tar.gz android_packages_apps_Trebuchet-8565e7eb2d78f6eb4caff79150ca2a0bc3b03b1a.tar.bz2 android_packages_apps_Trebuchet-8565e7eb2d78f6eb4caff79150ca2a0bc3b03b1a.zip |
Merge "Added 'Cancel' drop target from all apps and widget picker." into ub-launcher3-master
-rw-r--r-- | res/layout/app_info_drop_target_bar.xml | 2 | ||||
-rw-r--r-- | res/layout/search_drop_target_bar.xml | 4 | ||||
-rw-r--r-- | res/values/strings.xml | 10 | ||||
-rw-r--r-- | src/com/android/launcher3/AppInfoDropTargetBar.java | 4 | ||||
-rw-r--r-- | src/com/android/launcher3/BaseDropTargetBar.java | 8 | ||||
-rw-r--r-- | src/com/android/launcher3/ButtonDropTarget.java | 8 | ||||
-rw-r--r-- | src/com/android/launcher3/DeleteDropTarget.java | 21 | ||||
-rw-r--r-- | src/com/android/launcher3/DragSource.java | 2 | ||||
-rw-r--r-- | src/com/android/launcher3/SearchDropTargetBar.java | 4 | ||||
-rw-r--r-- | src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java | 8 | ||||
-rw-r--r-- | src/com/android/launcher3/dragndrop/DragController.java | 3 | ||||
-rw-r--r-- | src/com/android/launcher3/widget/WidgetsContainerView.java | 2 |
12 files changed, 46 insertions, 30 deletions
diff --git a/res/layout/app_info_drop_target_bar.xml b/res/layout/app_info_drop_target_bar.xml index b8f30d0c8..5f19d4331 100644 --- a/res/layout/app_info_drop_target_bar.xml +++ b/res/layout/app_info_drop_target_bar.xml @@ -35,7 +35,7 @@ <com.android.launcher3.InfoDropTarget android:id="@+id/info_target_text" style="@style/DropTargetButton" - android:text="@string/info_target_label" /> + android:text="@string/app_info_drop_target_label" /> </FrameLayout> </LinearLayout> diff --git a/res/layout/search_drop_target_bar.xml b/res/layout/search_drop_target_bar.xml index 724eb943d..50f96791a 100644 --- a/res/layout/search_drop_target_bar.xml +++ b/res/layout/search_drop_target_bar.xml @@ -36,7 +36,7 @@ <com.android.launcher3.DeleteDropTarget android:id="@+id/delete_target_text" style="@style/DropTargetButton" - android:text="@string/delete_target_label" /> + android:text="@string/remove_drop_target_label" /> </FrameLayout> <FrameLayout @@ -48,7 +48,7 @@ <com.android.launcher3.UninstallDropTarget android:id="@+id/uninstall_target_text" style="@style/DropTargetButton" - android:text="@string/delete_target_uninstall_label" /> + android:text="@string/uninstall_drop_target_label" /> </FrameLayout> </LinearLayout> diff --git a/res/values/strings.xml b/res/values/strings.xml index ca92e1134..a17437e80 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -78,12 +78,12 @@ for accessibilty (spoken when the button gets focus). --> <string name="all_apps_home_button_label">Home</string> - <!-- Label for delete drop target. [CHAR_LIMIT=20] --> - <string name="delete_target_label">Remove</string> + <!-- Label for remove drop target. [CHAR_LIMIT=20] --> + <string name="remove_drop_target_label">Remove</string> <!-- Label for uninstall drop target. [CHAR_LIMIT=20]--> - <string name="delete_target_uninstall_label">Uninstall</string> - <!-- Label for the info icon. [CHAR_LIMIT=20] --> - <string name="info_target_label">App info</string> + <string name="uninstall_drop_target_label">Uninstall</string> + <!-- Label for app info drop target. [CHAR_LIMIT=20] --> + <string name="app_info_drop_target_label">App info</string> <!-- Permissions: --> <skip /> 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 |