miguelbcr / RxPaparazzo

RxJava extension for Android to take images using camera and gallery and pick files up
Apache License 2.0
465 stars 53 forks source link

Multiple images selection #103

Open BorisLaskov opened 5 years ago

BorisLaskov commented 5 years ago

I am trying to select multiple images from the gallery.

RxPaparazzo
    .multiple(this)  // From a fragment
    .usingGallery()
    .subscribeOn(Schedulers.io())
    .observeOn(AndroidSchedulers.mainThread())
    .subscribe { response ->
        if (response.resultCode() != RESULT_OK) {
            return@subscribe
        }
        // handle response.data()
    }

It works fine for the files stored locally. Yet, when I choose Google Photos from the drawer menu, it allows me to select multiple pictures just fine but returns an array of just a single file.

I have done a little bit of debugging. I see that in PickFiles.java right in this place:

    Uri pickedUri = intent.getData();
    if (pickedUri != null) {
      PermissionUtil.grantReadPermissionToUri(targetUi, pickedUri);

      return Arrays.asList(pickedUri);
    } else {
      return getUris(intent);
    }

it takes only a single Uri from .getData() and proceeds without checking ClipData (which is done in the getUris(intent) method). It looks like this ClipData actually contains Uris for all selected files including the first one, which is duplicated inside whatever getData() returns.

If it allows me to select multiple images through GUI, I would expect it to return all of them instead of just one.

Tested on Nokia 7 plus and an emulator, both running Android 9.

BorisLaskov commented 5 years ago

I've just realized that images that I pick through "Photos" are also stored locally... My point is: it simply works when I choose images from the default picker that appears first, but when I go to "Photos" through the drawer menu (where "Photos", Google Drive and potentially other apps reside) I encounter the bug described above. Sorry for confusion.