content://com.android.providers.downloads.documents
is currently not supported in
TitaniumBlob.java
, this prevents obtaining file information for images selected in the
Downloads
category of
Titanium.Media.openPhotoGallery
.
*TEST CASE*
var w = Ti.UI.createWindow({backgroundColor : 'grey'}),
b = Titanium.UI.createButton({
title : 'OPEN GALLERY',
top : '10dp'
}),
iv = Ti.UI.createImageView({
top : '65dp',
width : '95%'
}),
sp = 'android.permission.READ_EXTERNAL_STORAGE';
function openGallery() {
Ti.Media.openPhotoGallery({
mediaTypes : [Ti.Media.MEDIA_TYPE_PHOTO],
success: function(e) {
iv.height = e.media.height * (iv.rect.width / e.media.width);
iv.image = e.media;
alert('filename: ' + e.media.file.name);
alert('filesize: ' + e.media.length);
},
error: function(e) {
Ti.API.error(JSON.stringify(e));
}
});
}
b.addEventListener('click', function(e) {
if (Ti.Android.hasPermission(sp)) {
openGallery();
} else {
Ti.Android.requestPermissions([sp], function(e) {
if (e.success) {
openGallery();
} else {
Ti.API.info('ERROR: ' + e.error);
}
});
}
});
w.add(b);
w.add(iv);
w.open();
master: https://github.com/appcelerator/titanium_mobile/pull/9021
Moved to 6.1.0. We will need a back port [~gmathews]
6_1_X: https://github.com/appcelerator/titanium_mobile/pull/9038
Verified fix on SDK version 6.2.0.v20170510084833 and 6.1.0.v20170509170935. Test and other information can be found at: Master:https://github.com/appcelerator/titanium_mobile/pull/9021 6_1_X:https://github.com/appcelerator/titanium_mobile/pull/9038