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
refactor(android): media/file APIs to use scoped storage #12143
Conversation
- TIMOB-27201: Updated Ti.Filesystem.File to support below APIs when wrapping "content://" URL: * createdAt(), deleteFile(), exists(), modifiedAt(), read(), readonly, write(), writable - Updated Ti.Filesystem.File to support below APIs when resource files: * createdAt(). modifiedAt() - Optimized Ti.Filesystem.File move() when performed on the same volume. - TIMOB-28146: Updated Ti.Filesystem.File rename() to support absolute path in same directory and source. Fixes TIMOB-27201, TIMOB-28146
- TIMOB-28059: Modified Ti.Media.showCamera() and saveToPhotoGallery() to use scoped storage. * Removed requirement for WRITE_EXTERNAL_STORAGE and READ_EXTERNAL_STORAGE permissions. - TIMOB-27481: Fixed bug where navigating back from camera overlay may wrongly close the app. - TIMOB-26602: Fixed bug where Ti.Media.takePicture() may use wrong file extension. - Fixed Ti.Media.VideoPlayer crash that can occur if error callback is invoked during playback. Fixes TIMOB-28059, TIMOB-27481, TIMOB-26602
|
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.
CR: PASS
Finally got rid of TitaniumBlob.java
, much better named now 😃
}); | ||
|
||
it.androidAndIosBroken('file:// relative path', () => { | ||
// FIXME: Android seems to basically forcibly place '/' in front of paths not beginning with '..' or '/' | ||
// FIXME: iOS does not seem to try and resolve relative paths for file:// URIs | ||
const file = Ti.Filesystem.getFile('file://app.js'); // app.js should be relative to this file... | ||
should.exist(file); | ||
should(file.exists()).equal(true); | ||
should(file.exists()).be.true(); |
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.
NOTE: Should these tests be enabled on Android 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.
This test still won't work on Android. We would have to modify TiFileFactory
to check if the "file://" URL has a relative and have it use our TiResourceFile
instead of a TiFile
object since our APK's "assets/Resources" folder is not accessible from the file system.
But the problem here is if you set a relative path without a URL scheme like this...
Ti.Filesystem.getFile('app.js');
...then TiFileFactory
defaults to the applicationDataDirectory
, not resourcesDirectory
like this unit test assumes. So, we have an inconsistency here.
Fixes TIMOB-28183
FR: Pass Test Environment |
JIRA:
Summary:
Ti.Media.showCamera()
andsaveToPhotoGallery()
to use scoped storage.Ti.Media.takePicture()
may use the wrong file extension.Ti.Media.VideoPlayer
crash which can occur if error callback is invoked during playback.Ti.Media.hasPhotoGalleryPermissions()
Ti.Media.requestPhotoGalleryPermissions()
Ti.Filesystem.File
APIs when wrapping "content://" URL.createdAt()
,deleteFile()
,exists()
,extension()
,modifiedAt()
,read()
,readonly
,write()
,writable
createDirectory()
,open()
,readLine()
Ti.Filesystem.File
object'smove()
method when performed on same volume.Ti.Filesystem.File
object'srename()
to support absolute path in same folder.TitaniumBlob.java
toTiContentFile.java
.Camera Photo Test:
(Run this test on Android 11 and Android 4.4.)
// saveToPhotoGallery: true
Camera Video Test:
(Run this test on Android 11 and Android 4.4.)
// saveToPhotoGallery: true
Save Image File to Gallery Test:
(Run this test on Android 11 and Android 4.4.)