Merge "Added 'Cancel' drop target from all apps and widget picker." into ub-launcher3-master

This commit is contained in:
Tony Wickham
2015-10-05 19:42:24 +00:00
committed by Android (Google) Code Review
12 changed files with 46 additions and 30 deletions
+1 -1
View File
@@ -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>
+2 -2
View File
@@ -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>
+5 -5
View File
@@ -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 />
@@ -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);
}
@@ -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);
@@ -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) {
@@ -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
+1 -1
View File
@@ -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();
@@ -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);
}
@@ -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)) {
@@ -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 {
@@ -271,7 +271,7 @@ public class WidgetsContainerView extends BaseContainerView
@Override
public boolean supportsFlingToDelete() {
return false;
return true;
}
@Override