Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1ce9c476 authored by Sunny Goyal's avatar Sunny Goyal
Browse files

Removing some methods from the DragSource

This makes is easier to create new DragSource and sets up
proper default values in DragOptions

Change-Id: I6cb0b1df41b9730cf29f785fe85fe7f0b573ee3a
parent 37920966
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -178,7 +178,7 @@ public abstract class ButtonDropTarget extends TextView

    @Override
    public void onDragStart(DropTarget.DragObject dragObject, DragOptions options) {
        mActive = supportsDrop(dragObject.dragSource, dragObject.dragInfo);
        mActive = supportsDrop(dragObject.dragInfo);
        mDrawable.setColorFilter(null);
        if (mCurrentColorAnim != null) {
            mCurrentColorAnim.cancel();
@@ -194,10 +194,10 @@ public abstract class ButtonDropTarget extends TextView

    @Override
    public final boolean acceptDrop(DragObject dragObject) {
        return supportsDrop(dragObject.dragSource, dragObject.dragInfo);
        return supportsDrop(dragObject.dragInfo);
    }

    protected abstract boolean supportsDrop(DragSource source, ItemInfo info);
    protected abstract boolean supportsDrop(ItemInfo info);

    @Override
    public boolean isDropEnabled() {
+5 −5
Original line number Diff line number Diff line
@@ -46,7 +46,7 @@ public class DeleteDropTarget extends ButtonDropTarget {
    @Override
    public void onDragStart(DropTarget.DragObject dragObject, DragOptions options) {
        super.onDragStart(dragObject, options);
        setTextBasedOnDragSource(dragObject.dragSource);
        setTextBasedOnDragSource(dragObject.dragInfo);
    }

    /** @return true for items that should have a "Remove" action in accessibility. */
@@ -57,16 +57,16 @@ public class DeleteDropTarget extends ButtonDropTarget {
    }

    @Override
    protected boolean supportsDrop(DragSource source, ItemInfo info) {
    protected boolean supportsDrop(ItemInfo info) {
        return true;
    }

    /**
     * Set the drop target's text to either "Remove" or "Cancel" depending on the drag source.
     * Set the drop target's text to either "Remove" or "Cancel" depending on the drag item.
     */
    public void setTextBasedOnDragSource(DragSource dragSource) {
    private void setTextBasedOnDragSource(ItemInfo item) {
        if (!TextUtils.isEmpty(mText)) {
            mText = getResources().getString(dragSource.supportsDeleteDropTarget()
            mText = getResources().getString(item.id != ItemInfo.NO_ID
                    ? R.string.remove_drop_target_label
                    : android.R.string.cancel);
            requestLayout();
+0 −16
Original line number Diff line number Diff line
@@ -26,22 +26,6 @@ import com.android.launcher3.logging.UserEventDispatcher.LogContainerProvider;
 */
public interface DragSource extends LogContainerProvider {

    /**
     * @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.) If this returns false, the drop target will say "Cancel" instead of "Remove."
     */
    boolean supportsDeleteDropTarget();

    /*
     * @return the scale of the icons over the workspace icon size
     */
    float getIntrinsicIconScaleFactor();

    /**
     * A callback made back to the source after an item from this source has been dropped on a
     * DropTarget.
+2 −2
Original line number Diff line number Diff line
@@ -99,8 +99,8 @@ public class InfoDropTarget extends UninstallDropTarget {
    }

    @Override
    protected boolean supportsDrop(DragSource source, ItemInfo info) {
        return source.supportsAppInfoDropTarget() && supportsDrop(getContext(), info);
    protected boolean supportsDrop(ItemInfo info) {
        return supportsDrop(getContext(), info);
    }

    public static boolean supportsDrop(Context context, ItemInfo info) {
+1 −1
Original line number Diff line number Diff line
@@ -44,7 +44,7 @@ public class UninstallDropTarget extends ButtonDropTarget {
    }

    @Override
    protected boolean supportsDrop(DragSource source, ItemInfo info) {
    protected boolean supportsDrop(ItemInfo info) {
        return supportsDrop(getContext(), info);
    }

Loading