Respect file display names during Android drag-and-drop
* java/org/gnu/emacs/EmacsService.java (buildContentName): Remove redundant projection argument to resolver.query. * java/org/gnu/emacs/EmacsWindow.java (onDragEvent): If a content resolver is available, attempt to convert content URIs into file names in advance. * lisp/term/android-win.el (android-handle-dnd-event): Adjust correspondingly.
This commit is contained in:
parent
014cd00402
commit
e72f17e462
3 changed files with 39 additions and 20 deletions
|
@ -1072,7 +1072,6 @@ If a display name can be requested from URI (using the resolver
|
|||
{
|
||||
StringBuilder builder;
|
||||
String displayName;
|
||||
String[] projection;
|
||||
Cursor cursor;
|
||||
int column;
|
||||
|
||||
|
@ -1081,8 +1080,7 @@ If a display name can be requested from URI (using the resolver
|
|||
|
||||
try
|
||||
{
|
||||
projection = new String[] { OpenableColumns.DISPLAY_NAME, };
|
||||
cursor = resolver.query (uri, projection, null, null, null);
|
||||
cursor = resolver.query (uri, null, null, null, null);
|
||||
|
||||
if (cursor != null)
|
||||
{
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipDescription;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
|
||||
import android.graphics.Rect;
|
||||
|
@ -1699,10 +1700,11 @@ else if (EmacsWindow.this.isMapped)
|
|||
ClipData data;
|
||||
ClipDescription description;
|
||||
int i, j, x, y, itemCount;
|
||||
String type;
|
||||
String type, uriString;
|
||||
Uri uri;
|
||||
EmacsActivity activity;
|
||||
StringBuilder builder;
|
||||
ContentResolver resolver;
|
||||
|
||||
x = (int) event.getX ();
|
||||
y = (int) event.getY ();
|
||||
|
@ -1799,6 +1801,20 @@ else if (type.equals (ClipDescription.MIMETYPE_TEXT_URILIST))
|
|||
{
|
||||
if ((activity.requestDragAndDropPermissions (event) == null))
|
||||
uri = null;
|
||||
else
|
||||
{
|
||||
resolver = activity.getContentResolver ();
|
||||
|
||||
/* Substitute a content file name for the URI, if
|
||||
possible. */
|
||||
uriString = EmacsService.buildContentName (uri, resolver);
|
||||
|
||||
if (uriString != null)
|
||||
{
|
||||
builder.append (uriString).append ("\n");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (uri != null)
|
||||
|
|
|
@ -282,11 +282,12 @@ If it reflects the motion of an item above a frame, call
|
|||
`dnd-handle-movement' to move the cursor or scroll the window
|
||||
under the item pursuant to the pertinent user options.
|
||||
|
||||
If it reflects dropped text, insert such text within window at
|
||||
the location of the drop.
|
||||
If it holds dropped text, insert such text within window at the
|
||||
location of the drop.
|
||||
|
||||
If it reflects a list of URIs, then open each URI, converting
|
||||
content:// URIs into the special file names which represent them."
|
||||
If it holds a list of URIs, or file names, then open each URI or
|
||||
file name, converting content:// URIs into the special file
|
||||
names which represent them."
|
||||
(interactive "e")
|
||||
(let ((message (caddr event))
|
||||
(posn (event-start event)))
|
||||
|
@ -304,18 +305,22 @@ content:// URIs into the special file names which represent them."
|
|||
(new-uri-list nil)
|
||||
(dnd-unescape-file-uris t))
|
||||
(dolist (uri uri-list)
|
||||
(ignore-errors
|
||||
(let ((url (url-generic-parse-url uri)))
|
||||
(when (equal (url-type url) "content")
|
||||
;; Replace URI with a matching /content file
|
||||
;; name.
|
||||
(setq uri (format "file:/content/by-authority/%s%s"
|
||||
(url-host url)
|
||||
(url-filename url))
|
||||
;; And guarantee that this file URI is not
|
||||
;; subject to URI decoding, for it must be
|
||||
;; transformed back into a content URI.
|
||||
dnd-unescape-file-uris nil))))
|
||||
;; If the URI is a preprepared file name, insert it directly.
|
||||
(if (string-match-p "^/content/by-authority\\(-named\\)?/" uri)
|
||||
(setq uri (concat "file:" uri)
|
||||
dnd-unescape-file-uris nil)
|
||||
(ignore-errors
|
||||
(let ((url (url-generic-parse-url uri)))
|
||||
(when (equal (url-type url) "content")
|
||||
;; Replace URI with a matching /content file
|
||||
;; name.
|
||||
(setq uri (format "file:/content/by-authority/%s%s"
|
||||
(url-host url)
|
||||
(url-filename url))
|
||||
;; And guarantee that this file URI is not
|
||||
;; subject to URI decoding, for it must be
|
||||
;; transformed back into a content URI.
|
||||
dnd-unescape-file-uris nil)))))
|
||||
(push uri new-uri-list))
|
||||
(dnd-handle-multiple-urls (posn-window posn)
|
||||
new-uri-list
|
||||
|
|
Loading…
Add table
Reference in a new issue