Closed Viral891 closed 3 years ago
Which version of the library are you using @Viral891 ?
Which version of the library are you using @Viral891 ?
implementation 'com.canhub.cropper:android-image-cropper:1.1.0'
OK, look like a bug, will investigate later.
@Viral891 could you please add
Thanks!
Device Name: Mi Redmi Note 7 Pro Android Version: Android 10 Please check on all Android 10 devices
<ImageView android:id="@+id/profileEditImg" android:src="@drawable/camera_icon" android:layout_width="30dp" android:layout_height="30dp" android:layout_alignParentRight="true" android:layout_alignParentBottom="true" android:elevation="5dp" />
`Permission Library: implementation 'gun0912.ted:tedpermission:2.2.3'
Permission Code: private void takePermissionNGetImg() { PermissionListener permissionlistener = new PermissionListener() { @Override public void onPermissionGranted() { onSelectImageClick(); }
@Override
public void onPermissionDenied(List<String> deniedPermissions) {
AppHelper.showSnackBar(mainContainer, "Permission denied!", Snackbar.LENGTH_LONG);
}
};
TedPermission.with(CustomerInformationFormActivity.this)
.setPermissionListener(permissionlistener)
.setDeniedTitle("Permission denied")
.setDeniedMessage("If you reject this permission, you will be unable to use this service\n\nPlease turn on permissions in Settings")
.setGotoSettingButtonText("Go To Settings")
.setPermissions(Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.CAMERA)
.check();
}
//Permission Granted public void onSelectImageClick() { CropImage.startPickImageActivity(this); }
@Override
@SuppressLint("NewApi")
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
try {
if (requestCode == CropImage.PICK_IMAGE_CHOOSER_REQUEST_CODE && resultCode == Activity.RESULT_OK) {
Uri imageUri = CropImage.getPickImageResultUri(this, data);
if (CropImage.isReadExternalStoragePermissionsRequired(this, imageUri)) {
mCropImageUri = imageUri;
requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, 0);
} else {
startCropImageActivity(imageUri);
}
}
if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) {
final CropImage.ActivityResult result = CropImage.getActivityResult(data);
if (resultCode == RESULT_OK) {
final Uri uri = result.getUri();
Bitmap bitmap = null;
try {
bitmap = MediaStore.Images.Media.getBitmap(this.getContentResolver(), uri);
bitmap = Bitmap.createScaledBitmap(bitmap, 500, 500, true);
final Bitmap finalBitmap = bitmap;
Glide.with(CustomerInformationFormActivity.this).asBitmap().load(uri).into(new BitmapImageViewTarget(userImg) {
@Override
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
super.onResourceReady(resource, transition);
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
finalBitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
byte[] b = baos.toByteArray();
temp = Base64.encodeToString(b, Base64.DEFAULT);
RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(CustomerInformationFormActivity.this.getResources(), resource);
circularBitmapDrawable.setCircular(true);
userImg.setImageDrawable(circularBitmapDrawable);
String extension = ".jpg";
} catch (Exception e) {
Logger.error(e.getLocalizedMessage());
}
}
});
} catch (IOException e) {
e.printStackTrace();
}
} else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) {
Toast.makeText(this, "Somethiing went wrong...", Toast.LENGTH_LONG).show();
}
}
} catch (Exception e) {
Logger.log(e.getLocalizedMessage());
}
}
@Override
public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
if (mCropImageUri != null && grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
startCropImageActivity(mCropImageUri);
} else {
Toast.makeText(this, "Cancelling, required permissions are not granted", Toast.LENGTH_LONG).show();
}
}
/**
* Start crop image activity for the given image.
*/
private void startCropImageActivity(Uri imageUri) {
CropImage.activity(imageUri)
.setCropMenuCropButtonTitle("Next")
.setActivityTitle("Crop Image")
.setGuidelines(CropImageView.Guidelines.OFF)
.setMultiTouchEnabled(false)
.setFixAspectRatio(true)
.setAutoZoomEnabled(false)
.start(this);
}
`
Please check on all Android 10 devices
sorry this is not possible.
@Viral891 could not reproduce, look like a permissions library issue. If you look in their issues https://github.com/ParkSangGwon/TedPermission/issues/108 They are having issues with Android 10/11 permissions
Google change a lot the storage permissions on Android 10 and enforce it for Android 11. We change the code to use Scope Storage and the permissions need to be update
Would suggest to use google Request Permissions, like this https://github.com/android/permissions-samples/pull/8
If you want to test the library code without interferences in your device, checkout the main branch and build the quick-start
app in your test device and try to get the image from the gallery.
Let me know the output so we can keep digging if need
I have the same issue.
Android 10. Galaxy Note 10+ implementation 'com.canhub.cropper:android-image-cropper:1.1.1'
CropImage.activity() .setGuidelines(CropImageView.Guidelines.ON) .setAspectRatio(1,1) .start(activity);
@rexyrex Could you reproduce with one of the build provide in the project like I ask?
quick-start
or sample
or test
@Canato I'm quite new to this. How would I go about testing the different builds that you mentioned above? I've only tried implementing the most recent version into my app
@Canato I'm quite new to this. How would I go about testing the different builds that you mentioned above? I've only tried implementing the most recent version into my app
Hey @rexyrex you will need to import this project in your machine and build the apps in your emulator/device for test
@Canato I finally found the time to get around to this.
I've tested all 3 projects and only "Camera" and "Files" is listed
This will be done with a code refactor of startPickImageActivity
method.
Need to fix and rethink the intent to open Camera
, Gallery
and storage
We've encountered the same error. I have just created a PR for this. Simply by copying the source code for gallery intents from legacy source code. Please review.
@datdescartes what about camera option not showing for few phones?
@kaustubhkp could you tell me which device and android version?
@kaustubhkp I've just updated the PR that possibly fix the camera bug.
@datdescartes here are details about issue I was mentioning https://github.com/CanHub/Android-Image-Cropper/issues/52
@kaustubhkp I see. Thank you. I think that my PR also fixes that bug
@Canato do you have any idea how long will this PR take to merge to library ?
@kaustubhkp will do some tests, if everything is fine we merge now and I open the release PR
Android 10
Using Android Studio 3.6.3
I followed the steps as given but only camera and file options show up in the intent . The gallery option is not visible.I am also using the latest version of the library.