Comments (19)
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);
}
`
from android-image-cropper.
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.
from android-image-cropper.
@kaustubhkp I see. Thank you.
I think that my PR also fixes that bug
from android-image-cropper.
@kaustubhkp will do some tests, if everything is fine we merge now and I open the release PR
from android-image-cropper.
Which version of the library are you using @Viral891 ?
from android-image-cropper.
Which version of the library are you using @Viral891 ?
implementation 'com.canhub.cropper:android-image-cropper:1.1.0'
from android-image-cropper.
OK, look like a bug, will investigate later.
@Viral891 could you please add
- The piece of code you call to show this
- The device used
Thanks!
from android-image-cropper.
Please check on all Android 10 devices
sorry this is not possible.
About the Bug
@Viral891 could not reproduce, look like a permissions library issue.
If you look in their issues ParkSangGwon/TedPermission#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 android/permissions-samples#8
Local Test
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
from android-image-cropper.
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);
from android-image-cropper.
@rexyrex Could you reproduce with one of the build provide in the project like I ask?
quick-start
or sample
or test
from android-image-cropper.
@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
from android-image-cropper.
@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
from android-image-cropper.
@Canato I finally found the time to get around to this.
I've tested all 3 projects and only "Camera" and "Files" is listed
from android-image-cropper.
This will be done with a code refactor of startPickImageActivity
method.
Need to fix and rethink the intent to open Camera
, Gallery
and storage
from android-image-cropper.
@datdescartes what about camera option not showing for few phones?
from android-image-cropper.
@kaustubhkp could you tell me which device and android version?
from android-image-cropper.
@kaustubhkp I've just updated the PR that possibly fix the camera bug.
from android-image-cropper.
@datdescartes here are details about issue I was mentioning #52
from android-image-cropper.
@Canato do you have any idea how long will this PR take to merge to library ?
from android-image-cropper.
Related Issues (20)
- Build failing since version 4.3.3 HOT 1
- Managing cache file HOT 4
- Is this repo still being supported or not? HOT 1
- CropImageView fails to respect the match_parent size upon resizing the window HOT 1
- ActivityResultContract for custom activity
- Can I Customize Crip Edit Screen In Android Compose? HOT 1
- URI validation security issue
- Crashing on calling the copping activity...
- Multiple call of cropImage in loop when we can pick more then one image from gallery
- Getting crash while selection of camera cropping only in Android 10
- Question : Is it possible move and scale the picture itself instead of the crop overlay? HOT 3
- v
- Can crop by path or region? HOT 1
- Prevent CropRect Translation in Image Cropper
- Tool bar and its buttons(back, crop etc) is not shown. just white space HOT 2
- [Feature Request] Support for Rounded Rectangle Crop Shape HOT 4
- Integrate the Photo picker tool HOT 1
- Opening camera doesn't allow exiting the activity HOT 1
- How to customize the AlertDialog in Jetpack Compose? HOT 3
- Allow selecting multiple images at a time from the Gallery HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from android-image-cropper.