Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] - 3.2.0 camera error on picking image #160

Closed
sdlingam7 opened this issue Jul 10, 2021 · 7 comments 路 Fixed by #161
Closed

[BUG] - 3.2.0 camera error on picking image #160

sdlingam7 opened this issue Jul 10, 2021 · 7 comments 路 Fixed by #161
Assignees

Comments

@sdlingam7
Copy link

馃毃馃毃 Before open the ticket please check if you can reproduce the bug in the sample code

  • Lib Version : 3.2.0

Describe the bug
Could not get the camera pic for crop

Device :
oneplus nord : version 11
Vivo : Version 11

21-07-10-18-50-20.mp4
  ActivityResultLauncher<CropImageContractOptions> pickImageResult =
            registerForActivityResult(new CropImageContract(), (result) -> {
                if (result.isSuccessful()) {
                    picturePath = result.getUriFilePath(getContext(), true);
                    Picasso.get().load(new File(picturePath)).fit().into(img_User_Image);
                    getRetro_UpdateProfilePic(picturePath);
                }
            });

    public void pickImage() {
        pickImageResult.launch(new CropImageContractOptions(imageUri, new CropImageOptions())
                .setGuidelines(CropImageView.Guidelines.ON));
    }

This is my code. While i pick image from gallery, it's working fine. But while capture image from camera, it does not goes to crop activity.

Check this code in android 11, i have tried in vivo and oneplus device, both are android 11.

@sdlingam7 sdlingam7 added the bug label Jul 10, 2021
@lordrians
Copy link

lordrians commented Jul 12, 2021

i had that problem too, my device Samsung Galaxy A71 android 11

@Eldhopj
Copy link

Eldhopj commented Jul 12, 2021

I too have the same issue on my realme device which is running on android 10

@Canato Canato self-assigned this Jul 12, 2021
@Canato
Copy link
Member

Canato commented Jul 12, 2021

Hey people thanks, will try to reproduce later. But right now is working on my phone, so maybe is device related (mine is pixel 3 on Android 11)

If you have time and can help me with this tests:

  • Use library 3.2.0 but don't use the Activity contracts, use the old onActivityResult and cropImage (they are deprecated now)
  • Use the library version 3.1.3

So I can understand if the last changes are the responsible for it.

Thanks!

@Canato Canato added the pinned label Jul 12, 2021
@ondree
Copy link
Contributor

ondree commented Jul 13, 2021

I can see same issue on Huawei P20 Lite with Android 9 and library version 3.2.0, it is ok with 3.1.3.
With Pixel 5 (Android 12) and Motorola Moto Z (Android 8) - both library versions working without any issue.

@Canato
Copy link
Member

Canato commented Jul 13, 2021

Hey team, I tested in 3 of my devices and some Android Studio emulators, could not reproduce and without it cannot fix =/

Someone could reproduce in an Android Studio emulator?

If someone wanna fix, probably is something on PickImageContract

Check CropImageActivity method onPickImageResult

@connyduck any insight on it? maybe you can reproduce...

@Canato Canato changed the title [BUG] - [BUG] - 3.2.0 camera error on picking image Jul 13, 2021
@ondree
Copy link
Contributor

ondree commented Jul 14, 2021

Hi I can see there is difference in parameters returned to PickImageContract.parseResult(resultCode: Int, intent: Intent?)

Problematic device: resultCode == -1; intent == null
Working device: resultCode == -1 but intent is not null.

In problematic devices CropImage.getPickImageResultUriContent() is not called because of Intent null check.

    open override fun parseResult(
        resultCode: Int,
        intent: Intent?
    ): Uri? {
        if (intent != null) {
            context?.let {
                context = null
                return getPickImageResultUriContent(it, intent)
            }
        }
        context = null
        return null
    }

Is Intent null check required here? It seems its values are not mandatory later.

@Canato
Copy link
Member

Canato commented Jul 14, 2021

Good catch @ondree , -1 means RESULT_OK

And looking the getPickImageResultUriContent method we have a solution when intent is null.
(and we need to remove this !! notations).

Could you remove this if and test the sample code? if work you can open a PR and we merge it!
(or I can open, what you prefer)

open override fun parseResult(
        resultCode: Int,
        intent: Intent?
): Uri? {
        context?.let {
                context = null
                return getPickImageResultUriContent(it, intent)
        }
        context = null
        return null
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants