Skip to content
This repository has been archived by the owner on Mar 1, 2022. It is now read-only.

Commit

Permalink
Minor tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
darryncampbell committed Apr 16, 2017
1 parent 73ad35c commit fe3a08e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 25 deletions.
25 changes: 12 additions & 13 deletions src/android/IntentShim.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@

import static android.R.attr.filter;

/**
* @todo
*/
public class IntentShim extends CordovaPlugin {

private static final String LOG_TAG = "Cordova Intents Shim";
Expand Down Expand Up @@ -81,9 +78,6 @@ public boolean execute(String action, JSONArray args, final CallbackContext call
{
bExpectResult = true;
this.onActivityResultCallbackContext = callbackContext;
PluginResult result = new PluginResult(PluginResult.Status.NO_RESULT);
result.setKeepCallback(true);
callbackContext.sendPluginResult(result);
}
else {
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK));
Expand All @@ -92,10 +86,6 @@ public boolean execute(String action, JSONArray args, final CallbackContext call

return true;
}
else if (action.equals("startService"))
{
// todo
}
else if (action.equals("sendBroadcast"))
{
// Credit: https://github.com/chrisekelley/cordova-webintent
Expand All @@ -122,6 +112,13 @@ else if (action.equals("sendBroadcast"))
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK));
return true;
} else if (action.equals("registerBroadcastReceiver")) {
try
{
// Ensure we only have a single registered broadcast receiver
((CordovaActivity)this.cordova.getActivity()).unregisterReceiver(myBroadcastReceiver);
}
catch (IllegalArgumentException e) {}

// No error callback
if(args.length() != 1) {
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.INVALID_ACTION));
Expand Down Expand Up @@ -171,7 +168,6 @@ else if (action.equals("onIntent"))
result.setKeepCallback(true);
callbackContext.sendPluginResult(result);
return true;
// todo
}
else if (action.equals("onActivityResult"))
{
Expand Down Expand Up @@ -256,15 +252,18 @@ public void onNewIntent(Intent intent) {
public void onActivityResult(int requestCode, int resultCode, Intent intent)
{
super.onActivityResult(requestCode, resultCode, intent);
// todo
if (onActivityResultCallbackContext != null)
if (onActivityResultCallbackContext != null && intent != null)
{
intent.putExtra("requestCode", requestCode);
intent.putExtra("resultCode", resultCode);
PluginResult result = new PluginResult(PluginResult.Status.OK, getIntentJson(intent));
result.setKeepCallback(true);
onActivityResultCallbackContext.sendPluginResult(result);
}
else if (onActivityResultCallbackContext != null)
{
onActivityResultCallbackContext.sendPluginResult(new PluginResult(PluginResult.Status.INVALID_ACTION));
}

}

Expand Down
12 changes: 0 additions & 12 deletions www/IntentShim.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
//cordova.define("com.darryncampbell.cordova.plugin.intent.IntentShim", function(require, exports, module) {
//exports.coolMethod = function(arg0, success, error) {
// exec(success, error, "EnterpriseBarcode", "coolMethod", [arg0]);
//};

var argscheck = require('cordova/argscheck'),
channel = require('cordova/channel'),
Expand Down Expand Up @@ -31,7 +27,6 @@ function IntentShim() {
// StartActivityForResult
IntentShim.prototype.ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT";
IntentShim.prototype.ACTION_PICK = "android.intent.action.PICK";
IntentShim.prototype.PICK_CONTACT = "content://com.android.contacts/contacts";

/**
* @param {Function} successCallback The function to call when the heading data is available
Expand All @@ -47,11 +42,6 @@ IntentShim.prototype.startActivityForResult = function(params, successCallback,
exec(successCallback, errorCallback, "IntentShim", "startActivityForResult", [params]);
};

IntentShim.prototype.startService = function(params, successCallback, errorCallback) {
argscheck.checkArgs('off', 'IntentShim.startService', arguments);
exec(successCallback, errorCallback, "IntentShim", "startService", [params]);
};

IntentShim.prototype.sendBroadcast = function(params, successCallback, errorCallback) {
argscheck.checkArgs('off', 'IntentShim.sendBroadcast', arguments);
exec(successCallback, errorCallback, "IntentShim", "sendBroadcast", [params]);
Expand Down Expand Up @@ -91,5 +81,3 @@ window.plugins = window.plugins || {};
window.plugins.intentShim = window.intentShim;



//});

0 comments on commit fe3a08e

Please sign in to comment.