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

Commit 2226a19f authored by Gilles Debunne's avatar Gilles Debunne
Browse files

Refactor onDrop in TextView

Change-Id: Ied80565852a452c15c7b7a66cbb05965bead04cd
parent c868b154
Loading
Loading
Loading
Loading
+56 −55
Original line number Diff line number Diff line
@@ -8923,13 +8923,26 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
                TextView.this.requestFocus();
                return true;

            case DragEvent.ACTION_DRAG_LOCATION: {
            case DragEvent.ACTION_DRAG_LOCATION:
                final int offset = getOffset((int) event.getX(), (int) event.getY());
                Selection.setSelection((Spannable)mText, offset);
                return true;

            case DragEvent.ACTION_DROP:
                onDrop(event);
                return true;

            case DragEvent.ACTION_DRAG_ENDED:
                mDragSourcePositions = -1;
                return true;

            case DragEvent.ACTION_DRAG_EXITED:
            default:
                return true;
        }
    }

            case DragEvent.ACTION_DROP: {
    private void onDrop(DragEvent event) {
        StringBuilder content = new StringBuilder("");
        ClipData clipData = event.getClipData();
        final int itemCount = clipData.getItemCount();
@@ -8945,7 +8958,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
            final int dragSourceEnd = extractRangeEndFromLong(mDragSourcePositions);
            if (offset >= dragSourceStart && offset < dragSourceEnd) {
                // A drop inside the original selection discards the drop.
                        return true;
                return;
            }
        }

@@ -8980,18 +8993,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
                ((Editable) mText).delete(pos, pos + 1);
            }
        }

                return true;
            }

            case DragEvent.ACTION_DRAG_ENDED:
                mDragSourcePositions = -1;
                return true;

            case DragEvent.ACTION_DRAG_EXITED:
            default:
                return true;
        }
    }

    /**