| Summary: | Use SDL_DropEvent to retrieve file path on Android | ||
|---|---|---|---|
| Product: | SDL | Reporter: | noxalus |
| Component: | events | Assignee: | Ryan C. Gordon <icculus> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | CC: | icculus, philipp.wiesemann |
| Version: | HG 2.1 | Keywords: | target-2.0.4, triage-2.0.4 |
| Hardware: | All | ||
| OS: | Android (All) | ||
| Bug Depends on: | |||
| Bug Blocks: | 3181 | ||
| Attachments: |
SDL Activity.java: I added a method named "onNativeDropFile" and call at the end of "onCreate" method. | SDL_android.c: I added the native function "Java_org_libsdl_app_SDLActivity_onNativeDropFile".
Patch. |
||
Created attachment 1912 [details]
Patch.
Thank you for working on an implementation. There is small fault in the patch because getPath() may return null for invalid URIs. [1] This may lead to a crash at least in SDL_SendDropFile() at SDL_strdup(). [1] http://developer.android.com/reference/android/net/Uri.html#getPath%28%29 Marking a large number of bugs with the "triage-2.0.4" keyword at once. Sorry if you got a lot of email from this. This is to help me sort through some bugs in regards to a 2.0.4 release. We may or may not fix this bug for 2.0.4, though! (sorry if you get a lot of copies of this email, I'm marking several bugs at once) Marking bugs for the (mostly) final 2.0.4 TODO list. This means we're hoping to resolve this bug before 2.0.4 ships if possible. In a perfect world, the open bug count with the target-2.0.4 keyword is zero when we ship. (Note that closing a bug report as WONTFIX, INVALID or WORKSFORME might still happen.) --ryan. I added the null check that Philipp requested and put this patch in revision control as https://hg.libsdl.org/SDL/rev/d86771e28c51 ...thanks! --ryan. |
Created attachment 1911 [details] SDL Activity.java: I added a method named "onNativeDropFile" and call at the end of "onCreate" method. | SDL_android.c: I added the native function "Java_org_libsdl_app_SDLActivity_onNativeDropFile". When we open file into a SDL application with another application using "Open with" command, we don't have any way to retrieve the file path pass as argument. We could manage this into the Activity that extends from SDLActivity, but, for me, it's the work of SDL to manage that. On iOS, into the file SDL_uikitappdelegate.m, we can see (line 275) that it uses SDL_SendDropFile function to trigger an SDL_DropEvent with the filename. I would like the same behaviour for Android, so I updated the SDL source code (default branch, rev. 9176) to allow that.