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

fix(android): return original camera image if edition was canceled #2358

Merged
merged 1 commit into from
Feb 4, 2020
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
@@ -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