[TIMOB-28183] Android: Add Ti.Media.requestPhotoGalleryPermissions() support
GitHub Issue | n/a |
---|---|
Type | Improvement |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2020-10-22T22:22:28.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 9.3.0 |
Components | Android |
Labels | android, media, parity, permission, photo, photogallery |
Reporter | Joshua Quick |
Assignee | Joshua Quick |
Created | 2020-10-09T03:03:48.000+0000 |
Updated | 2020-10-22T22:22:28.000+0000 |
Description
*Summary:*
We should add the following methods on Android for parity with iOS...
* [Ti.Media.requestPhotoGalleryPermissions()](https://docs.appcelerator.com/platform/latest/#!/api/Titanium.Media-method-requestPhotoGalleryPermissions)
* [Ti.Media.hasPhotoGalleryPermissions()](https://docs.appcelerator.com/platform/latest/#!/api/Titanium.Media-method-hasPhotoGalleryPermissions)
*Functionality:*
On Android 9 and below, these methods should check if the app has
WRITE_EXTERNAL_STORAGE
permission.
On Android 10 and above, these methods should always return true
since we do not need write permission to save a photo/video to the gallery once [TIMOB-28059] has been implemented. Google documents this here...
https://developer.android.com/training/camera/photobasics#TaskPath
*Note:*
Currently, Titanium app developers must use the [Ti.Filesystem.requestStoragePermissions()](https://docs.appcelerator.com/platform/latest/#!/api/Titanium.Filesystem-method-requestStoragePermissions) and [Ti.Filesystem.hasStoragePermissions()](https://docs.appcelerator.com/platform/latest/#!/api/Titanium.Filesystem-method-hasStoragePermissions) methods before saving to the gallery. This is okay, but we don't need to check for WRITE_EXTERNAL_STORAGE
permission on Android 10 and above when saving to the gallery. We also don't want to change the [Ti.Filesystem.requestStoragePermissions()](https://docs.appcelerator.com/platform/latest/#!/api/Titanium.Filesystem-method-requestStoragePermissions) method's implementation since it's still needed in case you want to write to other locations on external storage.
PR (master): https://github.com/appcelerator/titanium_mobile/pull/12143 See commits... https://github.com/appcelerator/titanium_mobile/pull/12143/commits/b8e5f150b012ac81b4ac6543f5845a09707d9d29 https://github.com/appcelerator/titanium_mobile/pull/12143/commits/5d0a7b42d36f1479353c7ab1eaf79d90a958a8ae
Verified the fix with SDK 9.3.0.v20201022111908. Closing.