capacitor-community-multilens-camerapreview 6.0.4 → 6.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -62,6 +62,7 @@ public class CameraActivity extends Fragment {
|
|
|
62
62
|
void onStartRecordVideoError(String message);
|
|
63
63
|
void onStopRecordVideo(String file);
|
|
64
64
|
void onStopRecordVideoError(String error);
|
|
65
|
+
void setSavePath(String path);
|
|
65
66
|
}
|
|
66
67
|
|
|
67
68
|
private CameraPreviewListener eventListener;
|
|
@@ -558,18 +559,12 @@ public class CameraActivity extends Fragment {
|
|
|
558
559
|
data = outputStream.toByteArray();
|
|
559
560
|
}
|
|
560
561
|
}
|
|
561
|
-
|
|
562
|
-
if (
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
eventListener.onPictureTaken(encodedImage);
|
|
566
|
-
} else {
|
|
567
|
-
String path = getTempFilePath();
|
|
568
|
-
FileOutputStream out = new FileOutputStream(path);
|
|
569
|
-
out.write(data);
|
|
570
|
-
out.close();
|
|
571
|
-
eventListener.onPictureTaken(path);
|
|
562
|
+
String encodedImage = Base64.encodeToString(data, Base64.NO_WRAP);
|
|
563
|
+
if (storeToFile) {
|
|
564
|
+
writeImageToCache(data);
|
|
572
565
|
}
|
|
566
|
+
eventListener.onPictureTaken(encodedImage);
|
|
567
|
+
|
|
573
568
|
Log.d(TAG, "CameraPreview pictureTakenHandler called back");
|
|
574
569
|
} catch (OutOfMemoryError e) {
|
|
575
570
|
// most likely failed to allocate memory for rotateBitmap
|
|
@@ -588,6 +583,20 @@ public class CameraActivity extends Fragment {
|
|
|
588
583
|
}
|
|
589
584
|
};
|
|
590
585
|
|
|
586
|
+
private void writeImageToCache(byte[] data){
|
|
587
|
+
try {
|
|
588
|
+
String path = getTempFilePath();
|
|
589
|
+
FileOutputStream out = new FileOutputStream(path);
|
|
590
|
+
out.write(data);
|
|
591
|
+
out.close();
|
|
592
|
+
eventListener.setSavePath(path);
|
|
593
|
+
} catch (Exception e) {
|
|
594
|
+
// TODO: handle exception
|
|
595
|
+
Log.d(TAG, "cannot write image");
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
}
|
|
599
|
+
|
|
591
600
|
private Camera.Size getOptimalPictureSize(
|
|
592
601
|
final int width,
|
|
593
602
|
final int height,
|
|
@@ -52,6 +52,9 @@ public class CameraPreviewMultiLens extends Plugin implements CameraActivity.Cam
|
|
|
52
52
|
private int containerViewId = 21;
|
|
53
53
|
private int zoomLevel = 0;
|
|
54
54
|
|
|
55
|
+
private String savePath = null;
|
|
56
|
+
private String saveData = null;
|
|
57
|
+
|
|
55
58
|
@PluginMethod
|
|
56
59
|
public void echo(PluginCall call) {
|
|
57
60
|
String value = call.getString("value");
|
|
@@ -431,7 +434,23 @@ public class CameraPreviewMultiLens extends Plugin implements CameraActivity.Cam
|
|
|
431
434
|
public void onPictureTaken(String originalPicture) {
|
|
432
435
|
JSObject jsObject = new JSObject();
|
|
433
436
|
jsObject.put("value", originalPicture);
|
|
434
|
-
|
|
437
|
+
if(fragment.storeToFile){
|
|
438
|
+
saveData = originalPicture;
|
|
439
|
+
} else {
|
|
440
|
+
bridge.getSavedCall(captureCallbackId).resolve(jsObject);
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
@Override
|
|
444
|
+
public void setSavePath(String path) {
|
|
445
|
+
JSObject jsObject = new JSObject();
|
|
446
|
+
jsObject.put("value", saveData);
|
|
447
|
+
jsObject.put("webPath", "file://" + path);
|
|
448
|
+
if(fragment.storeToFile){
|
|
449
|
+
bridge.getSavedCall(captureCallbackId).resolve(jsObject);
|
|
450
|
+
}
|
|
451
|
+
saveData = null;
|
|
452
|
+
savePath = null;
|
|
453
|
+
|
|
435
454
|
}
|
|
436
455
|
|
|
437
456
|
@Override
|
|
@@ -61,9 +61,7 @@ export interface CameraPreviewMultiLensPlugin {
|
|
|
61
61
|
startRecordVideo(options: CameraPreviewOptions): Promise<{}>;
|
|
62
62
|
stop(): Promise<{}>;
|
|
63
63
|
stopRecordVideo(): Promise<{}>;
|
|
64
|
-
capture(options: CameraPreviewPictureOptions): Promise<
|
|
65
|
-
value: string;
|
|
66
|
-
}>;
|
|
64
|
+
capture(options: CameraPreviewPictureOptions): Promise<any>;
|
|
67
65
|
captureSample(options: CameraSampleOptions): Promise<{
|
|
68
66
|
value: string;
|
|
69
67
|
}>;
|
package/package.json
CHANGED