Skip to content

Commit

Permalink
check permission before startCropping. Fix of ivpusic#957
Browse files Browse the repository at this point in the history
  • Loading branch information
Obi1Kennoby committed Aug 15, 2019
1 parent 33fd526 commit 6417a6e
Showing 1 changed file with 9 additions and 3 deletions.
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

0 comments on commit 6417a6e

Please sign in to comment.