New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[TIMOB-25363] Android: Use ContentProvider for Intent data #9500
Conversation
} else { | ||
intent.setType(type); | ||
} | ||
} else if (data != null) { | ||
intent.setData(Uri.parse(data)); | ||
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); | ||
intent.setData(TiFileProvider.createUriFrom(data)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing import:
import org.appcelerator.titanium.io.TiFileProvider;
67026ff
to
cad371f
Compare
Tests:
Generated by 🚫 dangerJS |
try { | ||
String path = getUriPrefix() + file.getAbsolutePath(); | ||
String path = getUriPrefix() + filePath.replaceAll("^file://(/android_asset)?", ""); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When we wrote the TiContentProvider
, we purposely limited the createUriFrom()
method to only support File
objects to limit it to only supporting external files on the filesystem. If we were to add support for reading asset files and resource files in the future (and we should), we would have to override the ContentProvider.openAssetFile()
method in order to access embedded files within the APK as well change the URI prefix to better represent where the file came from (currently hardcoded to "/filesystem").
The test case for this code change is limited to external files. Can we keep the old way of doing it for now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is still only limited to external files (even though there's regex that cleans our /android_asset
identifier). I've just added the ability to pass a file path String in addition to the existing File object. Which is more appropriate for passing the data
String when creating the Intent
instead of needing to create a File
object only to grab it's path again.
FR Passed No Studio Ver: 4.10.0.201709271713 |
b26d506
to
c57b0e7
Compare
ContentProvider
forIntent
DATA
TEST CASE
JIRA Ticket