diff options
| author | Po Lu | 2024-03-20 10:23:42 +0800 |
|---|---|---|
| committer | Po Lu | 2024-03-20 10:23:42 +0800 |
| commit | e72f17e4622fae45c9814f6ed196e5a9ed06cdd2 (patch) | |
| tree | 3de87fc6c8c82166871c817cc20e7902b730f799 /java/org | |
| parent | 014cd0040275bb2a4d08d392825b4814452275db (diff) | |
| download | emacs-e72f17e4622fae45c9814f6ed196e5a9ed06cdd2.tar.gz emacs-e72f17e4622fae45c9814f6ed196e5a9ed06cdd2.zip | |
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.
Diffstat (limited to 'java/org')
| -rw-r--r-- | java/org/gnu/emacs/EmacsService.java | 4 | ||||
| -rw-r--r-- | java/org/gnu/emacs/EmacsWindow.java | 18 |
2 files changed, 18 insertions, 4 deletions
diff --git a/java/org/gnu/emacs/EmacsService.java b/java/org/gnu/emacs/EmacsService.java index 19aa3dee456..785163c713c 100644 --- a/java/org/gnu/emacs/EmacsService.java +++ b/java/org/gnu/emacs/EmacsService.java | |||
| @@ -1072,7 +1072,6 @@ public final class EmacsService extends Service | |||
| 1072 | { | 1072 | { |
| 1073 | StringBuilder builder; | 1073 | StringBuilder builder; |
| 1074 | String displayName; | 1074 | String displayName; |
| 1075 | String[] projection; | ||
| 1076 | Cursor cursor; | 1075 | Cursor cursor; |
| 1077 | int column; | 1076 | int column; |
| 1078 | 1077 | ||
| @@ -1081,8 +1080,7 @@ public final class EmacsService extends Service | |||
| 1081 | 1080 | ||
| 1082 | try | 1081 | try |
| 1083 | { | 1082 | { |
| 1084 | projection = new String[] { OpenableColumns.DISPLAY_NAME, }; | 1083 | cursor = resolver.query (uri, null, null, null, null); |
| 1085 | cursor = resolver.query (uri, projection, null, null, null); | ||
| 1086 | 1084 | ||
| 1087 | if (cursor != null) | 1085 | if (cursor != null) |
| 1088 | { | 1086 | { |
diff --git a/java/org/gnu/emacs/EmacsWindow.java b/java/org/gnu/emacs/EmacsWindow.java index 6e8bdaf7401..93a512cc7ef 100644 --- a/java/org/gnu/emacs/EmacsWindow.java +++ b/java/org/gnu/emacs/EmacsWindow.java | |||
| @@ -31,6 +31,7 @@ import android.app.Activity; | |||
| 31 | 31 | ||
| 32 | import android.content.ClipData; | 32 | import android.content.ClipData; |
| 33 | import android.content.ClipDescription; | 33 | import android.content.ClipDescription; |
| 34 | import android.content.ContentResolver; | ||
| 34 | import android.content.Context; | 35 | import android.content.Context; |
| 35 | 36 | ||
| 36 | import android.graphics.Rect; | 37 | import android.graphics.Rect; |
| @@ -1699,10 +1700,11 @@ public final class EmacsWindow extends EmacsHandleObject | |||
| 1699 | ClipData data; | 1700 | ClipData data; |
| 1700 | ClipDescription description; | 1701 | ClipDescription description; |
| 1701 | int i, j, x, y, itemCount; | 1702 | int i, j, x, y, itemCount; |
| 1702 | String type; | 1703 | String type, uriString; |
| 1703 | Uri uri; | 1704 | Uri uri; |
| 1704 | EmacsActivity activity; | 1705 | EmacsActivity activity; |
| 1705 | StringBuilder builder; | 1706 | StringBuilder builder; |
| 1707 | ContentResolver resolver; | ||
| 1706 | 1708 | ||
| 1707 | x = (int) event.getX (); | 1709 | x = (int) event.getX (); |
| 1708 | y = (int) event.getY (); | 1710 | y = (int) event.getY (); |
| @@ -1799,6 +1801,20 @@ public final class EmacsWindow extends EmacsHandleObject | |||
| 1799 | { | 1801 | { |
| 1800 | if ((activity.requestDragAndDropPermissions (event) == null)) | 1802 | if ((activity.requestDragAndDropPermissions (event) == null)) |
| 1801 | uri = null; | 1803 | uri = null; |
| 1804 | else | ||
| 1805 | { | ||
| 1806 | resolver = activity.getContentResolver (); | ||
| 1807 | |||
| 1808 | /* Substitute a content file name for the URI, if | ||
| 1809 | possible. */ | ||
| 1810 | uriString = EmacsService.buildContentName (uri, resolver); | ||
| 1811 | |||
| 1812 | if (uriString != null) | ||
| 1813 | { | ||
| 1814 | builder.append (uriString).append ("\n"); | ||
| 1815 | continue; | ||
| 1816 | } | ||
| 1817 | } | ||
| 1802 | } | 1818 | } |
| 1803 | 1819 | ||
| 1804 | if (uri != null) | 1820 | if (uri != null) |