am 1eeb3fc9: Generalize support for \'App Info\', \'Uninstall\' and \'Delete\'
* commit '1eeb3fc9d874d98dfb43883d17efb4202d83d88a': Generalize support for 'App Info', 'Uninstall' and 'Delete'
This commit is contained in:
@@ -915,6 +915,16 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsAppInfoDropTarget() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsDeleteDropTarget() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getIntrinsicIconScaleFactor() {
|
||||
LauncherAppState app = LauncherAppState.getInstance();
|
||||
|
||||
@@ -95,7 +95,7 @@ public class DeleteDropTarget extends ButtonDropTarget {
|
||||
}
|
||||
|
||||
private boolean isAllAppsApplication(DragSource source, Object info) {
|
||||
return (source instanceof AppsCustomizePagedView) && (info instanceof AppInfo);
|
||||
return source.supportsAppInfoDropTarget() && (info instanceof AppInfo);
|
||||
}
|
||||
private boolean isAllAppsWidget(DragSource source, Object info) {
|
||||
if (source instanceof AppsCustomizePagedView) {
|
||||
@@ -175,6 +175,7 @@ public class DeleteDropTarget extends ButtonDropTarget {
|
||||
boolean isVisible = true;
|
||||
boolean useUninstallLabel = !AppsCustomizePagedView.DISABLE_ALL_APPS &&
|
||||
isAllAppsApplication(source, info);
|
||||
boolean useDeleteLabel = !useUninstallLabel && source.supportsDeleteDropTarget();
|
||||
|
||||
// If we are dragging an application from AppsCustomize, only show the control if we can
|
||||
// delete the app (it was downloaded), and rename the string to "uninstall" in such a case.
|
||||
@@ -185,15 +186,17 @@ public class DeleteDropTarget extends ButtonDropTarget {
|
||||
|
||||
if (useUninstallLabel) {
|
||||
setCompoundDrawablesRelativeWithIntrinsicBounds(mUninstallDrawable, null, null, null);
|
||||
} else {
|
||||
} else if (useDeleteLabel) {
|
||||
setCompoundDrawablesRelativeWithIntrinsicBounds(mRemoveDrawable, null, null, null);
|
||||
} else {
|
||||
isVisible = false;
|
||||
}
|
||||
mCurrentDrawable = (TransitionDrawable) getCurrentDrawable();
|
||||
|
||||
mActive = isVisible;
|
||||
resetHoverColor();
|
||||
((ViewGroup) getParent()).setVisibility(isVisible ? View.VISIBLE : View.GONE);
|
||||
if (getText().length() > 0) {
|
||||
if (isVisible && getText().length() > 0) {
|
||||
setText(useUninstallLabel ? R.string.delete_target_uninstall_label
|
||||
: R.string.delete_target_label);
|
||||
}
|
||||
|
||||
@@ -30,6 +30,17 @@ public interface DragSource {
|
||||
*/
|
||||
boolean supportsFlingToDelete();
|
||||
|
||||
/**
|
||||
* @return whether items dragged from this source supports 'App Info'
|
||||
*/
|
||||
boolean supportsAppInfoDropTarget();
|
||||
|
||||
/**
|
||||
* @return whether items dragged from this source supports 'Delete' drop target (e.g. to remove
|
||||
* a shortcut.
|
||||
*/
|
||||
boolean supportsDeleteDropTarget();
|
||||
|
||||
/*
|
||||
* @return the scale of the icons over the workspace icon size
|
||||
*/
|
||||
|
||||
@@ -801,6 +801,16 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsAppInfoDropTarget() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsDeleteDropTarget() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void onFlingToDelete(DragObject d, int x, int y, PointF vec) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
@@ -62,10 +62,6 @@ public class InfoDropTarget extends ButtonDropTarget {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isFromAllApps(DragSource source) {
|
||||
return (source instanceof AppsCustomizePagedView);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptDrop(DragObject d) {
|
||||
// acceptDrop is called just before onDrop. We do the work here, rather than
|
||||
@@ -93,7 +89,7 @@ public class InfoDropTarget extends ButtonDropTarget {
|
||||
boolean isVisible = true;
|
||||
|
||||
// Hide this button unless we are dragging something from AllApps
|
||||
if (!isFromAllApps(source)) {
|
||||
if (!source.supportsAppInfoDropTarget()) {
|
||||
isVisible = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -4212,6 +4212,16 @@ public class Workspace extends SmoothPagedView
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsAppInfoDropTarget() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsDeleteDropTarget() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFlingToDelete(DragObject d, int x, int y, PointF vec) {
|
||||
// Do nothing
|
||||
|
||||
Reference in New Issue
Block a user