mirror of
https://gitee.com/shuto/customCamera.git
synced 2026-04-14 00:00:03 +08:00
Merge branch 'feature-interaction_js_java'
This commit is contained in:
@@ -3,16 +3,30 @@ package org.geneanet.customcamera;
|
||||
import XXX_NAME_CURRENT_PACKAGE_XXX.CameraView;
|
||||
import org.apache.cordova.CordovaPlugin;
|
||||
import org.apache.cordova.CallbackContext;
|
||||
import org.apache.cordova.PluginResult;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
public class CameraLauncher extends CordovaPlugin {
|
||||
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
|
||||
Intent intent = new Intent(this.cordova.getActivity(), CameraView.class);
|
||||
cordova.getActivity().startActivity(intent);
|
||||
if (action.equals("startCamera")) {
|
||||
Intent intent = new Intent(this.cordova.getActivity(), CameraView.class);
|
||||
|
||||
return true;
|
||||
Bundle imgBackgroundBase64 = new Bundle();
|
||||
imgBackgroundBase64.putString("imgBackgroundBase64", args.getString(0));
|
||||
intent.putExtras(imgBackgroundBase64);
|
||||
|
||||
cordova.getActivity().startActivity(intent);
|
||||
|
||||
PluginResult r = new PluginResult(PluginResult.Status.OK, "base64retour");
|
||||
callbackContext.sendPluginResult(r);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import java.util.List;
|
||||
import java.lang.Math;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.hardware.Camera;
|
||||
import android.os.Bundle;
|
||||
import android.view.Display;
|
||||
@@ -32,7 +33,19 @@ public class CameraView extends Activity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
Bundle currentBundle = this.getIntent().getExtras();
|
||||
if (currentBundle != null) {
|
||||
String imgBackgroundBase64 = currentBundle.getString("imgBackgroundBase64");
|
||||
new AlertDialog.Builder(this)
|
||||
.setTitle("Delete entry")
|
||||
.setMessage(imgBackgroundBase64)
|
||||
.show();
|
||||
} else {
|
||||
new AlertDialog.Builder(this)
|
||||
.setTitle("que neni")
|
||||
.setMessage("que neni")
|
||||
.show();
|
||||
}
|
||||
|
||||
System.out.println("ON RENTRE DANS L'APPLICATION");
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
'use strict';
|
||||
/**
|
||||
* Permet de faire l'interface entre phonegap et l'application customcamera en java.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var exec = require('cordova/exec');
|
||||
|
||||
@@ -10,24 +10,13 @@ var exec = require('cordova/exec');
|
||||
var customCameraExport = function() {
|
||||
};
|
||||
|
||||
// add method.
|
||||
customCameraExport.prototype.getPicture = function() {
|
||||
alert("Oh yeah !");
|
||||
};
|
||||
|
||||
customCameraExport.prototype.startCamera = function() {
|
||||
customCameraExport.prototype.startCamera = function(imgBackgroundBase64, successFct, failFct) {
|
||||
exec(
|
||||
function(result) {
|
||||
console.log("success");
|
||||
console.log(result);
|
||||
},
|
||||
function(result) {
|
||||
console.log("fail");
|
||||
console.log(result);
|
||||
},
|
||||
successFct,
|
||||
failFct,
|
||||
"CustomCamera",
|
||||
"testAction",
|
||||
[]
|
||||
"startCamera",
|
||||
[imgBackgroundBase64]
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user