Skip to content

Commit

Permalink
fix(android): return original camera image if edition was canceled (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
JhonArlex authored Feb 4, 2020
1 parent 120969c commit ce93ed3
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.getcapacitor.plugin;

import android.Manifest;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
Expand Down Expand Up @@ -53,7 +54,6 @@ public class Camera extends Plugin {
static final int REQUEST_IMAGE_CAPTURE = PluginRequestCodes.CAMERA_IMAGE_CAPTURE;
static final int REQUEST_IMAGE_PICK = PluginRequestCodes.CAMERA_IMAGE_PICK;
static final int REQUEST_IMAGE_EDIT = PluginRequestCodes.CAMERA_IMAGE_EDIT;

// Message constants
private static final String INVALID_RESULT_TYPE_ERROR = "Invalid resultType option";
private static final String PERMISSION_DENIED_ERROR = "Unable to access camera, user denied permission request";
Expand Down Expand Up @@ -221,7 +221,7 @@ public void openPhotos(final PluginCall call) {
}
}

public void processCameraImage(PluginCall call, Intent data) {
public void processCameraImage(PluginCall call) {
boolean saveToGallery = call.getBoolean("saveToGallery", CameraSettings.DEFAULT_SAVE_IMAGE_TO_GALLERY);
CameraResultType resultType = getResultType(call.getString("resultType"));
if(imageFileSavePath == null) {
Expand Down Expand Up @@ -468,12 +468,15 @@ protected void handleOnActivityResult(int requestCode, int resultCode, Intent da
settings = getSettings(savedCall);

if (requestCode == REQUEST_IMAGE_CAPTURE) {
processCameraImage(savedCall, data);
processCameraImage(savedCall);
} else if (requestCode == REQUEST_IMAGE_PICK) {
processPickedImage(savedCall, data);
} else if (requestCode == REQUEST_IMAGE_EDIT) {
} else if (requestCode == REQUEST_IMAGE_EDIT && resultCode == Activity.RESULT_OK) {
isEdited = true;
processPickedImage(savedCall, data);
} else if (resultCode == Activity.RESULT_CANCELED && imageFileSavePath != null) {
isEdited = true;
processCameraImage(savedCall);
}
}

Expand Down

0 comments on commit ce93ed3

Please sign in to comment.