aboutsummaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
Diffstat (limited to 'java')
-rw-r--r--java/org/gnu/emacs/EmacsWindow.java69
1 files changed, 43 insertions, 26 deletions
diff --git a/java/org/gnu/emacs/EmacsWindow.java b/java/org/gnu/emacs/EmacsWindow.java
index 386eaca8c41..7662186a0eb 100644
--- a/java/org/gnu/emacs/EmacsWindow.java
+++ b/java/org/gnu/emacs/EmacsWindow.java
@@ -1605,6 +1605,7 @@ public final class EmacsWindow extends EmacsHandleObject
1605 String type; 1605 String type;
1606 Uri uri; 1606 Uri uri;
1607 EmacsActivity activity; 1607 EmacsActivity activity;
1608 StringBuilder builder;
1608 1609
1609 x = (int) event.getX (); 1610 x = (int) event.getX ();
1610 y = (int) event.getY (); 1611 y = (int) event.getY ();
@@ -1659,38 +1660,54 @@ public final class EmacsWindow extends EmacsHandleObject
1659 EmacsNative.sendDndUri (handle, x, y, type); 1660 EmacsNative.sendDndUri (handle, x, y, type);
1660 return true; 1661 return true;
1661 } 1662 }
1662 else 1663 }
1663 {
1664 /* If the item dropped is a URI, send it to the main
1665 thread. */
1666
1667 uri = data.getItemAt (0).getUri ();
1668 1664
1669 /* Attempt to acquire permissions for this URI; 1665 /* There's no plain text data within this clipboard item, so
1670 failing which, insert it as text instead. */ 1666 each item within should be treated as a content URI
1667 designating a file. */
1671 1668
1672 if (uri != null 1669 /* Collect the URIs into a string with each suffixed
1673 && uri.getScheme () != null 1670 by newlines, much as in a text/uri-list. */
1674 && uri.getScheme ().equals ("content") 1671 builder = new StringBuilder ();
1675 && (activity = EmacsActivity.lastFocusedActivity) != null)
1676 {
1677 if (activity.requestDragAndDropPermissions (event) == null)
1678 uri = null;
1679 }
1680 1672
1681 if (uri != null) 1673 for (i = 0; i < itemCount; ++i)
1682 EmacsNative.sendDndUri (handle, x, y, uri.toString ()); 1674 {
1683 else 1675 /* If the item dropped is a URI, send it to the
1684 { 1676 main thread. */
1685 type = (data.getItemAt (0) 1677
1686 .coerceToText (EmacsService.SERVICE) 1678 uri = data.getItemAt (i).getUri ();
1687 .toString ()); 1679
1688 EmacsNative.sendDndText (handle, x, y, type); 1680 /* Attempt to acquire permissions for this URI;
1689 } 1681 failing which, insert it as text instead. */
1682
1683 if (uri != null
1684 && uri.getScheme () != null
1685 && uri.getScheme ().equals ("content")
1686 && (activity = EmacsActivity.lastFocusedActivity) != null)
1687 {
1688 if ((activity.requestDragAndDropPermissions (event) == null))
1689 uri = null;
1690 }
1690 1691
1691 return true; 1692 if (uri != null)
1693 builder.append (uri.toString ()).append ("\n");
1694 else
1695 {
1696 /* Treat each URI that Emacs cannot secure
1697 permissions for as plain text. */
1698 type = (data.getItemAt (i)
1699 .coerceToText (EmacsService.SERVICE)
1700 .toString ());
1701 EmacsNative.sendDndText (handle, x, y, type);
1692 } 1702 }
1693 } 1703 }
1704
1705 /* Now send each URI to Emacs. */
1706
1707 if (builder.length () > 0)
1708 EmacsNative.sendDndUri (handle, x, y, builder.toString ());
1709
1710 return true;
1694 } 1711 }
1695 1712
1696 return true; 1713 return true;