We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 2762 - Use SDL_DropEvent to retrieve file path on Android
Summary: Use SDL_DropEvent to retrieve file path on Android
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: events (show other bugs)
Version: HG 2.1
Hardware: All Android (All)
: P2 normal
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords: target-2.0.4, triage-2.0.4
Depends on:
Blocks: 3181
  Show dependency treegraph
 
Reported: 2014-10-22 13:43 UTC by noxalus
Modified: 2015-11-15 22:23 UTC (History)
2 users (show)

See Also:


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". (22.04 KB, application/x-zip-compressed)
2014-10-22 13:43 UTC, noxalus
Details
Patch. (1.88 KB, patch)
2014-10-22 14:27 UTC, noxalus
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description noxalus 2014-10-22 13:43:50 UTC
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.
Comment 1 noxalus 2014-10-22 14:27:19 UTC
Created attachment 1912 [details]
Patch.
Comment 2 Philipp Wiesemann 2014-10-24 09:09:40 UTC
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
Comment 3 Ryan C. Gordon 2015-02-19 05:22:19 UTC
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!
Comment 4 Ryan C. Gordon 2015-04-07 04:57:57 UTC
(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.
Comment 5 Ryan C. Gordon 2015-05-27 00:37:49 UTC
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.