Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-24660] Android: openPhotoGallery is not working for downloads

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2017-05-09T23:26:33.000+0000
Affected Version/sRelease 6.0.0
Fix Version/sRelease 6.1.0
ComponentsAndroid
Labelsmerge-6.1.0
ReporterDavid Fox
AssigneeSamir Mohammed
Created2017-05-05T12:23:06.000+0000
Updated2017-05-10T16:59:18.000+0000

Description

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();

Comments

  1. Gary Mathews 2017-05-05

    master: https://github.com/appcelerator/titanium_mobile/pull/9021
  2. Eric Merriman 2017-05-05

    Moved to 6.1.0. We will need a back port [~gmathews]
  3. Gary Mathews 2017-05-09

    6_1_X: https://github.com/appcelerator/titanium_mobile/pull/9038
  4. Samir Mohammed 2017-05-10

    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

JSON Source