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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check permission before startCropping. Fix of #957 #1095

Merged
merged 1 commit into from
Aug 15, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -396,8 +396,14 @@ public void openCropper(final ReadableMap options, final Promise promise) {
setConfiguration(options);
resultCollector.setup(promise, false);

Uri uri = Uri.parse(options.getString("path"));
startCropping(activity, uri);
final Uri uri = Uri.parse(options.getString("path"));
permissionsCheck(activity, promise, Collections.singletonList(Manifest.permission.WRITE_EXTERNAL_STORAGE), new Callable<Void>() {
@Override
public Void call() {
startCropping(activity, uri);
return null;
}
});
}

private String getBase64StringFromFile(String absoluteFilePath) {
Expand Down Expand Up @@ -614,7 +620,7 @@ private void configureCropperColors(UCrop.Options options) {
}
}

private void startCropping(Activity activity, Uri uri) {
private void startCropping(final Activity activity, final Uri uri) {
UCrop.Options options = new UCrop.Options();
options.setCompressionFormat(Bitmap.CompressFormat.JPEG);
options.setCompressionQuality(100);
Expand Down